- const uint8_t *addr;
- const uint8_t *pastend;
-
- zassert(hello_option_addr_list);
-
- /*
- Scan addr list
- */
- addr = tlv_curr;
- pastend = tlv_curr + option_len;
- while (addr < pastend) {
- struct prefix tmp;
- int addr_offset;
-
- /*
- Parse ucast addr
- */
- addr_offset = pim_parse_addr_ucast(&tmp, addr, pastend - addr);
- if (addr_offset < 1) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
- zlog_warn("%s: pim_parse_addr_ucast() failure: from %s on %s",
- __PRETTY_FUNCTION__,
- src_str, ifname);
- FREE_ADDR_LIST(*hello_option_addr_list);
- return -1;
- }
- addr += addr_offset;
-
- /*
- Debug
- */
- if (PIM_DEBUG_PIM_TRACE) {
- switch (tmp.family) {
- case AF_INET:
- {
- char addr_str[INET_ADDRSTRLEN];
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<addr?>", tmp.u.prefix4, addr_str, sizeof(addr_str));
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
- zlog_debug("%s: PIM hello TLV option: list_old_size=%d IPv4 address %s from %s on %s",
- __PRETTY_FUNCTION__,
- *hello_option_addr_list ?
- ((int) listcount(*hello_option_addr_list)) : -1,
- addr_str, src_str, ifname);
- }
- break;
- case AF_INET6:
- break;
- default:
- {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
- zlog_debug("%s: PIM hello TLV option: list_old_size=%d UNKNOWN address family from %s on %s",
- __PRETTY_FUNCTION__,
- *hello_option_addr_list ?
- ((int) listcount(*hello_option_addr_list)) : -1,
- src_str, ifname);
- }
- }
- }
-
- /*
- Exclude neighbor's primary address if incorrectly included in
- the secondary address list
- */
- if (tmp.family == AF_INET) {
- if (tmp.u.prefix4.s_addr == src_addr.s_addr) {
- char src_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
- zlog_warn("%s: ignoring primary address in secondary list from %s on %s",
- __PRETTY_FUNCTION__,
- src_str, ifname);
- continue;
- }
- }
-
- /*
- Allocate list if needed
- */
- if (!*hello_option_addr_list) {
- *hello_option_addr_list = list_new();
- if (!*hello_option_addr_list) {
- zlog_err("%s %s: failure: hello_option_addr_list=list_new()",
- __FILE__, __PRETTY_FUNCTION__);
- return -2;
- }
- (*hello_option_addr_list)->del = (void (*)(void *)) prefix_free;
- }
-
- /*
- Attach addr to list
- */
- {
- struct prefix *p;
- p = prefix_new();
- if (!p) {
- zlog_err("%s %s: failure: prefix_new()",
- __FILE__, __PRETTY_FUNCTION__);
- FREE_ADDR_LIST(*hello_option_addr_list);
- return -3;
- }
- prefix_copy(p, &tmp);
- listnode_add(*hello_option_addr_list, p);
- }
-
- } /* while (addr < pastend) */
-
- /*
- Mark hello option
- */
- PIM_OPTION_SET(*hello_options, PIM_OPTION_MASK_ADDRESS_LIST);
-
- return 0;
+ const uint8_t *addr;
+ const uint8_t *pastend;
+
+ zassert(hello_option_addr_list);
+
+ /*
+ Scan addr list
+ */
+ addr = tlv_curr;
+ pastend = tlv_curr + option_len;
+ while (addr < pastend) {
+ struct prefix tmp;
+ int addr_offset;
+
+ /*
+ Parse ucast addr
+ */
+ addr_offset = pim_parse_addr_ucast(&tmp, addr, pastend - addr);
+ if (addr_offset < 1) {
+ char src_str[INET_ADDRSTRLEN];
+ pim_inet4_dump("<src?>", src_addr, src_str,
+ sizeof(src_str));
+ zlog_warn(
+ "%s: pim_parse_addr_ucast() failure: from %s on %s",
+ __PRETTY_FUNCTION__, src_str, ifname);
+ FREE_ADDR_LIST(*hello_option_addr_list);
+ return -1;
+ }
+ addr += addr_offset;
+
+ /*
+ Debug
+ */
+ if (PIM_DEBUG_PIM_TRACE) {
+ switch (tmp.family) {
+ case AF_INET: {
+ char addr_str[INET_ADDRSTRLEN];
+ char src_str[INET_ADDRSTRLEN];
+ pim_inet4_dump("<addr?>", tmp.u.prefix4,
+ addr_str, sizeof(addr_str));
+ pim_inet4_dump("<src?>", src_addr, src_str,
+ sizeof(src_str));
+ zlog_debug(
+ "%s: PIM hello TLV option: list_old_size=%d IPv4 address %s from %s on %s",
+ __PRETTY_FUNCTION__,
+ *hello_option_addr_list
+ ? ((int)listcount(
+ *hello_option_addr_list))
+ : -1,
+ addr_str, src_str, ifname);
+ } break;
+ case AF_INET6:
+ break;
+ default: {
+ char src_str[INET_ADDRSTRLEN];
+ pim_inet4_dump("<src?>", src_addr, src_str,
+ sizeof(src_str));
+ zlog_debug(
+ "%s: PIM hello TLV option: list_old_size=%d UNKNOWN address family from %s on %s",
+ __PRETTY_FUNCTION__,
+ *hello_option_addr_list
+ ? ((int)listcount(
+ *hello_option_addr_list))
+ : -1,
+ src_str, ifname);
+ }
+ }
+ }
+
+ /*
+ Exclude neighbor's primary address if incorrectly included in
+ the secondary address list
+ */
+ if (tmp.family == AF_INET) {
+ if (tmp.u.prefix4.s_addr == src_addr.s_addr) {
+ char src_str[INET_ADDRSTRLEN];
+ pim_inet4_dump("<src?>", src_addr, src_str,
+ sizeof(src_str));
+ zlog_warn(
+ "%s: ignoring primary address in secondary list from %s on %s",
+ __PRETTY_FUNCTION__, src_str, ifname);
+ continue;
+ }
+ }
+
+ /*
+ Allocate list if needed
+ */
+ if (!*hello_option_addr_list) {
+ *hello_option_addr_list = list_new();
+ (*hello_option_addr_list)->del =
+ (void (*)(void *))prefix_free;
+ }
+
+ /*
+ Attach addr to list
+ */
+ {
+ struct prefix *p;
+ p = prefix_new();
+ prefix_copy(p, &tmp);
+ listnode_add(*hello_option_addr_list, p);
+ }
+
+ } /* while (addr < pastend) */
+
+ /*
+ Mark hello option
+ */
+ PIM_OPTION_SET(*hello_options, PIM_OPTION_MASK_ADDRESS_LIST);
+
+ return 0;