From 6fd04594bb36321158558326993d00b760d1a51f Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 10 May 2019 19:29:01 +0200 Subject: [PATCH] bgpd: add packet send hook Unlike MRT dumps, BMP also provides packets sent by the router. Add another hook for that. Signed-off-by: David Lamparter --- bgpd/bgp_packet.c | 6 ++++++ bgpd/bgp_packet.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index da00c7b3fe..99522a6522 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -68,6 +68,11 @@ DEFINE_HOOK(bgp_packet_dump, struct stream *s), (peer, type, size, s)) +DEFINE_HOOK(bgp_packet_send, + (struct peer *peer, uint8_t type, bgp_size_t size, + struct stream *s), + (peer, type, size, s)) + /** * Sets marker and type fields for a BGP message. * @@ -547,6 +552,7 @@ void bgp_open_send(struct peer *peer) /* Dump packet if debug option is set. */ /* bgp_packet_dump (s); */ + hook_call(bgp_packet_send, peer, BGP_MSG_OPEN, stream_get_endp(s), s); /* Add packet to the peer. */ bgp_packet_add(peer, s); diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h index 91031589a7..e8eacee589 100644 --- a/bgpd/bgp_packet.h +++ b/bgpd/bgp_packet.h @@ -28,6 +28,11 @@ DECLARE_HOOK(bgp_packet_dump, struct stream *s), (peer, type, size, s)) +DECLARE_HOOK(bgp_packet_send, + (struct peer *peer, uint8_t type, bgp_size_t size, + struct stream *s), + (peer, type, size, s)) + #define BGP_NLRI_LENGTH 1U #define BGP_TOTAL_ATTR_LEN 2U #define BGP_UNFEASIBLE_LEN 2U -- 2.39.5