1@node  Packet Binary Dump Format
2@appendix Packet Binary Dump Format
3
4  Quagga can dump routing protocol packet into file with a binary format
5(@pxref{Dump BGP packets and table}).
6
7  It seems to be better that we share the MRT's header format for
8backward compatibility with MRT's dump logs. We should also define the
9binary format excluding the header, because we must support both IP
10v4 and v6 addresses as socket addresses and / or routing entries.
11
12  In the last meeting, we discussed to have a version field in the
13header. But Masaki told us that we can define new `type' value rather
14than having a `version' field, and it seems to be better because we
15don't need to change header format.
16
17  Here is the common header format. This is same as that of MRT.
18
19@example
20@group
210                   1                   2                   3
220 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
23+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24|                              Time                             |
25+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26|             Type              |            Subtype            |
27+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28|                             Length                            |
29+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30@end group
31@end example
32
33  If `type' is PROTOCOL_BGP4MP, `subtype' is BGP4MP_STATE_CHANGE, and
34Address Family == IP (version 4)
35
36@example
37@group
38 0                   1                   2                   3
39 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
40+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41|        Source AS number       |     Destination AS number     |
42+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43|        Interface Index        |      Address Family           |
44+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45|                        Source IP address                      |
46+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47|                     Destination IP address                    |
48+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49|            Old State          |           New State           |
50+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51@end group
52@end example
53
54Where State is the value defined in RFC1771.
55
56If `type' is PROTOCOL_BGP4MP, `subtype' is BGP4MP_STATE_CHANGE,
57and Address Family == IP version 6
58
59@example
60@group
61 0                   1                   2                   3
62 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
63+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64|        Source AS number       |     Destination AS number     |
65+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66|        Interface Index        |      Address Family           |
67+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68|                        Source IP address                      |
69+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70|                        Source IP address (Cont'd)             |
71+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72|                        Source IP address (Cont'd)             |
73+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74|                        Source IP address (Cont'd)             |
75+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76|                     Destination IP address                    |
77+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78|                     Destination IP address (Cont'd)           |
79+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80|                     Destination IP address (Cont'd)           |
81+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82|                     Destination IP address (Cont'd)           |
83+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84|            Old State          |           New State           |
85+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
86@end group
87@end example
88
89If `type' is PROTOCOL_BGP4MP, `subtype' is BGP4MP_MESSAGE,
90and Address Family == IP (version 4)
91
92@example
93@group
94 0                   1                   2                   3
95 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
96+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97|        Source AS number       |     Destination AS number     |
98+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
99|        Interface Index        |      Address Family           |
100+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
101|                        Source IP address                      |
102+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
103|                     Destination IP address                    |
104+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
105|                       BGP Message Packet                      |
106|                                                               |
107+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
108@end group
109@end example
110
111Where BGP Message Packet is the whole contents of the
112BGP4 message including header portion.
113
114If `type' is PROTOCOL_BGP4MP, `subtype' is BGP4MP_MESSAGE,
115and Address Family == IP version 6
116
117@example
118@group
119 0                   1                   2                   3
120 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
121+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
122|        Source AS number       |     Destination AS number     |
123+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
124|        Interface Index        |      Address Family           |
125+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126|                        Source IP address                      |
127+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128|                        Source IP address (Cont'd)             |
129+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130|                        Source IP address (Cont'd)             |
131+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132|                        Source IP address (Cont'd)             |
133+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
134|                     Destination IP address                    |
135+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
136|                     Destination IP address (Cont'd)           |
137+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
138|                     Destination IP address (Cont'd)           |
139+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140|                     Destination IP address (Cont'd)           |
141+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
142|                       BGP Message Packet                      |
143|                                                               |
144+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145@end group
146@end example
147
148If `type' is PROTOCOL_BGP4MP, `subtype' is BGP4MP_ENTRY,
149and Address Family == IP (version 4)
150
151@example
152@group
153 0                   1                   2                   3
154 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
155+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
156|            View #             |            Status             |
157+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
158|                        Time Last Change                       |
159+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
160|       Address Family          |    SAFI       | Next-Hop-Len  |
161+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
162|                        Next Hop Address                       |
163+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
164| Prefix Length |             Address Prefix [variable]         |
165+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
166|       Attribute Length        |
167+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
168|      BGP Attribute [variable length]    			|
169+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
170@end group
171@end example
172
173If `type' is PROTOCOL_BGP4MP, `subtype' is BGP4MP_ENTRY,
174and Address Family == IP version 6
175
176@example
177@group
178 0                   1                   2                   3
179 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
180+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
181|            View #             |            Status             |
182+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
183|                        Time Last Change                       |
184+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
185|       Address Family          |    SAFI       | Next-Hop-Len  |
186+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
187|                        Next Hop Address                       |
188+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
189|                        Next Hop Address (Cont'd)              |
190+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
191|                        Next Hop Address (Cont'd)              |
192+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
193|                        Next Hop Address (Cont'd)              |
194+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
195| Prefix Length |             Address Prefix [variable]         |
196+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
197|     Address Prefix (cont'd) [variable]        |
198+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
199|       Attribute Length        |
200+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201|      BGP Attribute [variable length]    			    |
202+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
203@end group
204@end example
205
206	BGP4 Attribute must not contain MP_UNREACH_NLRI.
207	If BGP Attribute has MP_REACH_NLRI field, it must has
208	zero length NLRI, e.g., MP_REACH_NLRI has only Address
209	Family, SAFI and next-hop values.
210
211If `type' is PROTOCOL_BGP4MP and `subtype' is BGP4MP_SNAPSHOT,
212
213@example
214@group
215 0                   1                   2                   3
216 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
217+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
218|           View #              |       File Name [variable]    |
219+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
220@end group
221@end example
222
223    The file specified in "File Name" contains all routing entries,
224    which are in the format of ``subtype == BGP4MP_ENTRY''.
225
226@example
227@group
228Constants:
229  /* type value */
230  #define MSG_PROTOCOL_BGP4MP 16
231  /* subtype value */
232  #define BGP4MP_STATE_CHANGE 0
233  #define BGP4MP_MESSAGE 1
234  #define BGP4MP_ENTRY 2
235  #define BGP4MP_SNAPSHOT 3
236@end group
237@end example
238