|
|
| version 1.1, 2012/02/21 22:14:23 | version 1.1.1.2, 2013/07/22 11:54:42 |
|---|---|
| Line 67 libnet_close_raw6(libnet_t *l) | Line 67 libnet_close_raw6(libnet_t *l) |
| int | int |
| libnet_open_raw4(libnet_t *l) | libnet_open_raw4(libnet_t *l) |
| { | { |
| int len; | int len; /* now supposed to be socklen_t, but maybe old systems used int? */ |
| #if !(__WIN32__) | #if !(__WIN32__) |
| int n = 1; | int n = 1; |
| Line 107 libnet_open_raw4(libnet_t *l) | Line 107 libnet_open_raw4(libnet_t *l) |
| if (setsockopt(l->fd, IPPROTO_IP, IP_HDRINCL, nptr, sizeof(n)) == -1) | if (setsockopt(l->fd, IPPROTO_IP, IP_HDRINCL, nptr, sizeof(n)) == -1) |
| #else | #else |
| n = TRUE; | n = TRUE; |
| if (setsockopt(l->fd, IPPROTO_IP, IP_HDRINCL, (int8_t *)&n, | if (setsockopt(l->fd, IPPROTO_IP, IP_HDRINCL, &n, sizeof(n)) == -1) |
| sizeof(n)) == -1) | |
| #endif | #endif |
| { | { |
| Line 219 libnet_open_raw6(libnet_t *l) | Line 218 libnet_open_raw6(libnet_t *l) |
| return (-1); | return (-1); |
| } | } |
| l->fd = socket(PF_INET6, SOCK_RAW, IPPROTO_RAW); | l->fd = socket(AF_INET6, SOCK_RAW, IPPROTO_RAW); |
| if (l->fd == -1) | if (l->fd == -1) |
| { | { |
| snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
| Line 236 libnet_open_raw6(libnet_t *l) | Line 235 libnet_open_raw6(libnet_t *l) |
| strerror(errno)); | strerror(errno)); |
| goto bad; | goto bad; |
| } | } |
| if(l->device != NULL) | |
| if(setsockopt(l->fd, SOL_SOCKET, SO_BINDTODEVICE, l->device, strlen(l->device)) == -1) { | |
| snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
| "%s(): set SO_BINDTODEVICE failed: %s\n", __func__, strerror(errno)); | |
| goto bad; | |
| } | |
| #endif /* __linux__ */ | #endif /* __linux__ */ |
| return (l->fd); | return (l->fd); |