]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_ptm_redistribute.c
doc: Add `show ipv6 rpf X:X::X:X` command to docs
[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 *
896014f4
DL
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
c43ed2e4
DS
19 */
20
21#include <zebra.h>
22#include "prefix.h"
23#include "vty.h"
24#include "stream.h"
161e9ab7 25#include "zebra/zebra_router.h"
bf094f69 26#include "zebra/zapi_msg.h"
4943f243 27#include "zebra/zebra_ptm.h"
88177fe3 28#include "zebra/zebra_ptm_redistribute.h"
c43ed2e4 29
d62a17ae 30static int zsend_interface_bfd_update(int cmd, struct zserv *client,
31 struct interface *ifp, struct prefix *dp,
32 struct prefix *sp, int status,
33 vrf_id_t vrf_id)
c43ed2e4 34{
d62a17ae 35 int blen;
36 struct stream *s;
37
1002497a 38 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
d62a17ae 39
7cf15b25 40 zclient_create_header(s, cmd, vrf_id);
d62a17ae 41 if (ifp)
42 stream_putl(s, ifp->ifindex);
43 else
44 stream_putl(s, 0);
45
46 /* BFD destination prefix information. */
47 stream_putc(s, dp->family);
48 blen = prefix_blen(dp);
49 stream_put(s, &dp->u.prefix, blen);
50 stream_putc(s, dp->prefixlen);
51
52 /* BFD status */
53 stream_putl(s, status);
54
55 /* BFD source prefix information. */
56 stream_putc(s, sp->family);
57 blen = prefix_blen(sp);
58 stream_put(s, &sp->u.prefix, blen);
59 stream_putc(s, sp->prefixlen);
60
72c54143
DS
61 /* c-bit bullshit */
62 stream_putc(s, 0);
63
d62a17ae 64 /* Write packet size. */
65 stream_putw_at(s, 0, stream_get_endp(s));
66
67 client->if_bfd_cnt++;
21ccc0cf 68 return zserv_send_message(client, s);
c43ed2e4
DS
69}
70
d62a17ae 71void zebra_interface_bfd_update(struct interface *ifp, struct prefix *dp,
72 struct prefix *sp, int status, vrf_id_t vrf_id)
c43ed2e4 73{
d62a17ae 74 struct listnode *node, *nnode;
75 struct zserv *client;
76
161e9ab7 77 for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
4943f243 78 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
d62a17ae 79 continue;
80
81 /* Notify to the protocol daemons. */
82 zsend_interface_bfd_update(ZEBRA_INTERFACE_BFD_DEST_UPDATE,
83 client, ifp, dp, sp, status, vrf_id);
84 }
c43ed2e4
DS
85}
86
d62a17ae 87static int zsend_bfd_peer_replay(int cmd, struct zserv *client)
c43ed2e4 88{
d62a17ae 89 struct stream *s;
c43ed2e4 90
1002497a 91 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
c43ed2e4 92
7cf15b25 93 zclient_create_header(s, cmd, VRF_DEFAULT);
c43ed2e4 94
d62a17ae 95 /* Write packet size. */
96 stream_putw_at(s, 0, stream_get_endp(s));
c43ed2e4 97
d62a17ae 98 client->bfd_peer_replay_cnt++;
21ccc0cf 99 return zserv_send_message(client, s);
c43ed2e4
DS
100}
101
d62a17ae 102void zebra_bfd_peer_replay_req(void)
c43ed2e4 103{
d62a17ae 104 struct listnode *node, *nnode;
105 struct zserv *client;
106
161e9ab7 107 for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
4943f243 108 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
d62a17ae 109 continue;
110
111 /* Notify to the protocol daemons. */
112 zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY, client);
113 }
c43ed2e4 114}