Lines 2-8
Link Here
|
2 |
* Routines for OSPF packet disassembly |
2 |
* Routines for OSPF packet disassembly |
3 |
* (c) Copyright Hannes R. Boehm <hannes@boehm.org> |
3 |
* (c) Copyright Hannes R. Boehm <hannes@boehm.org> |
4 |
* |
4 |
* |
5 |
* $Id: packet-ospf.c 15996 2005-09-25 01:44:23Z sahlberg $ |
5 |
* $Id$ |
6 |
* |
6 |
* |
7 |
* At this time, this module is able to analyze OSPF |
7 |
* At this time, this module is able to analyze OSPF |
8 |
* packets as specified in RFC2328. MOSPF (RFC1584) and other |
8 |
* packets as specified in RFC2328. MOSPF (RFC1584) and other |
Lines 199-204
Link Here
|
199 |
|
199 |
|
200 |
|
200 |
|
201 |
static int proto_ospf = -1; |
201 |
static int proto_ospf = -1; |
|
|
202 |
static int hf_ospf_options_v2 = -1; |
203 |
static int hf_ospf_options_v2_e = -1; |
204 |
static int hf_ospf_options_v2_mc = -1; |
205 |
static int hf_ospf_options_v2_np = -1; |
206 |
static int hf_ospf_options_v2_ea = -1; |
207 |
static int hf_ospf_options_v2_dc = -1; |
208 |
static int hf_ospf_options_v2_o = -1; |
209 |
static int hf_ospf_options_v2_dn = -1; |
210 |
static int hf_ospf_options_v3 = -1; |
211 |
static int hf_ospf_options_v3_v6 = -1; |
212 |
static int hf_ospf_options_v3_e = -1; |
213 |
static int hf_ospf_options_v3_mc = -1; |
214 |
static int hf_ospf_options_v3_n = -1; |
215 |
static int hf_ospf_options_v3_r = -1; |
216 |
static int hf_ospf_options_v3_dc = -1; |
217 |
static int hf_ospf_dbd = -1; |
218 |
static int hf_ospf_dbd_i = -1; |
219 |
static int hf_ospf_dbd_m = -1; |
220 |
static int hf_ospf_dbd_ms = -1; |
202 |
|
221 |
|
203 |
static gint ett_ospf = -1; |
222 |
static gint ett_ospf = -1; |
204 |
static gint ett_ospf_hdr = -1; |
223 |
static gint ett_ospf_hdr = -1; |
Lines 208-213
Link Here
|
208 |
static gint ett_ospf_lsa = -1; |
227 |
static gint ett_ospf_lsa = -1; |
209 |
static gint ett_ospf_lsa_router_link = -1; |
228 |
static gint ett_ospf_lsa_router_link = -1; |
210 |
static gint ett_ospf_lsa_upd = -1; |
229 |
static gint ett_ospf_lsa_upd = -1; |
|
|
230 |
static gint ett_ospf_options_v2 = -1; |
231 |
static gint ett_ospf_options_v3 = -1; |
232 |
static gint ett_ospf_dbd = -1; |
211 |
|
233 |
|
212 |
/* Trees for opaque LSAs */ |
234 |
/* Trees for opaque LSAs */ |
213 |
static gint ett_ospf_lsa_mpls = -1; |
235 |
static gint ett_ospf_lsa_mpls = -1; |
Lines 218-223
Link Here
|
218 |
static gint ett_ospf_lsa_oif_tna = -1; |
240 |
static gint ett_ospf_lsa_oif_tna = -1; |
219 |
static gint ett_ospf_lsa_oif_tna_stlv = -1; |
241 |
static gint ett_ospf_lsa_oif_tna_stlv = -1; |
220 |
|
242 |
|
|
|
243 |
|
244 |
|
245 |
static const true_false_string tfs_options_v2_dc = { |
246 |
"Demand Circuits are supported", |
247 |
"Demand circuits are NOT supported" |
248 |
}; |
249 |
static const true_false_string tfs_options_v2_ea = { |
250 |
"External Attributes are supported", |
251 |
"External attributes are NOT supported" |
252 |
}; |
253 |
static const true_false_string tfs_options_v2_np = { |
254 |
"NSSA is supported", |
255 |
"Nssa is NOT supported" |
256 |
}; |
257 |
static const true_false_string tfs_options_v2_mc = { |
258 |
"Multicast Capable", |
259 |
"NOT multicast capable" |
260 |
}; |
261 |
static const true_false_string tfs_options_v2_e = { |
262 |
"ExternalRoputingCapability", |
263 |
"NO ExternalRoutingCapability" |
264 |
}; |
265 |
static const true_false_string tfs_options_v2_o = { |
266 |
"O-bit is SET", |
267 |
"O-bit is CLEAR" |
268 |
}; |
269 |
static const true_false_string tfs_options_v2_dn = { |
270 |
"DN-bit is SET", |
271 |
"DN-bit is CLEAR" |
272 |
}; |
273 |
|
274 |
static const true_false_string tfs_options_v3_v6 = { |
275 |
"V6 is SET", |
276 |
"V6 is NOT set" |
277 |
}; |
278 |
static const true_false_string tfs_options_v3_e = { |
279 |
"E is SET", |
280 |
"E is NOT set" |
281 |
}; |
282 |
static const true_false_string tfs_options_v3_mc = { |
283 |
"MC is SET", |
284 |
"MC is NOT set" |
285 |
}; |
286 |
static const true_false_string tfs_options_v3_n = { |
287 |
"N is SET", |
288 |
"N is NOT set" |
289 |
}; |
290 |
static const true_false_string tfs_options_v3_r = { |
291 |
"R is SET", |
292 |
"R is NOT set" |
293 |
}; |
294 |
static const true_false_string tfs_options_v3_dc = { |
295 |
"DC is SET", |
296 |
"DC is NOT set" |
297 |
}; |
298 |
static const true_false_string tfs_dbd_i = { |
299 |
"I is SET", |
300 |
"I is NOT set" |
301 |
}; |
302 |
static const true_false_string tfs_dbd_m = { |
303 |
"M is SET", |
304 |
"M is NOT set" |
305 |
}; |
306 |
static const true_false_string tfs_dbd_ms = { |
307 |
"MS is SET", |
308 |
"MS is NOT set" |
309 |
}; |
310 |
|
221 |
/*----------------------------------------------------------------------- |
311 |
/*----------------------------------------------------------------------- |
222 |
* OSPF Filtering |
312 |
* OSPF Filtering |
223 |
*-----------------------------------------------------------------------*/ |
313 |
*-----------------------------------------------------------------------*/ |
Lines 373-379
Link Here
|
373 |
{&ospf_filter[OSPFF_LS_MPLS_LINKCOLOR], |
463 |
{&ospf_filter[OSPFF_LS_MPLS_LINKCOLOR], |
374 |
{ "MPLS/TE Link Resource Class/Color", "ospf.mpls.linkcolor", FT_UINT32, |
464 |
{ "MPLS/TE Link Resource Class/Color", "ospf.mpls.linkcolor", FT_UINT32, |
375 |
BASE_HEX, NULL, 0x0, "MPLS/TE Link Resource Class/Color", HFILL }}, |
465 |
BASE_HEX, NULL, 0x0, "MPLS/TE Link Resource Class/Color", HFILL }}, |
376 |
|
466 |
{&hf_ospf_options_v2, |
|
|
467 |
{ "Options", "ospf.options.v2", FT_UINT8, BASE_HEX, |
468 |
NULL, 0x0, "", HFILL }}, |
469 |
{&hf_ospf_options_v2_e, |
470 |
{ "E", "ospf.options.v2.e", FT_BOOLEAN, 8, |
471 |
TFS(&tfs_options_v2_e), OSPF_V2_OPTIONS_E, "", HFILL }}, |
472 |
{&hf_ospf_options_v2_mc, |
473 |
{ "MC", "ospf.options.v2.mc", FT_BOOLEAN, 8, |
474 |
TFS(&tfs_options_v2_mc), OSPF_V2_OPTIONS_MC, "", HFILL }}, |
475 |
{&hf_ospf_options_v2_np, |
476 |
{ "NP", "ospf.options.v2.np", FT_BOOLEAN, 8, |
477 |
TFS(&tfs_options_v2_np), OSPF_V2_OPTIONS_NP, "", HFILL }}, |
478 |
{&hf_ospf_options_v2_ea, |
479 |
{ "EA", "ospf.options.v2.ea", FT_BOOLEAN, 8, |
480 |
TFS(&tfs_options_v2_ea), OSPF_V2_OPTIONS_EA, "", HFILL }}, |
481 |
{&hf_ospf_options_v2_dc, |
482 |
{ "DC", "ospf.options.v2.dc", FT_BOOLEAN, 8, |
483 |
TFS(&tfs_options_v2_dc), OSPF_V2_OPTIONS_DC, "", HFILL }}, |
484 |
{&hf_ospf_options_v2_o, |
485 |
{ "O", "ospf.options.v2.o", FT_BOOLEAN, 8, |
486 |
TFS(&tfs_options_v2_o), OSPF_V2_OPTIONS_O, "", HFILL }}, |
487 |
{&hf_ospf_options_v2_dn, |
488 |
{ "DN", "ospf.options.v2.dn", FT_BOOLEAN, 8, |
489 |
TFS(&tfs_options_v2_dn), OSPF_V2_OPTIONS_DN, "", HFILL }}, |
490 |
{&hf_ospf_options_v3, |
491 |
{ "Options", "ospf.options.v3", FT_UINT24, BASE_HEX, |
492 |
NULL, 0x0, "", HFILL }}, |
493 |
{&hf_ospf_options_v3_v6, |
494 |
{ "V6", "ospf.options.v3.v6", FT_BOOLEAN, 24, |
495 |
TFS(&tfs_options_v3_v6), OSPF_V3_OPTIONS_V6, "", HFILL }}, |
496 |
{&hf_ospf_options_v3_e, |
497 |
{ "E", "ospf.options.v3.e", FT_BOOLEAN, 24, |
498 |
TFS(&tfs_options_v3_e), OSPF_V3_OPTIONS_E, "", HFILL }}, |
499 |
{&hf_ospf_options_v3_mc, |
500 |
{ "MC", "ospf.options.v3.mc", FT_BOOLEAN, 24, |
501 |
TFS(&tfs_options_v3_mc), OSPF_V3_OPTIONS_MC, "", HFILL }}, |
502 |
{&hf_ospf_options_v3_n, |
503 |
{ "N", "ospf.options.v3.n", FT_BOOLEAN, 24, |
504 |
TFS(&tfs_options_v3_n), OSPF_V3_OPTIONS_N, "", HFILL }}, |
505 |
{&hf_ospf_options_v3_r, |
506 |
{ "R", "ospf.options.v3.r", FT_BOOLEAN, 24, |
507 |
TFS(&tfs_options_v3_r), OSPF_V3_OPTIONS_R, "", HFILL }}, |
508 |
{&hf_ospf_options_v3_dc, |
509 |
{ "DC", "ospf.options.v3.dc", FT_BOOLEAN, 24, |
510 |
TFS(&tfs_options_v3_dc), OSPF_V3_OPTIONS_DC, "", HFILL }}, |
511 |
{&hf_ospf_dbd, |
512 |
{ "DB Description", "ospf.dbd", FT_UINT8, BASE_HEX, |
513 |
NULL, 0x0, "", HFILL }}, |
514 |
{&hf_ospf_dbd_i, |
515 |
{ "I", "ospf.dbd.i", FT_BOOLEAN, 8, |
516 |
TFS(&tfs_dbd_i), OSPF_DBD_FLAG_I, "", HFILL }}, |
517 |
{&hf_ospf_dbd_m, |
518 |
{ "M", "ospf.dbd.m", FT_BOOLEAN, 8, |
519 |
TFS(&tfs_dbd_m), OSPF_DBD_FLAG_M, "", HFILL }}, |
520 |
{&hf_ospf_dbd_ms, |
521 |
{ "MS", "ospf.dbd.ms", FT_BOOLEAN, 8, |
522 |
TFS(&tfs_dbd_ms), OSPF_DBD_FLAG_MS, "", HFILL }}, |
377 |
|
523 |
|
378 |
|
524 |
|
379 |
}; |
525 |
}; |
Lines 742-754
Link Here
|
742 |
} |
888 |
} |
743 |
|
889 |
|
744 |
static void |
890 |
static void |
|
|
891 |
dissect_ospf_dbd (proto_tree *parent_tree, tvbuff_t *tvb, int offset) |
892 |
{ |
893 |
proto_item *item=NULL; |
894 |
proto_tree *tree=NULL; |
895 |
guint8 flags; |
896 |
|
897 |
flags = tvb_get_guint8 (tvb, offset); |
898 |
if(parent_tree){ |
899 |
item=proto_tree_add_uint(parent_tree, hf_ospf_dbd, |
900 |
tvb, offset, 1, flags); |
901 |
tree=proto_item_add_subtree(item, ett_ospf_dbd); |
902 |
} |
903 |
|
904 |
proto_tree_add_boolean(tree, hf_ospf_dbd_i, tvb, offset, 1, flags); |
905 |
if (flags&OSPF_DBD_FLAG_I){ |
906 |
proto_item_append_text(item, " I"); |
907 |
} |
908 |
flags&=(~( OSPF_DBD_FLAG_I )); |
909 |
|
910 |
proto_tree_add_boolean(tree, hf_ospf_dbd_m, tvb, offset, 1, flags); |
911 |
if (flags&OSPF_DBD_FLAG_M){ |
912 |
proto_item_append_text(item, " M"); |
913 |
} |
914 |
flags&=(~( OSPF_DBD_FLAG_M )); |
915 |
|
916 |
proto_tree_add_boolean(tree, hf_ospf_dbd_ms, tvb, offset, 1, flags); |
917 |
if (flags&OSPF_DBD_FLAG_MS){ |
918 |
proto_item_append_text(item, " MS"); |
919 |
} |
920 |
flags&=(~( OSPF_DBD_FLAG_MS )); |
921 |
} |
922 |
|
923 |
|
924 |
static void |
745 |
dissect_ospf_db_desc(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version) |
925 |
dissect_ospf_db_desc(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version) |
746 |
{ |
926 |
{ |
747 |
proto_tree *ospf_db_desc_tree=NULL; |
927 |
proto_tree *ospf_db_desc_tree=NULL; |
748 |
proto_item *ti; |
928 |
proto_item *ti; |
749 |
guint8 flags; |
|
|
750 |
guint8 reserved; |
929 |
guint8 reserved; |
751 |
char flags_string[20] = ""; |
|
|
752 |
|
930 |
|
753 |
if (tree) { |
931 |
if (tree) { |
754 |
ti = proto_tree_add_text(tree, tvb, offset, -1, "OSPF DB Description"); |
932 |
ti = proto_tree_add_text(tree, tvb, offset, -1, "OSPF DB Description"); |
Lines 757-783
Link Here
|
757 |
switch (version ) { |
935 |
switch (version ) { |
758 |
|
936 |
|
759 |
case OSPF_VERSION_2: |
937 |
case OSPF_VERSION_2: |
760 |
|
|
|
761 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 2, "Interface MTU: %u", |
938 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 2, "Interface MTU: %u", |
762 |
tvb_get_ntohs(tvb, offset)); |
939 |
tvb_get_ntohs(tvb, offset)); |
763 |
|
940 |
|
764 |
dissect_ospf_options(tvb, offset + 2, ospf_db_desc_tree, version); |
941 |
dissect_ospf_options(tvb, offset + 2, ospf_db_desc_tree, version); |
765 |
|
942 |
|
766 |
flags = tvb_get_guint8(tvb, offset + 3); |
943 |
dissect_ospf_dbd(ospf_db_desc_tree, tvb, offset+3); |
767 |
if (flags & OSPF_DBD_FLAG_MS) |
944 |
|
768 |
strcat(flags_string, "MS"); |
|
|
769 |
if (flags & OSPF_DBD_FLAG_M) { |
770 |
if (flags_string[0] != '\0') |
771 |
strcat(flags_string, "/"); |
772 |
strcat(flags_string, "M"); |
773 |
} |
774 |
if (flags & OSPF_DBD_FLAG_I) { |
775 |
if (flags_string[0] != '\0') |
776 |
strcat(flags_string, "/"); |
777 |
strcat(flags_string, "I"); |
778 |
} |
779 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 3, 1, "Flags: 0x%x (%s)", |
780 |
flags, flags_string); |
781 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 4, "DD Sequence: %u", |
945 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 4, "DD Sequence: %u", |
782 |
tvb_get_ntohl(tvb, offset + 4)); |
946 |
tvb_get_ntohl(tvb, offset + 4)); |
783 |
|
947 |
|
Lines 799-819
Link Here
|
799 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 6, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"), |
963 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 6, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"), |
800 |
reserved); |
964 |
reserved); |
801 |
|
965 |
|
802 |
flags = tvb_get_guint8(tvb, offset + 7); |
966 |
dissect_ospf_dbd(ospf_db_desc_tree, tvb, offset+7); |
803 |
if (flags & OSPF_DBD_FLAG_MS) |
|
|
804 |
strcat(flags_string, "MS"); |
805 |
if (flags & OSPF_DBD_FLAG_M) { |
806 |
if (flags_string[0] != '\0') |
807 |
strcat(flags_string, "/"); |
808 |
strcat(flags_string, "M"); |
809 |
} |
810 |
if (flags & OSPF_DBD_FLAG_I) { |
811 |
if (flags_string[0] != '\0') |
812 |
strcat(flags_string, "/"); |
813 |
strcat(flags_string, "I"); |
814 |
} |
815 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 7, 1, "Flags: 0x%x (%s)", |
816 |
flags, flags_string); |
817 |
|
967 |
|
818 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 8, 4, "DD Sequence: %u", |
968 |
proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 8, 4, "DD Sequence: %u", |
819 |
tvb_get_ntohl(tvb, offset + 8)); |
969 |
tvb_get_ntohl(tvb, offset + 8)); |
Lines 2165-2267
Link Here
|
2165 |
|
2315 |
|
2166 |
|
2316 |
|
2167 |
static void |
2317 |
static void |
2168 |
dissect_ospf_options(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version) |
2318 |
dissect_ospf_v2_options (proto_tree *parent_tree, tvbuff_t *tvb, int offset) |
2169 |
{ |
2319 |
{ |
2170 |
guint8 options_ospfv2; |
2320 |
proto_item *item=NULL; |
2171 |
guint32 options_ospfv3; |
2321 |
proto_tree *tree=NULL; |
2172 |
char options_string[20] = ""; |
2322 |
guint8 flags; |
2173 |
|
2323 |
|
2174 |
/* ATTENTION !!! no check for length of options string - with OSPFv3 maximum length is 14 characters */ |
2324 |
flags = tvb_get_guint8 (tvb, offset); |
|
|
2325 |
if(parent_tree){ |
2326 |
item=proto_tree_add_uint(parent_tree, hf_ospf_options_v2, |
2327 |
tvb, offset, 1, flags); |
2328 |
tree=proto_item_add_subtree(item, ett_ospf_options_v2); |
2329 |
} |
2175 |
|
2330 |
|
2176 |
switch ( version ) { |
2331 |
proto_tree_add_boolean(tree, hf_ospf_options_v2_o, tvb, offset, 1, flags); |
|
|
2332 |
if (flags&OSPF_V2_OPTIONS_O){ |
2333 |
proto_item_append_text(item, " O"); |
2334 |
} |
2335 |
flags&=(~( OSPF_V2_OPTIONS_O )); |
2177 |
|
2336 |
|
2178 |
case OSPF_VERSION_2: |
|
|
2179 |
|
2337 |
|
2180 |
options_ospfv2 = tvb_get_guint8(tvb, offset); |
2338 |
proto_tree_add_boolean(tree, hf_ospf_options_v2_dc, tvb, offset, 1, flags); |
|
|
2339 |
if (flags&OSPF_V2_OPTIONS_DC){ |
2340 |
proto_item_append_text(item, " DC"); |
2341 |
} |
2342 |
flags&=(~( OSPF_V2_OPTIONS_DC )); |
2181 |
|
2343 |
|
2182 |
if (options_ospfv2 & OSPF_V2_OPTIONS_E) |
2344 |
proto_tree_add_boolean(tree, hf_ospf_options_v2_ea, tvb, offset, 1, flags); |
2183 |
strcat(options_string, "E"); |
2345 |
if (flags&OSPF_V2_OPTIONS_EA){ |
|
|
2346 |
proto_item_append_text(item, " EA"); |
2347 |
} |
2348 |
flags&=(~( OSPF_V2_OPTIONS_EA )); |
2184 |
|
2349 |
|
2185 |
if (options_ospfv2 & OSPF_V2_OPTIONS_MC) { |
2350 |
proto_tree_add_boolean(tree, hf_ospf_options_v2_np, tvb, offset, 1, flags); |
2186 |
if (options_string[0] != '\0') |
2351 |
if (flags&OSPF_V2_OPTIONS_NP){ |
2187 |
strcat(options_string, "/"); |
2352 |
proto_item_append_text(item, " NP"); |
2188 |
strcat(options_string, "MC"); |
2353 |
} |
2189 |
} |
2354 |
flags&=(~( OSPF_V2_OPTIONS_NP )); |
2190 |
|
2355 |
|
2191 |
if (options_ospfv2 & OSPF_V2_OPTIONS_NP) { |
2356 |
proto_tree_add_boolean(tree, hf_ospf_options_v2_mc, tvb, offset, 1, flags); |
2192 |
if (options_string[0] != '\0') |
2357 |
if (flags&OSPF_V2_OPTIONS_MC){ |
2193 |
strcat(options_string, "/"); |
2358 |
proto_item_append_text(item, " MC"); |
2194 |
strcat(options_string, "NP"); |
2359 |
} |
2195 |
} |
2360 |
flags&=(~( OSPF_V2_OPTIONS_MC )); |
2196 |
|
2361 |
|
2197 |
if (options_ospfv2 & OSPF_V2_OPTIONS_EA) { |
2362 |
proto_tree_add_boolean(tree, hf_ospf_options_v2_e, tvb, offset, 1, flags); |
2198 |
if (options_string[0] != '\0') |
2363 |
if (flags&OSPF_V2_OPTIONS_E){ |
2199 |
strcat(options_string, "/"); |
2364 |
proto_item_append_text(item, " E"); |
2200 |
strcat(options_string, "EA"); |
2365 |
} |
2201 |
} |
2366 |
flags&=(~( OSPF_V2_OPTIONS_E )); |
2202 |
|
2367 |
|
2203 |
if (options_ospfv2 & OSPF_V2_OPTIONS_DC) { |
2368 |
proto_tree_add_boolean(tree, hf_ospf_options_v2_dn, tvb, offset, 1, flags); |
2204 |
if (options_string[0] != '\0') |
2369 |
if (flags&OSPF_V2_OPTIONS_DN){ |
2205 |
strcat(options_string, "/"); |
2370 |
proto_item_append_text(item, " DN"); |
2206 |
strcat(options_string, "DC"); |
2371 |
} |
2207 |
} |
2372 |
flags&=(~( OSPF_V2_OPTIONS_DN )); |
|
|
2373 |
} |
2208 |
|
2374 |
|
2209 |
if (options_ospfv2 & OSPF_V2_OPTIONS_O) { |
2375 |
static void |
2210 |
if (options_string[0] != '\0') |
2376 |
dissect_ospf_v3_options (proto_tree *parent_tree, tvbuff_t *tvb, int offset) |
2211 |
strcat(options_string, "/"); |
2377 |
{ |
2212 |
strcat(options_string, "O"); |
2378 |
proto_item *item=NULL; |
2213 |
} |
2379 |
proto_tree *tree=NULL; |
|
|
2380 |
guint32 flags; |
2381 |
|
2382 |
flags = tvb_get_ntoh24 (tvb, offset); |
2383 |
if(parent_tree){ |
2384 |
item=proto_tree_add_uint(parent_tree, hf_ospf_options_v3, |
2385 |
tvb, offset, 3, flags); |
2386 |
tree=proto_item_add_subtree(item, ett_ospf_options_v3); |
2387 |
} |
2214 |
|
2388 |
|
2215 |
if (options_ospfv2 & OSPF_V2_OPTIONS_DN) { |
2389 |
proto_tree_add_boolean(tree, hf_ospf_options_v3_dc, tvb, offset, 3, flags); |
2216 |
if (options_string[0] != '\0') |
2390 |
if (flags&OSPF_V3_OPTIONS_DC){ |
2217 |
strcat(options_string, "/"); |
2391 |
proto_item_append_text(item, " DC"); |
2218 |
strcat(options_string, "DN"); |
2392 |
} |
2219 |
} |
2393 |
flags&=(~( OSPF_V3_OPTIONS_DC )); |
2220 |
|
2394 |
|
2221 |
proto_tree_add_text(tree, tvb, offset, 1, "Options: 0x%x (%s)", |
2395 |
proto_tree_add_boolean(tree, hf_ospf_options_v3_r, tvb, offset, 3, flags); |
2222 |
options_ospfv2, options_string); |
2396 |
if (flags&OSPF_V3_OPTIONS_R){ |
2223 |
break; |
2397 |
proto_item_append_text(item, " R"); |
|
|
2398 |
} |
2399 |
flags&=(~( OSPF_V3_OPTIONS_R )); |
2224 |
|
2400 |
|
|
|
2401 |
proto_tree_add_boolean(tree, hf_ospf_options_v3_n, tvb, offset, 3, flags); |
2402 |
if (flags&OSPF_V3_OPTIONS_N){ |
2403 |
proto_item_append_text(item, " N"); |
2404 |
} |
2405 |
flags&=(~( OSPF_V3_OPTIONS_N )); |
2225 |
|
2406 |
|
2226 |
case OSPF_VERSION_3: |
2407 |
proto_tree_add_boolean(tree, hf_ospf_options_v3_mc, tvb, offset, 3, flags); |
|
|
2408 |
if (flags&OSPF_V3_OPTIONS_MC){ |
2409 |
proto_item_append_text(item, " MC"); |
2410 |
} |
2411 |
flags&=(~( OSPF_V3_OPTIONS_MC )); |
2227 |
|
2412 |
|
2228 |
options_ospfv3 = tvb_get_ntoh24(tvb, offset); |
2413 |
proto_tree_add_boolean(tree, hf_ospf_options_v3_e, tvb, offset, 3, flags); |
|
|
2414 |
if (flags&OSPF_V3_OPTIONS_E){ |
2415 |
proto_item_append_text(item, " E"); |
2416 |
} |
2417 |
flags&=(~( OSPF_V3_OPTIONS_E )); |
2229 |
|
2418 |
|
2230 |
if (options_ospfv3 & OSPF_V3_OPTIONS_V6) |
2419 |
proto_tree_add_boolean(tree, hf_ospf_options_v3_v6, tvb, offset, 3, flags); |
2231 |
strcat(options_string, "V6"); |
2420 |
if (flags&OSPF_V3_OPTIONS_V6){ |
|
|
2421 |
proto_item_append_text(item, " V6"); |
2422 |
} |
2423 |
flags&=(~( OSPF_V3_OPTIONS_V6 )); |
2232 |
|
2424 |
|
2233 |
if (options_ospfv3 & OSPF_V3_OPTIONS_E) { |
2425 |
} |
2234 |
if (options_string[0] != '\0') |
|
|
2235 |
strcat(options_string, "/"); |
2236 |
strcat(options_string, "E"); |
2237 |
} |
2238 |
|
2426 |
|
2239 |
if (options_ospfv3 & OSPF_V3_OPTIONS_MC) { |
|
|
2240 |
if (options_string[0] != '\0') |
2241 |
strcat(options_string, "/"); |
2242 |
strcat(options_string, "MC"); |
2243 |
} |
2244 |
|
2427 |
|
2245 |
if (options_ospfv3 & OSPF_V3_OPTIONS_N) { |
2428 |
static void |
2246 |
if (options_string[0] != '\0') |
2429 |
dissect_ospf_options(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version) |
2247 |
strcat(options_string, "/"); |
2430 |
{ |
2248 |
strcat(options_string, "N"); |
2431 |
switch ( version ) { |
2249 |
} |
|
|
2250 |
|
2432 |
|
2251 |
if (options_ospfv3 & OSPF_V3_OPTIONS_R) { |
2433 |
case OSPF_VERSION_2: |
2252 |
if (options_string[0] != '\0') |
2434 |
dissect_ospf_v2_options (tree, tvb, offset); |
2253 |
strcat(options_string, "/"); |
2435 |
break; |
2254 |
strcat(options_string, "R"); |
|
|
2255 |
} |
2256 |
|
2436 |
|
2257 |
if (options_ospfv3 & OSPF_V3_OPTIONS_DC) { |
|
|
2258 |
if (options_string[0] != '\0') |
2259 |
strcat(options_string, "/"); |
2260 |
strcat(options_string, "DC"); |
2261 |
} |
2262 |
|
2437 |
|
2263 |
proto_tree_add_text(tree, tvb, offset, 3, "Options: 0x%x (%s)", |
2438 |
case OSPF_VERSION_3: |
2264 |
options_ospfv3, options_string); |
2439 |
dissect_ospf_v3_options (tree, tvb, offset); |
2265 |
break; |
2440 |
break; |
2266 |
} |
2441 |
} |
2267 |
|
2442 |
|
Lines 2321-2359
Link Here
|
2321 |
static void dissect_ospf_v3_address_prefix(tvbuff_t *tvb, int offset, int prefix_length, proto_tree *tree) |
2496 |
static void dissect_ospf_v3_address_prefix(tvbuff_t *tvb, int offset, int prefix_length, proto_tree *tree) |
2322 |
{ |
2497 |
{ |
2323 |
|
2498 |
|
2324 |
guint8 value; |
2499 |
int bytes_to_process; |
2325 |
guint8 position; |
2500 |
struct e_in6_addr prefix; |
2326 |
guint8 bufpos; |
|
|
2327 |
gchar *buffer; |
2328 |
gchar *bytebuf; |
2329 |
guint8 bytes_to_process; |
2330 |
int start_offset; |
2331 |
|
2501 |
|
2332 |
start_offset=offset; |
|
|
2333 |
position=0; |
2334 |
bufpos=0; |
2335 |
bytes_to_process=((prefix_length+31)/32)*4; |
2502 |
bytes_to_process=((prefix_length+31)/32)*4; |
2336 |
|
2503 |
|
2337 |
buffer=ep_alloc(32+7); |
2504 |
if (prefix_length > 128) { |
2338 |
while (bytes_to_process > 0 ) { |
2505 |
proto_tree_add_text(tree, tvb, offset, bytes_to_process, |
2339 |
|
2506 |
"Address Prefix: length is invalid (%d, should be <= 128)", |
2340 |
value=tvb_get_guint8(tvb, offset); |
2507 |
prefix_length); |
2341 |
|
2508 |
return; |
2342 |
if ( (position > 0) && ( (position%2) == 0 ) ) |
|
|
2343 |
buffer[bufpos++]=':'; |
2344 |
|
2345 |
bytebuf=ep_alloc(3); |
2346 |
g_snprintf(bytebuf, 3, "%02x",value); |
2347 |
buffer[bufpos++]=bytebuf[0]; |
2348 |
buffer[bufpos++]=bytebuf[1]; |
2349 |
|
2350 |
position++; |
2351 |
offset++; |
2352 |
bytes_to_process--; |
2353 |
} |
2509 |
} |
2354 |
|
2510 |
|
2355 |
buffer[bufpos]=0; |
2511 |
memset(prefix.bytes, 0, sizeof prefix.bytes); |
2356 |
proto_tree_add_text(tree, tvb, start_offset, ((prefix_length+31)/32)*4, "Address Prefix: %s",buffer); |
2512 |
if (bytes_to_process != 0) { |
|
|
2513 |
tvb_memcpy(tvb, prefix.bytes, offset, bytes_to_process); |
2514 |
if (prefix_length % 8) { |
2515 |
prefix.bytes[bytes_to_process - 1] &= |
2516 |
((0xff00 >> (prefix_length % 8)) & 0xff); |
2517 |
} |
2518 |
} |
2519 |
proto_tree_add_text(tree, tvb, offset, bytes_to_process, |
2520 |
"Address Prefix: %s", ip6_to_str(&prefix)); |
2357 |
|
2521 |
|
2358 |
} |
2522 |
} |
2359 |
|
2523 |
|
Lines 2376-2382
Link Here
|
2376 |
&ett_ospf_lsa_mpls_link_stlv, |
2540 |
&ett_ospf_lsa_mpls_link_stlv, |
2377 |
&ett_ospf_lsa_mpls_link_stlv_admingrp, |
2541 |
&ett_ospf_lsa_mpls_link_stlv_admingrp, |
2378 |
&ett_ospf_lsa_oif_tna, |
2542 |
&ett_ospf_lsa_oif_tna, |
2379 |
&ett_ospf_lsa_oif_tna_stlv |
2543 |
&ett_ospf_lsa_oif_tna_stlv, |
|
|
2544 |
&ett_ospf_options_v2, |
2545 |
&ett_ospf_options_v3, |
2546 |
&ett_ospf_dbd |
2380 |
}; |
2547 |
}; |
2381 |
|
2548 |
|
2382 |
proto_ospf = proto_register_protocol("Open Shortest Path First", |
2549 |
proto_ospf = proto_register_protocol("Open Shortest Path First", |