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 #define ND_LONGJMP_FROM_TCHECK
28 #include "netdissect.h"
33 #define ForCES_HDRL 24
34 #define ForCES_ALNL 4U
39 #define TOM_ASSNSETUP 0x1
40 #define TOM_ASSNTEARD 0x2
41 #define TOM_CONFIG 0x3
43 #define TOM_EVENTNOT 0x5
44 #define TOM_PKTREDIR 0x6
45 #define TOM_HEARTBT 0x0F
46 #define TOM_ASSNSETREP 0x11
47 #define TOM_CONFIGREP 0x13
48 #define TOM_QUERYREP 0x14
51 * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
53 #define ZERO_TTLV 0x01
54 #define ZERO_MORE_TTLV 0x02
55 #define ONE_MORE_TTLV 0x04
61 #define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
62 #define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
69 int (*print
) (netdissect_options
*ndo
, const u_char
* pptr
, u_int len
,
70 uint16_t op_msk
, int indent
);
87 #define TOM_MAX_IND (_TOM_RSV_MAX - 1)
90 tom_valid(uint8_t tom
)
93 if (tom
>= 0x7 && tom
<= 0xe)
105 ForCES_node(uint32_t node
)
107 if (node
<= 0x3FFFFFFF)
109 if (node
>= 0x40000000 && node
<= 0x7FFFFFFF)
111 if (node
>= 0xC0000000 && node
<= 0xFFFFFFEF)
112 return "AllMulticast";
113 if (node
== 0xFFFFFFFD)
114 return "AllCEsBroadcast";
115 if (node
== 0xFFFFFFFE)
116 return "AllFEsBroadcast";
117 if (node
== 0xFFFFFFFF)
118 return "AllBroadcast";
120 return "ForCESreserved";
124 static const struct tok ForCES_ACKs
[] = {
132 static const struct tok ForCES_EMs
[] = {
134 {0x1, "execute-all-or-none"},
135 {0x2, "execute-until-failure"},
136 {0x3, "continue-execute-on-failure"},
140 static const struct tok ForCES_ATs
[] = {
142 {0x1, "2PCtransaction"},
146 static const struct tok ForCES_TPs
[] = {
147 {0x0, "StartofTransaction"},
148 {0x1, "MiddleofTransaction"},
149 {0x2, "EndofTransaction"},
155 * Structure of forces header, naked of TLVs.
158 nd_uint8_t fm_vrsvd
; /* version and reserved */
159 #define ForCES_V(forcesh) (GET_U_1((forcesh)->fm_vrsvd) >> 4)
160 nd_uint8_t fm_tom
; /* type of message */
161 nd_uint16_t fm_len
; /* total length * 4 bytes */
162 #define ForCES_BLN(forcesh) ((uint32_t)(GET_BE_U_2((forcesh)->fm_len) << 2))
163 nd_uint32_t fm_sid
; /* Source ID */
164 #define ForCES_SID(forcesh) GET_BE_U_4((forcesh)->fm_sid)
165 nd_uint32_t fm_did
; /* Destination ID */
166 #define ForCES_DID(forcesh) GET_BE_U_4((forcesh)->fm_did)
167 nd_uint8_t fm_cor
[8]; /* correlator */
168 nd_uint32_t fm_flags
; /* flags */
169 #define ForCES_ACK(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0xC0000000) >> 30)
170 #define ForCES_PRI(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x38000000) >> 27)
171 #define ForCES_RS1(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x07000000) >> 24)
172 #define ForCES_EM(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00C00000) >> 22)
173 #define ForCES_AT(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00200000) >> 21)
174 #define ForCES_TP(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00180000) >> 19)
175 #define ForCES_RS2(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x0007FFFF) >> 0)
178 #define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
179 (fhl) >= ForCES_HDRL && \
182 #define F_LFB_RSVD 0x0
183 #define F_LFB_FEO 0x1
184 #define F_LFB_FEPO 0x2
185 static const struct tok ForCES_LFBs
[] = {
186 {F_LFB_RSVD
, "Invalid TLV"},
187 {F_LFB_FEO
, "FEObj LFB"},
188 {F_LFB_FEPO
, "FEProtoObj LFB"},
192 /* this is defined in RFC5810 section A.2 */
193 /* https://www.iana.org/assignments/forces/forces.xhtml#oper-tlv-types */
212 #define F_OP_MAX (_F_OP_MAX - 1)
215 B_OP_SET
= 1 << (F_OP_SET
- 1),
216 B_OP_SETPROP
= 1 << (F_OP_SETPROP
- 1),
217 B_OP_SETRESP
= 1 << (F_OP_SETRESP
- 1),
218 B_OP_SETPRESP
= 1 << (F_OP_SETPRESP
- 1),
219 B_OP_DEL
= 1 << (F_OP_DEL
- 1),
220 B_OP_DELRESP
= 1 << (F_OP_DELRESP
- 1),
221 B_OP_GET
= 1 << (F_OP_GET
- 1),
222 B_OP_GETPROP
= 1 << (F_OP_GETPROP
- 1),
223 B_OP_GETRESP
= 1 << (F_OP_GETRESP
- 1),
224 B_OP_GETPRESP
= 1 << (F_OP_GETPRESP
- 1),
225 B_OP_REPORT
= 1 << (F_OP_REPORT
- 1),
226 B_OP_COMMIT
= 1 << (F_OP_COMMIT
- 1),
227 B_OP_RCOMMIT
= 1 << (F_OP_RCOMMIT
- 1),
228 B_OP_RTRCOMP
= 1 << (F_OP_RTRCOMP
- 1)
235 int (*print
) (netdissect_options
*ndo
, const u_char
* pptr
, u_int len
,
236 uint16_t op_msk
, int indent
);
239 static int genoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
240 uint16_t op_msk
, int indent
);
241 static int recpdoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
242 uint16_t op_msk
, int indent
);
243 static int invoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
244 uint16_t op_msk
, int indent
);
259 static const struct optlv_h OPTLV_msg
[F_OP_MAX
+ 1] = {
260 /* F_OP_RSV */ {ZERO_TTLV
, 0, "Invalid OPTLV", invoptlv_print
},
261 /* F_OP_SET */ {TTLV_T2
, B_FULLD
| B_SPARD
, " Set", recpdoptlv_print
},
263 {TTLV_T2
, B_FULLD
| B_SPARD
, " SetProp", recpdoptlv_print
},
264 /* F_OP_SETRESP */ {TTLV_T2
, B_RESTV
, " SetResp", recpdoptlv_print
},
265 /* F_OP_SETPRESP */ {TTLV_T2
, B_RESTV
, " SetPropResp", recpdoptlv_print
},
266 /* F_OP_DEL */ {ZERO_TTLV
, 0, " Del", recpdoptlv_print
},
267 /* F_OP_DELRESP */ {TTLV_T2
, B_RESTV
, " DelResp", recpdoptlv_print
},
268 /* F_OP_GET */ {ZERO_TTLV
, 0, " Get", recpdoptlv_print
},
269 /* F_OP_GETPROP */ {ZERO_TTLV
, 0, " GetProp", recpdoptlv_print
},
271 {TTLV_T2
, B_FULLD
| B_SPARD
| B_RESTV
, " GetResp", recpdoptlv_print
},
273 {TTLV_T2
, B_FULLD
| B_RESTV
, " GetPropResp", recpdoptlv_print
},
275 {TTLV_T2
, B_FULLD
| B_SPARD
, " Report", recpdoptlv_print
},
276 /* F_OP_COMMIT */ {ZERO_TTLV
, 0, " Commit", NULL
},
277 /* F_OP_RCOMMIT */ {TTLV_T1
, B_RESTV
, " RCommit", genoptlv_print
},
278 /* F_OP_RTRCOMP */ {ZERO_TTLV
, 0, " RTRCOMP", NULL
},
281 static const struct optlv_h
*
282 get_forces_optlv_h(uint16_t opt
)
284 if (opt
> F_OP_MAX
|| opt
== F_OP_RSV
)
285 return &OPTLV_msg
[F_OP_RSV
];
287 return &OPTLV_msg
[opt
];
292 #define IND_PREF '\n'
294 static char ind_buf
[IND_SIZE
];
297 indent_pr(int indent
, int nlpref
)
302 if (indent
> (IND_SIZE
- 1))
303 indent
= IND_SIZE
- 1;
311 while (--indent
>= 0)
319 op_valid(uint16_t op
, uint16_t mask
)
324 return (1 << (op
- 1)) & mask
; /* works only for 0x0001 through 0x0010 */
325 /* I guess we should allow vendor operations? */
331 #define F_TLV_RSVD 0x0000
332 #define F_TLV_REDR 0x0001
333 #define F_TLV_ASRS 0x0010
334 #define F_TLV_ASRT 0x0011
335 #define F_TLV_LFBS 0x1000
336 #define F_TLV_PDAT 0x0110
337 #define F_TLV_KEYI 0x0111
338 #define F_TLV_FULD 0x0112
339 #define F_TLV_SPAD 0x0113
340 #define F_TLV_REST 0x0114
341 #define F_TLV_METD 0x0115
342 #define F_TLV_REDD 0x0116
343 #define F_TLV_TRNG 0x0117
346 #define F_TLV_VNST 0x8000
348 static const struct tok ForCES_TLV
[] = {
349 {F_TLV_RSVD
, "Invalid TLV"},
350 {F_TLV_REDR
, "REDIRECT TLV"},
351 {F_TLV_ASRS
, "ASResult TLV"},
352 {F_TLV_ASRT
, "ASTreason TLV"},
353 {F_TLV_LFBS
, "LFBselect TLV"},
354 {F_TLV_PDAT
, "PATH-DATA TLV"},
355 {F_TLV_KEYI
, "KEYINFO TLV"},
356 {F_TLV_FULD
, "FULLDATA TLV"},
357 {F_TLV_SPAD
, "SPARSEDATA TLV"},
358 {F_TLV_REST
, "RESULT TLV"},
359 {F_TLV_METD
, "METADATA TLV"},
360 {F_TLV_REDD
, "REDIRECTDATA TLV"},
366 ttlv_valid(uint16_t ttlv
)
369 if (ttlv
== 1 || ttlv
== 0x1000)
371 if (ttlv
>= 0x10 && ttlv
<= 0x11)
373 if (ttlv
>= 0x110 && ttlv
<= 0x116)
392 #define F_ALN_LEN(len) roundup2(len, ForCES_ALNL)
393 #define GET_TOP_TLV(fhdr) ((const struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
394 #define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
395 #define TLV_DATA(tlvp) ((const void*)(((const char*)(tlvp)) + TLV_SET_LEN(0)))
396 #define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(GET_BE_U_2((tlv)->length)), \
397 (const struct forces_tlv*)(((const char*)(tlv)) \
398 + F_ALN_LEN(GET_BE_U_2((tlv)->length))))
399 #define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
400 #define ILV_DATA(ilvp) ((const void*)(((const char*)(ilvp)) + ILV_SET_LEN(0)))
401 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(GET_BE_U_4((ilv)->length)), \
402 (const struct forces_ilv *)(((const char*)(ilv)) \
403 + F_ALN_LEN(GET_BE_U_4((ilv)->length))))
404 #define INVALID_RLEN 1
405 #define INVALID_STLN 2
406 #define INVALID_LTLN 3
407 #define INVALID_ALEN 4
409 static const struct tok ForCES_TLV_err
[] = {
410 {INVALID_RLEN
, "Invalid total length"},
411 {INVALID_STLN
, "xLV too short"},
412 {INVALID_LTLN
, "xLV too long"},
413 {INVALID_ALEN
, "data padding missing"},
418 tlv_valid(u_int tlvl
, u_int rlen
)
426 if (rlen
< F_ALN_LEN(tlvl
))
433 ilv_valid(netdissect_options
*ndo
, const struct forces_ilv
*ilv
, u_int rlen
)
437 if (GET_BE_U_4(ilv
->length
) < ILV_HDRL
)
439 if (GET_BE_U_4(ilv
->length
) > rlen
)
441 if (rlen
< F_ALN_LEN(GET_BE_U_4(ilv
->length
)))
447 static int lfbselect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
448 uint16_t op_msk
, int indent
);
449 static int redirect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
450 uint16_t op_msk
, int indent
);
451 static int asrtlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
452 uint16_t op_msk
, int indent
);
453 static int asttlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
454 uint16_t op_msk
, int indent
);
456 struct forces_lfbsh
{
458 nd_uint32_t instance
;
461 #define ASSNS_OPS (B_OP_REPORT)
462 #define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
463 #define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
464 #define CFG_QY (B_OP_GET|B_OP_GETPROP)
465 #define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
466 #define CFG_EVN (B_OP_REPORT)
468 static const struct tom_h ForCES_msg
[TOM_MAX_IND
+ 1] = {
469 /* TOM_RSV_I */ {TOM_RSVD
, ZERO_TTLV
, 0, "Invalid message", NULL
},
470 /* TOM_ASS_I */ {TOM_ASSNSETUP
, ZERO_MORE_TTLV
| TWO_TLV
, ASSNS_OPS
,
471 "Association Setup", lfbselect_print
},
473 {TOM_ASSNTEARD
, TTLV_T1
, 0, "Association TearDown", asttlv_print
},
474 /* TOM_CFG_I */ {TOM_CONFIG
, TTLV_T2
, CFG_OPS
, "Config", lfbselect_print
},
475 /* TOM_QRY_I */ {TOM_QUERY
, TTLV_T2
, CFG_QY
, "Query", lfbselect_print
},
476 /* TOM_EVN_I */ {TOM_EVENTNOT
, TTLV_T1
, CFG_EVN
, "Event Notification",
479 {TOM_PKTREDIR
, TTLV_T2
, 0, "Packet Redirect", redirect_print
},
480 /* TOM_HBT_I */ {TOM_HEARTBT
, ZERO_TTLV
, 0, "HeartBeat", NULL
},
482 {TOM_ASSNSETREP
, TTLV_T1
, 0, "Association Response", asrtlv_print
},
483 /* TOM_CNR_I */ {TOM_CONFIGREP
, TTLV_T2
, CFG_ROPS
, "Config Response",
486 {TOM_QUERYREP
, TTLV_T2
, CFG_QYR
, "Query Response", lfbselect_print
},
489 static const struct tom_h
*
490 get_forces_tom(uint8_t tom
)
493 for (i
= TOM_RSV_I
; i
<= TOM_MAX_IND
; i
++) {
494 const struct tom_h
*th
= &ForCES_msg
[i
];
498 return &ForCES_msg
[TOM_RSV_I
];
506 int (*print
) (netdissect_options
*, const u_char
* pptr
, u_int len
,
507 uint16_t op_msk
, int indent
);
519 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
522 pd_valid(uint16_t pd
)
524 if (pd
>= F_TLV_PDAT
&& pd
<= F_TLV_REST
)
530 chk_op_type(netdissect_options
*ndo
,
531 uint16_t type
, uint16_t msk
, uint16_t omsk
)
533 if (type
!= F_TLV_PDAT
) {
535 if (type
!= F_TLV_KEYI
) {
536 ND_PRINT("Based on flags expected KEYINFO TLV!\n");
540 ND_PRINT("Illegal DATA encoding for type 0x%x programmed %x got %x\n",
549 #define F_SELTABRANGE 2
550 #define F_TABAPPEND 4
558 static int prestlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
559 uint16_t op_msk
, int indent
);
560 static int pkeyitlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
561 uint16_t op_msk
, int indent
);
562 static int fdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
563 uint16_t op_msk
, int indent
);
564 static int sdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
565 uint16_t op_msk
, int indent
);
567 static const struct pdata_ops ForCES_pdata
[PD_MAX_IND
+ 1] = {
568 /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL
},
569 /* PD_SEL_I */ {F_TLV_KEYI
, 0, 0, "KEYINFO TLV", pkeyitlv_print
},
570 /* PD_FDT_I */ {F_TLV_FULD
, 0, B_FULLD
, "FULLDATA TLV", fdatatlv_print
},
571 /* PD_SDT_I */ {F_TLV_SPAD
, 0, B_SPARD
, "SPARSEDATA TLV", sdatatlv_print
},
572 /* PD_RES_I */ {F_TLV_REST
, 0, B_RESTV
, "RESULT TLV", prestlv_print
},
574 {F_TLV_PDAT
, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print
},
577 static const struct pdata_ops
*
578 get_forces_pd(uint16_t pd
)
581 for (i
= PD_RSV_I
+ 1; i
<= PD_MAX_IND
; i
++) {
582 const struct pdata_ops
*pdo
= &ForCES_pdata
[i
];
586 return &ForCES_pdata
[TOM_RSV_I
];
594 E_INVALID_DESTINATION_PID
,
597 E_LFB_INSTANCE_ID_NOT_FOUND
,
599 E_COMPONENT_DOES_NOT_EXIST
,
603 E_INVALID_ARRAY_CREATION
,
604 E_VALUE_OUT_OF_RANGE
,
606 E_INVALID_PARAMETERS
,
607 E_INVALID_MESSAGE_TYPE
,
614 /* 0x18-0xFE are reserved .. */
615 E_UNSPECIFIED_ERROR
= 0XFF
618 static const struct tok ForCES_errs
[] = {
619 {E_SUCCESS
, "SUCCESS"},
620 {E_INVALID_HEADER
, "INVALID HEADER"},
621 {E_LENGTH_MISMATCH
, "LENGTH MISMATCH"},
622 {E_VERSION_MISMATCH
, "VERSION MISMATCH"},
623 {E_INVALID_DESTINATION_PID
, "INVALID DESTINATION PID"},
624 {E_LFB_UNKNOWN
, "LFB UNKNOWN"},
625 {E_LFB_NOT_FOUND
, "LFB NOT FOUND"},
626 {E_LFB_INSTANCE_ID_NOT_FOUND
, "LFB INSTANCE ID NOT FOUND"},
627 {E_INVALID_PATH
, "INVALID PATH"},
628 {E_COMPONENT_DOES_NOT_EXIST
, "COMPONENT DOES NOT EXIST"},
629 {E_EXISTS
, "EXISTS ALREADY"},
630 {E_NOT_FOUND
, "NOT FOUND"},
631 {E_READ_ONLY
, "READ ONLY"},
632 {E_INVALID_ARRAY_CREATION
, "INVALID ARRAY CREATION"},
633 {E_VALUE_OUT_OF_RANGE
, "VALUE OUT OF RANGE"},
634 {E_CONTENTS_TOO_LONG
, "CONTENTS TOO LONG"},
635 {E_INVALID_PARAMETERS
, "INVALID PARAMETERS"},
636 {E_INVALID_MESSAGE_TYPE
, "INVALID MESSAGE TYPE"},
637 {E_INVALID_FLAGS
, "INVALID FLAGS"},
638 {E_INVALID_TLV
, "INVALID TLV"},
639 {E_EVENT_ERROR
, "EVENT ERROR"},
640 {E_NOT_SUPPORTED
, "NOT SUPPORTED"},
641 {E_MEMORY_ERROR
, "MEMORY ERROR"},
642 {E_INTERNAL_ERROR
, "INTERNAL ERROR"},
643 {E_UNSPECIFIED_ERROR
, "UNSPECIFIED ERROR"},
647 static const struct tok tdr_str
[] = {
648 { 0, "Normal Teardown" },
649 { 1, "Loss of Heartbeats" },
650 { 2, "Out of bandwidth" },
651 { 3, "Out of Memory" },
652 { 4, "Application Crash" },
659 prestlv_print(netdissect_options
*ndo
,
660 const u_char
* pptr
, u_int len
,
661 uint16_t op_msk _U_
, int indent
)
663 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
664 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
665 const struct res_val
*r
= (const struct res_val
*)tdp
;
670 * pdatacnt_print() has ensured that len (the TLV length)
673 dlen
= len
- TLV_HDRL
;
674 if (dlen
!= RESLEN
) {
675 ND_PRINT("illegal RESULT-TLV: %u bytes!\n", dlen
);
680 result
= GET_U_1(r
->result
);
681 if (result
>= 0x18 && result
<= 0xFE) {
682 ND_PRINT("illegal reserved result code: 0x%x!\n", result
);
686 if (ndo
->ndo_vflag
>= 3) {
687 char *ib
= indent_pr(indent
, 0);
688 ND_PRINT("%s Result: %s (code 0x%x)\n", ib
,
689 tok2str(ForCES_errs
, NULL
, result
), result
);
698 fdatatlv_print(netdissect_options
*ndo
,
699 const u_char
* pptr
, u_int len
,
700 uint16_t op_msk _U_
, int indent
)
702 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
704 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
708 * pdatacnt_print() or pkeyitlv_print() has ensured that len
709 * (the TLV length) >= TLV_HDRL.
711 rlen
= len
- TLV_HDRL
;
713 type
= GET_BE_U_2(tlv
->type
);
714 if (type
!= F_TLV_FULD
) {
715 ND_PRINT("Error: expecting FULLDATA!\n");
719 if (ndo
->ndo_vflag
>= 3) {
720 char *ib
= indent_pr(indent
+ 2, 1);
721 ND_PRINT("%s[", ib
+ 1);
722 hex_print(ndo
, ib
, tdp
, rlen
);
723 ND_PRINT("\n%s]", ib
+ 1);
732 sdatailv_print(netdissect_options
*ndo
,
733 const u_char
* pptr
, u_int len
,
734 uint16_t op_msk _U_
, int indent
)
737 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
740 if (len
< ILV_HDRL
) {
741 ND_PRINT("Error: BAD SPARSEDATA-TLV!\n");
747 char *ib
= indent_pr(indent
, 1);
748 const u_char
*tdp
= (const u_char
*) ILV_DATA(ilv
);
749 invilv
= ilv_valid(ndo
, ilv
, rlen
);
751 ND_PRINT("%s[", ib
+ 1);
752 hex_print(ndo
, ib
, tdp
, rlen
);
753 ND_PRINT("\n%s]\n", ib
+ 1);
756 if (ndo
->ndo_vflag
>= 3) {
757 u_int ilvl
= GET_BE_U_4(ilv
->length
);
758 ND_PRINT("\n%s ILV: type %x length %u\n", ib
+ 1,
759 GET_BE_U_4(ilv
->type
), ilvl
);
760 hex_print(ndo
, "\t\t[", tdp
, ilvl
-ILV_HDRL
);
763 ilv
= GO_NXT_ILV(ilv
, rlen
);
772 sdatatlv_print(netdissect_options
*ndo
,
773 const u_char
* pptr
, u_int len
,
774 uint16_t op_msk
, int indent
)
776 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
778 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
782 * pdatacnt_print() has ensured that len (the TLV length)
785 rlen
= len
- TLV_HDRL
;
787 type
= GET_BE_U_2(tlv
->type
);
788 if (type
!= F_TLV_SPAD
) {
789 ND_PRINT("Error: expecting SPARSEDATA!\n");
793 return sdatailv_print(ndo
, tdp
, rlen
, op_msk
, indent
);
800 pkeyitlv_print(netdissect_options
*ndo
,
801 const u_char
* pptr
, u_int len
,
802 uint16_t op_msk
, int indent
)
804 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
805 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
806 const u_char
*dp
= tdp
+ 4;
807 const struct forces_tlv
*kdtlv
= (const struct forces_tlv
*)dp
;
809 char *ib
= indent_pr(indent
, 0);
813 id
= GET_BE_U_4(tdp
);
814 ND_PRINT("%sKeyinfo: Key 0x%x\n", ib
, id
);
815 type
= GET_BE_U_2(kdtlv
->type
);
816 tll
= GET_BE_U_2(kdtlv
->length
);
817 invtlv
= tlv_valid(tll
, len
);
820 ND_PRINT("%s TLV type 0x%x len %u\n",
821 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
826 * At this point, tlv_valid() has ensured that the TLV
827 * length is large enough but not too large (it doesn't
828 * go past the end of the containing TLV).
830 tll
= GET_BE_U_2(kdtlv
->length
);
831 dp
= (const u_char
*) TLV_DATA(kdtlv
);
832 return fdatatlv_print(ndo
, dp
, tll
, op_msk
, indent
);
837 #define PTH_DESC_SIZE 12
840 pdatacnt_print(netdissect_options
*ndo
,
841 const u_char
* pptr
, u_int len
,
842 uint16_t IDcnt
, uint16_t op_msk
, int indent
)
846 char *ib
= indent_pr(indent
, 0);
848 if ((op_msk
& B_APPND
) && ndo
->ndo_vflag
>= 3) {
849 ND_PRINT("%sTABLE APPEND\n", ib
);
851 for (i
= 0; i
< IDcnt
; i
++) {
855 id
= GET_BE_U_4(pptr
);
856 if (ndo
->ndo_vflag
>= 3)
857 ND_PRINT("%sID#%02u: %u\n", ib
, i
+ 1, id
);
862 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
863 if (op_msk
& B_TRNG
) {
864 uint32_t starti
, endi
;
866 if (len
< PTH_DESC_SIZE
) {
867 ND_PRINT("pathlength %u with key/range too short %u\n",
872 pptr
+= sizeof(struct forces_tlv
);
873 len
-= sizeof(struct forces_tlv
);
875 starti
= GET_BE_U_4(pptr
);
879 endi
= GET_BE_U_4(pptr
);
883 if (ndo
->ndo_vflag
>= 3)
884 ND_PRINT("%sTable range: [%u,%u]\n", ib
, starti
, endi
);
887 if (op_msk
& B_KEYIN
) {
888 const struct forces_tlv
*keytlv
;
891 if (len
< PTH_DESC_SIZE
) {
892 ND_PRINT("pathlength %u with key/range too short %u\n",
900 keytlv
= (const struct forces_tlv
*)pptr
;
902 pptr
+= sizeof(struct forces_tlv
);
903 len
-= sizeof(struct forces_tlv
);
904 /* skip key content */
905 tll
= GET_BE_U_2(keytlv
->length
);
906 if (tll
< TLV_HDRL
) {
907 ND_PRINT("key content length %u < %u\n",
913 ND_PRINT("key content too short\n");
923 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
930 type
= GET_BE_U_2(pdtlv
->type
);
931 tlvl
= GET_BE_U_2(pdtlv
->length
);
932 invtlv
= tlv_valid(tlvl
, len
);
934 ND_PRINT("%s Outstanding bytes %u for TLV type 0x%x TLV len %u\n",
935 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
940 * At this point, tlv_valid() has ensured that the TLV
941 * length is large enough but not too large (it doesn't
942 * go past the end of the containing TLV).
944 tll
= tlvl
- TLV_HDRL
;
945 aln
= F_ALN_LEN(tlvl
);
948 ND_PRINT("Invalid padded pathdata TLV type 0x%x len %u missing %u pad bytes\n",
949 type
, tlvl
, aln
- len
);
954 if (pd_valid(type
)) {
955 const struct pdata_ops
*ops
= get_forces_pd(type
);
957 if (ndo
->ndo_vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
959 ND_PRINT("%s %s (Length %u DataLen %u pad %u Bytes)\n",
960 ib
, ops
->s
, tlvl
, tll
, pad
);
962 ND_PRINT("%s %s (Length %u DataLen %u Bytes)\n",
963 ib
, ops
->s
, tlvl
, tll
);
966 chk_op_type(ndo
, type
, op_msk
, ops
->op_msk
);
968 if (ops
->print(ndo
, (const u_char
*)pdtlv
,
969 tll
+ pad
+ TLV_HDRL
, op_msk
,
972 len
-= (TLV_HDRL
+ pad
+ tll
);
974 ND_PRINT("Invalid path data content type 0x%x len %u\n",
978 hex_print(ndo
, "Bad Data val\n\t [",
993 pdata_print(netdissect_options
*ndo
,
994 const u_char
* pptr
, u_int len
,
995 uint16_t op_msk
, int indent
)
997 const struct pathdata_h
*pdh
= (const struct pathdata_h
*)pptr
;
998 char *ib
= indent_pr(indent
, 0);
1003 ND_TCHECK_SIZE(pdh
);
1004 if (len
< sizeof(struct pathdata_h
))
1006 if (ndo
->ndo_vflag
>= 3) {
1007 ND_PRINT("\n%sPathdata: Flags 0x%x ID count %u\n",
1008 ib
, GET_BE_U_2(pdh
->pflags
),
1009 GET_BE_U_2(pdh
->pIDcnt
));
1012 if (GET_BE_U_2(pdh
->pflags
) & F_SELKEY
) {
1016 /* Table GET Range operation */
1017 if (GET_BE_U_2(pdh
->pflags
) & F_SELTABRANGE
) {
1020 /* Table SET append operation */
1021 if (GET_BE_U_2(pdh
->pflags
) & F_TABAPPEND
) {
1025 pptr
+= sizeof(struct pathdata_h
);
1026 len
-= sizeof(struct pathdata_h
);
1027 idcnt
= GET_BE_U_2(pdh
->pIDcnt
);
1028 minsize
= idcnt
* 4;
1029 if (len
< minsize
) {
1030 ND_PRINT("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
1032 hex_print(ndo
, "\t\t\tID Data[", pptr
, len
);
1037 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
1038 ND_PRINT("\t\t\tIllegal to have both Table ranges and keys\n");
1042 more_pd
= pdatacnt_print(ndo
, pptr
, len
, idcnt
, op_msk
, indent
);
1044 int consumed
= len
- more_pd
;
1047 /* XXX: Argh, recurse some more */
1048 return recpdoptlv_print(ndo
, pptr
, len
, op_msk
, indent
+1);
1057 genoptlv_print(netdissect_options
*ndo
,
1058 const u_char
* pptr
, u_int len
,
1059 uint16_t op_msk
, int indent
)
1061 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1065 char *ib
= indent_pr(indent
, 0);
1067 type
= GET_BE_U_2(pdtlv
->type
);
1068 tlvl
= GET_BE_U_2(pdtlv
->length
);
1069 invtlv
= tlv_valid(tlvl
, len
);
1070 ND_PRINT("genoptlvprint - %s TLV type 0x%x len %u\n",
1071 tok2str(ForCES_TLV
, NULL
, type
), type
, tlvl
);
1073 ND_PRINT("\t\t\tInvalid ForCES TLV type=%x", type
);
1077 * At this point, tlv_valid() has ensured that the TLV
1078 * length is large enough but not too large (it doesn't
1079 * go past the end of the containing TLV).
1081 const u_char
*dp
= (const u_char
*) TLV_DATA(pdtlv
);
1083 if (!ttlv_valid(type
)) {
1084 ND_PRINT("%s TLV type 0x%x len %u\n",
1085 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
1089 if (ndo
->ndo_vflag
>= 3)
1090 ND_PRINT("%s%s, length %u (data length %u Bytes)",
1091 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1092 tlvl
, tlvl
- TLV_HDRL
);
1094 return pdata_print(ndo
, dp
, tlvl
- TLV_HDRL
, op_msk
, indent
+ 1);
1100 recpdoptlv_print(netdissect_options
*ndo
,
1101 const u_char
* pptr
, u_int len
,
1102 uint16_t op_msk
, int indent
)
1104 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1107 uint16_t type
, tlvl
;
1112 tlvl
= GET_BE_U_2(pdtlv
->length
);
1113 invtlv
= tlv_valid(tlvl
, len
);
1119 * At this point, tlv_valid() has ensured that the TLV
1120 * length is large enough but not too large (it doesn't
1121 * go past the end of the containing TLV).
1123 ib
= indent_pr(indent
, 0);
1124 type
= GET_BE_U_2(pdtlv
->type
);
1125 dp
= (const u_char
*) TLV_DATA(pdtlv
);
1127 if (ndo
->ndo_vflag
>= 3)
1128 ND_PRINT("%s%s, length %u (data encapsulated %u Bytes)",
1129 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1133 if (pdata_print(ndo
, dp
, tlvl
- TLV_HDRL
, op_msk
, indent
+ 1) == -1)
1135 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
1139 ND_PRINT("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1140 GET_BE_U_2(pdtlv
->type
),
1141 len
- GET_BE_U_2(pdtlv
->length
));
1151 invoptlv_print(netdissect_options
*ndo
,
1152 const u_char
* pptr
, u_int len
,
1153 uint16_t op_msk _U_
, int indent
)
1155 char *ib
= indent_pr(indent
, 1);
1157 if (ndo
->ndo_vflag
>= 3) {
1158 ND_PRINT("%sData[", ib
+ 1);
1159 hex_print(ndo
, ib
, pptr
, len
);
1160 ND_PRINT("%s]\n", ib
);
1166 otlv_print(netdissect_options
*ndo
,
1167 const struct forces_tlv
*otlv
, uint16_t op_msk _U_
, int indent
)
1170 const u_char
*dp
= (const u_char
*) TLV_DATA(otlv
);
1173 char *ib
= indent_pr(indent
, 0);
1174 const struct optlv_h
*ops
;
1177 * lfbselect_print() has ensured that GET_BE_U_2(otlv->length)
1180 type
= GET_BE_U_2(otlv
->type
);
1181 tll
= GET_BE_U_2(otlv
->length
) - TLV_HDRL
;
1182 ops
= get_forces_optlv_h(type
);
1183 if (ndo
->ndo_vflag
>= 3) {
1184 ND_PRINT("%sOper TLV %s(0x%x) length %u\n", ib
, ops
->s
, type
,
1185 GET_BE_U_2(otlv
->length
));
1187 /* rest of ops must at least have 12B {pathinfo} */
1188 if (tll
< OP_MIN_SIZ
) {
1189 ND_PRINT("\t\tOper TLV %s(0x%x) length %u\n", ops
->s
, type
,
1190 GET_BE_U_2(otlv
->length
));
1191 ND_PRINT("\t\tTruncated data size %u minimum required %u\n", tll
,
1193 return invoptlv_print(ndo
, dp
, tll
, ops
->op_msk
, indent
);
1197 /* XXX - do anything with ops->flags? */
1199 rc
= ops
->print(ndo
, dp
, tll
, ops
->op_msk
, indent
+ 1);
1207 asttlv_print(netdissect_options
*ndo
,
1208 const u_char
* pptr
, u_int len
,
1209 uint16_t op_msk _U_
, int indent
)
1213 char *ib
= indent_pr(indent
, 0);
1216 * forces_type_print() has ensured that len (the TLV length)
1219 dlen
= len
- TLV_HDRL
;
1220 if (dlen
!= ASTDLN
) {
1221 ND_PRINT("illegal ASTresult-TLV: %u bytes!\n", dlen
);
1224 rescode
= GET_BE_U_4(pptr
);
1225 if (rescode
> ASTMCD
) {
1226 ND_PRINT("illegal ASTresult result code: %u!\n", rescode
);
1230 if (ndo
->ndo_vflag
>= 3) {
1231 ND_PRINT("Teardown reason:\n%s%s", ib
,
1232 tok2str(tdr_str
, "unknown (%u)", rescode
));
1233 ND_PRINT("(%x)\n%s", rescode
, ib
);
1243 asrtlv_print(netdissect_options
*ndo
,
1244 const u_char
* pptr
, u_int len
,
1245 uint16_t op_msk _U_
, int indent
)
1249 char *ib
= indent_pr(indent
, 0);
1252 * forces_type_print() has ensured that len (the TLV length)
1255 dlen
= len
- TLV_HDRL
;
1256 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
1257 ND_PRINT("illegal ASRresult-TLV: %u bytes!\n", dlen
);
1260 rescode
= GET_BE_U_4(pptr
);
1262 if (rescode
> ASRMCD
) {
1263 ND_PRINT("illegal ASRresult result code: %u!\n", rescode
);
1267 if (ndo
->ndo_vflag
>= 3) {
1268 ND_PRINT("\n%s", ib
);
1271 ND_PRINT("Success ");
1274 ND_PRINT("FE ID invalid ");
1277 ND_PRINT("permission denied ");
1280 ND_PRINT("Unknown ");
1283 ND_PRINT("(%x)\n%s", rescode
, ib
);
1295 gentltlv_print(netdissect_options
*ndo
,
1296 const u_char
* pptr _U_
, u_int len
,
1297 uint16_t op_msk _U_
, int indent _U_
)
1299 u_int dlen
= len
- TLV_HDRL
;
1301 if (dlen
< 4) { /* at least 32 bits must exist */
1302 ND_PRINT("truncated TLV: %u bytes missing! ", 4 - dlen
);
1312 print_metailv(netdissect_options
*ndo
,
1313 const u_char
* pptr
, uint16_t op_msk _U_
, int indent
)
1316 char *ib
= indent_pr(indent
, 0);
1317 /* XXX: check header length */
1318 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
1321 * print_metatlv() has ensured that len (what remains in the
1324 rlen
= GET_BE_U_4(ilv
->length
) - ILV_HDRL
;
1325 ND_PRINT("%sMetaID 0x%x length %u\n", ib
, GET_BE_U_4(ilv
->type
),
1326 GET_BE_U_4(ilv
->length
));
1327 if (ndo
->ndo_vflag
>= 3) {
1328 hex_print(ndo
, "\t\t[", ILV_DATA(ilv
), rlen
);
1335 print_metatlv(netdissect_options
*ndo
,
1336 const u_char
* pptr
, u_int len
,
1337 uint16_t op_msk _U_
, int indent
)
1340 char *ib
= indent_pr(indent
, 0);
1342 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
1346 * redirect_print() has ensured that len (what remains in the
1349 dlen
= len
- TLV_HDRL
;
1351 ND_PRINT("\n%s METADATA length %u\n", ib
, rlen
);
1353 invilv
= ilv_valid(ndo
, ilv
, rlen
);
1359 * At this point, ilv_valid() has ensured that the ILV
1360 * length is large enough but not too large (it doesn't
1361 * go past the end of the containing TLV).
1363 print_metailv(ndo
, (const u_char
*) ilv
, 0, indent
+ 1);
1364 ilv
= GO_NXT_ILV(ilv
, rlen
);
1372 print_reddata(netdissect_options
*ndo
,
1373 const u_char
* pptr
, u_int len
,
1374 uint16_t op_msk _U_
, int indent
)
1377 char *ib
= indent_pr(indent
, 0);
1380 dlen
= len
- TLV_HDRL
;
1382 ND_PRINT("\n%s Redirect Data length %u\n", ib
, rlen
);
1384 if (ndo
->ndo_vflag
>= 3) {
1386 hex_print(ndo
, "\n\t\t", pptr
, rlen
);
1387 ND_PRINT("\n\t\t]");
1394 redirect_print(netdissect_options
*ndo
,
1395 const u_char
* pptr
, u_int len
,
1396 uint16_t op_msk _U_
, int indent
)
1398 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
1404 * forces_type_print() has ensured that len (the TLV length)
1407 dlen
= len
- TLV_HDRL
;
1408 if (dlen
<= RD_MIN
) {
1409 ND_PRINT("\n\t\ttruncated Redirect TLV: %u bytes missing! ",
1417 uint16_t type
, tlvl
;
1419 type
= GET_BE_U_2(tlv
->type
);
1420 tlvl
= GET_BE_U_2(tlv
->length
);
1421 invtlv
= tlv_valid(tlvl
, rlen
);
1423 ND_PRINT("Bad Redirect data\n");
1428 * At this point, tlv_valid() has ensured that the TLV
1429 * length is large enough but not too large (it doesn't
1430 * go past the end of the containing TLV).
1432 if (type
== F_TLV_METD
) {
1433 print_metatlv(ndo
, (const u_char
*) TLV_DATA(tlv
),
1436 } else if (type
== F_TLV_REDD
) {
1437 print_reddata(ndo
, (const u_char
*) TLV_DATA(tlv
),
1441 ND_PRINT("Unknown REDIRECT TLV 0x%x len %u\n",
1446 tlv
= GO_NXT_TLV(tlv
, rlen
);
1450 ND_PRINT("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1451 GET_BE_U_2(tlv
->type
),
1452 rlen
- GET_BE_U_2(tlv
->length
));
1465 lfbselect_print(netdissect_options
*ndo
,
1466 const u_char
* pptr
, u_int len
,
1467 uint16_t op_msk
, int indent
)
1469 const struct forces_lfbsh
*lfbs
;
1470 const struct forces_tlv
*otlv
;
1471 char *ib
= indent_pr(indent
, 0);
1477 * forces_type_print() has ensured that len (the TLV length)
1480 dlen
= len
- TLV_HDRL
;
1481 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
1482 ND_PRINT("\n\t\tundersized lfb selector: %u bytes missing! ",
1488 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
1489 * we also know that it's > OP_OFF.
1491 rlen
= dlen
- OP_OFF
;
1493 lfbs
= (const struct forces_lfbsh
*)pptr
;
1494 ND_TCHECK_SIZE(lfbs
);
1495 if (ndo
->ndo_vflag
>= 3) {
1496 ND_PRINT("\n%s%s(Classid %x) instance %x\n",
1498 tok2str(ForCES_LFBs
, NULL
, GET_BE_U_4(lfbs
->class)),
1499 GET_BE_U_4(lfbs
->class),
1500 GET_BE_U_4(lfbs
->instance
));
1503 otlv
= (const struct forces_tlv
*)(lfbs
+ 1);
1507 uint16_t type
, tlvl
;
1509 type
= GET_BE_U_2(otlv
->type
);
1510 tlvl
= GET_BE_U_2(otlv
->length
);
1511 invtlv
= tlv_valid(tlvl
, rlen
);
1516 * At this point, tlv_valid() has ensured that the TLV
1517 * length is large enough but not too large (it doesn't
1518 * go past the end of the containing TLV).
1520 if (op_valid(type
, op_msk
)) {
1521 otlv_print(ndo
, otlv
, 0, indent
);
1523 if (ndo
->ndo_vflag
< 3)
1525 ND_PRINT("\t\tINValid oper-TLV type 0x%x length %u for this ForCES message\n",
1527 invoptlv_print(ndo
, (const u_char
*)otlv
, rlen
, 0, indent
);
1529 otlv
= GO_NXT_TLV(otlv
, rlen
);
1533 ND_PRINT("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1534 GET_BE_U_2(otlv
->type
),
1535 rlen
- GET_BE_U_2(otlv
->length
));
1546 forces_type_print(netdissect_options
*ndo
,
1547 const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
1548 u_int mlen
, const struct tom_h
*tops
)
1550 const struct forces_tlv
*tltlv
;
1557 * forces_print() has already checked that mlen >= ForCES_HDRL
1558 * by calling ForCES_HLN_VALID().
1560 rlen
= mlen
- ForCES_HDRL
;
1562 if (rlen
> TLV_HLN
) {
1563 if (tops
->flags
& ZERO_TTLV
) {
1564 ND_PRINT("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
1568 if (tops
->flags
& ZERO_MORE_TTLV
)
1570 if (tops
->flags
& ONE_MORE_TTLV
) {
1571 ND_PRINT("\tTop level TLV Data missing!\n");
1576 if (tops
->flags
& ZERO_TTLV
) {
1580 ttlv
= tops
->flags
>> 4;
1581 tltlv
= GET_TOP_TLV(pptr
);
1583 /*XXX: 15 top level tlvs will probably be fine
1584 You are nuts if you send more ;-> */
1586 uint16_t type
, tlvl
;
1588 type
= GET_BE_U_2(tltlv
->type
);
1589 tlvl
= GET_BE_U_2(tltlv
->length
);
1590 invtlv
= tlv_valid(tlvl
, rlen
);
1595 * At this point, tlv_valid() has ensured that the TLV
1596 * length is large enough but not too large (it doesn't
1597 * go past the end of the packet).
1599 if (!ttlv_valid(type
)) {
1600 ND_PRINT("\n\tInvalid ForCES Top TLV type=0x%x",
1605 if (ndo
->ndo_vflag
>= 3)
1606 ND_PRINT("\t%s, length %u (data length %u Bytes)",
1607 tok2str(ForCES_TLV
, NULL
, type
),
1611 rc
= tops
->print(ndo
, (const u_char
*) TLV_DATA(tltlv
),
1617 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1623 * XXX - if ttlv != 0, does that mean that the packet was too
1624 * short, and didn't have *enough* TLVs in it?
1627 ND_PRINT("\tMess TopTLV header: min %u, total %u advertised %u ",
1628 TLV_HDRL
, rlen
, GET_BE_U_2(tltlv
->length
));
1638 forces_print(netdissect_options
*ndo
,
1639 const u_char
* pptr
, u_int len
)
1641 const struct forcesh
*fhdr
;
1645 const struct tom_h
*tops
;
1648 ndo
->ndo_protocol
= "forces";
1649 fhdr
= (const struct forcesh
*)pptr
;
1650 ND_TCHECK_SIZE(fhdr
);
1651 tom
= GET_U_1(fhdr
->fm_tom
);
1652 if (!tom_valid(tom
)) {
1653 ND_PRINT("Invalid ForCES message type %u\n", tom
);
1657 mlen
= ForCES_BLN(fhdr
);
1659 tops
= get_forces_tom(tom
);
1660 if (tops
->v
== TOM_RSVD
) {
1661 ND_PRINT("\n\tUnknown ForCES message type=0x%x", tom
);
1665 ND_PRINT("\n\tForCES %s ", tops
->s
);
1666 if (!ForCES_HLN_VALID(mlen
, len
)) {
1667 ND_PRINT("Illegal ForCES pkt len - min %u, total recvd %u, advertised %u ",
1668 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1672 flg_raw
= GET_BE_U_4(pptr
+ 20);
1673 if (ndo
->ndo_vflag
>= 1) {
1674 ND_PRINT("\n\tForCES Version %u len %uB flags 0x%08x ",
1675 ForCES_V(fhdr
), mlen
, flg_raw
);
1676 ND_PRINT("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1677 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1678 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1679 GET_BE_U_8(fhdr
->fm_cor
));
1682 if (ndo
->ndo_vflag
>= 2) {
1683 ND_PRINT("\n\tForCES flags:\n\t %s(0x%x), prio=%u, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1684 tok2str(ForCES_ACKs
, "ACKUnknown", ForCES_ACK(fhdr
)),
1687 tok2str(ForCES_EMs
, "EMUnknown", ForCES_EM(fhdr
)),
1689 tok2str(ForCES_ATs
, "ATUnknown", ForCES_AT(fhdr
)),
1691 tok2str(ForCES_TPs
, "TPUnknown", ForCES_TP(fhdr
)),
1693 ND_PRINT("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1694 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1696 rc
= forces_type_print(ndo
, pptr
, fhdr
, mlen
, tops
);
1701 if (ndo
->ndo_vflag
>= 4) {
1702 ND_PRINT("\n\t Raw ForCES message\n\t [");
1703 hex_print(ndo
, "\n\t ", pptr
, len
);
1708 nd_print_invalid(ndo
);