2 * (C)opyright 1992-1998 Darren Reed. (from tcplog)
4 * See the IPFILTER.LICENCE file for details on licencing.
13 #include <sys/types.h>
15 #include <sys/timeb.h>
16 #include <sys/socket.h>
18 #include <sys/ioctl.h>
19 #include <sys/stropts.h>
22 #include <sys/pfmod.h>
23 #include <sys/bufmod.h>
28 #include <netinet/in.h>
29 #include <netinet/in_systm.h>
30 #include <netinet/ip.h>
31 #include <netinet/if_ether.h>
32 #include <netinet/ip_var.h>
33 #include <netinet/udp.h>
34 #include <netinet/udp_var.h>
35 #include <netinet/tcp.h>
40 static const char sccsid
[] = "@(#)sdlpi.c 1.3 10/30/95 (C)1995 Darren Reed";
41 static const char rcsid
[] = "@(#)$Id: sdlpi.c,v 2.1.4.2 2001/06/26 10:43:22 darrenr Exp $";
44 #define CHUNKSIZE 8192
45 #define BUFSPACE (4*CHUNKSIZE)
49 * Be careful to only include those defined in the flags option for the
50 * interface are included in the header size.
52 int initdevice(device
, sport
, tout
)
56 char devname
[16], *s
, buf
[256];
59 (void) strcpy(devname
, "/dev/");
60 (void) strncat(devname
, device
, sizeof(devname
) - strlen(devname
));
63 while (*s
&& !isdigit(*s
))
67 fprintf(stderr
, "bad device name %s\n", devname
);
75 if ((fd
= open(devname
, O_RDWR
)) < 0)
77 fprintf(stderr
, "O_RDWR(1) ");
82 if (dlattachreq(fd
, i
) == -1 || dlokack(fd
, buf
) == -1)
84 fprintf(stderr
, "DLPI error\n");
87 dlbindreq(fd
, ETHERTYPE_IP
, 0, DL_CLDLS
, 0, 0);
92 #ifdef sun /* we require RAW DLPI mode, which is a Sun extension */
93 if (strioctl(fd
, DLIOCRAW
, -1, 0, NULL
) == -1)
95 fprintf(stderr
, "DLIOCRAW error\n");
106 * output an IP packet onto a fd opened for /dev/nit
108 int sendip(fd
, pkt
, len
)
112 struct strbuf dbuf
, *dp
= &dbuf
;
115 * construct NIT STREAMS messages, first control then data.
119 dp
->maxlen
= dp
->len
;
121 if (putmsg(fd
, NULL
, dp
, 0) == -1)
126 if (ioctl(fd
, I_FLUSH
, FLUSHW
) == -1)