summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2012-02-15 17:51:16 -0800
committerSam Roberts <vieuxtech@gmail.com>2012-02-15 17:51:16 -0800
commit22b428e121d6a8458da79b2aa2f58bf795dfba6a (patch)
treed238e7e8d96e0f60a2b8e363dbc551416416ba4f
parentbdb720c97e96c9dbc0d9d7ed4b8e00a65d7686bc (diff)
downloadlibnet-22b428e121d6a8458da79b2aa2f58bf795dfba6a.tar.gz
libnet_build_igmp reserved field was mistakenly called 'code'
Looks like error occurred because function was a copy of libnet_build_icmp().
-rw-r--r--libnet/include/libnet/libnet-functions.h6
-rw-r--r--libnet/include/libnet/libnet-headers.h2
-rw-r--r--libnet/src/libnet_build_igmp.c8
3 files changed, 9 insertions, 7 deletions
diff --git a/libnet/include/libnet/libnet-functions.h b/libnet/include/libnet/libnet-functions.h
index 7cc3060..49a968f 100644
--- a/libnet/include/libnet/libnet-functions.h
+++ b/libnet/include/libnet/libnet-functions.h
@@ -797,7 +797,7 @@ uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/**
* Builds an RFC 1112 Internet Group Memebership Protocol (IGMP) header.
* @param type packet type
- * @param code packet code (should be 0)
+ * @param reserved (should be 0 for IGMPv1)
* @param sum checksum (0 for libnet to autofill)
* @param ip IPv4 address (in standard/network byte order)
* @param payload optional payload or NULL
@@ -805,9 +805,11 @@ uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
* @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error
+ *
+ * @note 'reserved' was previously called 'code', which it is not, in any IGMP version.
*/
libnet_ptag_t
-libnet_build_igmp(uint8_t type, uint8_t code, uint16_t sum, uint32_t ip,
+libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip,
const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/**
diff --git a/libnet/include/libnet/libnet-headers.h b/libnet/include/libnet/libnet-headers.h
index 11065c7..b126e39 100644
--- a/libnet/include/libnet/libnet-headers.h
+++ b/libnet/include/libnet/libnet-headers.h
@@ -1062,7 +1062,7 @@ struct libnet_igmp_hdr
#ifndef IGMP_LEAVE_GROUP
#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
#endif
- uint8_t igmp_code; /* IGMP code */
+ uint8_t igmp_code; /* IGMP reserved field (0), mistakenly called 'code' in early libnet versions */
uint16_t igmp_sum; /* IGMP checksum */
struct in_addr igmp_group;/* IGMP host IP */
};
diff --git a/libnet/src/libnet_build_igmp.c b/libnet/src/libnet_build_igmp.c
index 9dd5bc6..70ac10d 100644
--- a/libnet/src/libnet_build_igmp.c
+++ b/libnet/src/libnet_build_igmp.c
@@ -40,7 +40,7 @@
#endif
libnet_ptag_t
-libnet_build_igmp(uint8_t type, uint8_t code, uint16_t sum, uint32_t ip,
+libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip,
const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
{
uint32_t n, h;
@@ -66,9 +66,9 @@ const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
}
memset(&igmp_hdr, 0, sizeof(igmp_hdr));
- igmp_hdr.igmp_type = type; /* packet type */
- igmp_hdr.igmp_code = code; /* packet code */
- igmp_hdr.igmp_sum = (sum ? htons(sum) : 0); /* packet checksum */
+ igmp_hdr.igmp_type = type;
+ igmp_hdr.igmp_code = reserved;
+ igmp_hdr.igmp_sum = (sum ? htons(sum) : 0);
igmp_hdr.igmp_group.s_addr = ip;
n = libnet_pblock_append(l, p, (uint8_t *)&igmp_hdr, LIBNET_IGMP_H);