]>
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 const 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 const 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 const 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 ipv4
; /* Processed table is IPv4 */
81 int add_path
; /* Current message subtype is *_ADDPATH */
82 int want_add_path
; /* Want *_ADDPATH message later */
83 int max
; /* Decreasing counter of dumped routes */
84 u32 seqnum
; /* MRT message sequence number */
85 btime time_offset
; /* Time offset between monotonic and real time */
86 struct bgp_write_state
*bws
; /* */
88 u16 peer_count
; /* Number of peers */
89 u32 peer_count_offset
; /* Buffer offset to store peer_count later */
90 u16 entry_count
; /* Number of RIB Entries */
91 u32 entry_count_offset
; /* Buffer offset to store entry_count later */
93 struct rfile
*file
; /* tracking for mrt table dump file */
113 #define MRT_HDR_LENGTH 12 /* MRT Timestamp + MRT Type + MRT Subtype + MRT Load Length */
114 #define MRT_PEER_TYPE_32BIT_ASN 2 /* MRT Table Dump: Peer Index Table: Peer Type: Use 32bit ASN */
115 #define MRT_PEER_TYPE_IPV6 1 /* MRT Table Dump: Peer Index Table: Peer Type: Use IPv6 IP Address */
117 #define MRT_ATTR_BUFFER_SIZE 65536
120 #define MRT_TABLE_DUMP_V2 13
121 #define MRT_BGP4MP 16
123 /* MRT Table Dump v2 Subtypes */
124 #define MRT_PEER_INDEX_TABLE 1
125 #define MRT_RIB_IPV4_UNICAST 2
126 #define MRT_RIB_IPV4_MULTICAST 3
127 #define MRT_RIB_IPV6_UNICAST 4
128 #define MRT_RIB_IPV6_MULTICAST 5
129 #define MRT_RIB_GENERIC 6
130 #define MRT_RIB_IPV4_UNICAST_ADDPATH 8
131 #define MRT_RIB_IPV4_MULTICAST_ADDPATH 9
132 #define MRT_RIB_IPV6_UNICAST_ADDPATH 10
133 #define MRT_RIB_IPV6_MULTICAST_ADDPATH 11
134 #define MRT_RIB_GENERIC_ADDPATH 12
136 /* MRT BGP4MP Subtypes */
137 #define MRT_BGP4MP_MESSAGE 1
138 #define MRT_BGP4MP_MESSAGE_AS4 4
139 #define MRT_BGP4MP_STATE_CHANGE_AS4 5
140 #define MRT_BGP4MP_MESSAGE_LOCAL 6
141 #define MRT_BGP4MP_MESSAGE_AS4_LOCAL 7
142 #define MRT_BGP4MP_MESSAGE_ADDPATH 8
143 #define MRT_BGP4MP_MESSAGE_AS4_ADDPATH 9
144 #define MRT_BGP4MP_MESSAGE_LOCAL_ADDPATH 10
145 #define MRT_BGP4MP_MESSAGE_AS4_LOCAL_ADDPATH 11
149 void mrt_dump_cmd(struct mrt_dump_data
*d
);
150 void mrt_dump_bgp_message(struct mrt_bgp_data
*d
);
151 void mrt_dump_bgp_state_change(struct mrt_bgp_data
*d
);
152 void mrt_check_config(struct proto_config
*C
);
154 static inline void mrt_dump_bgp_message(struct mrt_bgp_data
*d UNUSED
) { }
155 static inline void mrt_dump_bgp_state_change(struct mrt_bgp_data
*d UNUSED
) { }
158 #endif /* _BIRD_MRT_H_ */