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 */
23 #include "netdissect-stdinc.h"
25 #define ND_LONGJMP_FROM_TCHECK
26 #include "netdissect.h"
31 #define ForCES_HDRL 24
32 #define ForCES_ALNL 4U
37 #define TOM_ASSNSETUP 0x1
38 #define TOM_ASSNTEARD 0x2
39 #define TOM_CONFIG 0x3
41 #define TOM_EVENTNOT 0x5
42 #define TOM_PKTREDIR 0x6
43 #define TOM_HEARTBT 0x0F
44 #define TOM_ASSNSETREP 0x11
45 #define TOM_CONFIGREP 0x13
46 #define TOM_QUERYREP 0x14
49 * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
51 #define ZERO_TTLV 0x01
52 #define ZERO_MORE_TTLV 0x02
53 #define ONE_MORE_TTLV 0x04
59 #define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
60 #define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
67 int (*print
) (netdissect_options
*ndo
, const u_char
* pptr
, u_int len
,
68 uint16_t op_msk
, int indent
);
85 #define TOM_MAX_IND (_TOM_RSV_MAX - 1)
88 tom_valid(uint8_t tom
)
91 if (tom
>= 0x7 && tom
<= 0xe)
103 ForCES_node(uint32_t node
)
105 if (node
<= 0x3FFFFFFF)
107 if (node
>= 0x40000000 && node
<= 0x7FFFFFFF)
109 if (node
>= 0xC0000000 && node
<= 0xFFFFFFEF)
110 return "AllMulticast";
111 if (node
== 0xFFFFFFFD)
112 return "AllCEsBroadcast";
113 if (node
== 0xFFFFFFFE)
114 return "AllFEsBroadcast";
115 if (node
== 0xFFFFFFFF)
116 return "AllBroadcast";
118 return "ForCESreserved";
122 static const struct tok ForCES_ACKs
[] = {
130 static const struct tok ForCES_EMs
[] = {
132 {0x1, "execute-all-or-none"},
133 {0x2, "execute-until-failure"},
134 {0x3, "continue-execute-on-failure"},
138 static const struct tok ForCES_ATs
[] = {
140 {0x1, "2PCtransaction"},
144 static const struct tok ForCES_TPs
[] = {
145 {0x0, "StartofTransaction"},
146 {0x1, "MiddleofTransaction"},
147 {0x2, "EndofTransaction"},
153 * Structure of forces header, naked of TLVs.
156 nd_uint8_t fm_vrsvd
; /* version and reserved */
157 #define ForCES_V(forcesh) (GET_U_1((forcesh)->fm_vrsvd) >> 4)
158 nd_uint8_t fm_tom
; /* type of message */
159 nd_uint16_t fm_len
; /* total length * 4 bytes */
160 #define ForCES_BLN(forcesh) ((uint32_t)(GET_BE_U_2((forcesh)->fm_len) << 2))
161 nd_uint32_t fm_sid
; /* Source ID */
162 #define ForCES_SID(forcesh) GET_BE_U_4((forcesh)->fm_sid)
163 nd_uint32_t fm_did
; /* Destination ID */
164 #define ForCES_DID(forcesh) GET_BE_U_4((forcesh)->fm_did)
165 nd_uint8_t fm_cor
[8]; /* correlator */
166 nd_uint32_t fm_flags
; /* flags */
167 #define ForCES_ACK(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0xC0000000) >> 30)
168 #define ForCES_PRI(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x38000000) >> 27)
169 #define ForCES_RS1(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x07000000) >> 24)
170 #define ForCES_EM(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00C00000) >> 22)
171 #define ForCES_AT(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00200000) >> 21)
172 #define ForCES_TP(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x00180000) >> 19)
173 #define ForCES_RS2(forcesh) ((GET_BE_U_4((forcesh)->fm_flags)&0x0007FFFF) >> 0)
176 #define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
177 (fhl) >= ForCES_HDRL && \
180 #define F_LFB_RSVD 0x0
181 #define F_LFB_FEO 0x1
182 #define F_LFB_FEPO 0x2
183 static const struct tok ForCES_LFBs
[] = {
184 {F_LFB_RSVD
, "Invalid TLV"},
185 {F_LFB_FEO
, "FEObj LFB"},
186 {F_LFB_FEPO
, "FEProtoObj LFB"},
190 /* this is defined in RFC5810 section A.2 */
191 /* https://www.iana.org/assignments/forces/forces.xhtml#oper-tlv-types */
210 #define F_OP_MAX (_F_OP_MAX - 1)
213 B_OP_SET
= 1 << (F_OP_SET
- 1),
214 B_OP_SETPROP
= 1 << (F_OP_SETPROP
- 1),
215 B_OP_SETRESP
= 1 << (F_OP_SETRESP
- 1),
216 B_OP_SETPRESP
= 1 << (F_OP_SETPRESP
- 1),
217 B_OP_DEL
= 1 << (F_OP_DEL
- 1),
218 B_OP_DELRESP
= 1 << (F_OP_DELRESP
- 1),
219 B_OP_GET
= 1 << (F_OP_GET
- 1),
220 B_OP_GETPROP
= 1 << (F_OP_GETPROP
- 1),
221 B_OP_GETRESP
= 1 << (F_OP_GETRESP
- 1),
222 B_OP_GETPRESP
= 1 << (F_OP_GETPRESP
- 1),
223 B_OP_REPORT
= 1 << (F_OP_REPORT
- 1),
224 B_OP_COMMIT
= 1 << (F_OP_COMMIT
- 1),
225 B_OP_RCOMMIT
= 1 << (F_OP_RCOMMIT
- 1),
226 B_OP_RTRCOMP
= 1 << (F_OP_RTRCOMP
- 1)
233 int (*print
) (netdissect_options
*ndo
, const u_char
* pptr
, u_int len
,
234 uint16_t op_msk
, int indent
);
237 static int genoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
238 uint16_t op_msk
, int indent
);
239 static int recpdoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
240 uint16_t op_msk
, int indent
);
241 static int invoptlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
242 uint16_t op_msk
, int indent
);
257 static const struct optlv_h OPTLV_msg
[F_OP_MAX
+ 1] = {
258 /* F_OP_RSV */ {ZERO_TTLV
, 0, "Invalid OPTLV", invoptlv_print
},
259 /* F_OP_SET */ {TTLV_T2
, B_FULLD
| B_SPARD
, " Set", recpdoptlv_print
},
261 {TTLV_T2
, B_FULLD
| B_SPARD
, " SetProp", recpdoptlv_print
},
262 /* F_OP_SETRESP */ {TTLV_T2
, B_RESTV
, " SetResp", recpdoptlv_print
},
263 /* F_OP_SETPRESP */ {TTLV_T2
, B_RESTV
, " SetPropResp", recpdoptlv_print
},
264 /* F_OP_DEL */ {ZERO_TTLV
, 0, " Del", recpdoptlv_print
},
265 /* F_OP_DELRESP */ {TTLV_T2
, B_RESTV
, " DelResp", recpdoptlv_print
},
266 /* F_OP_GET */ {ZERO_TTLV
, 0, " Get", recpdoptlv_print
},
267 /* F_OP_GETPROP */ {ZERO_TTLV
, 0, " GetProp", recpdoptlv_print
},
269 {TTLV_T2
, B_FULLD
| B_SPARD
| B_RESTV
, " GetResp", recpdoptlv_print
},
271 {TTLV_T2
, B_FULLD
| B_RESTV
, " GetPropResp", recpdoptlv_print
},
273 {TTLV_T2
, B_FULLD
| B_SPARD
, " Report", recpdoptlv_print
},
274 /* F_OP_COMMIT */ {ZERO_TTLV
, 0, " Commit", NULL
},
275 /* F_OP_RCOMMIT */ {TTLV_T1
, B_RESTV
, " RCommit", genoptlv_print
},
276 /* F_OP_RTRCOMP */ {ZERO_TTLV
, 0, " RTRCOMP", NULL
},
279 static const struct optlv_h
*
280 get_forces_optlv_h(uint16_t opt
)
282 if (opt
> F_OP_MAX
|| opt
== F_OP_RSV
)
283 return &OPTLV_msg
[F_OP_RSV
];
285 return &OPTLV_msg
[opt
];
290 #define IND_PREF '\n'
292 static char ind_buf
[IND_SIZE
];
295 indent_pr(int indent
, int nlpref
)
300 if (indent
> (IND_SIZE
- 1))
301 indent
= IND_SIZE
- 1;
309 while (--indent
>= 0)
317 op_valid(uint16_t op
, uint16_t mask
)
322 return (1 << (op
- 1)) & mask
; /* works only for 0x0001 through 0x0010 */
323 /* I guess we should allow vendor operations? */
329 #define F_TLV_RSVD 0x0000
330 #define F_TLV_REDR 0x0001
331 #define F_TLV_ASRS 0x0010
332 #define F_TLV_ASRT 0x0011
333 #define F_TLV_LFBS 0x1000
334 #define F_TLV_PDAT 0x0110
335 #define F_TLV_KEYI 0x0111
336 #define F_TLV_FULD 0x0112
337 #define F_TLV_SPAD 0x0113
338 #define F_TLV_REST 0x0114
339 #define F_TLV_METD 0x0115
340 #define F_TLV_REDD 0x0116
341 #define F_TLV_TRNG 0x0117
344 #define F_TLV_VNST 0x8000
346 static const struct tok ForCES_TLV
[] = {
347 {F_TLV_RSVD
, "Invalid TLV"},
348 {F_TLV_REDR
, "REDIRECT TLV"},
349 {F_TLV_ASRS
, "ASResult TLV"},
350 {F_TLV_ASRT
, "ASTreason TLV"},
351 {F_TLV_LFBS
, "LFBselect TLV"},
352 {F_TLV_PDAT
, "PATH-DATA TLV"},
353 {F_TLV_KEYI
, "KEYINFO TLV"},
354 {F_TLV_FULD
, "FULLDATA TLV"},
355 {F_TLV_SPAD
, "SPARSEDATA TLV"},
356 {F_TLV_REST
, "RESULT TLV"},
357 {F_TLV_METD
, "METADATA TLV"},
358 {F_TLV_REDD
, "REDIRECTDATA TLV"},
364 ttlv_valid(uint16_t ttlv
)
367 if (ttlv
== 1 || ttlv
== 0x1000)
369 if (ttlv
>= 0x10 && ttlv
<= 0x11)
371 if (ttlv
>= 0x110 && ttlv
<= 0x116)
390 #define F_ALN_LEN(len) roundup2(len, ForCES_ALNL)
391 #define GET_TOP_TLV(fhdr) ((const struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
392 #define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
393 #define TLV_DATA(tlvp) ((const void*)(((const char*)(tlvp)) + TLV_SET_LEN(0)))
394 #define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(GET_BE_U_2((tlv)->length)), \
395 (const struct forces_tlv*)(((const char*)(tlv)) \
396 + F_ALN_LEN(GET_BE_U_2((tlv)->length))))
397 #define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
398 #define ILV_DATA(ilvp) ((const void*)(((const char*)(ilvp)) + ILV_SET_LEN(0)))
399 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(GET_BE_U_4((ilv)->length)), \
400 (const struct forces_ilv *)(((const char*)(ilv)) \
401 + F_ALN_LEN(GET_BE_U_4((ilv)->length))))
402 #define INVALID_RLEN 1
403 #define INVALID_STLN 2
404 #define INVALID_LTLN 3
405 #define INVALID_ALEN 4
407 static const struct tok ForCES_TLV_err
[] = {
408 {INVALID_RLEN
, "Invalid total length"},
409 {INVALID_STLN
, "xLV too short"},
410 {INVALID_LTLN
, "xLV too long"},
411 {INVALID_ALEN
, "data padding missing"},
416 tlv_valid(u_int tlvl
, u_int rlen
)
424 if (rlen
< F_ALN_LEN(tlvl
))
431 ilv_valid(netdissect_options
*ndo
, const struct forces_ilv
*ilv
, u_int rlen
)
435 if (GET_BE_U_4(ilv
->length
) < ILV_HDRL
)
437 if (GET_BE_U_4(ilv
->length
) > rlen
)
439 if (rlen
< F_ALN_LEN(GET_BE_U_4(ilv
->length
)))
445 static int lfbselect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
446 uint16_t op_msk
, int indent
);
447 static int redirect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
448 uint16_t op_msk
, int indent
);
449 static int asrtlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
450 uint16_t op_msk
, int indent
);
451 static int asttlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
452 uint16_t op_msk
, int indent
);
454 struct forces_lfbsh
{
456 nd_uint32_t instance
;
459 #define ASSNS_OPS (B_OP_REPORT)
460 #define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
461 #define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
462 #define CFG_QY (B_OP_GET|B_OP_GETPROP)
463 #define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
464 #define CFG_EVN (B_OP_REPORT)
466 static const struct tom_h ForCES_msg
[TOM_MAX_IND
+ 1] = {
467 /* TOM_RSV_I */ {TOM_RSVD
, ZERO_TTLV
, 0, "Invalid message", NULL
},
468 /* TOM_ASS_I */ {TOM_ASSNSETUP
, ZERO_MORE_TTLV
| TWO_TLV
, ASSNS_OPS
,
469 "Association Setup", lfbselect_print
},
471 {TOM_ASSNTEARD
, TTLV_T1
, 0, "Association TearDown", asttlv_print
},
472 /* TOM_CFG_I */ {TOM_CONFIG
, TTLV_T2
, CFG_OPS
, "Config", lfbselect_print
},
473 /* TOM_QRY_I */ {TOM_QUERY
, TTLV_T2
, CFG_QY
, "Query", lfbselect_print
},
474 /* TOM_EVN_I */ {TOM_EVENTNOT
, TTLV_T1
, CFG_EVN
, "Event Notification",
477 {TOM_PKTREDIR
, TTLV_T2
, 0, "Packet Redirect", redirect_print
},
478 /* TOM_HBT_I */ {TOM_HEARTBT
, ZERO_TTLV
, 0, "HeartBeat", NULL
},
480 {TOM_ASSNSETREP
, TTLV_T1
, 0, "Association Response", asrtlv_print
},
481 /* TOM_CNR_I */ {TOM_CONFIGREP
, TTLV_T2
, CFG_ROPS
, "Config Response",
484 {TOM_QUERYREP
, TTLV_T2
, CFG_QYR
, "Query Response", lfbselect_print
},
487 static const struct tom_h
*
488 get_forces_tom(uint8_t tom
)
491 for (i
= TOM_RSV_I
; i
<= TOM_MAX_IND
; i
++) {
492 const struct tom_h
*th
= &ForCES_msg
[i
];
496 return &ForCES_msg
[TOM_RSV_I
];
504 int (*print
) (netdissect_options
*, const u_char
* pptr
, u_int len
,
505 uint16_t op_msk
, int indent
);
517 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
520 pd_valid(uint16_t pd
)
522 if (pd
>= F_TLV_PDAT
&& pd
<= F_TLV_REST
)
528 chk_op_type(netdissect_options
*ndo
,
529 uint16_t type
, uint16_t msk
, uint16_t omsk
)
531 if (type
!= F_TLV_PDAT
) {
533 if (type
!= F_TLV_KEYI
) {
534 ND_PRINT("Based on flags expected KEYINFO TLV!\n");
538 ND_PRINT("Illegal DATA encoding for type 0x%x programmed %x got %x\n",
547 #define F_SELTABRANGE 2
548 #define F_TABAPPEND 4
556 static int prestlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
557 uint16_t op_msk
, int indent
);
558 static int pkeyitlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
559 uint16_t op_msk
, int indent
);
560 static int fdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
561 uint16_t op_msk
, int indent
);
562 static int sdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
563 uint16_t op_msk
, int indent
);
565 static const struct pdata_ops ForCES_pdata
[PD_MAX_IND
+ 1] = {
566 /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL
},
567 /* PD_SEL_I */ {F_TLV_KEYI
, 0, 0, "KEYINFO TLV", pkeyitlv_print
},
568 /* PD_FDT_I */ {F_TLV_FULD
, 0, B_FULLD
, "FULLDATA TLV", fdatatlv_print
},
569 /* PD_SDT_I */ {F_TLV_SPAD
, 0, B_SPARD
, "SPARSEDATA TLV", sdatatlv_print
},
570 /* PD_RES_I */ {F_TLV_REST
, 0, B_RESTV
, "RESULT TLV", prestlv_print
},
572 {F_TLV_PDAT
, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print
},
575 static const struct pdata_ops
*
576 get_forces_pd(uint16_t pd
)
579 for (i
= PD_RSV_I
+ 1; i
<= PD_MAX_IND
; i
++) {
580 const struct pdata_ops
*pdo
= &ForCES_pdata
[i
];
584 return &ForCES_pdata
[TOM_RSV_I
];
592 E_INVALID_DESTINATION_PID
,
595 E_LFB_INSTANCE_ID_NOT_FOUND
,
597 E_COMPONENT_DOES_NOT_EXIST
,
601 E_INVALID_ARRAY_CREATION
,
602 E_VALUE_OUT_OF_RANGE
,
604 E_INVALID_PARAMETERS
,
605 E_INVALID_MESSAGE_TYPE
,
612 /* 0x18-0xFE are reserved .. */
613 E_UNSPECIFIED_ERROR
= 0XFF
616 static const struct tok ForCES_errs
[] = {
617 {E_SUCCESS
, "SUCCESS"},
618 {E_INVALID_HEADER
, "INVALID HEADER"},
619 {E_LENGTH_MISMATCH
, "LENGTH MISMATCH"},
620 {E_VERSION_MISMATCH
, "VERSION MISMATCH"},
621 {E_INVALID_DESTINATION_PID
, "INVALID DESTINATION PID"},
622 {E_LFB_UNKNOWN
, "LFB UNKNOWN"},
623 {E_LFB_NOT_FOUND
, "LFB NOT FOUND"},
624 {E_LFB_INSTANCE_ID_NOT_FOUND
, "LFB INSTANCE ID NOT FOUND"},
625 {E_INVALID_PATH
, "INVALID PATH"},
626 {E_COMPONENT_DOES_NOT_EXIST
, "COMPONENT DOES NOT EXIST"},
627 {E_EXISTS
, "EXISTS ALREADY"},
628 {E_NOT_FOUND
, "NOT FOUND"},
629 {E_READ_ONLY
, "READ ONLY"},
630 {E_INVALID_ARRAY_CREATION
, "INVALID ARRAY CREATION"},
631 {E_VALUE_OUT_OF_RANGE
, "VALUE OUT OF RANGE"},
632 {E_CONTENTS_TOO_LONG
, "CONTENTS TOO LONG"},
633 {E_INVALID_PARAMETERS
, "INVALID PARAMETERS"},
634 {E_INVALID_MESSAGE_TYPE
, "INVALID MESSAGE TYPE"},
635 {E_INVALID_FLAGS
, "INVALID FLAGS"},
636 {E_INVALID_TLV
, "INVALID TLV"},
637 {E_EVENT_ERROR
, "EVENT ERROR"},
638 {E_NOT_SUPPORTED
, "NOT SUPPORTED"},
639 {E_MEMORY_ERROR
, "MEMORY ERROR"},
640 {E_INTERNAL_ERROR
, "INTERNAL ERROR"},
641 {E_UNSPECIFIED_ERROR
, "UNSPECIFIED ERROR"},
645 static const struct tok tdr_str
[] = {
646 { 0, "Normal Teardown" },
647 { 1, "Loss of Heartbeats" },
648 { 2, "Out of bandwidth" },
649 { 3, "Out of Memory" },
650 { 4, "Application Crash" },
657 prestlv_print(netdissect_options
*ndo
,
658 const u_char
* pptr
, u_int len
,
659 uint16_t op_msk _U_
, int indent
)
661 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
662 const u_char
*tdp
= TLV_DATA(tlv
);
663 const struct res_val
*r
= (const struct res_val
*)tdp
;
668 * pdatacnt_print() has ensured that len (the TLV length)
671 dlen
= len
- TLV_HDRL
;
672 if (dlen
!= RESLEN
) {
673 ND_PRINT("illegal RESULT-TLV: %u bytes!\n", dlen
);
678 result
= GET_U_1(r
->result
);
679 if (result
>= 0x18 && result
<= 0xFE) {
680 ND_PRINT("illegal reserved result code: 0x%x!\n", result
);
684 if (ndo
->ndo_vflag
>= 3) {
685 char *ib
= indent_pr(indent
, 0);
686 ND_PRINT("%s Result: %s (code 0x%x)\n", ib
,
687 tok2str(ForCES_errs
, NULL
, result
), result
);
696 fdatatlv_print(netdissect_options
*ndo
,
697 const u_char
* pptr
, u_int len
,
698 uint16_t op_msk _U_
, int indent
)
700 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
702 const u_char
*tdp
= TLV_DATA(tlv
);
706 * pdatacnt_print() or pkeyitlv_print() has ensured that len
707 * (the TLV length) >= TLV_HDRL.
709 rlen
= len
- TLV_HDRL
;
711 type
= GET_BE_U_2(tlv
->type
);
712 if (type
!= F_TLV_FULD
) {
713 ND_PRINT("Error: expecting FULLDATA!\n");
717 if (ndo
->ndo_vflag
>= 3) {
718 char *ib
= indent_pr(indent
+ 2, 1);
719 ND_PRINT("%s[", ib
+ 1);
720 hex_print(ndo
, ib
, tdp
, rlen
);
721 ND_PRINT("\n%s]", ib
+ 1);
730 sdatailv_print(netdissect_options
*ndo
,
731 const u_char
* pptr
, u_int len
,
732 uint16_t op_msk _U_
, int indent
)
735 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
738 if (len
< ILV_HDRL
) {
739 ND_PRINT("Error: BAD SPARSEDATA-TLV!\n");
745 char *ib
= indent_pr(indent
, 1);
746 const u_char
*tdp
= ILV_DATA(ilv
);
747 invilv
= ilv_valid(ndo
, ilv
, rlen
);
749 ND_PRINT("Error: %s, rlen %u\n",
750 tok2str(ForCES_TLV_err
, NULL
, invilv
), rlen
);
753 if (ndo
->ndo_vflag
>= 3) {
754 u_int ilvl
= GET_BE_U_4(ilv
->length
);
755 ND_PRINT("\n%s ILV: type %x length %u\n", ib
+ 1,
756 GET_BE_U_4(ilv
->type
), ilvl
);
757 hex_print(ndo
, "\t\t[", tdp
, ilvl
-ILV_HDRL
);
760 ilv
= GO_NXT_ILV(ilv
, rlen
);
769 sdatatlv_print(netdissect_options
*ndo
,
770 const u_char
* pptr
, u_int len
,
771 uint16_t op_msk
, int indent
)
773 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
775 const u_char
*tdp
= TLV_DATA(tlv
);
779 * pdatacnt_print() has ensured that len (the TLV length)
782 rlen
= len
- TLV_HDRL
;
784 type
= GET_BE_U_2(tlv
->type
);
785 if (type
!= F_TLV_SPAD
) {
786 ND_PRINT("Error: expecting SPARSEDATA!\n");
790 return sdatailv_print(ndo
, tdp
, rlen
, op_msk
, indent
);
797 pkeyitlv_print(netdissect_options
*ndo
,
798 const u_char
* pptr
, u_int len
,
799 uint16_t op_msk
, int indent
)
801 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
802 const u_char
*tdp
= TLV_DATA(tlv
);
803 const u_char
*dp
= tdp
+ 4;
804 const struct forces_tlv
*kdtlv
= (const struct forces_tlv
*)dp
;
806 char *ib
= indent_pr(indent
, 0);
810 id
= GET_BE_U_4(tdp
);
811 ND_PRINT("%sKeyinfo: Key 0x%x\n", ib
, id
);
812 type
= GET_BE_U_2(kdtlv
->type
);
813 tll
= GET_BE_U_2(kdtlv
->length
);
814 invtlv
= tlv_valid(tll
, len
);
817 ND_PRINT("%s TLV type 0x%x len %u\n",
818 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
823 * At this point, tlv_valid() has ensured that the TLV
824 * length is large enough but not too large (it doesn't
825 * go past the end of the containing TLV).
827 tll
= GET_BE_U_2(kdtlv
->length
);
828 dp
= TLV_DATA(kdtlv
);
829 return fdatatlv_print(ndo
, dp
, tll
, op_msk
, indent
);
834 #define PTH_DESC_SIZE 12
837 pdatacnt_print(netdissect_options
*ndo
,
838 const u_char
* pptr
, u_int len
,
839 uint16_t IDcnt
, uint16_t op_msk
, int indent
)
843 char *ib
= indent_pr(indent
, 0);
845 if ((op_msk
& B_APPND
) && ndo
->ndo_vflag
>= 3) {
846 ND_PRINT("%sTABLE APPEND\n", ib
);
848 for (i
= 0; i
< IDcnt
; i
++) {
849 ND_ICHECK_U(len
, <, 4);
850 id
= GET_BE_U_4(pptr
);
851 if (ndo
->ndo_vflag
>= 3)
852 ND_PRINT("%sID#%02u: %u\n", ib
, i
+ 1, id
);
857 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
858 if (op_msk
& B_TRNG
) {
859 uint32_t starti
, endi
;
861 if (len
< PTH_DESC_SIZE
) {
862 ND_PRINT("pathlength %u with key/range too short %u\n",
867 pptr
+= sizeof(struct forces_tlv
);
868 len
-= sizeof(struct forces_tlv
);
870 starti
= GET_BE_U_4(pptr
);
874 endi
= GET_BE_U_4(pptr
);
878 if (ndo
->ndo_vflag
>= 3)
879 ND_PRINT("%sTable range: [%u,%u]\n", ib
, starti
, endi
);
882 if (op_msk
& B_KEYIN
) {
883 const struct forces_tlv
*keytlv
;
886 if (len
< PTH_DESC_SIZE
) {
887 ND_PRINT("pathlength %u with key/range too short %u\n",
895 keytlv
= (const struct forces_tlv
*)pptr
;
897 pptr
+= sizeof(struct forces_tlv
);
898 len
-= sizeof(struct forces_tlv
);
899 /* skip key content */
900 tll
= GET_BE_U_2(keytlv
->length
);
901 if (tll
< TLV_HDRL
) {
902 ND_PRINT("key content length %u < %u\n",
908 ND_PRINT("key content too short\n");
918 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
925 type
= GET_BE_U_2(pdtlv
->type
);
926 tlvl
= GET_BE_U_2(pdtlv
->length
);
927 invtlv
= tlv_valid(tlvl
, len
);
929 ND_PRINT("%s Outstanding bytes %u for TLV type 0x%x TLV len %u\n",
930 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
935 * At this point, tlv_valid() has ensured that the TLV
936 * length is large enough but not too large (it doesn't
937 * go past the end of the containing TLV).
939 tll
= tlvl
- TLV_HDRL
;
940 aln
= F_ALN_LEN(tlvl
);
943 ND_PRINT("Invalid padded pathdata TLV type 0x%x len %u missing %u pad bytes\n",
944 type
, tlvl
, aln
- len
);
949 if (pd_valid(type
)) {
950 const struct pdata_ops
*ops
= get_forces_pd(type
);
952 if (ndo
->ndo_vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
954 ND_PRINT("%s %s (Length %u DataLen %u pad %u Bytes)\n",
955 ib
, ops
->s
, tlvl
, tll
, pad
);
957 ND_PRINT("%s %s (Length %u DataLen %u Bytes)\n",
958 ib
, ops
->s
, tlvl
, tll
);
961 chk_op_type(ndo
, type
, op_msk
, ops
->op_msk
);
963 ND_ICHECK_U(ops
->print(ndo
, (const u_char
*)pdtlv
,
964 tll
+ pad
+ TLV_HDRL
, op_msk
, indent
+ 2),
966 len
-= (TLV_HDRL
+ pad
+ tll
);
968 ND_PRINT("Invalid path data content type 0x%x len %u\n",
972 hex_print(ndo
, "Bad Data val\n\t [",
987 pdata_print(netdissect_options
*ndo
,
988 const u_char
* pptr
, u_int len
,
989 uint16_t op_msk
, int indent
)
991 const struct pathdata_h
*pdh
= (const struct pathdata_h
*)pptr
;
992 char *ib
= indent_pr(indent
, 0);
998 ND_ICHECK_ZU(len
, <, sizeof(struct pathdata_h
));
999 if (ndo
->ndo_vflag
>= 3) {
1000 ND_PRINT("\n%sPathdata: Flags 0x%x ID count %u\n",
1001 ib
, GET_BE_U_2(pdh
->pflags
),
1002 GET_BE_U_2(pdh
->pIDcnt
));
1005 if (GET_BE_U_2(pdh
->pflags
) & F_SELKEY
) {
1009 /* Table GET Range operation */
1010 if (GET_BE_U_2(pdh
->pflags
) & F_SELTABRANGE
) {
1013 /* Table SET append operation */
1014 if (GET_BE_U_2(pdh
->pflags
) & F_TABAPPEND
) {
1018 pptr
+= sizeof(struct pathdata_h
);
1019 len
-= sizeof(struct pathdata_h
);
1020 idcnt
= GET_BE_U_2(pdh
->pIDcnt
);
1021 minsize
= idcnt
* 4;
1022 if (len
< minsize
) {
1023 ND_PRINT("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
1025 hex_print(ndo
, "\t\t\tID Data[", pptr
, len
);
1030 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
1031 ND_PRINT("\t\t\tIllegal to have both Table ranges and keys\n");
1035 more_pd
= pdatacnt_print(ndo
, pptr
, len
, idcnt
, op_msk
, indent
);
1037 int consumed
= len
- more_pd
;
1040 /* XXX: Argh, recurse some more */
1041 return recpdoptlv_print(ndo
, pptr
, len
, op_msk
, indent
+1);
1050 genoptlv_print(netdissect_options
*ndo
,
1051 const u_char
* pptr
, u_int len
,
1052 uint16_t op_msk
, int indent
)
1054 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1058 char *ib
= indent_pr(indent
, 0);
1060 type
= GET_BE_U_2(pdtlv
->type
);
1061 tlvl
= GET_BE_U_2(pdtlv
->length
);
1062 invtlv
= tlv_valid(tlvl
, len
);
1063 ND_PRINT("genoptlvprint - %s TLV type 0x%x len %u\n",
1064 tok2str(ForCES_TLV
, NULL
, type
), type
, tlvl
);
1066 ND_PRINT("\t\t\tInvalid ForCES TLV type=%x", type
);
1070 * At this point, tlv_valid() has ensured that the TLV
1071 * length is large enough but not too large (it doesn't
1072 * go past the end of the containing TLV).
1074 const u_char
*dp
= TLV_DATA(pdtlv
);
1076 if (!ttlv_valid(type
)) {
1077 ND_PRINT("%s TLV type 0x%x len %u\n",
1078 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
1082 if (ndo
->ndo_vflag
>= 3)
1083 ND_PRINT("%s%s, length %u (data length %u Bytes)",
1084 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1085 tlvl
, tlvl
- TLV_HDRL
);
1087 return pdata_print(ndo
, dp
, tlvl
- TLV_HDRL
, op_msk
, indent
+ 1);
1093 recpdoptlv_print(netdissect_options
*ndo
,
1094 const u_char
* pptr
, u_int len
,
1095 uint16_t op_msk
, int indent
)
1097 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1100 uint16_t type
, tlvl
;
1105 tlvl
= GET_BE_U_2(pdtlv
->length
);
1106 invtlv
= tlv_valid(tlvl
, len
);
1112 * At this point, tlv_valid() has ensured that the TLV
1113 * length is large enough but not too large (it doesn't
1114 * go past the end of the containing TLV).
1116 ib
= indent_pr(indent
, 0);
1117 type
= GET_BE_U_2(pdtlv
->type
);
1118 dp
= TLV_DATA(pdtlv
);
1120 if (ndo
->ndo_vflag
>= 3)
1121 ND_PRINT("%s%s, length %u (data encapsulated %u Bytes)",
1122 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1126 ND_ICHECK_U(pdata_print(ndo
, dp
, tlvl
- TLV_HDRL
, op_msk
, indent
+ 1),
1128 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
1132 ND_PRINT("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1133 GET_BE_U_2(pdtlv
->type
),
1134 len
- GET_BE_U_2(pdtlv
->length
));
1144 invoptlv_print(netdissect_options
*ndo
,
1145 const u_char
* pptr
, u_int len
,
1146 uint16_t op_msk _U_
, int indent
)
1148 char *ib
= indent_pr(indent
, 1);
1150 if (ndo
->ndo_vflag
>= 3) {
1151 ND_PRINT("%sData[", ib
+ 1);
1152 hex_print(ndo
, ib
, pptr
, len
);
1153 ND_PRINT("%s]\n", ib
);
1159 otlv_print(netdissect_options
*ndo
,
1160 const struct forces_tlv
*otlv
, uint16_t op_msk _U_
, int indent
)
1163 const u_char
*dp
= TLV_DATA(otlv
);
1166 char *ib
= indent_pr(indent
, 0);
1167 const struct optlv_h
*ops
;
1170 * lfbselect_print() has ensured that GET_BE_U_2(otlv->length)
1173 type
= GET_BE_U_2(otlv
->type
);
1174 tll
= GET_BE_U_2(otlv
->length
) - TLV_HDRL
;
1175 ops
= get_forces_optlv_h(type
);
1176 if (ndo
->ndo_vflag
>= 3) {
1177 ND_PRINT("%sOper TLV %s(0x%x) length %u\n", ib
, ops
->s
, type
,
1178 GET_BE_U_2(otlv
->length
));
1180 /* rest of ops must at least have 12B {pathinfo} */
1181 if (tll
< OP_MIN_SIZ
) {
1182 ND_PRINT("\t\tOper TLV %s(0x%x) length %u\n", ops
->s
, type
,
1183 GET_BE_U_2(otlv
->length
));
1184 ND_PRINT("\t\tTruncated data size %u minimum required %u\n", tll
,
1186 return invoptlv_print(ndo
, dp
, tll
, ops
->op_msk
, indent
);
1190 /* XXX - do anything with ops->flags? */
1192 rc
= ops
->print(ndo
, dp
, tll
, ops
->op_msk
, indent
+ 1);
1200 asttlv_print(netdissect_options
*ndo
,
1201 const u_char
* pptr
, u_int len
,
1202 uint16_t op_msk _U_
, int indent
)
1206 char *ib
= indent_pr(indent
, 0);
1209 * forces_type_print() has ensured that len (the TLV length)
1212 dlen
= len
- TLV_HDRL
;
1213 if (dlen
!= ASTDLN
) {
1214 ND_PRINT("illegal ASTresult-TLV: %u bytes!\n", dlen
);
1217 rescode
= GET_BE_U_4(pptr
);
1218 if (rescode
> ASTMCD
) {
1219 ND_PRINT("illegal ASTresult result code: %u!\n", rescode
);
1223 if (ndo
->ndo_vflag
>= 3) {
1224 ND_PRINT("Teardown reason:\n%s%s", ib
,
1225 tok2str(tdr_str
, "unknown (%u)", rescode
));
1226 ND_PRINT("(%x)\n%s", rescode
, ib
);
1236 asrtlv_print(netdissect_options
*ndo
,
1237 const u_char
* pptr
, u_int len
,
1238 uint16_t op_msk _U_
, int indent
)
1242 char *ib
= indent_pr(indent
, 0);
1245 * forces_type_print() has ensured that len (the TLV length)
1248 dlen
= len
- TLV_HDRL
;
1249 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
1250 ND_PRINT("illegal ASRresult-TLV: %u bytes!\n", dlen
);
1253 rescode
= GET_BE_U_4(pptr
);
1255 if (rescode
> ASRMCD
) {
1256 ND_PRINT("illegal ASRresult result code: %u!\n", rescode
);
1260 if (ndo
->ndo_vflag
>= 3) {
1261 ND_PRINT("\n%s", ib
);
1264 ND_PRINT("Success ");
1267 ND_PRINT("FE ID invalid ");
1270 ND_PRINT("permission denied ");
1273 ND_PRINT("Unknown ");
1276 ND_PRINT("(%x)\n%s", rescode
, ib
);
1288 gentltlv_print(netdissect_options
*ndo
,
1289 const u_char
* pptr _U_
, u_int len
,
1290 uint16_t op_msk _U_
, int indent _U_
)
1292 u_int dlen
= len
- TLV_HDRL
;
1294 if (dlen
< 4) { /* at least 32 bits must exist */
1295 ND_PRINT("truncated TLV: %u bytes missing! ", 4 - dlen
);
1305 print_metailv(netdissect_options
*ndo
,
1306 const struct forces_ilv
* ilv
, uint16_t op_msk _U_
,
1310 char *ib
= indent_pr(indent
, 0);
1311 /* XXX: check header length */
1314 * print_metatlv() has ensured that len (what remains in the
1317 rlen
= GET_BE_U_4(ilv
->length
) - ILV_HDRL
;
1318 ND_PRINT("%sMetaID 0x%x length %u\n", ib
, GET_BE_U_4(ilv
->type
),
1319 GET_BE_U_4(ilv
->length
));
1320 if (ndo
->ndo_vflag
>= 3) {
1321 hex_print(ndo
, "\t\t[", ILV_DATA(ilv
), rlen
);
1328 print_metatlv(netdissect_options
*ndo
,
1329 const u_char
* pptr
, u_int len
,
1330 uint16_t op_msk _U_
, int indent
)
1333 char *ib
= indent_pr(indent
, 0);
1335 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
1339 * redirect_print() has ensured that len (what remains in the
1342 dlen
= len
- TLV_HDRL
;
1344 ND_PRINT("\n%s METADATA length %u\n", ib
, rlen
);
1346 invilv
= ilv_valid(ndo
, ilv
, rlen
);
1352 * At this point, ilv_valid() has ensured that the ILV
1353 * length is large enough but not too large (it doesn't
1354 * go past the end of the containing TLV).
1356 print_metailv(ndo
, ilv
, 0, indent
+ 1);
1357 ilv
= GO_NXT_ILV(ilv
, rlen
);
1365 print_reddata(netdissect_options
*ndo
,
1366 const u_char
* pptr
, u_int len
,
1367 uint16_t op_msk _U_
, int indent
)
1370 char *ib
= indent_pr(indent
, 0);
1373 dlen
= len
- TLV_HDRL
;
1375 ND_PRINT("\n%s Redirect Data length %u\n", ib
, rlen
);
1377 if (ndo
->ndo_vflag
>= 3) {
1379 hex_print(ndo
, "\n\t\t", pptr
, rlen
);
1380 ND_PRINT("\n\t\t]");
1387 redirect_print(netdissect_options
*ndo
,
1388 const u_char
* pptr
, u_int len
,
1389 uint16_t op_msk _U_
, int indent
)
1391 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
1397 * forces_type_print() has ensured that len (the TLV length)
1400 dlen
= len
- TLV_HDRL
;
1401 if (dlen
<= RD_MIN
) {
1402 ND_PRINT("\n\t\ttruncated Redirect TLV: %u bytes missing! ",
1410 uint16_t type
, tlvl
;
1412 type
= GET_BE_U_2(tlv
->type
);
1413 tlvl
= GET_BE_U_2(tlv
->length
);
1414 invtlv
= tlv_valid(tlvl
, rlen
);
1416 ND_PRINT("Bad Redirect data\n");
1421 * At this point, tlv_valid() has ensured that the TLV
1422 * length is large enough but not too large (it doesn't
1423 * go past the end of the containing TLV).
1425 if (type
== F_TLV_METD
) {
1426 print_metatlv(ndo
, TLV_DATA(tlv
),
1429 } else if (type
== F_TLV_REDD
) {
1430 print_reddata(ndo
, TLV_DATA(tlv
),
1434 ND_PRINT("Unknown REDIRECT TLV 0x%x len %u\n",
1439 tlv
= GO_NXT_TLV(tlv
, rlen
);
1443 ND_PRINT("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1444 GET_BE_U_2(tlv
->type
),
1445 rlen
- GET_BE_U_2(tlv
->length
));
1458 lfbselect_print(netdissect_options
*ndo
,
1459 const u_char
* pptr
, u_int len
,
1460 uint16_t op_msk
, int indent
)
1462 const struct forces_lfbsh
*lfbs
;
1463 const struct forces_tlv
*otlv
;
1464 char *ib
= indent_pr(indent
, 0);
1470 * forces_type_print() has ensured that len (the TLV length)
1473 dlen
= len
- TLV_HDRL
;
1474 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
1475 ND_PRINT("\n\t\tundersized lfb selector: %u bytes missing! ",
1481 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
1482 * we also know that it's > OP_OFF.
1484 rlen
= dlen
- OP_OFF
;
1486 lfbs
= (const struct forces_lfbsh
*)pptr
;
1487 ND_TCHECK_SIZE(lfbs
);
1488 if (ndo
->ndo_vflag
>= 3) {
1489 ND_PRINT("\n%s%s(Classid %x) instance %x\n",
1491 tok2str(ForCES_LFBs
, NULL
, GET_BE_U_4(lfbs
->class)),
1492 GET_BE_U_4(lfbs
->class),
1493 GET_BE_U_4(lfbs
->instance
));
1496 otlv
= (const struct forces_tlv
*)(lfbs
+ 1);
1500 uint16_t type
, tlvl
;
1502 type
= GET_BE_U_2(otlv
->type
);
1503 tlvl
= GET_BE_U_2(otlv
->length
);
1504 invtlv
= tlv_valid(tlvl
, rlen
);
1509 * At this point, tlv_valid() has ensured that the TLV
1510 * length is large enough but not too large (it doesn't
1511 * go past the end of the containing TLV).
1513 if (op_valid(type
, op_msk
)) {
1514 otlv_print(ndo
, otlv
, 0, indent
);
1516 if (ndo
->ndo_vflag
< 3)
1518 ND_PRINT("\t\tINValid oper-TLV type 0x%x length %u for this ForCES message\n",
1520 invoptlv_print(ndo
, (const u_char
*)otlv
, rlen
, 0, indent
);
1522 otlv
= GO_NXT_TLV(otlv
, rlen
);
1526 ND_PRINT("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %u Bytes ",
1527 GET_BE_U_2(otlv
->type
),
1528 rlen
- GET_BE_U_2(otlv
->length
));
1539 forces_type_print(netdissect_options
*ndo
,
1540 const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
1541 u_int mlen
, const struct tom_h
*tops
)
1543 const struct forces_tlv
*tltlv
;
1550 * forces_print() has already checked that mlen >= ForCES_HDRL
1551 * by calling ForCES_HLN_VALID().
1553 rlen
= mlen
- ForCES_HDRL
;
1555 if (rlen
> TLV_HLN
) {
1556 if (tops
->flags
& ZERO_TTLV
) {
1557 ND_PRINT("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
1561 if (tops
->flags
& ZERO_MORE_TTLV
)
1563 if (tops
->flags
& ONE_MORE_TTLV
) {
1564 ND_PRINT("\tTop level TLV Data missing!\n");
1569 if (tops
->flags
& ZERO_TTLV
) {
1573 ttlv
= tops
->flags
>> 4;
1574 tltlv
= GET_TOP_TLV(pptr
);
1576 /*XXX: 15 top level tlvs will probably be fine
1577 You are nuts if you send more ;-> */
1579 uint16_t type
, tlvl
;
1581 type
= GET_BE_U_2(tltlv
->type
);
1582 tlvl
= GET_BE_U_2(tltlv
->length
);
1583 invtlv
= tlv_valid(tlvl
, rlen
);
1588 * At this point, tlv_valid() has ensured that the TLV
1589 * length is large enough but not too large (it doesn't
1590 * go past the end of the packet).
1592 if (!ttlv_valid(type
)) {
1593 ND_PRINT("\n\tInvalid ForCES Top TLV type=0x%x",
1598 if (ndo
->ndo_vflag
>= 3)
1599 ND_PRINT("\t%s, length %u (data length %u Bytes)",
1600 tok2str(ForCES_TLV
, NULL
, type
),
1604 rc
= tops
->print(ndo
, TLV_DATA(tltlv
),
1607 ND_ICHECK_U(rc
, <, 0);
1608 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1614 * XXX - if ttlv != 0, does that mean that the packet was too
1615 * short, and didn't have *enough* TLVs in it?
1618 ND_PRINT("\tMess TopTLV header: min %u, total %u advertised %u ",
1619 TLV_HDRL
, rlen
, GET_BE_U_2(tltlv
->length
));
1629 forces_print(netdissect_options
*ndo
,
1630 const u_char
* pptr
, u_int len
)
1632 const struct forcesh
*fhdr
;
1636 const struct tom_h
*tops
;
1639 ndo
->ndo_protocol
= "forces";
1640 fhdr
= (const struct forcesh
*)pptr
;
1641 ND_TCHECK_SIZE(fhdr
);
1642 tom
= GET_U_1(fhdr
->fm_tom
);
1643 if (!tom_valid(tom
)) {
1644 ND_PRINT("Invalid ForCES message type %u\n", tom
);
1648 mlen
= ForCES_BLN(fhdr
);
1650 tops
= get_forces_tom(tom
);
1651 if (tops
->v
== TOM_RSVD
) {
1652 ND_PRINT("\n\tUnknown ForCES message type=0x%x", tom
);
1656 ND_PRINT("\n\tForCES %s ", tops
->s
);
1657 if (!ForCES_HLN_VALID(mlen
, len
)) {
1658 ND_PRINT("Illegal ForCES pkt len - min %u, total recvd %u, advertised %u ",
1659 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1663 flg_raw
= GET_BE_U_4(pptr
+ 20);
1664 if (ndo
->ndo_vflag
>= 1) {
1665 ND_PRINT("\n\tForCES Version %u len %uB flags 0x%08x ",
1666 ForCES_V(fhdr
), mlen
, flg_raw
);
1667 ND_PRINT("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1668 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1669 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1670 GET_BE_U_8(fhdr
->fm_cor
));
1673 if (ndo
->ndo_vflag
>= 2) {
1674 ND_PRINT("\n\tForCES flags:\n\t %s(0x%x), prio=%u, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1675 tok2str(ForCES_ACKs
, "ACKUnknown", ForCES_ACK(fhdr
)),
1678 tok2str(ForCES_EMs
, "EMUnknown", ForCES_EM(fhdr
)),
1680 tok2str(ForCES_ATs
, "ATUnknown", ForCES_AT(fhdr
)),
1682 tok2str(ForCES_TPs
, "TPUnknown", ForCES_TP(fhdr
)),
1684 ND_PRINT("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1685 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1687 rc
= forces_type_print(ndo
, pptr
, fhdr
, mlen
, tops
);
1688 ND_ICHECK_U(rc
, <, 0);
1690 if (ndo
->ndo_vflag
>= 4) {
1691 ND_PRINT("\n\t Raw ForCES message\n\t [");
1692 hex_print(ndo
, "\n\t ", pptr
, len
);
1697 nd_print_invalid(ndo
);