]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_ptm_redistribute.c
This patch changes ospfd from only listening mode for BFD status updates to interacti...
[mirror_frr.git] / zebra / zebra_ptm_redistribute.c
CommitLineData
c43ed2e4
DS
1/**
2 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
3 *
4 * This file is part of GNU Zebra.
5 *
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
9 * later version.
10 *
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22#include <zebra.h>
23#include "prefix.h"
24#include "vty.h"
25#include "stream.h"
26#include "zebra/zserv.h"
27
28/* master zebra server structure */
29extern struct zebra_t zebrad;
30
31int
32zsend_interface_bfd_update (int cmd, struct zserv *client,
33 struct interface *ifp, struct prefix *dp,
34 struct prefix *sp)
35{
36 int blen;
37 struct stream *s;
38
39 /* Check this client need interface information. */
40 if (! client->ifinfo)
41 return 0;
42
43 s = client->obuf;
44 stream_reset (s);
45
46 zserv_create_header (s, cmd);
47 if (ifp)
48 stream_putl (s, ifp->ifindex);
49 else
50 stream_putl (s, 0);
51
52 /* BFD destination prefix information. */
53 stream_putc (s, dp->family);
54 blen = prefix_blen (dp);
55 stream_put (s, &dp->u.prefix, blen);
56 stream_putc (s, dp->prefixlen);
57
58 /* BFD source prefix information. */
59 stream_putc (s, sp->family);
60 blen = prefix_blen (sp);
61 stream_put (s, &sp->u.prefix, blen);
62 stream_putc (s, sp->prefixlen);
63
64 /* Write packet size. */
65 stream_putw_at (s, 0, stream_get_endp (s));
66
67 client->if_bfd_cnt++;
68 return zebra_server_send_message(client);
69}
70
71void
72zebra_interface_bfd_update (struct interface *ifp, struct prefix *dp,
73 struct prefix *sp)
74{
75 struct listnode *node, *nnode;
76 struct zserv *client;
77
78 for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
79 {
80 /* Supporting for OSPF and BGP */
7f342629
DS
81 if (client->proto != ZEBRA_ROUTE_OSPF && client->proto != ZEBRA_ROUTE_BGP
82 && client->proto != ZEBRA_ROUTE_OSPF6)
c43ed2e4
DS
83 continue;
84
85 /* Notify to the protocol daemons. */
86 zsend_interface_bfd_update (ZEBRA_INTERFACE_BFD_DEST_DOWN, client, ifp,
87 dp, sp);
88 }
89}
90
91int
92zsend_bfd_peer_replay (int cmd, struct zserv *client)
93{
94 struct stream *s;
95
96 s = client->obuf;
97 stream_reset (s);
98
99 zserv_create_header (s, cmd);
100
101 /* Write packet size. */
102 stream_putw_at (s, 0, stream_get_endp (s));
103
104 client->bfd_peer_replay_cnt++;
105 return zebra_server_send_message(client);
106}
107
108void
109zebra_bfd_peer_replay_req (void)
110{
111 struct listnode *node, *nnode;
112 struct zserv *client;
113
114 for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
115 {
116 /* Supporting for BGP */
7f342629
DS
117 if ((client->proto != ZEBRA_ROUTE_BGP) &&
118 (client->proto != ZEBRA_ROUTE_OSPF) &&
119 (client->proto != ZEBRA_ROUTE_OSPF6))
c43ed2e4
DS
120 continue;
121
122 /* Notify to the protocol daemons. */
123 zsend_bfd_peer_replay (ZEBRA_BFD_DEST_REPLAY, client);
124 }
125}