#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_dump.h"
#include "bgpd/bgp_errors.h"
+#include "bgpd/bgp_packet.h"
enum bgp_dump_type {
BGP_DUMP_ALL,
}
/* Called from bgp_packet.c when BGP packet is received. */
-void bgp_dump_packet(struct peer *peer, int type, struct stream *packet)
+static int bgp_dump_packet(struct peer *peer, uint8_t type, bgp_size_t size,
+ struct stream *packet)
{
/* bgp_dump_all. */
bgp_dump_packet_func(&bgp_dump_all, peer, packet);
/* bgp_dump_updates. */
if (type == BGP_MSG_UPDATE)
bgp_dump_packet_func(&bgp_dump_updates, peer, packet);
+ return 0;
}
static unsigned int bgp_dump_parse_time(const char *str)
install_element(CONFIG_NODE, &dump_bgp_all_cmd);
install_element(CONFIG_NODE, &no_dump_bgp_all_cmd);
+
+ hook_register(bgp_packet_dump, bgp_dump_packet);
}
void bgp_dump_finish(void)
extern void bgp_dump_init(void);
extern void bgp_dump_finish(void);
extern void bgp_dump_state(struct peer *, int, int);
-extern void bgp_dump_packet(struct peer *, int, struct stream *);
#endif /* _QUAGGA_BGP_DUMP_H */
EC_BGP_PKT_PROCESS,
"[%s] Dropping pending packet on connection transfer:",
peer->host);
- uint16_t type = stream_getc_from(peer->curr,
- BGP_MARKER_SIZE + 2);
- bgp_dump_packet(peer, type, peer->curr);
+ /* there used to be a bgp_packet_dump call here, but
+ * that's extremely confusing since there's no way to
+ * identify the packet in MRT dumps or BMP as dropped
+ * due to connection transfer.
+ */
stream_free(peer->curr);
peer->curr = NULL;
}
#include "bgpd/bgp_keepalives.h"
#include "bgpd/bgp_flowspec.h"
+DEFINE_HOOK(bgp_packet_dump,
+ (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.
*
size = stream_getw(peer->curr);
type = stream_getc(peer->curr);
- /* BGP packet dump function. */
- bgp_dump_packet(peer, type, peer->curr);
+ hook_call(bgp_packet_dump, peer, type, size, peer->curr);
/* adjust size to exclude the marker + length + type */
size -= BGP_HEADER_SIZE;
#ifndef _QUAGGA_BGP_PACKET_H
#define _QUAGGA_BGP_PACKET_H
+#include "hook.h"
+
+DECLARE_HOOK(bgp_packet_dump,
+ (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