* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with GNU Zebra; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_mroute.h"
#include "zebra/rt.h"
+#include "zebra/debug.h"
-int zebra_ipmr_route_stats(struct zserv *client, int fd, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_ipmr_route_stats(ZAPI_HANDLER_ARGS)
{
struct mcast_route_data mroute;
struct stream *s;
- int suc;
-
- char sbuf[40];
- char gbuf[40];
+ int suc = -1;
memset(&mroute, 0, sizeof(mroute));
- stream_get(&mroute.sg.src, client->ibuf, 4);
- stream_get(&mroute.sg.grp, client->ibuf, 4);
- mroute.ifindex = stream_getl(client->ibuf);
+ STREAM_GET(&mroute.sg.src, msg, 4);
+ STREAM_GET(&mroute.sg.grp, msg, 4);
+ STREAM_GETL(msg, mroute.ifindex);
+
+ if (IS_ZEBRA_DEBUG_KERNEL) {
+ char sbuf[40];
+ char gbuf[40];
+
+ strlcpy(sbuf, inet_ntoa(mroute.sg.src), sizeof(sbuf));
+ strlcpy(gbuf, inet_ntoa(mroute.sg.grp), sizeof(gbuf));
- strcpy(sbuf, inet_ntoa(mroute.sg.src));
- strcpy(gbuf, inet_ntoa(mroute.sg.grp));
+ zlog_debug("Asking for (%s,%s)[%s(%u)] mroute information",
+ sbuf, gbuf, zvrf->vrf->name, zvrf->vrf->vrf_id);
+ }
- suc = kernel_get_ipmr_sg_stats(&mroute);
+ suc = kernel_get_ipmr_sg_stats(zvrf, &mroute);
- s = client->obuf;
+stream_failure:
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
stream_reset(s);
- zserv_create_header(s, ZEBRA_IPMR_ROUTE_STATS, zvrf_id(zvrf));
+ zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS, zvrf_id(zvrf));
stream_put_in_addr(s, &mroute.sg.src);
stream_put_in_addr(s, &mroute.sg.grp);
stream_put(s, &mroute.lastused, sizeof(mroute.lastused));
stream_putl(s, suc);
stream_putw_at(s, 0, stream_get_endp(s));
- zebra_server_send_message(client);
- return 0;
+ zserv_send_message(client, s);
}