]>
git.ipfire.org Git - thirdparty/bird.git/blob - proto/mrt/mrt.h
2 * BIRD -- Multi-Threaded Routing Toolkit (MRT) Protocol
4 * (c) 2017--2018 Ondrej Zajicek <santiago@crfreenet.org>
5 * (c) 2017--2018 CZ.NIC z.s.p.o.
7 * Can be freely distributed and used under the terms of the GNU GPL.
13 #include "nest/bird.h"
14 #include "nest/protocol.h"
15 #include "lib/lists.h"
16 #include "nest/route.h"
17 #include "lib/event.h"
22 struct proto_config c
;
24 struct rtable_config
*table_cf
;
25 const char *table_expr
;
26 struct filter
*filter
;
37 struct mrt_target
*file
;
38 struct mrt_table_dump_state
*table_dump
;
41 struct mrt_dump_data
{
42 const char *table_expr
;
43 struct rtable
*table_ptr
;
44 struct filter
*filter
;
48 struct mrt_peer_entry
{
53 struct mrt_peer_entry
*next
;
56 struct mrt_table_dump_state
{
57 struct mrt_proto
*proto
; /* Protocol for regular MRT dumps (or NULL) */
58 struct cli
*cli
; /* CLI for irregular MRT dumps (or NULL) */
59 struct config
*config
; /* Config valid during start of dump, locked */
61 /* Configuration information */
62 const char *table_expr
; /* Wildcard for table name (or NULL) */
63 struct rtable
*table_ptr
; /* Explicit table (or NULL) */
64 struct filter
*filter
; /* Optional filter */
65 const char *filename
; /* Filename pattern */
66 int always_add_path
; /* Always use *_ADDPATH message subtypes */
68 /* Allocated by mrt_table_dump_init() */
69 pool
*pool
; /* Pool for table dump */
70 linpool
*linpool
; /* Temporary linear pool */
71 linpool
*peer_lp
; /* Linear pool for peer entries in peer_hash */
72 buffer buf
; /* Buffer for MRT messages */
74 HASH(struct mrt_peer_entry
) peer_hash
; /* Hash for peers to find the index */
76 struct rtable
*table
; /* Processed table, NULL initially */
77 struct fib_iterator fit
; /* Iterator in processed table */
78 int table_open
; /* Whether iterator is linked */
80 int add_path
; /* Current message subtype is *_ADDPATH */
81 int want_add_path
; /* Want *_ADDPATH message later */
82 int max
; /* Decreasing counter of dumped routes */
83 u32 seqnum
; /* MRT message sequence number */
84 bird_clock_t time_offset
; /* Time offset between monotonic and real time */
86 u16 peer_count
; /* Number of peers */
87 u32 peer_count_offset
; /* Buffer offset to store peer_count later */
88 u16 entry_count
; /* Number of RIB Entries */
89 u32 entry_count_offset
; /* Buffer offset to store entry_count later */
91 struct rfile
*file
; /* tracking for mrt table dump file */
111 #define MRT_HDR_LENGTH 12 /* MRT Timestamp + MRT Type + MRT Subtype + MRT Load Length */
112 #define MRT_PEER_TYPE_32BIT_ASN 2 /* MRT Table Dump: Peer Index Table: Peer Type: Use 32bit ASN */
113 #define MRT_PEER_TYPE_IPV6 1 /* MRT Table Dump: Peer Index Table: Peer Type: Use IPv6 IP Address */
115 #define MRT_ATTR_BUFFER_SIZE 65536
118 #define MRT_TABLE_DUMP_V2 13
119 #define MRT_BGP4MP 16
121 /* MRT Table Dump v2 Subtypes */
122 #define MRT_PEER_INDEX_TABLE 1
123 #define MRT_RIB_IPV4_UNICAST 2
124 #define MRT_RIB_IPV4_MULTICAST 3
125 #define MRT_RIB_IPV6_UNICAST 4
126 #define MRT_RIB_IPV6_MULTICAST 5
127 #define MRT_RIB_GENERIC 6
128 #define MRT_RIB_IPV4_UNICAST_ADDPATH 8
129 #define MRT_RIB_IPV4_MULTICAST_ADDPATH 9
130 #define MRT_RIB_IPV6_UNICAST_ADDPATH 10
131 #define MRT_RIB_IPV6_MULTICAST_ADDPATH 11
132 #define MRT_RIB_GENERIC_ADDPATH 12
134 /* MRT BGP4MP Subtypes */
135 #define MRT_BGP4MP_MESSAGE 1
136 #define MRT_BGP4MP_MESSAGE_AS4 4
137 #define MRT_BGP4MP_STATE_CHANGE_AS4 5
138 #define MRT_BGP4MP_MESSAGE_LOCAL 6
139 #define MRT_BGP4MP_MESSAGE_AS4_LOCAL 7
140 #define MRT_BGP4MP_MESSAGE_ADDPATH 8
141 #define MRT_BGP4MP_MESSAGE_AS4_ADDPATH 9
142 #define MRT_BGP4MP_MESSAGE_LOCAL_ADDPATH 10
143 #define MRT_BGP4MP_MESSAGE_AS4_LOCAL_ADDPATH 11
147 void mrt_dump_cmd(struct mrt_dump_data
*d
);
148 void mrt_dump_bgp_message(struct mrt_bgp_data
*d
);
149 void mrt_dump_bgp_state_change(struct mrt_bgp_data
*d
);
150 void mrt_check_config(struct proto_config
*C
);
152 static inline void mrt_dump_bgp_message(struct mrt_bgp_data
*d UNUSED
) { }
153 static inline void mrt_dump_bgp_state_change(struct mrt_bgp_data
*d UNUSED
) { }
156 #endif /* _BIRD_MRT_H_ */