diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-02-09 18:53:00 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-02-24 16:03:40 +0100 |
commit | 811ed42ae52578d75421f6b0bd03c1843db9829e (patch) | |
tree | 2f6cd85ea1495e988b02b0c2a53a55ff906baee3 | |
parent | Merge remote-tracking branch 'origin/stable/2.0' (diff) | |
download | frr-811ed42ae52578d75421f6b0bd03c1843db9829e.tar.xz frr-811ed42ae52578d75421f6b0bd03c1843db9829e.zip |
pimd: Convert sizes to #defines
Convert the const int size of the encoded
types to #defines so that they can be
used elsewhere.
Return Null instead of 0.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r-- | pimd/pim_msg.c | 24 | ||||
-rw-r--r-- | pimd/pimd.h | 4 |
2 files changed, 13 insertions, 15 deletions
diff --git a/pimd/pim_msg.c b/pimd/pim_msg.c index ab14b3ae5..339e21ad3 100644 --- a/pimd/pim_msg.c +++ b/pimd/pim_msg.c @@ -72,27 +72,23 @@ uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf, int buf_size, struct in_addr addr) { - const int ENCODED_IPV4_UCAST_SIZE = 6; - - if (buf_size < ENCODED_IPV4_UCAST_SIZE) { - return 0; + if (buf_size < PIM_ENCODED_IPV4_UCAST_SIZE) { + return NULL; } buf[0] = PIM_MSG_ADDRESS_FAMILY_IPV4; /* addr family */ buf[1] = '\0'; /* native encoding */ memcpy(buf+2, &addr, sizeof(struct in_addr)); - return buf + ENCODED_IPV4_UCAST_SIZE; + return buf + PIM_ENCODED_IPV4_UCAST_SIZE; } uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, int buf_size, struct in_addr addr) { - const int ENCODED_IPV4_GROUP_SIZE = 8; - - if (buf_size < ENCODED_IPV4_GROUP_SIZE) { - return 0; + if (buf_size < PIM_ENCODED_IPV4_GROUP_SIZE) { + return NULL; } buf[0] = PIM_MSG_ADDRESS_FAMILY_IPV4; /* addr family */ @@ -101,17 +97,15 @@ uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, buf[3] = 32; /* mask len */ memcpy(buf+4, &addr, sizeof(struct in_addr)); - return buf + ENCODED_IPV4_GROUP_SIZE; + return buf + PIM_ENCODED_IPV4_GROUP_SIZE; } uint8_t * pim_msg_addr_encode_ipv4_source(uint8_t *buf, int buf_size, struct in_addr addr, uint8_t bits) { - const int ENCODED_IPV4_SOURCE_SIZE = 8; - - if (buf_size < ENCODED_IPV4_SOURCE_SIZE) { - return 0; + if (buf_size < PIM_ENCODED_IPV4_SOURCE_SIZE) { + return NULL; } buf[0] = PIM_MSG_ADDRESS_FAMILY_IPV4; /* addr family */ @@ -120,7 +114,7 @@ pim_msg_addr_encode_ipv4_source(uint8_t *buf, int buf_size, buf[3] = 32; /* mask len */ memcpy(buf+4, &addr, sizeof(struct in_addr)); - return buf + ENCODED_IPV4_SOURCE_SIZE; + return buf + PIM_ENCODED_IPV4_SOURCE_SIZE; } int diff --git a/pimd/pimd.h b/pimd/pimd.h index 1f8dcdfb2..f7cc132ee 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -38,6 +38,10 @@ #define PIM_IGMP_MIN_LEN (8) #define PIM_MSG_HEADER_LEN (4) #define PIM_PIM_MIN_LEN PIM_MSG_HEADER_LEN + +#define PIM_ENCODED_IPV4_UCAST_SIZE (6) +#define PIM_ENCODED_IPV4_GROUP_SIZE (8) +#define PIM_ENCODED_IPV4_SOURCE_SIZE (8) #define PIM_PROTO_VERSION (2) #define MCAST_ALL_SYSTEMS "224.0.0.1" |