version 1.1.1.2, 2013/07/22 11:54:42
|
version 1.1.1.3, 2023/09/27 11:11:38
|
Line 30
|
Line 30
|
* Extraction/creation by Jeffrey Mogul, DECWRL |
* Extraction/creation by Jeffrey Mogul, DECWRL |
*/ |
*/ |
|
|
#if (HAVE_CONFIG_H) | #include "common.h" |
#include "../include/config.h" | |
#endif | |
#include "../include/low_libnet.h" | |
|
|
#include "../include/gnuc.h" |
#include "../include/gnuc.h" |
#ifdef HAVE_OS_PROTO_H |
#ifdef HAVE_OS_PROTO_H |
Line 52 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
Line 49 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
l = (struct libnet_link_int *)malloc(sizeof(*l)); |
l = (struct libnet_link_int *)malloc(sizeof(*l)); |
if (l == NULL) |
if (l == NULL) |
{ |
{ |
sprintf(ebuf, "libnet_open_link_int: %s", strerror(errno)); | snprintf(ebuf, LIBNET_ERRBUF_SIZE, |
| "libnet_open_link_int: %s", strerror(errno)); |
return (0); |
return (0); |
} |
} |
memset(l, 0, sizeof(*l)); |
memset(l, 0, sizeof(*l)); |
l->fd = pfopen(device, O_RDWR); |
l->fd = pfopen(device, O_RDWR); |
if (l->fd < 0) |
if (l->fd < 0) |
{ |
{ |
sprintf(ebuf, "pf open: %s: %s\n\your system may not be properly configured; see \"man packetfilter(4)\"\n", | snprintf(ebuf, LIBNET_ERRBUF_SIZE, |
| "pf open: %s: %s\nyour system may not be properly configured; see \"man packetfilter(4)\"", |
device, strerror(errno)); |
device, strerror(errno)); |
goto bad; |
goto bad; |
} |
} |
Line 67 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
Line 66 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
enmode = ENTSTAMP|ENBATCH|ENNONEXCL; |
enmode = ENTSTAMP|ENBATCH|ENNONEXCL; |
if (ioctl(l->fd, EIOCMBIS, (caddr_t)&enmode) < 0) |
if (ioctl(l->fd, EIOCMBIS, (caddr_t)&enmode) < 0) |
{ |
{ |
sprintf(ebuf, "EIOCMBIS: %s", strerror(errno)); | snprintf(ebuf, LIBNET_ERRBUF_SIZE, |
| "EIOCMBIS: %s", strerror(errno)); |
goto bad; |
goto bad; |
} |
} |
#ifdef ENCOPYALL |
#ifdef ENCOPYALL |
Line 78 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
Line 78 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
/* set the backlog */ |
/* set the backlog */ |
if (ioctl(l->fd, EIOCSETW, (caddr_t)&backlog) < 0) |
if (ioctl(l->fd, EIOCSETW, (caddr_t)&backlog) < 0) |
{ |
{ |
sprintf(ebuf, "EIOCSETW: %s", strerror(errno)); | snprintf(ebuf, LIBNET_ERRBUF_SIZE, |
| "EIOCSETW: %s", strerror(errno)); |
goto bad; |
goto bad; |
} |
} |
/* |
/* |
Line 86 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
Line 87 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
*/ |
*/ |
if (ioctl(l->fd, EIOCDEVP, (caddr_t)&devparams) < 0) |
if (ioctl(l->fd, EIOCDEVP, (caddr_t)&devparams) < 0) |
{ |
{ |
sprintf(ebuf, "EIOCDEVP: %s", strerror(errno)); | snprintf(ebuf, LIBNET_ERRBUF_SIZE, |
| "EIOCDEVP: %s", strerror(errno)); |
goto bad; |
goto bad; |
} |
} |
|
|
Line 120 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
Line 122 libnet_open_link_interface(int8_t *device, int8_t *ebu
|
Filter.enf_FilterLen = 0; /* means "always true" */ |
Filter.enf_FilterLen = 0; /* means "always true" */ |
if (ioctl(l->fd, EIOCSETF, (caddr_t)&Filter) < 0) |
if (ioctl(l->fd, EIOCSETF, (caddr_t)&Filter) < 0) |
{ |
{ |
sprintf(ebuf, "EIOCSETF: %s", strerror(errno)); | snprintf(ebuf, LIBNET_ERRBUF_SIZE, |
| "EIOCSETF: %s", strerror(errno)); |
goto bad; |
goto bad; |
} |
} |
|
|
Line 157 libnet_write_link_layer(struct libnet_link_int *l, con
|
Line 160 libnet_write_link_layer(struct libnet_link_int *l, con
|
if (c != len) |
if (c != len) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"libnet_write_link: %d bytes written (%s)\n", c, | "libnet_write_link: %d bytes written (%s)", c, |
strerror(errno)); |
strerror(errno)); |
} |
} |
return (c); |
return (c); |
} |
} |
|
|
|
/** |
|
* Local Variables: |
|
* indent-tabs-mode: nil |
|
* c-file-style: "stroustrup" |
|
* End: |
|
*/ |