mirror of
https://github.com/Interlisp/maiko.git
synced 2026-01-29 13:01:30 +00:00
Cleanup USE_DPLI usage (#378)
Until now, the only differentiation between using DLPI and using NIT for the ethernet interface was expressed as a function of USE_DLPI. This commit makes explicit when code is for the DLPI interface or the NIT interface, with USE_DLPI and USE_NIT. This is setup for using the BPF interface to the ethernet as an alternative.
This commit is contained in:
42
src/ether.c
42
src/ether.c
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
#define PKTFILTER 1
|
||||
#define NIOCSFLAGS SBIOCSFLAGS
|
||||
#endif
|
||||
@@ -34,9 +34,9 @@
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
#include "dlpidefs.h"
|
||||
#else
|
||||
#elif defined(USE_NIT)
|
||||
#include <net/nit.h>
|
||||
#endif
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#endif /* OS4 */
|
||||
#endif /* PKTFILTER */
|
||||
|
||||
#ifndef USE_DLPI
|
||||
#if defined(USE_NIT)
|
||||
#include <sys/mbuf.h>
|
||||
#endif
|
||||
#include <nlist.h>
|
||||
@@ -73,7 +73,7 @@
|
||||
#include "dbprint.h"
|
||||
#include "etherdefs.h"
|
||||
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
#define NIOCSETF PFIOCSETF
|
||||
#endif
|
||||
|
||||
@@ -245,7 +245,7 @@ LispPTR ether_suspend(LispPTR args[])
|
||||
|
||||
/* The trick here is to install a packet filter */
|
||||
/* that rejects all packets, I think... */
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
|
||||
si.ic_cmd = PFIOCSETF;
|
||||
si.ic_timout = -1;
|
||||
@@ -257,7 +257,7 @@ LispPTR ether_suspend(LispPTR args[])
|
||||
return (NIL);
|
||||
}
|
||||
|
||||
#else
|
||||
#elif defined(USE_NIT)
|
||||
if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) {
|
||||
perror("ether_suspend: NIOCSETF failed\n");
|
||||
return (NIL);
|
||||
@@ -291,7 +291,7 @@ LispPTR ether_resume(LispPTR args[])
|
||||
#else /* PKTFILTER */
|
||||
|
||||
/* Install a packet filter that accepts all packets we want */
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
|
||||
si.ic_cmd = PFIOCSETF;
|
||||
si.ic_timout = -1;
|
||||
@@ -303,7 +303,7 @@ LispPTR ether_resume(LispPTR args[])
|
||||
return (NIL);
|
||||
}
|
||||
|
||||
#else
|
||||
#elif defined(USE_NIT)
|
||||
if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) {
|
||||
perror("ether_resume: NIOCSETF failed\n");
|
||||
return (NIL);
|
||||
@@ -763,9 +763,9 @@ void init_ifpage_ether() {
|
||||
#ifdef MAIKO_ENABLE_ETHERNET
|
||||
/* this needs to be a global so the name can be set by main() in Ctest */
|
||||
/* But MAIKO_ENABLE_ETHERNET doesn't support NIT, so dyke it out for MAIKO_ENABLE_ETHERNET */
|
||||
#ifndef USE_DLPI
|
||||
#if defined(USE_NIT)
|
||||
struct sockaddr_nit snit;
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* USE_NIT */
|
||||
#endif /* MAIKO_ENABLE_ETHERNET */
|
||||
|
||||
/************************************************************************/
|
||||
@@ -793,7 +793,7 @@ void init_ether() {
|
||||
if it's already open here, it was opened by ldeether and
|
||||
all the appropriate stuff was done to it there.
|
||||
*/
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
/* Use DLPI to connect to the ethernet. This code is stolen
|
||||
from NFSWATCH4.3
|
||||
*/
|
||||
@@ -832,9 +832,7 @@ void init_ether() {
|
||||
}
|
||||
seteuid(getuid());
|
||||
}
|
||||
#else
|
||||
/* N O T D L P I C O D E */
|
||||
|
||||
#elif defined(USE_NIT)
|
||||
#ifndef OS4
|
||||
if (getuid() != geteuid()) {
|
||||
if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) {
|
||||
@@ -995,7 +993,7 @@ void init_ether() {
|
||||
|
||||
/* first and foremost, flush out ether_fd's buffers and filter it */
|
||||
/* install packetfilter that rejects everything */
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
|
||||
si.ic_cmd = PFIOCSETF;
|
||||
si.ic_timout = -1;
|
||||
@@ -1009,7 +1007,7 @@ void init_ether() {
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
#elif defined(USE_NIT)
|
||||
if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) {
|
||||
perror("init_ether: nopf NIOCSETF failed:\n");
|
||||
|
||||
@@ -1028,9 +1026,9 @@ void init_ether() {
|
||||
/* then throw away everything that's currently buffered there;
|
||||
this descriptor may have been open since ldeether ran, with
|
||||
no filtering; a busy net will have stuffed it full */
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
if (ioctl(ether_fd, I_FLUSH, (char *)FLUSHR) < 0) { perror("init_ether I_FLUSH"); }
|
||||
#else
|
||||
#elif defined(USE_NIT)
|
||||
{
|
||||
FD_SET(ether_fd, &rfds);
|
||||
while (select(32, &rfds, NULL, NULL, &EtherTimeout) > 0)
|
||||
@@ -1044,7 +1042,7 @@ void init_ether() {
|
||||
goodpf.Pf_Filter[11] = (DLword)((ether_host[2] << 8) + ether_host[3]);
|
||||
goodpf.Pf_Filter[14] = (DLword)((ether_host[4] << 8) + ether_host[5]);
|
||||
/* and set up the packetfilter */
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
|
||||
si.ic_cmd = PFIOCSETF;
|
||||
si.ic_timout = -1;
|
||||
@@ -1066,7 +1064,7 @@ void init_ether() {
|
||||
return;
|
||||
}
|
||||
#endif /* USE_DLPI */
|
||||
#ifndef USE_DLPI
|
||||
#if defined(USE_NIT)
|
||||
DBPRINT(("INIT ETHER: Doing I_SETSIG.\n"));
|
||||
if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) {
|
||||
perror("init_ether: I_SETSIG failed:\n");
|
||||
@@ -1074,7 +1072,7 @@ void init_ether() {
|
||||
ether_fd = -1;
|
||||
return;
|
||||
}
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* USE_NIT */
|
||||
#endif /* PKTFILTER */
|
||||
|
||||
if (ether_fd < 0) error ("ether_fd is -1, but enet opened??");
|
||||
|
||||
@@ -21,7 +21,7 @@ int main(int argc, char *argv[]) { return (0); }
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
#include <sys/stream.h>
|
||||
#include <sys/stropts.h>
|
||||
#include <sys/pfmod.h>
|
||||
@@ -53,14 +53,14 @@ char *devices[] = {"le0", "le1", "le2", "le3", "le4", "ie0", "ie1", "i
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <sys/ioctl.h>
|
||||
#ifndef USE_DLPI
|
||||
#if defined(USE_NIT)
|
||||
#include <net/nit.h>
|
||||
#ifdef OS4
|
||||
#include <stropts.h>
|
||||
#include <net/nit_if.h>
|
||||
#include <net/nit_pf.h>
|
||||
#endif /* OS4 */
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* USE_NIT */
|
||||
|
||||
#include <nlist.h>
|
||||
#include <fcntl.h>
|
||||
@@ -75,7 +75,7 @@ char filetorun[30] = "lde";
|
||||
int main(int argc, char *argv[]) {
|
||||
char Earg[30], Ename[30], **newargv;
|
||||
int i;
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}};
|
||||
struct strioctl si;
|
||||
#endif /* USE_DLPI */
|
||||
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
|
||||
*/
|
||||
|
||||
if (!geteuid()) {
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
/* Use DLPI to connect to the ethernet. This code is stolen
|
||||
from NFSWATCH4.3
|
||||
*/
|
||||
@@ -127,13 +127,10 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_NONBLOCK);
|
||||
|
||||
#else
|
||||
/* N O T D L P I C O D E */
|
||||
|
||||
#elif defined(USE_NIT)
|
||||
#ifndef OS4
|
||||
if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) {
|
||||
#else /* OS4 */
|
||||
|
||||
if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) {
|
||||
#endif /* OS4 */
|
||||
|
||||
@@ -230,10 +227,10 @@ int main(int argc, char *argv[]) {
|
||||
/* then if the net is active, spit out the ether info */
|
||||
if (ether_fd > 0) {
|
||||
newargv[i++] = "-E";
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x", ether_fd, ether_host[0], ether_host[1], ether_host[2],
|
||||
ether_host[3], ether_host[4], ether_host[5]);
|
||||
#else
|
||||
#elif defined(USE_NIT)
|
||||
sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, ether_host[0], ether_host[1], ether_host[2],
|
||||
ether_host[3], ether_host[4], ether_host[5], Ename);
|
||||
#endif /* USE_DLPI */
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#endif /* DOS */
|
||||
|
||||
#ifdef MAIKO_ENABLE_ETHERNET
|
||||
#ifndef USE_DLPI
|
||||
#if defined(USE_NIT)
|
||||
#include <net/nit.h> /* needed for Ethernet stuff below */
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* MAIKO_ENABLE_ETHERNET */
|
||||
@@ -428,7 +428,7 @@ int main(int argc, char *argv[])
|
||||
else if (!strcmp(argv[i], "-E")) { /**** ethernet info ****/
|
||||
#ifdef MAIKO_ENABLE_ETHERNET
|
||||
int b0, b1, b2, b3, b4, b5;
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
if (argc > ++i &&
|
||||
sscanf(argv[i], "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5) == 7)
|
||||
#else
|
||||
|
||||
@@ -45,7 +45,7 @@ unsigned long tick_count = 0; /* approx 18 ticks per sec */
|
||||
#include <sys/time.h>
|
||||
#endif /* DOS */
|
||||
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
#include <stropts.h>
|
||||
extern int ether_fd;
|
||||
#endif
|
||||
@@ -546,7 +546,7 @@ static void int_io_init() {
|
||||
perror("ioctl on X fd - SETSIG for input handling failed");
|
||||
#endif
|
||||
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
DBPRINT(("INIT ETHER: Doing I_SETSIG.\n"));
|
||||
if (ether_fd > 0)
|
||||
if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) {
|
||||
|
||||
@@ -1083,7 +1083,7 @@ int device_after_raid() {
|
||||
|
||||
#ifdef MAIKO_ENABLE_ETHERNET
|
||||
init_ether();
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
if (ether_fd > 0)
|
||||
if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) {
|
||||
perror("after-uraid: I_SETSIG for ether failed:\n");
|
||||
|
||||
14
src/xrdopt.c
14
src/xrdopt.c
@@ -19,9 +19,9 @@
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#ifdef MAIKO_ENABLE_ETHERNET
|
||||
#ifndef USE_DLPI
|
||||
#if defined(USE_NIT)
|
||||
#include <net/nit.h> /* needed for Ethernet stuff below */
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* USE_NIT */
|
||||
#endif /* MAIKO_ENABLE_ETHERNET */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
@@ -92,9 +92,9 @@ extern int sysout_size, for_makeinit, please_fork;
|
||||
#ifdef MAIKO_ENABLE_ETHERNET
|
||||
extern int ether_fd;
|
||||
extern u_char ether_host[6];
|
||||
#ifndef USE_DLPI
|
||||
#if defined(USE_NIT)
|
||||
extern struct sockaddr_nit snit;
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* USE_NIT */
|
||||
#endif /* MAIKO_ENABLE_ETHERNET */
|
||||
|
||||
/************************************************************************/
|
||||
@@ -297,12 +297,12 @@ void read_Xoption(int *argc, char *argv[])
|
||||
if (XrmGetResource(rDB, "ldex.EtherNet", "Ldex.EtherNet", str_type, &value) == True) {
|
||||
int b0, b1, b2, b3, b4, b5;
|
||||
(void)strncpy(tmp, value.addr, (int)value.size);
|
||||
#ifdef USE_DLPI
|
||||
#if defined(USE_DLPI)
|
||||
if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5) == 7)
|
||||
#else
|
||||
#elif defined(USE_NIT)
|
||||
if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x:%s", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5,
|
||||
snit.snit_ifname) == 8)
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* USE_NIT */
|
||||
{
|
||||
ether_host[0] = b0;
|
||||
ether_host[1] = b1;
|
||||
|
||||
Reference in New Issue
Block a user