2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that: (1) source code
4 * distributions retain the above copyright notice and this paragraph
5 * in its entirety, and (2) distributions including binary code include
6 * the above copyright notice and this paragraph in its entirety in
7 * the documentation or other materials provided with the distribution.
8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE.
13 * Copyright (c) 2009 Mojatatu Networks, Inc
17 /* \summary: Forwarding and Control Element Separation (ForCES) Protocol printer */
19 /* specification: RFC 5810 */
25 #include "netdissect-stdinc.h"
27 #include "netdissect.h"
32 #define ForCES_HDRL 24
33 #define ForCES_ALNL 4U
38 #define TOM_ASSNSETUP 0x1
39 #define TOM_ASSNTEARD 0x2
40 #define TOM_CONFIG 0x3
42 #define TOM_EVENTNOT 0x5
43 #define TOM_PKTREDIR 0x6
44 #define TOM_HEARTBT 0x0F
45 #define TOM_ASSNSETREP 0x11
46 #define TOM_CONFIGREP 0x13
47 #define TOM_QUERYREP 0x14
50 * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
52 #define ZERO_TTLV 0x01
53 #define ZERO_MORE_TTLV 0x02
54 #define ONE_MORE_TTLV 0x04
60 #define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
61 #define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
68 int (*print
) (netdissect_options
*ndo
, const u_char
* pptr
, u_int len
,
69 uint16_t op_msk
, int indent
);
86 #define TOM_MAX_IND (_TOM_RSV_MAX - 1)
89 tom_valid(uint8_t tom
)
92 if (tom
>= 0x7 && tom
<= 0xe)
104 ForCES_node(uint32_t node
)
106 if (node
<= 0x3FFFFFFF)
108 if (node
>= 0x40000000 && node
<= 0x7FFFFFFF)
110 if (node
>= 0xC0000000 && node
<= 0xFFFFFFEF)
111 return "AllMulticast";
112 if (node
== 0xFFFFFFFD)
113 return "AllCEsBroadcast";
114 if (node
== 0xFFFFFFFE)
115 return "AllFEsBroadcast";
116 if (node
== 0xFFFFFFFF)
117 return "AllBroadcast";
119 return "ForCESreserved";
123 static const struct tok ForCES_ACKs
[] = {
131 static const struct tok ForCES_EMs
[] = {
133 {0x1, "execute-all-or-none"},
134 {0x2, "execute-until-failure"},
135 {0x3, "continue-execute-on-failure"},
139 static const struct tok ForCES_ATs
[] = {
141 {0x1, "2PCtransaction"},
145 static const struct tok ForCES_TPs
[] = {
146 {0x0, "StartofTransaction"},
147 {0x1, "MiddleofTransaction"},
148 {0x2, "EndofTransaction"},
154 * Structure of forces header, naked of TLVs.
157 nd_uint8_t fm_vrsvd
; /* version and reserved */
158 #define ForCES_V(forcesh) (GET_U_1((forcesh)->fm_vrsvd) >> 4)
159 nd_uint8_t fm_tom
; /* type of message */
160 nd_uint16_t fm_len
; /* total length * 4 bytes */
161 #define ForCES_BLN(forcesh) ((uint32_t)(GET_BE_U_2((forcesh)->fm_len) << 2))
162 nd_uint32_t fm_sid
; /* Source ID */
163 #define ForCES_SID(forcesh) GET_BE_U_4((forcesh)->fm_sid)
164 nd_uint32_t fm_did
; /* Destination ID */
165 #define ForCES_DID(forcesh) GET_BE_U_4((forcesh)->fm_did)
166 nd_uint8_t fm_cor
[8]; /* correlator */
167 nd_uint32_t fm_flags
; /* flags */
168 #define ForCES_ACK(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0xC0000000) >> 30)
169 #define ForCES_PRI(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x38000000) >> 27)
170 #define ForCES_RS1(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x07000000) >> 24)
171 #define ForCES_EM(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00C00000) >> 22)
172 #define ForCES_AT(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00200000) >> 21)
173 #define ForCES_TP(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00180000) >> 19)
174 #define ForCES_RS2(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x0007FFFF) >> 0)
177 #define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
178 (fhl) >= ForCES_HDRL && \
181 #define F_LFB_RSVD 0x0
182 #define F_LFB_FEO 0x1
183 #define F_LFB_FEPO 0x2
184 static const struct tok ForCES_LFBs
[] = {
185 {F_LFB_RSVD
, "Invalid TLV"},
186 {F_LFB_FEO
, "FEObj LFB"},
187 {F_LFB_FEPO
, "FEProtoObj LFB"},
191 /* this is defined in RFC5810 section A.2 */
192 /* http://www.iana.org/assignments/forces/forces.xhtml#oper-tlv-types */
211 #define F_OP_MAX (_F_OP_MAX - 1)
214 B_OP_SET
= 1 << (F_OP_SET
- 1),
215 B_OP_SETPROP
= 1 << (F_OP_SETPROP
- 1),
216 B_OP_SETRESP
= 1 << (F_OP_SETRESP
- 1),
217 B_OP_SETPRESP
= 1 << (F_OP_SETPRESP
- 1),
218 B_OP_DEL
= 1 << (F_OP_DEL
- 1),
219 B_OP_DELRESP
= 1 << (F_OP_DELRESP
- 1),
220 B_OP_GET
= 1 << (F_OP_GET
- 1),
221 B_OP_GETPROP
= 1 << (F_OP_GETPROP
- 1),
222 B_OP_GETRESP
= 1 << (F_OP_GETRESP
- 1),
223 B_OP_GETPRESP
= 1 << (F_OP_GETPRESP
- 1),
224 B_OP_REPORT
= 1 << (F_OP_REPORT
- 1),
225 B_OP_COMMIT
= 1 << (F_OP_COMMIT
- 1),
226 B_OP_RCOMMIT
= 1 << (F_OP_RCOMMIT
- 1),
227 B_OP_RTRCOMP
= 1 << (F_OP_RTRCOMP
- 1)
234 int (*print
) (netdissect_options
*ndo
, const u_char
* pptr
, u_int len
,
235 uint16_t op_msk
, int indent
);
238 static int genoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
239 uint16_t op_msk
, int indent
);
240 static int recpdoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
241 uint16_t op_msk
, int indent
);
242 static int invoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
243 uint16_t op_msk
, int indent
);
258 static const struct optlv_h OPTLV_msg
[F_OP_MAX
+ 1] = {
259 /* F_OP_RSV */ {ZERO_TTLV
, 0, "Invalid OPTLV", invoptlv_print
},
260 /* F_OP_SET */ {TTLV_T2
, B_FULLD
| B_SPARD
, " Set", recpdoptlv_print
},
262 {TTLV_T2
, B_FULLD
| B_SPARD
, " SetProp", recpdoptlv_print
},
263 /* F_OP_SETRESP */ {TTLV_T2
, B_RESTV
, " SetResp", recpdoptlv_print
},
264 /* F_OP_SETPRESP */ {TTLV_T2
, B_RESTV
, " SetPropResp", recpdoptlv_print
},
265 /* F_OP_DEL */ {ZERO_TTLV
, 0, " Del", recpdoptlv_print
},
266 /* F_OP_DELRESP */ {TTLV_T2
, B_RESTV
, " DelResp", recpdoptlv_print
},
267 /* F_OP_GET */ {ZERO_TTLV
, 0, " Get", recpdoptlv_print
},
268 /* F_OP_GETPROP */ {ZERO_TTLV
, 0, " GetProp", recpdoptlv_print
},
270 {TTLV_T2
, B_FULLD
| B_SPARD
| B_RESTV
, " GetResp", recpdoptlv_print
},
272 {TTLV_T2
, B_FULLD
| B_RESTV
, " GetPropResp", recpdoptlv_print
},
274 {TTLV_T2
, B_FULLD
| B_SPARD
, " Report", recpdoptlv_print
},
275 /* F_OP_COMMIT */ {ZERO_TTLV
, 0, " Commit", NULL
},
276 /* F_OP_RCOMMIT */ {TTLV_T1
, B_RESTV
, " RCommit", genoptlv_print
},
277 /* F_OP_RTRCOMP */ {ZERO_TTLV
, 0, " RTRCOMP", NULL
},
280 static const struct optlv_h
*
281 get_forces_optlv_h(uint16_t opt
)
283 if (opt
> F_OP_MAX
|| opt
== F_OP_RSV
)
284 return &OPTLV_msg
[F_OP_RSV
];
286 return &OPTLV_msg
[opt
];
291 #define IND_PREF '\n'
293 static char ind_buf
[IND_SIZE
];
296 indent_pr(int indent
, int nlpref
)
301 if (indent
> (IND_SIZE
- 1))
302 indent
= IND_SIZE
- 1;
310 while (--indent
>= 0)
318 op_valid(uint16_t op
, uint16_t mask
)
323 return (1 << (op
- 1)) & mask
; /* works only for 0x0001 through 0x0010 */
324 /* I guess we should allow vendor operations? */
330 #define F_TLV_RSVD 0x0000
331 #define F_TLV_REDR 0x0001
332 #define F_TLV_ASRS 0x0010
333 #define F_TLV_ASRT 0x0011
334 #define F_TLV_LFBS 0x1000
335 #define F_TLV_PDAT 0x0110
336 #define F_TLV_KEYI 0x0111
337 #define F_TLV_FULD 0x0112
338 #define F_TLV_SPAD 0x0113
339 #define F_TLV_REST 0x0114
340 #define F_TLV_METD 0x0115
341 #define F_TLV_REDD 0x0116
342 #define F_TLV_TRNG 0x0117
345 #define F_TLV_VNST 0x8000
347 static const struct tok ForCES_TLV
[] = {
348 {F_TLV_RSVD
, "Invalid TLV"},
349 {F_TLV_REDR
, "REDIRECT TLV"},
350 {F_TLV_ASRS
, "ASResult TLV"},
351 {F_TLV_ASRT
, "ASTreason TLV"},
352 {F_TLV_LFBS
, "LFBselect TLV"},
353 {F_TLV_PDAT
, "PATH-DATA TLV"},
354 {F_TLV_KEYI
, "KEYINFO TLV"},
355 {F_TLV_FULD
, "FULLDATA TLV"},
356 {F_TLV_SPAD
, "SPARSEDATA TLV"},
357 {F_TLV_REST
, "RESULT TLV"},
358 {F_TLV_METD
, "METADATA TLV"},
359 {F_TLV_REDD
, "REDIRECTDATA TLV"},
365 ttlv_valid(uint16_t ttlv
)
368 if (ttlv
== 1 || ttlv
== 0x1000)
370 if (ttlv
>= 0x10 && ttlv
<= 0x11)
372 if (ttlv
>= 0x110 && ttlv
<= 0x116)
391 #define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
392 #define GET_TOP_TLV(fhdr) ((const struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
393 #define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
394 #define TLV_DATA(tlvp) ((const void*)(((const char*)(tlvp)) + TLV_SET_LEN(0)))
395 #define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(GET_BE_U_2((tlv)->length)), \
396 (const struct forces_tlv*)(((const char*)(tlv)) \
397 + F_ALN_LEN(GET_BE_U_2((tlv)->length))))
398 #define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
399 #define ILV_DATA(ilvp) ((const void*)(((const char*)(ilvp)) + ILV_SET_LEN(0)))
400 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(GET_BE_U_4((ilv)->length)), \
401 (const struct forces_ilv *)(((const char*)(ilv)) \
402 + F_ALN_LEN(GET_BE_U_4((ilv)->length))))
403 #define INVALID_RLEN 1
404 #define INVALID_STLN 2
405 #define INVALID_LTLN 3
406 #define INVALID_ALEN 4
408 static const struct tok ForCES_TLV_err
[] = {
409 {INVALID_RLEN
, "Invalid total length"},
410 {INVALID_STLN
, "xLV too short"},
411 {INVALID_LTLN
, "xLV too long"},
412 {INVALID_ALEN
, "data padding missing"},
417 tlv_valid(u_int tlvl
, u_int rlen
)
425 if (rlen
< F_ALN_LEN(tlvl
))
432 ilv_valid(netdissect_options
*ndo
, const struct forces_ilv
*ilv
, u_int rlen
)
436 if (GET_BE_U_4(ilv
->length
) < ILV_HDRL
)
438 if (GET_BE_U_4(ilv
->length
) > rlen
)
440 if (rlen
< F_ALN_LEN(GET_BE_U_4(ilv
->length
)))
446 static int lfbselect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
447 uint16_t op_msk
, int indent
);
448 static int redirect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
449 uint16_t op_msk
, int indent
);
450 static int asrtlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
451 uint16_t op_msk
, int indent
);
452 static int asttlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
453 uint16_t op_msk
, int indent
);
455 struct forces_lfbsh
{
457 nd_uint32_t instance
;
460 #define ASSNS_OPS (B_OP_REPORT)
461 #define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
462 #define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
463 #define CFG_QY (B_OP_GET|B_OP_GETPROP)
464 #define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
465 #define CFG_EVN (B_OP_REPORT)
467 static const struct tom_h ForCES_msg
[TOM_MAX_IND
+ 1] = {
468 /* TOM_RSV_I */ {TOM_RSVD
, ZERO_TTLV
, 0, "Invalid message", NULL
},
469 /* TOM_ASS_I */ {TOM_ASSNSETUP
, ZERO_MORE_TTLV
| TWO_TLV
, ASSNS_OPS
,
470 "Association Setup", lfbselect_print
},
472 {TOM_ASSNTEARD
, TTLV_T1
, 0, "Association TearDown", asttlv_print
},
473 /* TOM_CFG_I */ {TOM_CONFIG
, TTLV_T2
, CFG_OPS
, "Config", lfbselect_print
},
474 /* TOM_QRY_I */ {TOM_QUERY
, TTLV_T2
, CFG_QY
, "Query", lfbselect_print
},
475 /* TOM_EVN_I */ {TOM_EVENTNOT
, TTLV_T1
, CFG_EVN
, "Event Notification",
478 {TOM_PKTREDIR
, TTLV_T2
, 0, "Packet Redirect", redirect_print
},
479 /* TOM_HBT_I */ {TOM_HEARTBT
, ZERO_TTLV
, 0, "HeartBeat", NULL
},
481 {TOM_ASSNSETREP
, TTLV_T1
, 0, "Association Response", asrtlv_print
},
482 /* TOM_CNR_I */ {TOM_CONFIGREP
, TTLV_T2
, CFG_ROPS
, "Config Response",
485 {TOM_QUERYREP
, TTLV_T2
, CFG_QYR
, "Query Response", lfbselect_print
},
488 static const struct tom_h
*
489 get_forces_tom(uint8_t tom
)
492 for (i
= TOM_RSV_I
; i
<= TOM_MAX_IND
; i
++) {
493 const struct tom_h
*th
= &ForCES_msg
[i
];
497 return &ForCES_msg
[TOM_RSV_I
];
505 int (*print
) (netdissect_options
*, const u_char
* pptr
, u_int len
,
506 uint16_t op_msk
, int indent
);
518 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
521 pd_valid(uint16_t pd
)
523 if (pd
>= F_TLV_PDAT
&& pd
<= F_TLV_REST
)
529 chk_op_type(netdissect_options
*ndo
,
530 uint16_t type
, uint16_t msk
, uint16_t omsk
)
532 if (type
!= F_TLV_PDAT
) {
534 if (type
!= F_TLV_KEYI
) {
535 ND_PRINT("Based on flags expected KEYINFO TLV!\n");
539 ND_PRINT("Illegal DATA encoding for type 0x%x programmed %x got %x\n",
548 #define F_SELTABRANGE 2
549 #define F_TABAPPEND 4
557 static int prestlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
558 uint16_t op_msk
, int indent
);
559 static int pkeyitlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
560 uint16_t op_msk
, int indent
);
561 static int fdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
562 uint16_t op_msk
, int indent
);
563 static int sdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
564 uint16_t op_msk
, int indent
);
566 static const struct pdata_ops ForCES_pdata
[PD_MAX_IND
+ 1] = {
567 /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL
},
568 /* PD_SEL_I */ {F_TLV_KEYI
, 0, 0, "KEYINFO TLV", pkeyitlv_print
},
569 /* PD_FDT_I */ {F_TLV_FULD
, 0, B_FULLD
, "FULLDATA TLV", fdatatlv_print
},
570 /* PD_SDT_I */ {F_TLV_SPAD
, 0, B_SPARD
, "SPARSEDATA TLV", sdatatlv_print
},
571 /* PD_RES_I */ {F_TLV_REST
, 0, B_RESTV
, "RESULT TLV", prestlv_print
},
573 {F_TLV_PDAT
, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print
},
576 static const struct pdata_ops
*
577 get_forces_pd(uint16_t pd
)
580 for (i
= PD_RSV_I
+ 1; i
<= PD_MAX_IND
; i
++) {
581 const struct pdata_ops
*pdo
= &ForCES_pdata
[i
];
585 return &ForCES_pdata
[TOM_RSV_I
];
593 E_INVALID_DESTINATION_PID
,
596 E_LFB_INSTANCE_ID_NOT_FOUND
,
598 E_COMPONENT_DOES_NOT_EXIST
,
602 E_INVALID_ARRAY_CREATION
,
603 E_VALUE_OUT_OF_RANGE
,
605 E_INVALID_PARAMETERS
,
606 E_INVALID_MESSAGE_TYPE
,
613 /* 0x18-0xFE are reserved .. */
614 E_UNSPECIFIED_ERROR
= 0XFF
617 static const struct tok ForCES_errs
[] = {
618 {E_SUCCESS
, "SUCCESS"},
619 {E_INVALID_HEADER
, "INVALID HEADER"},
620 {E_LENGTH_MISMATCH
, "LENGTH MISMATCH"},
621 {E_VERSION_MISMATCH
, "VERSION MISMATCH"},
622 {E_INVALID_DESTINATION_PID
, "INVALID DESTINATION PID"},
623 {E_LFB_UNKNOWN
, "LFB UNKNOWN"},
624 {E_LFB_NOT_FOUND
, "LFB NOT FOUND"},
625 {E_LFB_INSTANCE_ID_NOT_FOUND
, "LFB INSTANCE ID NOT FOUND"},
626 {E_INVALID_PATH
, "INVALID PATH"},
627 {E_COMPONENT_DOES_NOT_EXIST
, "COMPONENT DOES NOT EXIST"},
628 {E_EXISTS
, "EXISTS ALREADY"},
629 {E_NOT_FOUND
, "NOT FOUND"},
630 {E_READ_ONLY
, "READ ONLY"},
631 {E_INVALID_ARRAY_CREATION
, "INVALID ARRAY CREATION"},
632 {E_VALUE_OUT_OF_RANGE
, "VALUE OUT OF RANGE"},
633 {E_CONTENTS_TOO_LONG
, "CONTENTS TOO LONG"},
634 {E_INVALID_PARAMETERS
, "INVALID PARAMETERS"},
635 {E_INVALID_MESSAGE_TYPE
, "INVALID MESSAGE TYPE"},
636 {E_INVALID_FLAGS
, "INVALID FLAGS"},
637 {E_INVALID_TLV
, "INVALID TLV"},
638 {E_EVENT_ERROR
, "EVENT ERROR"},
639 {E_NOT_SUPPORTED
, "NOT SUPPORTED"},
640 {E_MEMORY_ERROR
, "MEMORY ERROR"},
641 {E_INTERNAL_ERROR
, "INTERNAL ERROR"},
642 {E_UNSPECIFIED_ERROR
, "UNSPECIFIED ERROR"},
649 prestlv_print(netdissect_options
*ndo
,
650 const u_char
* pptr
, u_int len
,
651 uint16_t op_msk _U_
, int indent
)
653 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
654 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
655 const struct res_val
*r
= (const struct res_val
*)tdp
;
660 * pdatacnt_print() has ensured that len (the TLV length)
663 dlen
= len
- TLV_HDRL
;
664 if (dlen
!= RESLEN
) {
665 ND_PRINT("illegal RESULT-TLV: %u bytes!\n", dlen
);
670 result
= GET_U_1(r
->result
);
671 if (result
>= 0x18 && result
<= 0xFE) {
672 ND_PRINT("illegal reserved result code: 0x%x!\n", result
);
676 if (ndo
->ndo_vflag
>= 3) {
677 char *ib
= indent_pr(indent
, 0);
678 ND_PRINT("%s Result: %s (code 0x%x)\n", ib
,
679 tok2str(ForCES_errs
, NULL
, result
), result
);
689 fdatatlv_print(netdissect_options
*ndo
,
690 const u_char
* pptr
, u_int len
,
691 uint16_t op_msk _U_
, int indent
)
693 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
695 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
699 * pdatacnt_print() or pkeyitlv_print() has ensured that len
700 * (the TLV length) >= TLV_HDRL.
702 rlen
= len
- TLV_HDRL
;
704 type
= GET_BE_U_2(tlv
->type
);
705 if (type
!= F_TLV_FULD
) {
706 ND_PRINT("Error: expecting FULLDATA!\n");
710 if (ndo
->ndo_vflag
>= 3) {
711 char *ib
= indent_pr(indent
+ 2, 1);
712 ND_PRINT("%s[", ib
+ 1);
713 hex_print_with_offset(ndo
, ib
, tdp
, rlen
, 0);
714 ND_PRINT("\n%s]\n", ib
+ 1);
724 sdatailv_print(netdissect_options
*ndo
,
725 const u_char
* pptr
, u_int len
,
726 uint16_t op_msk _U_
, int indent
)
729 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
732 if (len
< ILV_HDRL
) {
733 ND_PRINT("Error: BAD SPARSEDATA-TLV!\n");
740 ND_PRINT("Jamal - outstanding length <%u>\n", rlen
);
742 char *ib
= indent_pr(indent
, 1);
743 const u_char
*tdp
= (const u_char
*) ILV_DATA(ilv
);
745 invilv
= ilv_valid(ndo
, ilv
, rlen
);
747 ND_PRINT("%s[", ib
+ 1);
748 hex_print_with_offset(ndo
, ib
, tdp
, rlen
, 0);
749 ND_PRINT("\n%s]\n", ib
+ 1);
752 if (ndo
->ndo_vflag
>= 3) {
753 u_int ilvl
= GET_BE_U_4(ilv
->length
);
754 ND_PRINT("\n%s ILV: type %x length %u\n", ib
+ 1,
755 GET_BE_U_4(ilv
->type
), ilvl
);
756 hex_print_with_offset(ndo
, "\t\t[", tdp
, ilvl
-ILV_HDRL
, 0);
759 ilv
= GO_NXT_ILV(ilv
, rlen
);
770 sdatatlv_print(netdissect_options
*ndo
,
771 const u_char
* pptr
, u_int len
,
772 uint16_t op_msk
, int indent
)
774 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
776 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
780 * pdatacnt_print() has ensured that len (the TLV length)
783 rlen
= len
- TLV_HDRL
;
785 type
= GET_BE_U_2(tlv
->type
);
786 if (type
!= F_TLV_SPAD
) {
787 ND_PRINT("Error: expecting SPARSEDATA!\n");
791 return sdatailv_print(ndo
, tdp
, rlen
, op_msk
, indent
);
799 pkeyitlv_print(netdissect_options
*ndo
,
800 const u_char
* pptr
, u_int len
,
801 uint16_t op_msk
, int indent
)
803 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
804 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
805 const u_char
*dp
= tdp
+ 4;
806 const struct forces_tlv
*kdtlv
= (const struct forces_tlv
*)dp
;
808 char *ib
= indent_pr(indent
, 0);
813 id
= GET_BE_U_4(tdp
);
814 ND_PRINT("%sKeyinfo: Key 0x%x\n", ib
, id
);
815 ND_TCHECK_SIZE(kdtlv
);
816 type
= GET_BE_U_2(kdtlv
->type
);
817 tll
= GET_BE_U_2(kdtlv
->length
);
818 invtlv
= tlv_valid(tll
, len
);
821 ND_PRINT("%s TLV type 0x%x len %u\n",
822 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
827 * At this point, tlv_valid() has ensured that the TLV
828 * length is large enough but not too large (it doesn't
829 * go past the end of the containing TLV).
831 tll
= GET_BE_U_2(kdtlv
->length
);
832 dp
= (const u_char
*) TLV_DATA(kdtlv
);
833 return fdatatlv_print(ndo
, dp
, tll
, op_msk
, indent
);
840 #define PTH_DESC_SIZE 12
843 pdatacnt_print(netdissect_options
*ndo
,
844 const u_char
* pptr
, u_int len
,
845 uint16_t IDcnt
, uint16_t op_msk
, int indent
)
849 char *ib
= indent_pr(indent
, 0);
851 if ((op_msk
& B_APPND
) && ndo
->ndo_vflag
>= 3) {
852 ND_PRINT("%sTABLE APPEND\n", ib
);
854 for (i
= 0; i
< IDcnt
; i
++) {
858 id
= GET_BE_U_4(pptr
);
859 if (ndo
->ndo_vflag
>= 3)
860 ND_PRINT("%sID#%02u: %u\n", ib
, i
+ 1, id
);
865 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
866 if (op_msk
& B_TRNG
) {
867 uint32_t starti
, endi
;
869 if (len
< PTH_DESC_SIZE
) {
870 ND_PRINT("pathlength %u with key/range too short %u\n",
875 pptr
+= sizeof(struct forces_tlv
);
876 len
-= sizeof(struct forces_tlv
);
878 starti
= GET_BE_U_4(pptr
);
882 endi
= GET_BE_U_4(pptr
);
886 if (ndo
->ndo_vflag
>= 3)
887 ND_PRINT("%sTable range: [%u,%u]\n", ib
, starti
, endi
);
890 if (op_msk
& B_KEYIN
) {
891 const struct forces_tlv
*keytlv
;
894 if (len
< PTH_DESC_SIZE
) {
895 ND_PRINT("pathlength %u with key/range too short %u\n",
903 keytlv
= (const struct forces_tlv
*)pptr
;
905 pptr
+= sizeof(struct forces_tlv
);
906 len
-= sizeof(struct forces_tlv
);
907 /* skip key content */
908 tll
= GET_BE_U_2(keytlv
->length
);
909 if (tll
< TLV_HDRL
) {
910 ND_PRINT("key content length %u < %u\n",
916 ND_PRINT("key content too short\n");
926 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
933 ND_TCHECK_SIZE(pdtlv
);
934 type
= GET_BE_U_2(pdtlv
->type
);
935 tlvl
= GET_BE_U_2(pdtlv
->length
);
936 invtlv
= tlv_valid(tlvl
, len
);
938 ND_PRINT("%s Outstanding bytes %u for TLV type 0x%x TLV len %u\n",
939 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
944 * At this point, tlv_valid() has ensured that the TLV
945 * length is large enough but not too large (it doesn't
946 * go past the end of the containing TLV).
948 tll
= tlvl
- TLV_HDRL
;
949 aln
= F_ALN_LEN(tlvl
);
952 ND_PRINT("Invalid padded pathdata TLV type 0x%x len %u missing %u pad bytes\n",
953 type
, tlvl
, aln
- len
);
958 if (pd_valid(type
)) {
959 const struct pdata_ops
*ops
= get_forces_pd(type
);
961 if (ndo
->ndo_vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
963 ND_PRINT("%s %s (Length %u DataLen %u pad %u Bytes)\n",
964 ib
, ops
->s
, tlvl
, tll
, pad
);
966 ND_PRINT("%s %s (Length %u DataLen %u Bytes)\n",
967 ib
, ops
->s
, tlvl
, tll
);
970 chk_op_type(ndo
, type
, op_msk
, ops
->op_msk
);
972 if (ops
->print(ndo
, (const u_char
*)pdtlv
,
973 tll
+ pad
+ TLV_HDRL
, op_msk
,
976 len
-= (TLV_HDRL
+ pad
+ tll
);
978 ND_PRINT("Invalid path data content type 0x%x len %u\n",
982 hex_print_with_offset(ndo
, "Bad Data val\n\t [",
998 pdata_print(netdissect_options
*ndo
,
999 const u_char
* pptr
, u_int len
,
1000 uint16_t op_msk
, int indent
)
1002 const struct pathdata_h
*pdh
= (const struct pathdata_h
*)pptr
;
1003 char *ib
= indent_pr(indent
, 0);
1008 ND_TCHECK_SIZE(pdh
);
1009 if (len
< sizeof(struct pathdata_h
))
1011 if (ndo
->ndo_vflag
>= 3) {
1012 ND_PRINT("\n%sPathdata: Flags 0x%x ID count %u\n",
1013 ib
, GET_BE_U_2(pdh
->pflags
),
1014 GET_BE_U_2(pdh
->pIDcnt
));
1017 if (GET_BE_U_2(pdh
->pflags
) & F_SELKEY
) {
1021 /* Table GET Range operation */
1022 if (GET_BE_U_2(pdh
->pflags
) & F_SELTABRANGE
) {
1025 /* Table SET append operation */
1026 if (GET_BE_U_2(pdh
->pflags
) & F_TABAPPEND
) {
1030 pptr
+= sizeof(struct pathdata_h
);
1031 len
-= sizeof(struct pathdata_h
);
1032 idcnt
= GET_BE_U_2(pdh
->pIDcnt
);
1033 minsize
= idcnt
* 4;
1034 if (len
< minsize
) {
1035 ND_PRINT("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
1037 hex_print_with_offset(ndo
, "\t\t\tID Data[", pptr
, len
, 0);
1042 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
1043 ND_PRINT("\t\t\tIllegal to have both Table ranges and keys\n");
1047 more_pd
= pdatacnt_print(ndo
, pptr
, len
, idcnt
, op_msk
, indent
);
1049 int consumed
= len
- more_pd
;
1052 /* XXX: Argh, recurse some more */
1053 return recpdoptlv_print(ndo
, pptr
, len
, op_msk
, indent
+1);
1058 nd_print_trunc(ndo
);
1063 genoptlv_print(netdissect_options
*ndo
,
1064 const u_char
* pptr
, u_int len
,
1065 uint16_t op_msk
, int indent
)
1067 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1071 char *ib
= indent_pr(indent
, 0);
1073 ND_TCHECK_SIZE(pdtlv
);
1074 type
= GET_BE_U_2(pdtlv
->type
);
1075 tlvl
= GET_BE_U_2(pdtlv
->length
);
1076 invtlv
= tlv_valid(tlvl
, len
);
1077 ND_PRINT("genoptlvprint - %s TLV type 0x%x len %u\n",
1078 tok2str(ForCES_TLV
, NULL
, type
), type
, tlvl
);
1081 * At this point, tlv_valid() has ensured that the TLV
1082 * length is large enough but not too large (it doesn't
1083 * go past the end of the containing TLV).
1085 const u_char
*dp
= (const u_char
*) TLV_DATA(pdtlv
);
1087 if (!ttlv_valid(type
)) {
1088 ND_PRINT("%s TLV type 0x%x len %u\n",
1089 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
1093 if (ndo
->ndo_vflag
>= 3)
1094 ND_PRINT("%s%s, length %u (data length %u Bytes)",
1095 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1096 tlvl
, tlvl
- TLV_HDRL
);
1098 return pdata_print(ndo
, dp
, tlvl
- TLV_HDRL
, op_msk
, indent
+ 1);
1100 ND_PRINT("\t\t\tInvalid ForCES TLV type=%x", type
);
1105 nd_print_trunc(ndo
);
1110 recpdoptlv_print(netdissect_options
*ndo
,
1111 const u_char
* pptr
, u_int len
,
1112 uint16_t op_msk
, int indent
)
1114 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1117 uint16_t type
, tlvl
;
1122 ND_TCHECK_SIZE(pdtlv
);
1123 tlvl
= GET_BE_U_2(pdtlv
->length
);
1124 invtlv
= tlv_valid(tlvl
, len
);
1130 * At this point, tlv_valid() has ensured that the TLV
1131 * length is large enough but not too large (it doesn't
1132 * go past the end of the containing TLV).
1134 ib
= indent_pr(indent
, 0);
1135 type
= GET_BE_U_2(pdtlv
->type
);
1136 dp
= (const u_char
*) TLV_DATA(pdtlv
);
1138 if (ndo
->ndo_vflag
>= 3)
1139 ND_PRINT("%s%s, length %u (data encapsulated %u Bytes)",
1140 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1144 if (pdata_print(ndo
, dp
, tlvl
- TLV_HDRL
, op_msk
, indent
+ 1) == -1)
1146 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
1150 ND_PRINT("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1151 GET_BE_U_2(pdtlv
->type
),
1152 len
- GET_BE_U_2(pdtlv
->length
));
1159 nd_print_trunc(ndo
);
1164 invoptlv_print(netdissect_options
*ndo
,
1165 const u_char
* pptr
, u_int len
,
1166 uint16_t op_msk _U_
, int indent
)
1168 char *ib
= indent_pr(indent
, 1);
1170 if (ndo
->ndo_vflag
>= 3) {
1171 ND_PRINT("%sData[", ib
+ 1);
1172 hex_print_with_offset(ndo
, ib
, pptr
, len
, 0);
1173 ND_PRINT("%s]\n", ib
);
1179 otlv_print(netdissect_options
*ndo
,
1180 const struct forces_tlv
*otlv
, uint16_t op_msk _U_
, int indent
)
1183 const u_char
*dp
= (const u_char
*) TLV_DATA(otlv
);
1186 char *ib
= indent_pr(indent
, 0);
1187 const struct optlv_h
*ops
;
1190 * lfbselect_print() has ensured that EXTRACT_BE_U_2(otlv->length)
1193 ND_TCHECK_SIZE(otlv
);
1194 type
= GET_BE_U_2(otlv
->type
);
1195 tll
= GET_BE_U_2(otlv
->length
) - TLV_HDRL
;
1196 ops
= get_forces_optlv_h(type
);
1197 if (ndo
->ndo_vflag
>= 3) {
1198 ND_PRINT("%sOper TLV %s(0x%x) length %u\n", ib
, ops
->s
, type
,
1199 GET_BE_U_2(otlv
->length
));
1201 /* rest of ops must at least have 12B {pathinfo} */
1202 if (tll
< OP_MIN_SIZ
) {
1203 ND_PRINT("\t\tOper TLV %s(0x%x) length %u\n", ops
->s
, type
,
1204 GET_BE_U_2(otlv
->length
));
1205 ND_PRINT("\t\tTruncated data size %u minimum required %u\n", tll
,
1207 return invoptlv_print(ndo
, dp
, tll
, ops
->op_msk
, indent
);
1211 /* XXX - do anything with ops->flags? */
1213 rc
= ops
->print(ndo
, dp
, tll
, ops
->op_msk
, indent
+ 1);
1218 nd_print_trunc(ndo
);
1225 asttlv_print(netdissect_options
*ndo
,
1226 const u_char
* pptr
, u_int len
,
1227 uint16_t op_msk _U_
, int indent
)
1231 char *ib
= indent_pr(indent
, 0);
1234 * forces_type_print() has ensured that len (the TLV length)
1237 dlen
= len
- TLV_HDRL
;
1238 if (dlen
!= ASTDLN
) {
1239 ND_PRINT("illegal ASTresult-TLV: %u bytes!\n", dlen
);
1243 rescode
= GET_BE_U_4(pptr
);
1244 if (rescode
> ASTMCD
) {
1245 ND_PRINT("illegal ASTresult result code: %u!\n", rescode
);
1249 if (ndo
->ndo_vflag
>= 3) {
1250 ND_PRINT("Teardown reason:\n%s", ib
);
1253 ND_PRINT("Normal Teardown");
1256 ND_PRINT("Loss of Heartbeats");
1259 ND_PRINT("Out of bandwidth");
1262 ND_PRINT("Out of Memory");
1265 ND_PRINT("Application Crash");
1268 ND_PRINT("Unknown Teardown reason");
1271 ND_PRINT("(%x)\n%s", rescode
, ib
);
1276 nd_print_trunc(ndo
);
1283 asrtlv_print(netdissect_options
*ndo
,
1284 const u_char
* pptr
, u_int len
,
1285 uint16_t op_msk _U_
, int indent
)
1289 char *ib
= indent_pr(indent
, 0);
1292 * forces_type_print() has ensured that len (the TLV length)
1295 dlen
= len
- TLV_HDRL
;
1296 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
1297 ND_PRINT("illegal ASRresult-TLV: %u bytes!\n", dlen
);
1301 rescode
= GET_BE_U_4(pptr
);
1303 if (rescode
> ASRMCD
) {
1304 ND_PRINT("illegal ASRresult result code: %u!\n", rescode
);
1308 if (ndo
->ndo_vflag
>= 3) {
1309 ND_PRINT("\n%s", ib
);
1312 ND_PRINT("Success ");
1315 ND_PRINT("FE ID invalid ");
1318 ND_PRINT("permission denied ");
1321 ND_PRINT("Unknown ");
1324 ND_PRINT("(%x)\n%s", rescode
, ib
);
1329 nd_print_trunc(ndo
);
1338 gentltlv_print(netdissect_options
*ndo
,
1339 const u_char
* pptr _U_
, u_int len
,
1340 uint16_t op_msk _U_
, int indent _U_
)
1342 u_int dlen
= len
- TLV_HDRL
;
1344 if (dlen
< 4) { /* at least 32 bits must exist */
1345 ND_PRINT("truncated TLV: %u bytes missing! ", 4 - dlen
);
1355 print_metailv(netdissect_options
*ndo
,
1356 const u_char
* pptr
, uint16_t op_msk _U_
, int indent
)
1359 char *ib
= indent_pr(indent
, 0);
1360 /* XXX: check header length */
1361 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
1364 * print_metatlv() has ensured that len (what remains in the
1367 rlen
= GET_BE_U_4(ilv
->length
) - ILV_HDRL
;
1368 ND_TCHECK_SIZE(ilv
);
1369 ND_PRINT("%sMetaID 0x%x length %u\n", ib
, GET_BE_U_4(ilv
->type
),
1370 GET_BE_U_4(ilv
->length
));
1371 if (ndo
->ndo_vflag
>= 3) {
1372 hex_print_with_offset(ndo
, "\t\t[", ILV_DATA(ilv
), rlen
, 0);
1378 nd_print_trunc(ndo
);
1383 print_metatlv(netdissect_options
*ndo
,
1384 const u_char
* pptr
, u_int len
,
1385 uint16_t op_msk _U_
, int indent
)
1388 char *ib
= indent_pr(indent
, 0);
1390 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
1394 * redirect_print() has ensured that len (what remains in the
1397 dlen
= len
- TLV_HDRL
;
1399 ND_PRINT("\n%s METADATA length %u\n", ib
, rlen
);
1401 ND_TCHECK_SIZE(ilv
);
1402 invilv
= ilv_valid(ndo
, ilv
, rlen
);
1408 * At this point, ilv_valid() has ensured that the ILV
1409 * length is large enough but not too large (it doesn't
1410 * go past the end of the containing TLV).
1412 print_metailv(ndo
, (const u_char
*) ilv
, 0, indent
+ 1);
1413 ilv
= GO_NXT_ILV(ilv
, rlen
);
1419 nd_print_trunc(ndo
);
1425 print_reddata(netdissect_options
*ndo
,
1426 const u_char
* pptr
, u_int len
,
1427 uint16_t op_msk _U_
, int indent
)
1430 char *ib
= indent_pr(indent
, 0);
1433 dlen
= len
- TLV_HDRL
;
1435 ND_PRINT("\n%s Redirect Data length %u\n", ib
, rlen
);
1437 if (ndo
->ndo_vflag
>= 3) {
1439 hex_print_with_offset(ndo
, "\n\t\t", pptr
, rlen
, 0);
1440 ND_PRINT("\n\t\t]");
1447 redirect_print(netdissect_options
*ndo
,
1448 const u_char
* pptr
, u_int len
,
1449 uint16_t op_msk _U_
, int indent
)
1451 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
1457 * forces_type_print() has ensured that len (the TLV length)
1460 dlen
= len
- TLV_HDRL
;
1461 if (dlen
<= RD_MIN
) {
1462 ND_PRINT("\n\t\ttruncated Redirect TLV: %u bytes missing! ",
1470 uint16_t type
, tlvl
;
1472 ND_TCHECK_SIZE(tlv
);
1473 type
= GET_BE_U_2(tlv
->type
);
1474 tlvl
= GET_BE_U_2(tlv
->length
);
1475 invtlv
= tlv_valid(tlvl
, rlen
);
1477 ND_PRINT("Bad Redirect data\n");
1482 * At this point, tlv_valid() has ensured that the TLV
1483 * length is large enough but not too large (it doesn't
1484 * go past the end of the containing TLV).
1486 if (type
== F_TLV_METD
) {
1487 print_metatlv(ndo
, (const u_char
*) TLV_DATA(tlv
),
1490 } else if (type
== F_TLV_REDD
) {
1491 print_reddata(ndo
, (const u_char
*) TLV_DATA(tlv
),
1495 ND_PRINT("Unknown REDIRECT TLV 0x%x len %u\n",
1500 tlv
= GO_NXT_TLV(tlv
, rlen
);
1504 ND_PRINT("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1505 GET_BE_U_2(tlv
->type
),
1506 rlen
- GET_BE_U_2(tlv
->length
));
1513 nd_print_trunc(ndo
);
1521 lfbselect_print(netdissect_options
*ndo
,
1522 const u_char
* pptr
, u_int len
,
1523 uint16_t op_msk
, int indent
)
1525 const struct forces_lfbsh
*lfbs
;
1526 const struct forces_tlv
*otlv
;
1527 char *ib
= indent_pr(indent
, 0);
1533 * forces_type_print() has ensured that len (the TLV length)
1536 dlen
= len
- TLV_HDRL
;
1537 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
1538 ND_PRINT("\n\t\ttruncated lfb selector: %u bytes missing! ",
1544 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
1545 * we also know that it's > OP_OFF.
1547 rlen
= dlen
- OP_OFF
;
1549 lfbs
= (const struct forces_lfbsh
*)pptr
;
1550 ND_TCHECK_SIZE(lfbs
);
1551 if (ndo
->ndo_vflag
>= 3) {
1552 ND_PRINT("\n%s%s(Classid %x) instance %x\n",
1554 tok2str(ForCES_LFBs
, NULL
, GET_BE_U_4(lfbs
->class)),
1555 GET_BE_U_4(lfbs
->class),
1556 GET_BE_U_4(lfbs
->instance
));
1559 otlv
= (const struct forces_tlv
*)(lfbs
+ 1);
1563 uint16_t type
, tlvl
;
1565 ND_TCHECK_SIZE(otlv
);
1566 type
= GET_BE_U_2(otlv
->type
);
1567 tlvl
= GET_BE_U_2(otlv
->length
);
1568 invtlv
= tlv_valid(tlvl
, rlen
);
1573 * At this point, tlv_valid() has ensured that the TLV
1574 * length is large enough but not too large (it doesn't
1575 * go past the end of the containing TLV).
1577 if (op_valid(type
, op_msk
)) {
1578 otlv_print(ndo
, otlv
, 0, indent
);
1580 if (ndo
->ndo_vflag
< 3)
1582 ND_PRINT("\t\tINValid oper-TLV type 0x%x length %u for this ForCES message\n",
1584 invoptlv_print(ndo
, (const u_char
*)otlv
, rlen
, 0, indent
);
1586 otlv
= GO_NXT_TLV(otlv
, rlen
);
1590 ND_PRINT("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1591 GET_BE_U_2(otlv
->type
),
1592 rlen
- GET_BE_U_2(otlv
->length
));
1599 nd_print_trunc(ndo
);
1604 forces_type_print(netdissect_options
*ndo
,
1605 const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
1606 u_int mlen
, const struct tom_h
*tops
)
1608 const struct forces_tlv
*tltlv
;
1615 * forces_print() has already checked that mlen >= ForCES_HDRL
1616 * by calling ForCES_HLN_VALID().
1618 rlen
= mlen
- ForCES_HDRL
;
1620 if (rlen
> TLV_HLN
) {
1621 if (tops
->flags
& ZERO_TTLV
) {
1622 ND_PRINT("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
1626 if (tops
->flags
& ZERO_MORE_TTLV
)
1628 if (tops
->flags
& ONE_MORE_TTLV
) {
1629 ND_PRINT("\tTop level TLV Data missing!\n");
1634 if (tops
->flags
& ZERO_TTLV
) {
1638 ttlv
= tops
->flags
>> 4;
1639 tltlv
= GET_TOP_TLV(pptr
);
1641 /*XXX: 15 top level tlvs will probably be fine
1642 You are nuts if you send more ;-> */
1644 uint16_t type
, tlvl
;
1646 ND_TCHECK_SIZE(tltlv
);
1647 type
= GET_BE_U_2(tltlv
->type
);
1648 tlvl
= GET_BE_U_2(tltlv
->length
);
1649 invtlv
= tlv_valid(tlvl
, rlen
);
1654 * At this point, tlv_valid() has ensured that the TLV
1655 * length is large enough but not too large (it doesn't
1656 * go past the end of the packet).
1658 if (!ttlv_valid(type
)) {
1659 ND_PRINT("\n\tInvalid ForCES Top TLV type=0x%x",
1664 if (ndo
->ndo_vflag
>= 3)
1665 ND_PRINT("\t%s, length %u (data length %u Bytes)",
1666 tok2str(ForCES_TLV
, NULL
, type
),
1670 rc
= tops
->print(ndo
, (const u_char
*) TLV_DATA(tltlv
),
1676 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1682 * XXX - if ttlv != 0, does that mean that the packet was too
1683 * short, and didn't have *enough* TLVs in it?
1686 ND_PRINT("\tMess TopTLV header: min %u, total %u advertised %u ",
1687 TLV_HDRL
, rlen
, GET_BE_U_2(tltlv
->length
));
1694 nd_print_trunc(ndo
);
1699 forces_print(netdissect_options
*ndo
,
1700 const u_char
* pptr
, u_int len
)
1702 const struct forcesh
*fhdr
;
1706 const struct tom_h
*tops
;
1709 ndo
->ndo_protocol
= "forces";
1710 fhdr
= (const struct forcesh
*)pptr
;
1711 ND_TCHECK_SIZE(fhdr
);
1712 tom
= GET_U_1(fhdr
->fm_tom
);
1713 if (!tom_valid(tom
)) {
1714 ND_PRINT("Invalid ForCES message type %u\n", tom
);
1718 mlen
= ForCES_BLN(fhdr
);
1720 tops
= get_forces_tom(tom
);
1721 if (tops
->v
== TOM_RSVD
) {
1722 ND_PRINT("\n\tUnknown ForCES message type=0x%x", tom
);
1726 ND_PRINT("\n\tForCES %s ", tops
->s
);
1727 if (!ForCES_HLN_VALID(mlen
, len
)) {
1728 ND_PRINT("Illegal ForCES pkt len - min %u, total recvd %u, advertised %u ",
1729 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1733 ND_TCHECK_4(pptr
+ 20);
1734 flg_raw
= GET_BE_U_4(pptr
+ 20);
1735 if (ndo
->ndo_vflag
>= 1) {
1736 ND_PRINT("\n\tForCES Version %u len %uB flags 0x%08x ",
1737 ForCES_V(fhdr
), mlen
, flg_raw
);
1738 ND_PRINT("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1739 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1740 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1741 GET_BE_U_8(fhdr
->fm_cor
));
1744 if (ndo
->ndo_vflag
>= 2) {
1745 ND_PRINT("\n\tForCES flags:\n\t %s(0x%x), prio=%u, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1746 tok2str(ForCES_ACKs
, "ACKUnknown", ForCES_ACK(fhdr
)),
1749 tok2str(ForCES_EMs
, "EMUnknown", ForCES_EM(fhdr
)),
1751 tok2str(ForCES_ATs
, "ATUnknown", ForCES_AT(fhdr
)),
1753 tok2str(ForCES_TPs
, "TPUnknown", ForCES_TP(fhdr
)),
1755 ND_PRINT("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1756 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1758 rc
= forces_type_print(ndo
, pptr
, fhdr
, mlen
, tops
);
1761 hex_print_with_offset(ndo
, "\n\t[", pptr
, len
, 0);
1766 if (ndo
->ndo_vflag
>= 4) {
1767 ND_PRINT("\n\t Raw ForCES message\n\t [");
1768 hex_print_with_offset(ndo
, "\n\t ", pptr
, len
, 0);
1775 nd_print_trunc(ndo
);