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"
30 static const char tstr
[] = "[|forces]";
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)
89 static inline int tom_valid(uint8_t tom
)
92 if (tom
>= 0x7 && tom
<= 0xe)
103 static inline const char *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) (EXTRACT_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)(EXTRACT_BE_U_2((forcesh)->fm_len) << 2))
161 nd_uint32_t fm_sid
; /* Source ID */
162 #define ForCES_SID(forcesh) EXTRACT_BE_U_4((forcesh)->fm_sid)
163 nd_uint32_t fm_did
; /* Destination ID */
164 #define ForCES_DID(forcesh) EXTRACT_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) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0xC0000000) >> 30)
168 #define ForCES_PRI(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x38000000) >> 27)
169 #define ForCES_RS1(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x07000000) >> 24)
170 #define ForCES_EM(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x00C00000) >> 22)
171 #define ForCES_AT(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x00200000) >> 21)
172 #define ForCES_TP(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x00180000) >> 19)
173 #define ForCES_RS2(forcesh) ((EXTRACT_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 /* http://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 inline const struct optlv_h
*get_forces_optlv_h(uint16_t opt
)
281 if (opt
> F_OP_MAX
|| opt
== F_OP_RSV
)
282 return &OPTLV_msg
[F_OP_RSV
];
284 return &OPTLV_msg
[opt
];
289 #define IND_PREF '\n'
291 static char ind_buf
[IND_SIZE
];
293 static inline char *indent_pr(int indent
, int nlpref
)
298 if (indent
> (IND_SIZE
- 1))
299 indent
= IND_SIZE
- 1;
307 while (--indent
>= 0)
314 static inline int op_valid(uint16_t op
, uint16_t mask
)
319 return (1 << (op
- 1)) & mask
; /* works only for 0x0001 through 0x0010 */
320 /* I guess we should allow vendor operations? */
326 #define F_TLV_RSVD 0x0000
327 #define F_TLV_REDR 0x0001
328 #define F_TLV_ASRS 0x0010
329 #define F_TLV_ASRT 0x0011
330 #define F_TLV_LFBS 0x1000
331 #define F_TLV_PDAT 0x0110
332 #define F_TLV_KEYI 0x0111
333 #define F_TLV_FULD 0x0112
334 #define F_TLV_SPAD 0x0113
335 #define F_TLV_REST 0x0114
336 #define F_TLV_METD 0x0115
337 #define F_TLV_REDD 0x0116
338 #define F_TLV_TRNG 0x0117
341 #define F_TLV_VNST 0x8000
343 static const struct tok ForCES_TLV
[] = {
344 {F_TLV_RSVD
, "Invalid TLV"},
345 {F_TLV_REDR
, "REDIRECT TLV"},
346 {F_TLV_ASRS
, "ASResult TLV"},
347 {F_TLV_ASRT
, "ASTreason TLV"},
348 {F_TLV_LFBS
, "LFBselect TLV"},
349 {F_TLV_PDAT
, "PATH-DATA TLV"},
350 {F_TLV_KEYI
, "KEYINFO TLV"},
351 {F_TLV_FULD
, "FULLDATA TLV"},
352 {F_TLV_SPAD
, "SPARSEDATA TLV"},
353 {F_TLV_REST
, "RESULT TLV"},
354 {F_TLV_METD
, "METADATA TLV"},
355 {F_TLV_REDD
, "REDIRECTDATA TLV"},
360 static inline int ttlv_valid(uint16_t ttlv
)
363 if (ttlv
== 1 || ttlv
== 0x1000)
365 if (ttlv
>= 0x10 && ttlv
<= 0x11)
367 if (ttlv
>= 0x110 && ttlv
<= 0x116)
386 #define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
387 #define GET_TOP_TLV(fhdr) ((const struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
388 #define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
389 #define TLV_DATA(tlvp) ((const void*)(((const char*)(tlvp)) + TLV_SET_LEN(0)))
390 #define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_BE_U_2((tlv)->length)), \
391 (const struct forces_tlv*)(((const char*)(tlv)) \
392 + F_ALN_LEN(EXTRACT_BE_U_2((tlv)->length))))
393 #define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
394 #define ILV_DATA(ilvp) ((const void*)(((const char*)(ilvp)) + ILV_SET_LEN(0)))
395 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_BE_U_4((ilv)->length)), \
396 (const struct forces_ilv *)(((const char*)(ilv)) \
397 + F_ALN_LEN(EXTRACT_BE_U_4((ilv)->length))))
398 #define INVALID_RLEN 1
399 #define INVALID_STLN 2
400 #define INVALID_LTLN 3
401 #define INVALID_ALEN 4
403 static const struct tok ForCES_TLV_err
[] = {
404 {INVALID_RLEN
, "Invalid total length"},
405 {INVALID_STLN
, "xLV too short"},
406 {INVALID_LTLN
, "xLV too long"},
407 {INVALID_ALEN
, "data padding missing"},
411 static inline u_int
tlv_valid(const struct forces_tlv
*tlv
, u_int rlen
)
415 if (EXTRACT_BE_U_2(tlv
->length
) < TLV_HDRL
)
417 if (EXTRACT_BE_U_2(tlv
->length
) > rlen
)
419 if (rlen
< F_ALN_LEN(EXTRACT_BE_U_2(tlv
->length
)))
425 static inline int ilv_valid(const struct forces_ilv
*ilv
, u_int rlen
)
429 if (EXTRACT_BE_U_4(ilv
->length
) < ILV_HDRL
)
431 if (EXTRACT_BE_U_4(ilv
->length
) > rlen
)
433 if (rlen
< F_ALN_LEN(EXTRACT_BE_U_4(ilv
->length
)))
439 static int lfbselect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
440 uint16_t op_msk
, int indent
);
441 static int redirect_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
442 uint16_t op_msk
, int indent
);
443 static int asrtlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
444 uint16_t op_msk
, int indent
);
445 static int asttlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
446 uint16_t op_msk
, int indent
);
448 struct forces_lfbsh
{
450 nd_uint32_t instance
;
453 #define ASSNS_OPS (B_OP_REPORT)
454 #define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
455 #define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
456 #define CFG_QY (B_OP_GET|B_OP_GETPROP)
457 #define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
458 #define CFG_EVN (B_OP_REPORT)
460 static const struct tom_h ForCES_msg
[TOM_MAX_IND
+ 1] = {
461 /* TOM_RSV_I */ {TOM_RSVD
, ZERO_TTLV
, 0, "Invalid message", NULL
},
462 /* TOM_ASS_I */ {TOM_ASSNSETUP
, ZERO_MORE_TTLV
| TWO_TLV
, ASSNS_OPS
,
463 "Association Setup", lfbselect_print
},
465 {TOM_ASSNTEARD
, TTLV_T1
, 0, "Association TearDown", asttlv_print
},
466 /* TOM_CFG_I */ {TOM_CONFIG
, TTLV_T2
, CFG_OPS
, "Config", lfbselect_print
},
467 /* TOM_QRY_I */ {TOM_QUERY
, TTLV_T2
, CFG_QY
, "Query", lfbselect_print
},
468 /* TOM_EVN_I */ {TOM_EVENTNOT
, TTLV_T1
, CFG_EVN
, "Event Notification",
471 {TOM_PKTREDIR
, TTLV_T2
, 0, "Packet Redirect", redirect_print
},
472 /* TOM_HBT_I */ {TOM_HEARTBT
, ZERO_TTLV
, 0, "HeartBeat", NULL
},
474 {TOM_ASSNSETREP
, TTLV_T1
, 0, "Association Response", asrtlv_print
},
475 /* TOM_CNR_I */ {TOM_CONFIGREP
, TTLV_T2
, CFG_ROPS
, "Config Response",
478 {TOM_QUERYREP
, TTLV_T2
, CFG_QYR
, "Query Response", lfbselect_print
},
481 static inline const struct tom_h
*get_forces_tom(uint8_t tom
)
484 for (i
= TOM_RSV_I
; i
<= TOM_MAX_IND
; i
++) {
485 const struct tom_h
*th
= &ForCES_msg
[i
];
489 return &ForCES_msg
[TOM_RSV_I
];
497 int (*print
) (netdissect_options
*, const u_char
* pptr
, u_int len
,
498 uint16_t op_msk
, int indent
);
510 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
512 static inline int pd_valid(uint16_t pd
)
514 if (pd
>= F_TLV_PDAT
&& pd
<= F_TLV_REST
)
520 chk_op_type(netdissect_options
*ndo
,
521 uint16_t type
, uint16_t msk
, uint16_t omsk
)
523 if (type
!= F_TLV_PDAT
) {
525 if (type
!= F_TLV_KEYI
) {
526 ND_PRINT("Based on flags expected KEYINFO TLV!\n");
530 ND_PRINT("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
539 #define F_SELTABRANGE 2
540 #define F_TABAPPEND 4
548 static int prestlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
549 uint16_t op_msk
, int indent
);
550 static int pkeyitlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
551 uint16_t op_msk
, int indent
);
552 static int fdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
553 uint16_t op_msk
, int indent
);
554 static int sdatatlv_print(netdissect_options
*, const u_char
* pptr
, u_int len
,
555 uint16_t op_msk
, int indent
);
557 static const struct pdata_ops ForCES_pdata
[PD_MAX_IND
+ 1] = {
558 /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL
},
559 /* PD_SEL_I */ {F_TLV_KEYI
, 0, 0, "KEYINFO TLV", pkeyitlv_print
},
560 /* PD_FDT_I */ {F_TLV_FULD
, 0, B_FULLD
, "FULLDATA TLV", fdatatlv_print
},
561 /* PD_SDT_I */ {F_TLV_SPAD
, 0, B_SPARD
, "SPARSEDATA TLV", sdatatlv_print
},
562 /* PD_RES_I */ {F_TLV_REST
, 0, B_RESTV
, "RESULT TLV", prestlv_print
},
564 {F_TLV_PDAT
, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print
},
567 static inline const struct pdata_ops
*get_forces_pd(uint16_t pd
)
570 for (i
= PD_RSV_I
+ 1; i
<= PD_MAX_IND
; i
++) {
571 const struct pdata_ops
*pdo
= &ForCES_pdata
[i
];
575 return &ForCES_pdata
[TOM_RSV_I
];
583 E_INVALID_DESTINATION_PID
,
586 E_LFB_INSTANCE_ID_NOT_FOUND
,
588 E_COMPONENT_DOES_NOT_EXIST
,
592 E_INVALID_ARRAY_CREATION
,
593 E_VALUE_OUT_OF_RANGE
,
595 E_INVALID_PARAMETERS
,
596 E_INVALID_MESSAGE_TYPE
,
603 /* 0x18-0xFE are reserved .. */
604 E_UNSPECIFIED_ERROR
= 0XFF
607 static const struct tok ForCES_errs
[] = {
608 {E_SUCCESS
, "SUCCESS"},
609 {E_INVALID_HEADER
, "INVALID HEADER"},
610 {E_LENGTH_MISMATCH
, "LENGTH MISMATCH"},
611 {E_VERSION_MISMATCH
, "VERSION MISMATCH"},
612 {E_INVALID_DESTINATION_PID
, "INVALID DESTINATION PID"},
613 {E_LFB_UNKNOWN
, "LFB UNKNOWN"},
614 {E_LFB_NOT_FOUND
, "LFB NOT FOUND"},
615 {E_LFB_INSTANCE_ID_NOT_FOUND
, "LFB INSTANCE ID NOT FOUND"},
616 {E_INVALID_PATH
, "INVALID PATH"},
617 {E_COMPONENT_DOES_NOT_EXIST
, "COMPONENT DOES NOT EXIST"},
618 {E_EXISTS
, "EXISTS ALREADY"},
619 {E_NOT_FOUND
, "NOT FOUND"},
620 {E_READ_ONLY
, "READ ONLY"},
621 {E_INVALID_ARRAY_CREATION
, "INVALID ARRAY CREATION"},
622 {E_VALUE_OUT_OF_RANGE
, "VALUE OUT OF RANGE"},
623 {E_CONTENTS_TOO_LONG
, "CONTENTS TOO LONG"},
624 {E_INVALID_PARAMETERS
, "INVALID PARAMETERS"},
625 {E_INVALID_MESSAGE_TYPE
, "INVALID MESSAGE TYPE"},
626 {E_INVALID_FLAGS
, "INVALID FLAGS"},
627 {E_INVALID_TLV
, "INVALID TLV"},
628 {E_EVENT_ERROR
, "EVENT ERROR"},
629 {E_NOT_SUPPORTED
, "NOT SUPPORTED"},
630 {E_MEMORY_ERROR
, "MEMORY ERROR"},
631 {E_INTERNAL_ERROR
, "INTERNAL ERROR"},
632 {E_UNSPECIFIED_ERROR
, "UNSPECIFIED ERROR"},
639 prestlv_print(netdissect_options
*ndo
,
640 const u_char
* pptr
, u_int len
,
641 uint16_t op_msk _U_
, int indent
)
643 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
644 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
645 const struct res_val
*r
= (const struct res_val
*)tdp
;
650 * pdatacnt_print() has ensured that len (the TLV length)
653 dlen
= len
- TLV_HDRL
;
654 if (dlen
!= RESLEN
) {
655 ND_PRINT("illegal RESULT-TLV: %d bytes!\n", dlen
);
660 result
= EXTRACT_U_1(r
->result
);
661 if (result
>= 0x18 && result
<= 0xFE) {
662 ND_PRINT("illegal reserved result code: 0x%x!\n", result
);
666 if (ndo
->ndo_vflag
>= 3) {
667 char *ib
= indent_pr(indent
, 0);
668 ND_PRINT("%s Result: %s (code 0x%x)\n", ib
,
669 tok2str(ForCES_errs
, NULL
, result
), result
);
674 ND_PRINT("%s", tstr
);
679 fdatatlv_print(netdissect_options
*ndo
,
680 const u_char
* pptr
, u_int len
,
681 uint16_t op_msk _U_
, int indent
)
683 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
685 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
689 * pdatacnt_print() or pkeyitlv_print() has ensured that len
690 * (the TLV length) >= TLV_HDRL.
692 rlen
= len
- TLV_HDRL
;
694 type
= EXTRACT_BE_U_2(tlv
->type
);
695 if (type
!= F_TLV_FULD
) {
696 ND_PRINT("Error: expecting FULLDATA!\n");
700 if (ndo
->ndo_vflag
>= 3) {
701 char *ib
= indent_pr(indent
+ 2, 1);
702 ND_PRINT("%s[", ib
+ 1);
703 hex_print_with_offset(ndo
, ib
, tdp
, rlen
, 0);
704 ND_PRINT("\n%s]\n", ib
+ 1);
709 ND_PRINT("%s", tstr
);
714 sdatailv_print(netdissect_options
*ndo
,
715 const u_char
* pptr
, u_int len
,
716 uint16_t op_msk _U_
, int indent
)
719 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
722 if (len
< ILV_HDRL
) {
723 ND_PRINT("Error: BAD SPARSEDATA-TLV!\n");
730 ND_PRINT("Jamal - outstanding length <%d>\n", rlen
);
732 char *ib
= indent_pr(indent
, 1);
733 const u_char
*tdp
= (const u_char
*) ILV_DATA(ilv
);
735 invilv
= ilv_valid(ilv
, rlen
);
737 ND_PRINT("%s[", ib
+ 1);
738 hex_print_with_offset(ndo
, ib
, tdp
, rlen
, 0);
739 ND_PRINT("\n%s]\n", ib
+ 1);
742 if (ndo
->ndo_vflag
>= 3) {
743 int ilvl
= EXTRACT_BE_U_4(ilv
->length
);
744 ND_PRINT("\n%s ILV: type %x length %d\n", ib
+ 1,
745 EXTRACT_BE_U_4(ilv
->type
), ilvl
);
746 hex_print_with_offset(ndo
, "\t\t[", tdp
, ilvl
-ILV_HDRL
, 0);
749 ilv
= GO_NXT_ILV(ilv
, rlen
);
755 ND_PRINT("%s", tstr
);
760 sdatatlv_print(netdissect_options
*ndo
,
761 const u_char
* pptr
, u_int len
,
762 uint16_t op_msk
, int indent
)
764 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
766 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
770 * pdatacnt_print() has ensured that len (the TLV length)
773 rlen
= len
- TLV_HDRL
;
775 type
= EXTRACT_BE_U_2(tlv
->type
);
776 if (type
!= F_TLV_SPAD
) {
777 ND_PRINT("Error: expecting SPARSEDATA!\n");
781 return sdatailv_print(ndo
, tdp
, rlen
, op_msk
, indent
);
784 ND_PRINT("%s", tstr
);
789 pkeyitlv_print(netdissect_options
*ndo
,
790 const u_char
* pptr
, u_int len
,
791 uint16_t op_msk
, int indent
)
793 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
794 const u_char
*tdp
= (const u_char
*) TLV_DATA(tlv
);
795 const u_char
*dp
= tdp
+ 4;
796 const struct forces_tlv
*kdtlv
= (const struct forces_tlv
*)dp
;
798 char *ib
= indent_pr(indent
, 0);
803 id
= EXTRACT_BE_U_4(tdp
);
804 ND_PRINT("%sKeyinfo: Key 0x%x\n", ib
, id
);
805 ND_TCHECK_SIZE(kdtlv
);
806 type
= EXTRACT_BE_U_2(kdtlv
->type
);
807 invtlv
= tlv_valid(kdtlv
, len
);
810 ND_PRINT("%s TLV type 0x%x len %d\n",
811 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
812 EXTRACT_BE_U_2(kdtlv
->length
));
816 * At this point, tlv_valid() has ensured that the TLV
817 * length is large enough but not too large (it doesn't
818 * go past the end of the containing TLV).
820 tll
= EXTRACT_BE_U_2(kdtlv
->length
);
821 dp
= (const u_char
*) TLV_DATA(kdtlv
);
822 return fdatatlv_print(ndo
, dp
, tll
, op_msk
, indent
);
825 ND_PRINT("%s", tstr
);
829 #define PTH_DESC_SIZE 12
832 pdatacnt_print(netdissect_options
*ndo
,
833 const u_char
* pptr
, u_int len
,
834 uint16_t IDcnt
, uint16_t op_msk
, int indent
)
838 char *ib
= indent_pr(indent
, 0);
840 if ((op_msk
& B_APPND
) && ndo
->ndo_vflag
>= 3) {
841 ND_PRINT("%sTABLE APPEND\n", ib
);
843 for (i
= 0; i
< IDcnt
; i
++) {
847 id
= EXTRACT_BE_U_4(pptr
);
848 if (ndo
->ndo_vflag
>= 3)
849 ND_PRINT("%sID#%02u: %d\n", ib
, i
+ 1, id
);
854 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
855 if (op_msk
& B_TRNG
) {
856 uint32_t starti
, endi
;
858 if (len
< PTH_DESC_SIZE
) {
859 ND_PRINT("pathlength %d with key/range too short %d\n",
864 pptr
+= sizeof(struct forces_tlv
);
865 len
-= sizeof(struct forces_tlv
);
867 starti
= EXTRACT_BE_U_4(pptr
);
871 endi
= EXTRACT_BE_U_4(pptr
);
875 if (ndo
->ndo_vflag
>= 3)
876 ND_PRINT("%sTable range: [%d,%d]\n", ib
, starti
, endi
);
879 if (op_msk
& B_KEYIN
) {
880 const struct forces_tlv
*keytlv
;
883 if (len
< PTH_DESC_SIZE
) {
884 ND_PRINT("pathlength %d with key/range too short %d\n",
892 keytlv
= (const struct forces_tlv
*)pptr
;
894 pptr
+= sizeof(struct forces_tlv
);
895 len
-= sizeof(struct forces_tlv
);
896 /* skip key content */
897 tll
= EXTRACT_BE_U_2(keytlv
->length
);
898 if (tll
< TLV_HDRL
) {
899 ND_PRINT("key content length %u < %u\n",
905 ND_PRINT("key content too short\n");
915 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
922 ND_TCHECK_SIZE(pdtlv
);
923 type
= EXTRACT_BE_U_2(pdtlv
->type
);
924 invtlv
= tlv_valid(pdtlv
, len
);
926 ND_PRINT("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
927 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
928 EXTRACT_BE_U_2(pdtlv
->length
));
932 * At this point, tlv_valid() has ensured that the TLV
933 * length is large enough but not too large (it doesn't
934 * go past the end of the containing TLV).
936 tll
= EXTRACT_BE_U_2(pdtlv
->length
) - TLV_HDRL
;
937 aln
= F_ALN_LEN(EXTRACT_BE_U_2(pdtlv
->length
));
938 if (aln
> EXTRACT_BE_U_2(pdtlv
->length
)) {
940 ND_PRINT("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
941 type
, EXTRACT_BE_U_2(pdtlv
->length
),
944 pad
= aln
- EXTRACT_BE_U_2(pdtlv
->length
);
947 if (pd_valid(type
)) {
948 const struct pdata_ops
*ops
= get_forces_pd(type
);
950 if (ndo
->ndo_vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
952 ND_PRINT("%s %s (Length %d DataLen %d pad %d Bytes)\n",
954 EXTRACT_BE_U_2(pdtlv
->length
),
957 ND_PRINT("%s %s (Length %d DataLen %d Bytes)\n",
959 EXTRACT_BE_U_2(pdtlv
->length
),
963 chk_op_type(ndo
, type
, op_msk
, ops
->op_msk
);
965 if (ops
->print(ndo
, (const u_char
*)pdtlv
,
966 tll
+ pad
+ TLV_HDRL
, op_msk
,
969 len
-= (TLV_HDRL
+ pad
+ tll
);
971 ND_PRINT("Invalid path data content type 0x%x len %d\n",
972 type
, EXTRACT_BE_U_2(pdtlv
->length
));
974 if (EXTRACT_BE_U_2(pdtlv
->length
)) {
975 hex_print_with_offset(ndo
, "Bad Data val\n\t [",
986 ND_PRINT("%s", tstr
);
991 pdata_print(netdissect_options
*ndo
,
992 const u_char
* pptr
, u_int len
,
993 uint16_t op_msk
, int indent
)
995 const struct pathdata_h
*pdh
= (const struct pathdata_h
*)pptr
;
996 char *ib
= indent_pr(indent
, 0);
1001 ND_TCHECK_SIZE(pdh
);
1002 if (len
< sizeof(struct pathdata_h
))
1004 if (ndo
->ndo_vflag
>= 3) {
1005 ND_PRINT("\n%sPathdata: Flags 0x%x ID count %d\n",
1006 ib
, EXTRACT_BE_U_2(pdh
->pflags
),
1007 EXTRACT_BE_U_2(pdh
->pIDcnt
));
1010 if (EXTRACT_BE_U_2(pdh
->pflags
) & F_SELKEY
) {
1014 /* Table GET Range operation */
1015 if (EXTRACT_BE_U_2(pdh
->pflags
) & F_SELTABRANGE
) {
1018 /* Table SET append operation */
1019 if (EXTRACT_BE_U_2(pdh
->pflags
) & F_TABAPPEND
) {
1023 pptr
+= sizeof(struct pathdata_h
);
1024 len
-= sizeof(struct pathdata_h
);
1025 idcnt
= EXTRACT_BE_U_2(pdh
->pIDcnt
);
1026 minsize
= idcnt
* 4;
1027 if (len
< minsize
) {
1028 ND_PRINT("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
1030 hex_print_with_offset(ndo
, "\t\t\tID Data[", pptr
, len
, 0);
1035 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
1036 ND_PRINT("\t\t\tIllegal to have both Table ranges and keys\n");
1040 more_pd
= pdatacnt_print(ndo
, pptr
, len
, idcnt
, op_msk
, indent
);
1042 int consumed
= len
- more_pd
;
1045 /* XXX: Argh, recurse some more */
1046 return recpdoptlv_print(ndo
, pptr
, len
, op_msk
, indent
+1);
1051 ND_PRINT("%s", tstr
);
1056 genoptlv_print(netdissect_options
*ndo
,
1057 const u_char
* pptr
, u_int len
,
1058 uint16_t op_msk
, int indent
)
1060 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1064 char *ib
= indent_pr(indent
, 0);
1066 ND_TCHECK_SIZE(pdtlv
);
1067 type
= EXTRACT_BE_U_2(pdtlv
->type
);
1068 tll
= EXTRACT_BE_U_2(pdtlv
->length
) - TLV_HDRL
;
1069 invtlv
= tlv_valid(pdtlv
, len
);
1070 ND_PRINT("genoptlvprint - %s TLV type 0x%x len %d\n",
1071 tok2str(ForCES_TLV
, NULL
, type
), type
,
1072 EXTRACT_BE_U_2(pdtlv
->length
));
1075 * At this point, tlv_valid() has ensured that the TLV
1076 * length is large enough but not too large (it doesn't
1077 * go past the end of the containing TLV).
1079 const u_char
*dp
= (const u_char
*) TLV_DATA(pdtlv
);
1080 if (!ttlv_valid(type
)) {
1081 ND_PRINT("%s TLV type 0x%x len %d\n",
1082 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
1083 EXTRACT_BE_U_2(pdtlv
->length
));
1086 if (ndo
->ndo_vflag
>= 3)
1087 ND_PRINT("%s%s, length %d (data length %d Bytes)",
1088 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1089 EXTRACT_BE_U_2(pdtlv
->length
), tll
);
1091 return pdata_print(ndo
, dp
, tll
, op_msk
, indent
+ 1);
1093 ND_PRINT("\t\t\tInvalid ForCES TLV type=%x", type
);
1098 ND_PRINT("%s", tstr
);
1103 recpdoptlv_print(netdissect_options
*ndo
,
1104 const u_char
* pptr
, u_int len
,
1105 uint16_t op_msk
, int indent
)
1107 const struct forces_tlv
*pdtlv
= (const struct forces_tlv
*)pptr
;
1115 ND_TCHECK_SIZE(pdtlv
);
1116 invtlv
= tlv_valid(pdtlv
, len
);
1122 * At this point, tlv_valid() has ensured that the TLV
1123 * length is large enough but not too large (it doesn't
1124 * go past the end of the containing TLV).
1126 ib
= indent_pr(indent
, 0);
1127 type
= EXTRACT_BE_U_2(pdtlv
->type
);
1128 dp
= (const u_char
*) TLV_DATA(pdtlv
);
1129 tll
= EXTRACT_BE_U_2(pdtlv
->length
) - TLV_HDRL
;
1131 if (ndo
->ndo_vflag
>= 3)
1132 ND_PRINT("%s%s, length %d (data encapsulated %d Bytes)",
1133 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1134 EXTRACT_BE_U_2(pdtlv
->length
),
1135 EXTRACT_BE_U_2(pdtlv
->length
) - TLV_HDRL
);
1137 if (pdata_print(ndo
, dp
, tll
, op_msk
, indent
+ 1) == -1)
1139 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
1143 ND_PRINT("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1144 EXTRACT_BE_U_2(pdtlv
->type
),
1145 len
- EXTRACT_BE_U_2(pdtlv
->length
));
1152 ND_PRINT("%s", tstr
);
1157 invoptlv_print(netdissect_options
*ndo
,
1158 const u_char
* pptr
, u_int len
,
1159 uint16_t op_msk _U_
, int indent
)
1161 char *ib
= indent_pr(indent
, 1);
1163 if (ndo
->ndo_vflag
>= 3) {
1164 ND_PRINT("%sData[", ib
+ 1);
1165 hex_print_with_offset(ndo
, ib
, pptr
, len
, 0);
1166 ND_PRINT("%s]\n", ib
);
1172 otlv_print(netdissect_options
*ndo
,
1173 const struct forces_tlv
*otlv
, uint16_t op_msk _U_
, int indent
)
1176 const u_char
*dp
= (const u_char
*) TLV_DATA(otlv
);
1179 char *ib
= indent_pr(indent
, 0);
1180 const struct optlv_h
*ops
;
1183 * lfbselect_print() has ensured that EXTRACT_BE_U_2(otlv->length)
1186 ND_TCHECK_SIZE(otlv
);
1187 type
= EXTRACT_BE_U_2(otlv
->type
);
1188 tll
= EXTRACT_BE_U_2(otlv
->length
) - TLV_HDRL
;
1189 ops
= get_forces_optlv_h(type
);
1190 if (ndo
->ndo_vflag
>= 3) {
1191 ND_PRINT("%sOper TLV %s(0x%x) length %d\n", ib
, ops
->s
, type
,
1192 EXTRACT_BE_U_2(otlv
->length
));
1194 /* rest of ops must at least have 12B {pathinfo} */
1195 if (tll
< OP_MIN_SIZ
) {
1196 ND_PRINT("\t\tOper TLV %s(0x%x) length %d\n", ops
->s
, type
,
1197 EXTRACT_BE_U_2(otlv
->length
));
1198 ND_PRINT("\t\tTruncated data size %d minimum required %d\n", tll
,
1200 return invoptlv_print(ndo
, dp
, tll
, ops
->op_msk
, indent
);
1204 /* XXX - do anything with ops->flags? */
1206 rc
= ops
->print(ndo
, dp
, tll
, ops
->op_msk
, indent
+ 1);
1211 ND_PRINT("%s", tstr
);
1218 asttlv_print(netdissect_options
*ndo
,
1219 const u_char
* pptr
, u_int len
,
1220 uint16_t op_msk _U_
, int indent
)
1224 char *ib
= indent_pr(indent
, 0);
1227 * forces_type_print() has ensured that len (the TLV length)
1230 dlen
= len
- TLV_HDRL
;
1231 if (dlen
!= ASTDLN
) {
1232 ND_PRINT("illegal ASTresult-TLV: %d bytes!\n", dlen
);
1236 rescode
= EXTRACT_BE_U_4(pptr
);
1237 if (rescode
> ASTMCD
) {
1238 ND_PRINT("illegal ASTresult result code: %d!\n", rescode
);
1242 if (ndo
->ndo_vflag
>= 3) {
1243 ND_PRINT("Teardown reason:\n%s", ib
);
1246 ND_PRINT("Normal Teardown");
1249 ND_PRINT("Loss of Heartbeats");
1252 ND_PRINT("Out of bandwidth");
1255 ND_PRINT("Out of Memory");
1258 ND_PRINT("Application Crash");
1261 ND_PRINT("Unknown Teardown reason");
1264 ND_PRINT("(%x)\n%s", rescode
, ib
);
1269 ND_PRINT("%s", tstr
);
1276 asrtlv_print(netdissect_options
*ndo
,
1277 const u_char
* pptr
, u_int len
,
1278 uint16_t op_msk _U_
, int indent
)
1282 char *ib
= indent_pr(indent
, 0);
1285 * forces_type_print() has ensured that len (the TLV length)
1288 dlen
= len
- TLV_HDRL
;
1289 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
1290 ND_PRINT("illegal ASRresult-TLV: %d bytes!\n", dlen
);
1294 rescode
= EXTRACT_BE_U_4(pptr
);
1296 if (rescode
> ASRMCD
) {
1297 ND_PRINT("illegal ASRresult result code: %d!\n", rescode
);
1301 if (ndo
->ndo_vflag
>= 3) {
1302 ND_PRINT("\n%s", ib
);
1305 ND_PRINT("Success ");
1308 ND_PRINT("FE ID invalid ");
1311 ND_PRINT("permission denied ");
1314 ND_PRINT("Unknown ");
1317 ND_PRINT("(%x)\n%s", rescode
, ib
);
1322 ND_PRINT("%s", tstr
);
1331 gentltlv_print(netdissect_options
*ndo
,
1332 const u_char
* pptr _U_
, u_int len
,
1333 uint16_t op_msk _U_
, int indent _U_
)
1335 u_int dlen
= len
- TLV_HDRL
;
1337 if (dlen
< 4) { /* at least 32 bits must exist */
1338 ND_PRINT("truncated TLV: %d bytes missing! ", 4 - dlen
);
1348 print_metailv(netdissect_options
*ndo
,
1349 const u_char
* pptr
, uint16_t op_msk _U_
, int indent
)
1352 char *ib
= indent_pr(indent
, 0);
1353 /* XXX: check header length */
1354 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
1357 * print_metatlv() has ensured that len (what remains in the
1360 rlen
= EXTRACT_BE_U_4(ilv
->length
) - ILV_HDRL
;
1361 ND_TCHECK_SIZE(ilv
);
1362 ND_PRINT("%sMetaID 0x%x length %d\n", ib
, EXTRACT_BE_U_4(ilv
->type
),
1363 EXTRACT_BE_U_4(ilv
->length
));
1364 if (ndo
->ndo_vflag
>= 3) {
1365 hex_print_with_offset(ndo
, "\t\t[", ILV_DATA(ilv
), rlen
, 0);
1371 ND_PRINT("%s", tstr
);
1376 print_metatlv(netdissect_options
*ndo
,
1377 const u_char
* pptr
, u_int len
,
1378 uint16_t op_msk _U_
, int indent
)
1381 char *ib
= indent_pr(indent
, 0);
1383 const struct forces_ilv
*ilv
= (const struct forces_ilv
*)pptr
;
1387 * redirect_print() has ensured that len (what remains in the
1390 dlen
= len
- TLV_HDRL
;
1392 ND_PRINT("\n%s METADATA length %d \n", ib
, rlen
);
1394 ND_TCHECK_SIZE(ilv
);
1395 invilv
= ilv_valid(ilv
, rlen
);
1401 * At this point, ilv_valid() has ensured that the ILV
1402 * length is large enough but not too large (it doesn't
1403 * go past the end of the containing TLV).
1405 print_metailv(ndo
, (const u_char
*) ilv
, 0, indent
+ 1);
1406 ilv
= GO_NXT_ILV(ilv
, rlen
);
1412 ND_PRINT("%s", tstr
);
1418 print_reddata(netdissect_options
*ndo
,
1419 const u_char
* pptr
, u_int len
,
1420 uint16_t op_msk _U_
, int indent
)
1423 char *ib
= indent_pr(indent
, 0);
1426 dlen
= len
- TLV_HDRL
;
1428 ND_PRINT("\n%s Redirect Data length %d \n", ib
, rlen
);
1430 if (ndo
->ndo_vflag
>= 3) {
1432 hex_print_with_offset(ndo
, "\n\t\t", pptr
, rlen
, 0);
1433 ND_PRINT("\n\t\t]");
1440 redirect_print(netdissect_options
*ndo
,
1441 const u_char
* pptr
, u_int len
,
1442 uint16_t op_msk _U_
, int indent
)
1444 const struct forces_tlv
*tlv
= (const struct forces_tlv
*)pptr
;
1450 * forces_type_print() has ensured that len (the TLV length)
1453 dlen
= len
- TLV_HDRL
;
1454 if (dlen
<= RD_MIN
) {
1455 ND_PRINT("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
1463 ND_TCHECK_SIZE(tlv
);
1464 invtlv
= tlv_valid(tlv
, rlen
);
1466 ND_PRINT("Bad Redirect data\n");
1471 * At this point, tlv_valid() has ensured that the TLV
1472 * length is large enough but not too large (it doesn't
1473 * go past the end of the containing TLV).
1475 if (EXTRACT_BE_U_2(tlv
->type
) == F_TLV_METD
) {
1476 print_metatlv(ndo
, (const u_char
*) TLV_DATA(tlv
),
1477 EXTRACT_BE_U_2(tlv
->length
), 0,
1479 } else if ((EXTRACT_BE_U_2(tlv
->type
) == F_TLV_REDD
)) {
1480 print_reddata(ndo
, (const u_char
*) TLV_DATA(tlv
),
1481 EXTRACT_BE_U_2(tlv
->length
), 0,
1484 ND_PRINT("Unknown REDIRECT TLV 0x%x len %d\n",
1485 EXTRACT_BE_U_2(tlv
->type
),
1486 EXTRACT_BE_U_2(tlv
->length
));
1489 tlv
= GO_NXT_TLV(tlv
, rlen
);
1493 ND_PRINT("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1494 EXTRACT_BE_U_2(tlv
->type
),
1495 rlen
- EXTRACT_BE_U_2(tlv
->length
));
1502 ND_PRINT("%s", tstr
);
1510 lfbselect_print(netdissect_options
*ndo
,
1511 const u_char
* pptr
, u_int len
,
1512 uint16_t op_msk
, int indent
)
1514 const struct forces_lfbsh
*lfbs
;
1515 const struct forces_tlv
*otlv
;
1516 char *ib
= indent_pr(indent
, 0);
1522 * forces_type_print() has ensured that len (the TLV length)
1525 dlen
= len
- TLV_HDRL
;
1526 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
1527 ND_PRINT("\n\t\ttruncated lfb selector: %d bytes missing! ",
1533 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
1534 * we also know that it's > OP_OFF.
1536 rlen
= dlen
- OP_OFF
;
1538 lfbs
= (const struct forces_lfbsh
*)pptr
;
1539 ND_TCHECK_SIZE(lfbs
);
1540 if (ndo
->ndo_vflag
>= 3) {
1541 ND_PRINT("\n%s%s(Classid %x) instance %x\n",
1543 tok2str(ForCES_LFBs
, NULL
, EXTRACT_BE_U_4(lfbs
->class)),
1544 EXTRACT_BE_U_4(lfbs
->class),
1545 EXTRACT_BE_U_4(lfbs
->instance
));
1548 otlv
= (const struct forces_tlv
*)(lfbs
+ 1);
1552 ND_TCHECK_SIZE(otlv
);
1553 invtlv
= tlv_valid(otlv
, rlen
);
1558 * At this point, tlv_valid() has ensured that the TLV
1559 * length is large enough but not too large (it doesn't
1560 * go past the end of the containing TLV).
1562 if (op_valid(EXTRACT_BE_U_2(otlv
->type
), op_msk
)) {
1563 otlv_print(ndo
, otlv
, 0, indent
);
1565 if (ndo
->ndo_vflag
< 3)
1567 ND_PRINT("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
1568 EXTRACT_BE_U_2(otlv
->type
),
1569 EXTRACT_BE_U_2(otlv
->length
));
1570 invoptlv_print(ndo
, (const u_char
*)otlv
, rlen
, 0, indent
);
1572 otlv
= GO_NXT_TLV(otlv
, rlen
);
1576 ND_PRINT("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1577 EXTRACT_BE_U_2(otlv
->type
),
1578 rlen
- EXTRACT_BE_U_2(otlv
->length
));
1585 ND_PRINT("%s", tstr
);
1590 forces_type_print(netdissect_options
*ndo
,
1591 const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
1592 u_int mlen
, const struct tom_h
*tops
)
1594 const struct forces_tlv
*tltlv
;
1601 * forces_print() has already checked that mlen >= ForCES_HDRL
1602 * by calling ForCES_HLN_VALID().
1604 rlen
= mlen
- ForCES_HDRL
;
1606 if (rlen
> TLV_HLN
) {
1607 if (tops
->flags
& ZERO_TTLV
) {
1608 ND_PRINT("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
1612 if (tops
->flags
& ZERO_MORE_TTLV
)
1614 if (tops
->flags
& ONE_MORE_TTLV
) {
1615 ND_PRINT("\tTop level TLV Data missing!\n");
1620 if (tops
->flags
& ZERO_TTLV
) {
1624 ttlv
= tops
->flags
>> 4;
1625 tltlv
= GET_TOP_TLV(pptr
);
1627 /*XXX: 15 top level tlvs will probably be fine
1628 You are nuts if you send more ;-> */
1630 ND_TCHECK_SIZE(tltlv
);
1631 invtlv
= tlv_valid(tltlv
, rlen
);
1636 * At this point, tlv_valid() has ensured that the TLV
1637 * length is large enough but not too large (it doesn't
1638 * go past the end of the packet).
1640 if (!ttlv_valid(EXTRACT_BE_U_2(tltlv
->type
))) {
1641 ND_PRINT("\n\tInvalid ForCES Top TLV type=0x%x",
1642 EXTRACT_BE_U_2(tltlv
->type
));
1646 if (ndo
->ndo_vflag
>= 3)
1647 ND_PRINT("\t%s, length %d (data length %d Bytes)",
1648 tok2str(ForCES_TLV
, NULL
, EXTRACT_BE_U_2(tltlv
->type
)),
1649 EXTRACT_BE_U_2(tltlv
->length
),
1650 EXTRACT_BE_U_2(tltlv
->length
) - TLV_HDRL
);
1652 rc
= tops
->print(ndo
, (const u_char
*) TLV_DATA(tltlv
),
1653 EXTRACT_BE_U_2(tltlv
->length
),
1658 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1664 * XXX - if ttlv != 0, does that mean that the packet was too
1665 * short, and didn't have *enough* TLVs in it?
1668 ND_PRINT("\tMess TopTLV header: min %u, total %d advertised %d ",
1669 TLV_HDRL
, rlen
, EXTRACT_BE_U_2(tltlv
->length
));
1676 ND_PRINT("%s", tstr
);
1681 forces_print(netdissect_options
*ndo
,
1682 const u_char
* pptr
, u_int len
)
1684 const struct forcesh
*fhdr
;
1688 const struct tom_h
*tops
;
1691 fhdr
= (const struct forcesh
*)pptr
;
1692 ND_TCHECK_SIZE(fhdr
);
1693 tom
= EXTRACT_U_1(fhdr
->fm_tom
);
1694 if (!tom_valid(tom
)) {
1695 ND_PRINT("Invalid ForCES message type %d\n", tom
);
1699 mlen
= ForCES_BLN(fhdr
);
1701 tops
= get_forces_tom(tom
);
1702 if (tops
->v
== TOM_RSVD
) {
1703 ND_PRINT("\n\tUnknown ForCES message type=0x%x", tom
);
1707 ND_PRINT("\n\tForCES %s ", tops
->s
);
1708 if (!ForCES_HLN_VALID(mlen
, len
)) {
1709 ND_PRINT("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
1710 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1714 ND_TCHECK_4(pptr
+ 20);
1715 flg_raw
= EXTRACT_BE_U_4(pptr
+ 20);
1716 if (ndo
->ndo_vflag
>= 1) {
1717 ND_PRINT("\n\tForCES Version %d len %uB flags 0x%08x ",
1718 ForCES_V(fhdr
), mlen
, flg_raw
);
1719 ND_PRINT("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1720 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1721 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1722 EXTRACT_BE_U_8(fhdr
->fm_cor
));
1725 if (ndo
->ndo_vflag
>= 2) {
1726 ND_PRINT("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1727 tok2str(ForCES_ACKs
, "ACKUnknown", ForCES_ACK(fhdr
)),
1730 tok2str(ForCES_EMs
, "EMUnknown", ForCES_EM(fhdr
)),
1732 tok2str(ForCES_ATs
, "ATUnknown", ForCES_AT(fhdr
)),
1734 tok2str(ForCES_TPs
, "TPUnknown", ForCES_TP(fhdr
)),
1736 ND_PRINT("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1737 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1739 rc
= forces_type_print(ndo
, pptr
, fhdr
, mlen
, tops
);
1742 hex_print_with_offset(ndo
, "\n\t[", pptr
, len
, 0);
1747 if (ndo
->ndo_vflag
>= 4) {
1748 ND_PRINT("\n\t Raw ForCES message\n\t [");
1749 hex_print_with_offset(ndo
, "\n\t ", pptr
, len
, 0);
1756 ND_PRINT("%s", tstr
);
1760 * c-style: whitesmith