]>
Commit | Line | Data |
---|---|---|
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" | |
88177fe3 | 27 | #include "zebra/zebra_ptm_redistribute.h" |
c43ed2e4 DS |
28 | |
29 | /* master zebra server structure */ | |
30 | extern struct zebra_t zebrad; | |
31 | ||
88177fe3 | 32 | static int |
c43ed2e4 DS |
33 | zsend_interface_bfd_update (int cmd, struct zserv *client, |
34 | struct interface *ifp, struct prefix *dp, | |
d553294e | 35 | struct prefix *sp, int status, vrf_id_t vrf_id) |
c43ed2e4 DS |
36 | { |
37 | int blen; | |
38 | struct stream *s; | |
39 | ||
40 | /* Check this client need interface information. */ | |
41 | if (! client->ifinfo) | |
42 | return 0; | |
43 | ||
44 | s = client->obuf; | |
45 | stream_reset (s); | |
46 | ||
d553294e | 47 | zserv_create_header (s, cmd, vrf_id); |
c43ed2e4 DS |
48 | if (ifp) |
49 | stream_putl (s, ifp->ifindex); | |
50 | else | |
51 | stream_putl (s, 0); | |
52 | ||
53 | /* BFD destination prefix information. */ | |
54 | stream_putc (s, dp->family); | |
55 | blen = prefix_blen (dp); | |
56 | stream_put (s, &dp->u.prefix, blen); | |
57 | stream_putc (s, dp->prefixlen); | |
58 | ||
68fe91d6 | 59 | /* BFD status */ |
60 | stream_putl(s, status); | |
61 | ||
c43ed2e4 DS |
62 | /* BFD source prefix information. */ |
63 | stream_putc (s, sp->family); | |
64 | blen = prefix_blen (sp); | |
65 | stream_put (s, &sp->u.prefix, blen); | |
66 | stream_putc (s, sp->prefixlen); | |
67 | ||
68 | /* Write packet size. */ | |
69 | stream_putw_at (s, 0, stream_get_endp (s)); | |
70 | ||
71 | client->if_bfd_cnt++; | |
72 | return zebra_server_send_message(client); | |
73 | } | |
74 | ||
75 | void | |
76 | zebra_interface_bfd_update (struct interface *ifp, struct prefix *dp, | |
d553294e | 77 | struct prefix *sp, int status, vrf_id_t vrf_id) |
c43ed2e4 DS |
78 | { |
79 | struct listnode *node, *nnode; | |
80 | struct zserv *client; | |
81 | ||
82 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) | |
83 | { | |
84 | /* Supporting for OSPF and BGP */ | |
7f342629 DS |
85 | if (client->proto != ZEBRA_ROUTE_OSPF && client->proto != ZEBRA_ROUTE_BGP |
86 | && client->proto != ZEBRA_ROUTE_OSPF6) | |
c43ed2e4 DS |
87 | continue; |
88 | ||
89 | /* Notify to the protocol daemons. */ | |
68fe91d6 | 90 | zsend_interface_bfd_update (ZEBRA_INTERFACE_BFD_DEST_UPDATE, client, ifp, |
d553294e | 91 | dp, sp, status, vrf_id); |
c43ed2e4 DS |
92 | } |
93 | } | |
94 | ||
88177fe3 | 95 | static int |
c43ed2e4 DS |
96 | zsend_bfd_peer_replay (int cmd, struct zserv *client) |
97 | { | |
98 | struct stream *s; | |
99 | ||
100 | s = client->obuf; | |
101 | stream_reset (s); | |
102 | ||
12f6fb97 | 103 | zserv_create_header (s, cmd, VRF_DEFAULT); //Pending: adjust when multi-vrf bfd work |
c43ed2e4 DS |
104 | |
105 | /* Write packet size. */ | |
106 | stream_putw_at (s, 0, stream_get_endp (s)); | |
107 | ||
108 | client->bfd_peer_replay_cnt++; | |
109 | return zebra_server_send_message(client); | |
110 | } | |
111 | ||
112 | void | |
113 | zebra_bfd_peer_replay_req (void) | |
114 | { | |
115 | struct listnode *node, *nnode; | |
116 | struct zserv *client; | |
117 | ||
118 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) | |
119 | { | |
120 | /* Supporting for BGP */ | |
7f342629 DS |
121 | if ((client->proto != ZEBRA_ROUTE_BGP) && |
122 | (client->proto != ZEBRA_ROUTE_OSPF) && | |
123 | (client->proto != ZEBRA_ROUTE_OSPF6)) | |
c43ed2e4 DS |
124 | continue; |
125 | ||
126 | /* Notify to the protocol daemons. */ | |
127 | zsend_bfd_peer_replay (ZEBRA_BFD_DEST_REPLAY, client); | |
128 | } | |
129 | } |