2 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "zebra/zebra_router.h"
26 #include "zebra/zapi_msg.h"
27 #include "zebra/zebra_ptm.h"
28 #include "zebra/zebra_ptm_redistribute.h"
29 #include "zebra/zebra_memory.h"
31 static int zsend_interface_bfd_update(int cmd
, struct zserv
*client
,
32 struct interface
*ifp
, struct prefix
*dp
,
33 struct prefix
*sp
, int status
,
39 /* Check this client need interface information. */
40 if (!vrf_bitmap_check(client
->ifinfo
, ifp
->vrf_id
))
43 s
= stream_new(ZEBRA_MAX_PACKET_SIZ
);
45 zclient_create_header(s
, cmd
, vrf_id
);
47 stream_putl(s
, ifp
->ifindex
);
51 /* BFD destination prefix information. */
52 stream_putc(s
, dp
->family
);
53 blen
= prefix_blen(dp
);
54 stream_put(s
, &dp
->u
.prefix
, blen
);
55 stream_putc(s
, dp
->prefixlen
);
58 stream_putl(s
, status
);
60 /* BFD source prefix information. */
61 stream_putc(s
, sp
->family
);
62 blen
= prefix_blen(sp
);
63 stream_put(s
, &sp
->u
.prefix
, blen
);
64 stream_putc(s
, sp
->prefixlen
);
66 /* Write packet size. */
67 stream_putw_at(s
, 0, stream_get_endp(s
));
70 return zserv_send_message(client
, s
);
73 void zebra_interface_bfd_update(struct interface
*ifp
, struct prefix
*dp
,
74 struct prefix
*sp
, int status
, vrf_id_t vrf_id
)
76 struct listnode
*node
, *nnode
;
79 for (ALL_LIST_ELEMENTS(zrouter
.client_list
, node
, nnode
, client
)) {
80 if (!IS_BFD_ENABLED_PROTOCOL(client
->proto
))
83 /* Notify to the protocol daemons. */
84 zsend_interface_bfd_update(ZEBRA_INTERFACE_BFD_DEST_UPDATE
,
85 client
, ifp
, dp
, sp
, status
, vrf_id
);
89 static int zsend_bfd_peer_replay(int cmd
, struct zserv
*client
)
93 s
= stream_new(ZEBRA_MAX_PACKET_SIZ
);
95 zclient_create_header(s
, cmd
, VRF_DEFAULT
);
97 /* Write packet size. */
98 stream_putw_at(s
, 0, stream_get_endp(s
));
100 client
->bfd_peer_replay_cnt
++;
101 return zserv_send_message(client
, s
);
104 void zebra_bfd_peer_replay_req(void)
106 struct listnode
*node
, *nnode
;
107 struct zserv
*client
;
109 for (ALL_LIST_ELEMENTS(zrouter
.client_list
, node
, nnode
, client
)) {
110 if (!IS_BFD_ENABLED_PROTOCOL(client
->proto
))
113 /* Notify to the protocol daemons. */
114 zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY
, client
);