]>
git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_mroute.c
2 * Copyright (C) 2016 Cumulus Networks, Inc.
5 * This file is part of Quagga
7 * Quagga is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * Quagga is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include "zebra/zserv.h"
30 #include "zebra/zebra_vrf.h"
31 #include "zebra/zebra_mroute.h"
33 #include "zebra/debug.h"
35 void zebra_ipmr_route_stats(ZAPI_HANDLER_ARGS
)
37 struct mcast_route_data mroute
;
41 memset(&mroute
, 0, sizeof(mroute
));
42 STREAM_GETL(msg
, mroute
.family
);
44 switch (mroute
.family
) {
46 SET_IPADDR_V4(&mroute
.src
);
47 SET_IPADDR_V4(&mroute
.grp
);
48 STREAM_GET(&mroute
.src
.ipaddr_v4
, msg
,
49 sizeof(mroute
.src
.ipaddr_v4
));
50 STREAM_GET(&mroute
.grp
.ipaddr_v4
, msg
,
51 sizeof(mroute
.grp
.ipaddr_v4
));
54 SET_IPADDR_V6(&mroute
.src
);
55 SET_IPADDR_V6(&mroute
.grp
);
56 STREAM_GET(&mroute
.src
.ipaddr_v6
, msg
,
57 sizeof(mroute
.src
.ipaddr_v6
));
58 STREAM_GET(&mroute
.grp
.ipaddr_v6
, msg
,
59 sizeof(mroute
.grp
.ipaddr_v6
));
62 zlog_warn("%s: Invalid address family received while parsing",
67 STREAM_GETL(msg
, mroute
.ifindex
);
69 if (IS_ZEBRA_DEBUG_KERNEL
)
70 zlog_debug("Asking for (%pIA,%pIA)[%s(%u)] mroute information",
71 &mroute
.src
, &mroute
.grp
, zvrf
->vrf
->name
,
74 suc
= kernel_get_ipmr_sg_stats(zvrf
, &mroute
);
77 s
= stream_new(ZEBRA_MAX_PACKET_SIZ
);
81 zclient_create_header(s
, ZEBRA_IPMR_ROUTE_STATS
, zvrf_id(zvrf
));
83 if (mroute
.family
== AF_INET
) {
84 stream_write(s
, &mroute
.src
.ipaddr_v4
,
85 sizeof(mroute
.src
.ipaddr_v4
));
86 stream_write(s
, &mroute
.grp
.ipaddr_v4
,
87 sizeof(mroute
.grp
.ipaddr_v4
));
89 stream_write(s
, &mroute
.src
.ipaddr_v6
,
90 sizeof(mroute
.src
.ipaddr_v6
));
91 stream_write(s
, &mroute
.grp
.ipaddr_v6
,
92 sizeof(mroute
.grp
.ipaddr_v6
));
95 stream_put(s
, &mroute
.lastused
, sizeof(mroute
.lastused
));
96 stream_putl(s
, (uint32_t)suc
);
98 stream_putw_at(s
, 0, stream_get_endp(s
));
99 zserv_send_message(client
, s
);