- struct stream *s;
- int ret;
- int len;
-
- /* Individual reg/dereg messages are supressed during shutdown. */
- if (CHECK_FLAG (bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN))
- {
- if (bfd_debug)
- zlog_debug("%s: Suppressing BFD peer reg/dereg messages", __FUNCTION__);
- return;
- }
-
- /* Check socket. */
- if (!zclient || zclient->sock < 0)
- {
- if (bfd_debug)
- zlog_debug("%s: Can't send BFD peer register, Zebra client not "
- "established", __FUNCTION__);
- return;
- }
-
- s = zclient->obuf;
- stream_reset (s);
- zclient_create_header (s, command, vrf_id);
-
- stream_putl(s, getpid());
-
- stream_putw(s, family);
- switch (family)
- {
- case AF_INET:
- stream_put_in_addr (s, (struct in_addr *)dst_ip);
- break;
- case AF_INET6:
- stream_put(s, dst_ip, 16);
- break;
- default:
- break;
- }
-
- if (command != ZEBRA_BFD_DEST_DEREGISTER)
- {
- stream_putl(s, bfd_info->required_min_rx);
- stream_putl(s, bfd_info->desired_min_tx);
- stream_putc(s, bfd_info->detect_mult);
- }
-
- if (multihop)
- {
- stream_putc(s, 1);
- /* Multi-hop destination send the source IP address to BFD */
- if (src_ip)
- {
- stream_putw(s, family);
- switch (family)
- {
- case AF_INET:
- stream_put_in_addr (s, (struct in_addr *) src_ip);
- break;
- case AF_INET6:
- stream_put(s, src_ip, 16);
- break;
- default:
- break;
- }
- }
- stream_putc(s, ttl);
- }
- else
- {
- stream_putc(s, 0);
- if ((family == AF_INET6) && (src_ip))
- {
- stream_putw(s, family);
- stream_put(s, src_ip, 16);
- }
- if (if_name)
- {
- len = strlen(if_name);
- stream_putc(s, len);
- stream_put(s, if_name, len);
- }
- else
- {
- stream_putc(s, 0);
- }
- }
-
- stream_putw_at (s, 0, stream_get_endp (s));
-
- ret = zclient_send_message(zclient);
-
- if (ret < 0)
- {
- if (bfd_debug)
- zlog_debug("bfd_peer_sendmsg: zclient_send_message() failed");
- return;
- }
-
- if (set_flag)
- {
- if (command == ZEBRA_BFD_DEST_REGISTER)
- SET_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG);
- else if (command == ZEBRA_BFD_DEST_DEREGISTER)
- UNSET_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG);
- }
-
- return;
+ struct stream *s;
+ int ret;
+ int len;
+
+ /* Individual reg/dereg messages are supressed during shutdown. */
+ if (CHECK_FLAG(bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN)) {
+ if (bfd_debug)
+ zlog_debug(
+ "%s: Suppressing BFD peer reg/dereg messages",
+ __FUNCTION__);
+ return;
+ }
+
+ /* Check socket. */
+ if (!zclient || zclient->sock < 0) {
+ if (bfd_debug)
+ zlog_debug(
+ "%s: Can't send BFD peer register, Zebra client not "
+ "established",
+ __FUNCTION__);
+ return;
+ }
+
+ s = zclient->obuf;
+ stream_reset(s);
+ zclient_create_header(s, command, vrf_id);
+
+ stream_putl(s, getpid());
+
+ stream_putw(s, family);
+ switch (family) {
+ case AF_INET:
+ stream_put_in_addr(s, (struct in_addr *)dst_ip);
+ break;
+ case AF_INET6:
+ stream_put(s, dst_ip, 16);
+ break;
+ default:
+ break;
+ }
+
+ if (command != ZEBRA_BFD_DEST_DEREGISTER) {
+ stream_putl(s, bfd_info->required_min_rx);
+ stream_putl(s, bfd_info->desired_min_tx);
+ stream_putc(s, bfd_info->detect_mult);
+ }
+
+ if (multihop) {
+ stream_putc(s, 1);
+ /* Multi-hop destination send the source IP address to BFD */
+ if (src_ip) {
+ stream_putw(s, family);
+ switch (family) {
+ case AF_INET:
+ stream_put_in_addr(s, (struct in_addr *)src_ip);
+ break;
+ case AF_INET6:
+ stream_put(s, src_ip, 16);
+ break;
+ default:
+ break;
+ }
+ }
+ stream_putc(s, ttl);
+ } else {
+ stream_putc(s, 0);
+ if ((family == AF_INET6) && (src_ip)) {
+ stream_putw(s, family);
+ stream_put(s, src_ip, 16);
+ }
+ if (if_name) {
+ len = strlen(if_name);
+ stream_putc(s, len);
+ stream_put(s, if_name, len);
+ } else {
+ stream_putc(s, 0);
+ }
+ }
+
+ stream_putw_at(s, 0, stream_get_endp(s));
+
+ ret = zclient_send_message(zclient);
+
+ if (ret < 0) {
+ if (bfd_debug)
+ zlog_debug(
+ "bfd_peer_sendmsg: zclient_send_message() failed");
+ return;
+ }
+
+ if (set_flag) {
+ if (command == ZEBRA_BFD_DEST_REGISTER)
+ SET_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG);
+ else if (command == ZEBRA_BFD_DEST_DEREGISTER)
+ UNSET_FLAG(bfd_info->flags, BFD_FLAG_BFD_REG);
+ }
+
+ return;