]>
Commit | Line | Data |
---|---|---|
e3be0432 DS |
1 | /* zebra_mroute code |
2 | * Copyright (C) 2016 Cumulus Networks, Inc. | |
3 | * Donald Sharp | |
4 | * | |
5 | * This file is part of Quagga | |
6 | * | |
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 | |
10 | * later version. | |
11 | * | |
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. | |
16 | * | |
896014f4 DL |
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 | |
e3be0432 DS |
20 | */ |
21 | ||
22 | #include <zebra.h> | |
23 | ||
24 | #include "stream.h" | |
25 | #include "prefix.h" | |
26 | #include "vrf.h" | |
27 | #include "rib.h" | |
28 | ||
29 | #include "zebra/zserv.h" | |
30 | #include "zebra/zebra_vrf.h" | |
31 | #include "zebra/zebra_mroute.h" | |
1498c059 | 32 | #include "zebra/rt.h" |
7649a4f6 | 33 | #include "zebra/debug.h" |
e3be0432 | 34 | |
89f4e507 | 35 | void zebra_ipmr_route_stats(ZAPI_HANDLER_ARGS) |
e3be0432 | 36 | { |
d62a17ae | 37 | struct mcast_route_data mroute; |
38 | struct stream *s; | |
ec93aa12 | 39 | int suc = -1; |
e3be0432 | 40 | |
d62a17ae | 41 | memset(&mroute, 0, sizeof(mroute)); |
1002497a QY |
42 | STREAM_GET(&mroute.sg.src, msg, 4); |
43 | STREAM_GET(&mroute.sg.grp, msg, 4); | |
44 | STREAM_GETL(msg, mroute.ifindex); | |
e3be0432 | 45 | |
7649a4f6 DS |
46 | if (IS_ZEBRA_DEBUG_KERNEL) { |
47 | char sbuf[40]; | |
48 | char gbuf[40]; | |
49 | ||
9bcef951 MS |
50 | inet_ntop(AF_INET, &mroute.sg.src, sbuf, sizeof(sbuf)); |
51 | inet_ntop(AF_INET, &mroute.sg.grp, gbuf, sizeof(gbuf)); | |
7649a4f6 | 52 | |
42364890 DS |
53 | zlog_debug("Asking for (%s,%s)[%s(%u)] mroute information", |
54 | sbuf, gbuf, zvrf->vrf->name, zvrf->vrf->vrf_id); | |
7649a4f6 | 55 | } |
e3be0432 | 56 | |
43b5cc5e | 57 | suc = kernel_get_ipmr_sg_stats(zvrf, &mroute); |
e3be0432 | 58 | |
ec93aa12 | 59 | stream_failure: |
1002497a | 60 | s = stream_new(ZEBRA_MAX_PACKET_SIZ); |
e3be0432 | 61 | |
d62a17ae | 62 | stream_reset(s); |
e3be0432 | 63 | |
7cf15b25 | 64 | zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS, zvrf_id(zvrf)); |
d62a17ae | 65 | stream_put_in_addr(s, &mroute.sg.src); |
66 | stream_put_in_addr(s, &mroute.sg.grp); | |
67 | stream_put(s, &mroute.lastused, sizeof(mroute.lastused)); | |
68 | stream_putl(s, suc); | |
e3be0432 | 69 | |
d62a17ae | 70 | stream_putw_at(s, 0, stream_get_endp(s)); |
21ccc0cf | 71 | zserv_send_message(client, s); |
e3be0432 | 72 | } |