version 1.1.1.1, 2012/02/21 22:14:23
|
version 1.1.1.3, 2023/09/27 11:11:38
|
Line 30
|
Line 30
|
* |
* |
*/ |
*/ |
|
|
#if (HAVE_CONFIG_H) | #include "common.h" |
#include "../include/config.h" | |
#endif | |
#if (!(_WIN32) || (__CYGWIN__)) | |
#include "../include/libnet.h" | |
#else | |
#include "../include/win32/libnet.h" | |
#endif | |
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_igmp(u_int8_t type, u_int8_t code, u_int16_t sum, u_int32_t ip, | libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip, |
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_igmp_hdr igmp_hdr; |
struct libnet_igmp_hdr igmp_hdr; |
|
|
Line 66 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 59 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
} |
} |
|
|
memset(&igmp_hdr, 0, sizeof(igmp_hdr)); |
memset(&igmp_hdr, 0, sizeof(igmp_hdr)); |
igmp_hdr.igmp_type = type; /* packet type */ | igmp_hdr.igmp_type = type; |
igmp_hdr.igmp_code = code; /* packet code */ | igmp_hdr.igmp_code = reserved; |
igmp_hdr.igmp_sum = (sum ? htons(sum) : 0); /* packet checksum */ | igmp_hdr.igmp_sum = (sum ? htons(sum) : 0); |
igmp_hdr.igmp_group.s_addr = htonl(ip); | igmp_hdr.igmp_group.s_addr = ip; |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&igmp_hdr, LIBNET_IGMP_H); | n = libnet_pblock_append(l, p, (uint8_t *)&igmp_hdr, LIBNET_IGMP_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, | |
"%s(): payload inconsistency\n", __func__); | |
goto bad; | |
} | |
|
|
if (payload && payload_s) |
|
{ |
|
n = libnet_pblock_append(l, p, payload, payload_s); |
|
if (n == -1) |
|
{ |
|
goto bad; |
|
} |
|
} |
|
if (sum == 0) |
if (sum == 0) |
{ |
{ |
/* |
/* |
Line 102 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 83 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
libnet_pblock_setflags(p, LIBNET_PBLOCK_DO_CHECKSUM); |
libnet_pblock_setflags(p, LIBNET_PBLOCK_DO_CHECKSUM); |
} |
} |
|
|
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, LIBNET_PBLOCK_IGMP_H)); |
return (ptag ? ptag : libnet_pblock_update(l, p, h, LIBNET_PBLOCK_IGMP_H)); |
bad: |
bad: |
libnet_pblock_delete(l, p); |
libnet_pblock_delete(l, p); |
return (-1); |
return (-1); |
} |
} |
|
|
/* EOF */ | /** |
| * Local Variables: |
| * indent-tabs-mode: nil |
| * c-file-style: "stroustrup" |
| * End: |
| */ |