Ethereal-dev: Re: [ethereal-dev] Sending raw packets
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Stefan `Sec` Zehl <sec@xxxxxx>
Date: Thu, 7 Jan 1999 04:56:56 +0100
On Thu, Jan 07, 1999 at 04:52:04AM +0100, Stefan `Sec` Zehl wrote: > Some searching around made me find that patch again, I attached it. attached ? I need a new brain :-( CU, Sec -- CUSTOMER: "I'm running Windows '95." > TECH: "Yes." CUSTOMER: "My computer isn't working now." > TECH: "Yes, you already said that." -- (found in comp.os.linux.misc)
--- libpcap-0.4a5/pcap-bpf.c Tue Dec 31 23:53:50 1996 +++ libpcap-changed/pcap-bpf.c Sun Dec 07 11:21:55 1997 @@ -141,7 +141,8 @@ */ do { (void)sprintf(device, "/dev/bpf%d", n++); - fd = open(device, O_RDONLY); +/*patched by jamal to allow writting */ + fd = open(device, O_RDWR); } while (fd < 0 && errno == EBUSY); /* @@ -253,3 +254,15 @@ } return (0); } + + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +*/ +int +pcap_write(pcap_t *pd, unsigned char *buf,int count) +{ +if (write(pd->fd, buf, count) != count) +return -1; +else return count; +} --- libpcap-0.4a5/pcap-dlpi.c Thu Oct 16 00:59:34 1997 +++ libpcap-changed/pcap-dlpi.c Sun Dec 07 11:23:07 1997 @@ -846,3 +846,14 @@ return (cc); } #endif + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +*/ +int +pcap_write(pcap_t *pd, unsigned char *buf,int count) +{ +if (write(pd->fd, buf, count) != count) +return -1; +else return count; +} --- libpcap-0.4a5/pcap-enet.c Wed Dec 11 02:11:47 1996 +++ libpcap-changed/pcap-enet.c Sun Dec 07 11:23:56 1997 @@ -148,10 +148,13 @@ u_int maxwaiting; int if_fd; +/* patched by jamal to read-write to allow +writting of frames +*/ #ifdef IBMRTPC - GETENETDEVICE(0, O_RDONLY, &if_fd); + GETENETDEVICE(0, O_RDWR, &if_fd); #else /* !IBMRTPC */ - if_fd = open("/dev/enet", O_RDONLY, 0); + if_fd = open("/dev/enet", O_RDWR, 0); #endif /* IBMRTPC */ if (if_fd == -1) { @@ -225,3 +228,15 @@ return(if_fd); } + + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +*/ +int +pcap_write(pcap_t *pd, unsigned char *buf,int count) +{ +if (write(pd->fd, buf, count) != count) +return -1; +else return count; +} --- libpcap-0.4a5/pcap-linux.c Fri Oct 3 01:39:53 1997 +++ libpcap-changed/pcap-linux.c Sun Dec 07 11:47:50 1997 @@ -329,3 +329,27 @@ else if (ioctl(fd, SIOCSIFFLAGS, &saved_ifr) < 0) fprintf(stderr, "linux SIOCSIFFLAGS: %s", pcap_strerror(errno)); } + + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +*/ +int +pcap_write(pcap_t *pd, unsigned unsigned char *buf,int count) +{ +int i; +struct sockaddr sa; + +sa.sa_family = PF_INET; +strcpy(sa.sa_data, pd->md.device); + +i=sendto(pd->fd, buf, count, 0, &sa, sizeof(sa)); +if (i<0) + { + return (-1); + } +if (i != count) +return -1; +else return i; + +} Only in libpcap-changed: pcap-linux.o --- libpcap-0.4a5/pcap-nit.c Wed Dec 11 02:15:01 1996 +++ libpcap-changed/pcap-nit.c Sun Dec 07 11:25:34 1997 @@ -242,3 +242,17 @@ p->fcode = *fp; return (0); } + + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +Someone please verify this; maybe we need to use +sendto() instead of write +*/ +int +pcap_write(pcap_t *pd, unsigned char *buf,count) +{ +if (write(pd->fd, buf, count) != count) +return -1; +else return count; +} --- libpcap-0.4a5/pcap-pf.c Wed Dec 11 02:15:01 1996 +++ libpcap-changed/pcap-pf.c Sun Dec 07 11:18:54 1997 @@ -214,7 +214,8 @@ return (0); } bzero((char *)p, sizeof(*p)); - p->fd = pfopen(device, O_RDONLY); +/* patched by jamal to allow writting */ + p->fd = pfopen(device, O_RDWR); if (p->fd < 0) { sprintf(ebuf, "pf open: %s: %s\n\ your system may not be properly configured; see \"man packetfilter(4)\"\n", @@ -349,3 +350,15 @@ fprintf(stderr, "tcpdump: Filtering in user process\n"); return (0); } + + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +*/ +int +pcap_write(pcap_t *pd, unsigned char *buf,int count) +{ +if (write(pd->fd, buf, count) != count +return -1; +else return count; +} --- libpcap-0.4a5/pcap-snit.c Wed Dec 11 02:15:02 1996 +++ libpcap-changed/pcap-snit.c Sun Dec 07 11:19:56 1997 @@ -222,7 +222,8 @@ snaplen = 96; bzero(p, sizeof(*p)); - p->fd = fd = open(dev, O_RDONLY); +/* patched by jamal to allow writting */ + p->fd = fd = open(dev, O_RDWR); if (fd < 0) { sprintf(ebuf, "%s: %s", dev, pcap_strerror(errno)); goto bad; @@ -298,3 +299,15 @@ p->fcode = *fp; return (0); } + + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +*/ +int +pcap_write(pcap_t *pd, unsigned char *buf,int count) +{ +if (write(pd->fd, buf, count) != count) +return -1; +else return count; +} --- libpcap-0.4a5/pcap-snoop.c Wed Apr 9 00:07:01 1997 +++ libpcap-changed/pcap-snoop.c Sun Dec 07 11:27:04 1997 @@ -214,3 +214,17 @@ p->fcode = *fp; return (0); } + + +/* patched by jamal to allow writting of +frames to the open device at the datalink layer +Someone please verify this +maybe we need to use sendto instead of write +*/ +int +pcap_write(pcap_t *pd, unsigned char *buf,int count) +{ +if (write(pd->fd, buf, count) != count) +return -1; +else return count; +} --- libpcap-0.4a5/pcap.h Thu Oct 16 00:59:16 1997 +++ libpcap-changed/pcap.h Sun Dec 07 11:40:08 1997 @@ -111,6 +111,7 @@ int pcap_stats(pcap_t *, struct pcap_stat *); int pcap_setfilter(pcap_t *, struct bpf_program *); void pcap_perror(pcap_t *, char *); +int pcap_write(pcap_t *, unsigned char *,int); char *pcap_strerror(int); char *pcap_geterr(pcap_t *); int pcap_compile(pcap_t *, struct bpf_program *, char *, int,
- References:
- Re: [ethereal-dev] Sending raw packets
- From: Stefan `Sec` Zehl
- Re: [ethereal-dev] Sending raw packets
- From: Christian Brunner
- Re: [ethereal-dev] Sending raw packets
- From: Stefan `Sec` Zehl
- Re: [ethereal-dev] Sending raw packets
- Prev by Date: Re: [ethereal-dev] Sending raw packets
- Next by Date: Re: [ethereal-dev] Viewing packets while capturing...
- Previous by thread: Re: [ethereal-dev] Sending raw packets
- Next by thread: Re: [ethereal-dev] Sending raw packets
- Index(es):