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
21 #include <tcpdump-stdinc.h>
26 #include "interface.h"
29 static const char tstr
[] = "[|forces]";
32 * Per draft-ietf-forces-protocol-22
35 #define ForCES_HDRL 24
36 #define ForCES_ALNL 4U
41 #define TOM_ASSNSETUP 0x1
42 #define TOM_ASSNTEARD 0x2
43 #define TOM_CONFIG 0x3
45 #define TOM_EVENTNOT 0x5
46 #define TOM_PKTREDIR 0x6
47 #define TOM_HEARTBT 0x0F
48 #define TOM_ASSNSETREP 0x11
49 #define TOM_CONFIGREP 0x13
50 #define TOM_QUERYREP 0x14
53 * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
55 #define ZERO_TTLV 0x01
56 #define ZERO_MORE_TTLV 0x02
57 #define ONE_MORE_TTLV 0x04
63 #define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
64 #define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
71 int (*print
) (register const u_char
* pptr
, register u_int len
,
72 u_int16_t op_msk
, int indent
);
89 #define TOM_MAX_IND (_TOM_RSV_MAX - 1)
91 static inline int tom_valid(u_int8_t tom
)
94 if (tom
>= 0x7 && tom
<= 0xe)
105 static inline const char *ForCES_node(u_int32_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 inline const char *ForCES_ACKp(u_int32_t flg
)
137 static inline const char *ForCES_EMp(u_int32_t flg
)
142 return "execute-all-or-none";
144 return "execute-until-failure";
146 return "continue-execute-on-failure";
150 static inline const char *ForCES_ATp(u_int32_t flg
)
155 return "2PCtransaction";
159 static inline const char *ForCES_TPp(u_int32_t flg
)
162 return "StartofTransaction";
164 return "MiddleofTransaction";
166 return "EndofTransaction";
173 * Structure of forces header, naked of TLVs.
176 u_int8_t fm_vrsvd
; /* version and reserved */
177 #define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
178 u_int8_t fm_tom
; /* type of message */
179 u_int16_t fm_len
; /* total length * 4 bytes */
180 #define ForCES_BLN(forcesh) ((u_int32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
181 u_int32_t fm_sid
; /* Source ID */
182 #define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
183 u_int32_t fm_did
; /* Destination ID */
184 #define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
185 u_int8_t fm_cor
[8]; /* correlator */
186 u_int32_t fm_flags
; /* flags */
187 #define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
188 #define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
189 #define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
190 #define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
191 #define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
192 #define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
193 #define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
196 #define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
197 (fhl) >= ForCES_HDRL && \
200 #define F_LFB_RSVD 0x0
201 #define F_LFB_FEO 0x1
202 #define F_LFB_FEPO 0x2
203 static const struct tok ForCES_LFBs
[] = {
204 {F_LFB_RSVD
, "Invalid TLV"},
205 {F_LFB_FEO
, "FEObj LFB"},
206 {F_LFB_FEPO
, "FEProtoObj LFB"},
229 #define F_OP_MAX (_F_OP_MAX - 1)
231 B_OP_SET
= 1 << (F_OP_SET
- 1),
232 B_OP_SETPROP
= 1 << (F_OP_SETPROP
- 1),
233 B_OP_SETRESP
= 1 << (F_OP_SETRESP
- 1),
234 B_OP_SETPRESP
= 1 << (F_OP_SETPRESP
- 1),
235 B_OP_DEL
= 1 << (F_OP_DEL
- 1),
236 B_OP_DELRESP
= 1 << (F_OP_DELRESP
- 1),
237 B_OP_GET
= 1 << (F_OP_GET
- 1),
238 B_OP_GETPROP
= 1 << (F_OP_GETPROP
- 1),
239 B_OP_GETRESP
= 1 << (F_OP_GETRESP
- 1),
240 B_OP_GETPRESP
= 1 << (F_OP_GETPRESP
- 1),
241 B_OP_REPORT
= 1 << (F_OP_REPORT
- 1),
242 B_OP_COMMIT
= 1 << (F_OP_COMMIT
- 1),
243 B_OP_RCOMMIT
= 1 << (F_OP_RCOMMIT
- 1),
244 B_OP_RTRCOMP
= 1 << (F_OP_RTRCOMP
- 1),
251 int (*print
) (register const u_char
* pptr
, register u_int len
,
252 u_int16_t op_msk
, int indent
);
255 static int genoptlv_print(register const u_char
* pptr
, register u_int len
,
256 u_int16_t op_msk
, int indent
);
257 static int recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
258 u_int16_t op_msk
, int indent
);
259 static int invoptlv_print(register const u_char
* pptr
, register u_int len
,
260 u_int16_t op_msk
, int indent
);
275 static const struct optlv_h OPTLV_msg
[F_OP_MAX
+ 1] = {
276 /* F_OP_RSV */ {ZERO_TTLV
, 0, "Invalid OPTLV", invoptlv_print
},
277 /* F_OP_SET */ {TTLV_T2
, B_FULLD
| B_SPARD
, " Set", recpdoptlv_print
},
279 {TTLV_T2
, B_FULLD
| B_SPARD
, " SetProp", recpdoptlv_print
},
280 /* F_OP_SETRESP */ {TTLV_T2
, B_RESTV
, " SetResp", recpdoptlv_print
},
281 /* F_OP_SETPRESP */ {TTLV_T2
, B_RESTV
, " SetPropResp", recpdoptlv_print
},
282 /* F_OP_DEL */ {ZERO_TTLV
, 0, " Del", recpdoptlv_print
},
283 /* F_OP_DELRESP */ {TTLV_T2
, B_RESTV
, " DelResp", recpdoptlv_print
},
284 /* F_OP_GET */ {ZERO_TTLV
, 0, " Get", recpdoptlv_print
},
285 /* F_OP_GETPROP */ {ZERO_TTLV
, 0, " GetProp", recpdoptlv_print
},
287 {TTLV_T2
, B_FULLD
| B_SPARD
| B_RESTV
, " GetResp", recpdoptlv_print
},
289 {TTLV_T2
, B_FULLD
| B_RESTV
, " GetPropResp", recpdoptlv_print
},
291 {TTLV_T2
, B_FULLD
| B_SPARD
, " Report", recpdoptlv_print
},
292 /* F_OP_COMMIT */ {ZERO_TTLV
, 0, " Commit", NULL
},
293 /* F_OP_RCOMMIT */ {TTLV_T1
, B_RESTV
, " RCommit", genoptlv_print
},
294 /* F_OP_RTRCOMP */ {ZERO_TTLV
, 0, " RTRCOMP", NULL
},
297 static inline const struct optlv_h
*get_forces_optlv_h(u_int16_t opt
)
299 if (opt
> F_OP_MAX
|| opt
<= F_OP_RSV
)
300 return &OPTLV_msg
[F_OP_RSV
];
302 return &OPTLV_msg
[opt
];
307 #define IND_PREF '\n'
309 char ind_buf
[IND_SIZE
];
311 static inline char *indent_pr(int indent
, int nlpref
)
316 if (indent
> (IND_SIZE
- 1))
317 indent
= IND_SIZE
- 1;
325 while (--indent
>= 0)
332 static inline int op_valid(u_int16_t op
, u_int16_t mask
)
334 int opb
= 1 << (op
- 1);
340 /* I guess we should allow vendor operations? */
346 #define F_TLV_RSVD 0x0000
347 #define F_TLV_REDR 0x0001
348 #define F_TLV_ASRS 0x0010
349 #define F_TLV_ASRT 0x0011
350 #define F_TLV_LFBS 0x1000
351 #define F_TLV_PDAT 0x0110
352 #define F_TLV_KEYI 0x0111
353 #define F_TLV_FULD 0x0112
354 #define F_TLV_SPAD 0x0113
355 #define F_TLV_REST 0x0114
356 #define F_TLV_METD 0x0115
357 #define F_TLV_REDD 0x0116
358 #define F_TLV_TRNG 0x0117
361 #define F_TLV_VNST 0x8000
363 static const struct tok ForCES_TLV
[] = {
364 {F_TLV_RSVD
, "Invalid TLV"},
365 {F_TLV_REDR
, "REDIRECT TLV"},
366 {F_TLV_ASRS
, "ASResult TLV"},
367 {F_TLV_ASRT
, "ASTreason TLV"},
368 {F_TLV_LFBS
, "LFBselect TLV"},
369 {F_TLV_PDAT
, "PATH-DATA TLV"},
370 {F_TLV_KEYI
, "KEYINFO TLV"},
371 {F_TLV_FULD
, "FULLDATA TLV"},
372 {F_TLV_SPAD
, "SPARSEDATA TLV"},
373 {F_TLV_REST
, "RESULT TLV"},
374 {F_TLV_METD
, "METADATA TLV"},
375 {F_TLV_REDD
, "REDIRECTDATA TLV"},
380 static inline int ttlv_valid(u_int16_t ttlv
)
383 if (ttlv
== 1 || ttlv
== 0x1000)
385 if (ttlv
>= 0x10 && ttlv
<= 0x11)
387 if (ttlv
>= 0x110 && ttlv
<= 0x116)
406 #define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
407 #define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
408 #define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
409 #define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
410 #define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
411 #define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0)))
412 #define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
413 (struct forces_tlv*)(((char*)(tlv)) \
414 + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
415 #define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
416 #define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
417 #define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
418 #define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0)))
419 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
420 (struct forces_ilv *)(((char*)(ilv)) \
421 + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
422 #define INVALID_RLEN -1
423 #define INVALID_STLN -2
424 #define INVALID_LTLN -3
425 #define INVALID_ALEN -4
427 static const struct tok ForCES_TLV_err
[] = {
428 {INVALID_RLEN
, "Invalid total length"},
429 {INVALID_STLN
, "xLV too short"},
430 {INVALID_LTLN
, "xLV too long"},
431 {INVALID_ALEN
, "data padding missing"},
435 static inline int tlv_valid(const struct forces_tlv
*tlv
, u_int rlen
)
439 if (EXTRACT_16BITS(&tlv
->length
) < TLV_HDRL
)
441 if (EXTRACT_16BITS(&tlv
->length
) > rlen
)
443 if (rlen
< F_ALN_LEN(EXTRACT_16BITS(&tlv
->length
)))
449 static inline int ilv_valid(const struct forces_ilv
*ilv
, u_int rlen
)
453 if (EXTRACT_32BITS(&ilv
->length
) < ILV_HDRL
)
455 if (EXTRACT_32BITS(&ilv
->length
) > rlen
)
457 if (rlen
< F_ALN_LEN(EXTRACT_32BITS(&ilv
->length
)))
463 static int lfbselect_print(register const u_char
* pptr
, register u_int len
,
464 u_int16_t op_msk
, int indent
);
465 static int redirect_print(register const u_char
* pptr
, register u_int len
,
466 u_int16_t op_msk
, int indent
);
467 static int asrtlv_print(register const u_char
* pptr
, register u_int len
,
468 u_int16_t op_msk
, int indent
);
469 static int asttlv_print(register const u_char
* pptr
, register u_int len
,
470 u_int16_t op_msk
, int indent
);
472 struct forces_lfbsh
{
477 #define ASSNS_OPS (B_OP_REPORT)
478 #define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
479 #define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
480 #define CFG_QY (B_OP_GET|B_OP_GETPROP)
481 #define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
482 #define CFG_EVN (B_OP_REPORT)
484 static const struct tom_h ForCES_msg
[TOM_MAX_IND
+ 1] = {
485 /* TOM_RSV_I */ {TOM_RSVD
, ZERO_TTLV
, 0, "Invalid message", NULL
},
486 /* TOM_ASS_I */ {TOM_ASSNSETUP
, ZERO_MORE_TTLV
| TWO_TLV
, ASSNS_OPS
,
487 "Association Setup", lfbselect_print
},
489 {TOM_ASSNTEARD
, TTLV_T1
, 0, "Association TearDown", asttlv_print
},
490 /* TOM_CFG_I */ {TOM_CONFIG
, TTLV_T2
, CFG_OPS
, "Config", lfbselect_print
},
491 /* TOM_QRY_I */ {TOM_QUERY
, TTLV_T2
, CFG_QY
, "Query", lfbselect_print
},
492 /* TOM_EVN_I */ {TOM_EVENTNOT
, TTLV_T1
, CFG_EVN
, "Event Notification",
495 {TOM_PKTREDIR
, TTLV_T2
, 0, "Packet Redirect", redirect_print
},
496 /* TOM_HBT_I */ {TOM_HEARTBT
, ZERO_TTLV
, 0, "HeartBeat", NULL
},
498 {TOM_ASSNSETREP
, TTLV_T1
, 0, "Association Response", asrtlv_print
},
499 /* TOM_CNR_I */ {TOM_CONFIGREP
, TTLV_T2
, CFG_ROPS
, "Config Response",
502 {TOM_QUERYREP
, TTLV_T2
, CFG_QYR
, "Query Response", lfbselect_print
},
505 static inline const struct tom_h
*get_forces_tom(u_int8_t tom
)
508 for (i
= TOM_RSV_I
; i
<= TOM_MAX_IND
; i
++) {
509 const struct tom_h
*th
= &ForCES_msg
[i
];
513 return &ForCES_msg
[TOM_RSV_I
];
521 int (*print
) (register const u_char
* pptr
, register u_int len
,
522 u_int16_t op_msk
, int indent
);
534 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
536 static inline int pd_valid(u_int16_t pd
)
538 if (pd
>= F_TLV_PDAT
&& pd
<= F_TLV_REST
)
543 static inline void chk_op_type(u_int16_t type
, u_int16_t msk
, u_int16_t omsk
)
545 if (type
!= F_TLV_PDAT
) {
547 if (type
!= F_TLV_KEYI
) {
549 ("Based on flags expected KEYINFO TLV!\n");
554 ("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
563 #define F_SELTABRANGE 2
564 #define F_TABAPPEND 4
572 static int prestlv_print(register const u_char
* pptr
, register u_int len
,
573 u_int16_t op_msk
, int indent
);
574 static int pkeyitlv_print(register const u_char
* pptr
, register u_int len
,
575 u_int16_t op_msk
, int indent
);
576 static int fdatatlv_print(register const u_char
* pptr
, register u_int len
,
577 u_int16_t op_msk
, int indent
);
578 static int sdatatlv_print(register const u_char
* pptr
, register u_int len
,
579 u_int16_t op_msk
, int indent
);
581 static const struct pdata_ops ForCES_pdata
[PD_MAX_IND
+ 1] = {
582 /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL
},
583 /* PD_SEL_I */ {F_TLV_KEYI
, 0, 0, "KEYINFO TLV", pkeyitlv_print
},
584 /* PD_FDT_I */ {F_TLV_FULD
, 0, B_FULLD
, "FULLDATA TLV", fdatatlv_print
},
585 /* PD_SDT_I */ {F_TLV_SPAD
, 0, B_SPARD
, "SPARSEDATA TLV", sdatatlv_print
},
586 /* PD_RES_I */ {F_TLV_REST
, 0, B_RESTV
, "RESULT TLV", prestlv_print
},
588 {F_TLV_PDAT
, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print
},
591 static inline const struct pdata_ops
*get_forces_pd(u_int16_t pd
)
594 for (i
= PD_RSV_I
+ 1; i
<= PD_MAX_IND
; i
++) {
595 const struct pdata_ops
*pdo
= &ForCES_pdata
[i
];
599 return &ForCES_pdata
[TOM_RSV_I
];
607 E_INVALID_DESTINATION_PID
,
610 E_LFB_INSTANCE_ID_NOT_FOUND
,
612 E_COMPONENT_DOES_NOT_EXIST
,
616 E_INVALID_ARRAY_CREATION
,
617 E_VALUE_OUT_OF_RANGE
,
619 E_INVALID_PARAMETERS
,
620 E_INVALID_MESSAGE_TYPE
,
627 /* 0x18-0xFE are reserved .. */
628 E_UNSPECIFIED_ERROR
= 0XFF
631 static const struct tok ForCES_errs
[] = {
632 {E_SUCCESS
, "SUCCESS"},
633 {E_INVALID_HEADER
, "INVALID HEADER"},
634 {E_LENGTH_MISMATCH
, "LENGTH MISMATCH"},
635 {E_VERSION_MISMATCH
, "VERSION MISMATCH"},
636 {E_INVALID_DESTINATION_PID
, "INVALID DESTINATION PID"},
637 {E_LFB_UNKNOWN
, "LFB UNKNOWN"},
638 {E_LFB_NOT_FOUND
, "LFB NOT FOUND"},
639 {E_LFB_INSTANCE_ID_NOT_FOUND
, "LFB INSTANCE ID NOT FOUND"},
640 {E_INVALID_PATH
, "INVALID PATH"},
641 {E_COMPONENT_DOES_NOT_EXIST
, "COMPONENT DOES NOT EXIST"},
642 {E_EXISTS
, "EXISTS ALREADY"},
643 {E_NOT_FOUND
, "NOT FOUND"},
644 {E_READ_ONLY
, "READ ONLY"},
645 {E_INVALID_ARRAY_CREATION
, "INVALID ARRAY CREATION"},
646 {E_VALUE_OUT_OF_RANGE
, "VALUE OUT OF RANGE"},
647 {E_CONTENTS_TOO_LONG
, "CONTENTS TOO LONG"},
648 {E_INVALID_PARAMETERS
, "INVALID PARAMETERS"},
649 {E_INVALID_MESSAGE_TYPE
, "INVALID MESSAGE TYPE"},
650 {E_INVALID_FLAGS
, "INVALID FLAGS"},
651 {E_INVALID_TLV
, "INVALID TLV"},
652 {E_EVENT_ERROR
, "EVENT ERROR"},
653 {E_NOT_SUPPORTED
, "NOT SUPPORTED"},
654 {E_MEMORY_ERROR
, "MEMORY ERROR"},
655 {E_INTERNAL_ERROR
, "INTERNAL ERROR"},
656 {E_UNSPECIFIED_ERROR
, "UNSPECIFIED ERROR"},
663 prestlv_print(register const u_char
* pptr
, register u_int len
,
664 u_int16_t op_msk _U_
, int indent
)
666 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
667 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
668 struct res_val
*r
= (struct res_val
*)tdp
;
672 * pdatacnt_print() has ensured that len (the TLV length)
675 dlen
= len
- TLV_HDRL
;
676 if (dlen
!= RESLEN
) {
677 printf("illegal RESULT-TLV: %d bytes!\n", dlen
);
682 if (r
->result
>= 0x18 && r
->result
<= 0xFE) {
683 printf("illegal reserved result code: 0x%x!\n", r
->result
);
688 char *ib
= indent_pr(indent
, 0);
689 printf("%s Result: %s (code 0x%x)\n", ib
,
690 tok2str(ForCES_errs
, NULL
, r
->result
), r
->result
);
700 fdatatlv_print(register const u_char
* pptr
, register u_int len
,
701 u_int16_t op_msk _U_
, int indent
)
703 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
705 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
709 * pdatacnt_print() or pkeyitlv_print() has ensured that len
710 * (the TLV length) >= TLV_HDRL.
712 rlen
= len
- TLV_HDRL
;
714 type
= EXTRACT_16BITS(&tlv
->type
);
715 if (type
!= F_TLV_FULD
) {
716 printf("Error: expecting FULLDATA!\n");
721 char *ib
= indent_pr(indent
+ 2, 1);
722 printf("%s[", &ib
[1]);
723 hex_print_with_offset(ib
, tdp
, rlen
, 0);
724 printf("\n%s]\n", &ib
[1]);
734 sdatailv_print(register const u_char
* pptr
, register u_int len
,
735 u_int16_t op_msk _U_
, int indent
)
738 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
741 if (len
< ILV_HDRL
) {
742 printf("Error: BAD SPARSEDATA-TLV!\n");
749 printf("Jamal - outstanding length <%d>\n", rlen
);
751 char *ib
= indent_pr(indent
, 1);
752 register const u_char
*tdp
= (u_char
*) ILV_DATA(ilv
);
754 invilv
= ilv_valid(ilv
, rlen
);
756 printf("%s[", &ib
[1]);
757 hex_print_with_offset(ib
, tdp
, rlen
, 0);
758 printf("\n%s]\n", &ib
[1]);
762 int ilvl
= EXTRACT_32BITS(&ilv
->length
);
763 printf("\n%s ILV: type %x length %d\n", &ib
[1],
764 EXTRACT_32BITS(&ilv
->type
), ilvl
);
765 hex_print_with_offset("\t\t[", tdp
, ilvl
-ILV_HDRL
, 0);
768 ilv
= GO_NXT_ILV(ilv
, rlen
);
779 sdatatlv_print(register const u_char
* pptr
, register u_int len
,
780 u_int16_t op_msk
, int indent
)
782 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
784 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
788 * pdatacnt_print() has ensured that len (the TLV length)
791 rlen
= len
- TLV_HDRL
;
793 type
= EXTRACT_16BITS(&tlv
->type
);
794 if (type
!= F_TLV_SPAD
) {
795 printf("Error: expecting SPARSEDATA!\n");
799 return sdatailv_print(tdp
, rlen
, op_msk
, indent
);
807 pkeyitlv_print(register const u_char
* pptr
, register u_int len
,
808 u_int16_t op_msk
, int indent
)
810 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
811 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
812 register const u_char
*dp
= tdp
+ 4;
813 const struct forces_tlv
*kdtlv
= (struct forces_tlv
*)dp
;
815 char *ib
= indent_pr(indent
, 0);
820 id
= EXTRACT_32BITS(tdp
);
821 printf("%sKeyinfo: Key 0x%x\n", ib
, id
);
823 type
= EXTRACT_16BITS(&kdtlv
->type
);
824 invtlv
= tlv_valid(kdtlv
, len
);
827 printf("%s TLV type 0x%x len %d\n",
828 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
829 EXTRACT_16BITS(&kdtlv
->length
));
833 * At this point, tlv_valid() has ensured that the TLV
834 * length is large enough but not too large (it doesn't
835 * go past the end of the containing TLV).
837 tll
= EXTRACT_16BITS(&kdtlv
->length
);
838 dp
= (u_char
*) TLV_DATA(kdtlv
);
839 return fdatatlv_print(dp
, tll
, op_msk
, indent
);
846 #define PTH_DESC_SIZE 12
849 pdatacnt_print(register const u_char
* pptr
, register u_int len
,
850 u_int16_t IDcnt
, u_int16_t op_msk
, int indent
)
854 char *ib
= indent_pr(indent
, 0);
856 if ((op_msk
& B_APPND
) && vflag
>= 3) {
857 printf("%sTABLE APPEND\n", ib
);
859 for (i
= 0; i
< IDcnt
; i
++) {
863 id
= EXTRACT_32BITS(pptr
);
865 printf("%sID#%02u: %d\n", ib
, i
+ 1, id
);
870 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
871 if (op_msk
& B_TRNG
) {
872 u_int32_t starti
, endi
;
874 if (len
< PTH_DESC_SIZE
) {
875 printf("pathlength %d with key/range too short %d\n",
880 pptr
+= sizeof(struct forces_tlv
);
881 len
-= sizeof(struct forces_tlv
);
883 starti
= EXTRACT_32BITS(pptr
);
887 endi
= EXTRACT_32BITS(pptr
);
892 printf("%sTable range: [%d,%d]\n", ib
, starti
, endi
);
895 if (op_msk
& B_KEYIN
) {
896 struct forces_tlv
*keytlv
;
899 if (len
< PTH_DESC_SIZE
) {
900 printf("pathlength %d with key/range too short %d\n",
908 keytlv
= (struct forces_tlv
*)pptr
;
910 pptr
+= sizeof(struct forces_tlv
);
911 len
-= sizeof(struct forces_tlv
);
912 /* skip key content */
913 tll
= EXTRACT_16BITS(&keytlv
->length
);
914 if (tll
< TLV_HDRL
) {
915 printf("key content length %u < %u\n",
921 printf("key content too short\n");
931 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
939 type
= EXTRACT_16BITS(&pdtlv
->type
);
940 invtlv
= tlv_valid(pdtlv
, len
);
943 ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
944 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
945 EXTRACT_16BITS(&pdtlv
->length
));
949 * At this point, tlv_valid() has ensured that the TLV
950 * length is large enough but not too large (it doesn't
951 * go past the end of the containing TLV).
953 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
954 aln
= F_ALN_LEN(EXTRACT_16BITS(&pdtlv
->length
));
955 if (aln
> EXTRACT_16BITS(&pdtlv
->length
)) {
958 ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
959 type
, EXTRACT_16BITS(&pdtlv
->length
), aln
- len
);
961 pad
= aln
- EXTRACT_16BITS(&pdtlv
->length
);
964 if (pd_valid(type
)) {
965 const struct pdata_ops
*ops
= get_forces_pd(type
);
967 if (vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
970 ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
971 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
975 ("%s %s (Length %d DataLen %d Bytes)\n",
976 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
980 chk_op_type(type
, op_msk
, ops
->op_msk
);
982 if (ops
->print((const u_char
*)pdtlv
,
983 tll
+ pad
+ TLV_HDRL
, op_msk
,
986 len
-= (TLV_HDRL
+ pad
+ tll
);
988 printf("Invalid path data content type 0x%x len %d\n",
989 type
, EXTRACT_16BITS(&pdtlv
->length
));
991 if (EXTRACT_16BITS(&pdtlv
->length
)) {
992 hex_print_with_offset("Bad Data val\n\t [",
1008 pdata_print(register const u_char
* pptr
, register u_int len
,
1009 u_int16_t op_msk
, int indent
)
1011 const struct pathdata_h
*pdh
= (struct pathdata_h
*)pptr
;
1012 char *ib
= indent_pr(indent
, 0);
1015 u_int16_t idcnt
= 0;
1018 if (len
< sizeof(struct pathdata_h
))
1021 printf("\n%sPathdata: Flags 0x%x ID count %d\n",
1022 ib
, EXTRACT_16BITS(&pdh
->pflags
), EXTRACT_16BITS(&pdh
->pIDcnt
));
1025 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELKEY
) {
1029 /* Table GET Range operation */
1030 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELTABRANGE
) {
1033 /* Table SET append operation */
1034 if (EXTRACT_16BITS(&pdh
->pflags
) & F_TABAPPEND
) {
1038 pptr
+= sizeof(struct pathdata_h
);
1039 len
-= sizeof(struct pathdata_h
);
1040 idcnt
= EXTRACT_16BITS(&pdh
->pIDcnt
);
1041 minsize
= idcnt
* 4;
1042 if (len
< minsize
) {
1043 printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
1045 hex_print_with_offset("\t\t\tID Data[", pptr
, len
, 0);
1050 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
1051 printf("\t\t\tIllegal to have both Table ranges and keys\n");
1055 more_pd
= pdatacnt_print(pptr
, len
, idcnt
, op_msk
, indent
);
1057 int consumed
= len
- more_pd
;
1060 /* XXX: Argh, recurse some more */
1061 return recpdoptlv_print(pptr
, len
, op_msk
, indent
+1);
1071 genoptlv_print(register const u_char
* pptr
, register u_int len
,
1072 u_int16_t op_msk
, int indent
)
1074 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
1078 char *ib
= indent_pr(indent
, 0);
1081 type
= EXTRACT_16BITS(&pdtlv
->type
);
1082 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
1083 invtlv
= tlv_valid(pdtlv
, len
);
1084 printf("genoptlvprint - %s TLV type 0x%x len %d\n",
1085 tok2str(ForCES_TLV
, NULL
, type
), type
, EXTRACT_16BITS(&pdtlv
->length
));
1088 * At this point, tlv_valid() has ensured that the TLV
1089 * length is large enough but not too large (it doesn't
1090 * go past the end of the containing TLV).
1092 register const u_char
*dp
= (u_char
*) TLV_DATA(pdtlv
);
1093 if (!ttlv_valid(type
)) {
1094 printf("%s TLV type 0x%x len %d\n",
1095 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
1096 EXTRACT_16BITS(&pdtlv
->length
));
1100 printf("%s%s, length %d (data length %d Bytes)",
1101 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1102 EXTRACT_16BITS(&pdtlv
->length
), tll
);
1104 return pdata_print(dp
, tll
, op_msk
, indent
+ 1);
1106 printf("\t\t\tInvalid ForCES TLV type=%x", type
);
1116 recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
1117 u_int16_t op_msk
, int indent
)
1119 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
1123 register const u_char
*dp
;
1128 invtlv
= tlv_valid(pdtlv
, len
);
1134 * At this point, tlv_valid() has ensured that the TLV
1135 * length is large enough but not too large (it doesn't
1136 * go past the end of the containing TLV).
1138 ib
= indent_pr(indent
, 0);
1139 type
= EXTRACT_16BITS(&pdtlv
->type
);
1140 dp
= (u_char
*) TLV_DATA(pdtlv
);
1141 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
1145 ("%s%s, length %d (data encapsulated %d Bytes)",
1146 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1147 EXTRACT_16BITS(&pdtlv
->length
),
1148 EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
);
1150 if (pdata_print(dp
, tll
, op_msk
, indent
+ 1) == -1)
1152 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
1157 ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1158 EXTRACT_16BITS(&pdtlv
->type
), len
- EXTRACT_16BITS(&pdtlv
->length
));
1170 invoptlv_print(register const u_char
* pptr
, register u_int len
,
1171 u_int16_t op_msk _U_
, int indent
)
1173 char *ib
= indent_pr(indent
, 1);
1176 printf("%sData[", &ib
[1]);
1177 hex_print_with_offset(ib
, pptr
, len
, 0);
1178 printf("%s]\n", ib
);
1184 otlv_print(const struct forces_tlv
*otlv
, u_int16_t op_msk _U_
, int indent
)
1187 register const u_char
*dp
= (u_char
*) TLV_DATA(otlv
);
1190 char *ib
= indent_pr(indent
, 0);
1191 const struct optlv_h
*ops
;
1194 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
1198 type
= EXTRACT_16BITS(&otlv
->type
);
1199 tll
= EXTRACT_16BITS(&otlv
->length
) - TLV_HDRL
;
1200 ops
= get_forces_optlv_h(type
);
1202 printf("%sOper TLV %s(0x%x) length %d\n", ib
, ops
->s
, type
,
1203 EXTRACT_16BITS(&otlv
->length
));
1205 /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
1206 if (!ops
->flags
& ZERO_TTLV
) {
1207 if (tll
!= 0) /* instead of "if (tll)" - for readability .. */
1208 printf("%s: Illegal - MUST be empty\n", ops
->s
);
1211 /* rest of ops must at least have 12B {pathinfo} */
1212 if (tll
< OP_MIN_SIZ
) {
1213 printf("\t\tOper TLV %s(0x%x) length %d\n", ops
->s
, type
,
1214 EXTRACT_16BITS(&otlv
->length
));
1215 printf("\t\tTruncated data size %d minimum required %d\n", tll
,
1217 return invoptlv_print(dp
, tll
, ops
->op_msk
, indent
);
1221 rc
= ops
->print(dp
, tll
, ops
->op_msk
, indent
+ 1);
1232 asttlv_print(register const u_char
* pptr
, register u_int len
,
1233 u_int16_t op_msk _U_
, int indent
)
1237 char *ib
= indent_pr(indent
, 0);
1240 * forces_type_print() has ensured that len (the TLV length)
1243 dlen
= len
- TLV_HDRL
;
1244 if (dlen
!= ASTDLN
) {
1245 printf("illegal ASTresult-TLV: %d bytes!\n", dlen
);
1249 rescode
= EXTRACT_32BITS(pptr
);
1250 if (rescode
> ASTMCD
) {
1251 printf("illegal ASTresult result code: %d!\n", rescode
);
1256 printf("Teardown reason:\n%s", ib
);
1259 printf("Normal Teardown");
1262 printf("Loss of Heartbeats");
1265 printf("Out of bandwidth");
1268 printf("Out of Memory");
1271 printf("Application Crash");
1274 printf("Unknown Teardown reason");
1277 printf("(%x)\n%s", rescode
, ib
);
1289 asrtlv_print(register const u_char
* pptr
, register u_int len
,
1290 u_int16_t op_msk _U_
, int indent
)
1294 char *ib
= indent_pr(indent
, 0);
1297 * forces_type_print() has ensured that len (the TLV length)
1300 dlen
= len
- TLV_HDRL
;
1301 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
1302 printf("illegal ASRresult-TLV: %d bytes!\n", dlen
);
1306 rescode
= EXTRACT_32BITS(pptr
);
1308 if (rescode
> ASRMCD
) {
1309 printf("illegal ASRresult result code: %d!\n", rescode
);
1320 printf("FE ID invalid ");
1323 printf("permission denied ");
1329 printf("(%x)\n%s", rescode
, ib
);
1343 gentltlv_print(register const u_char
* pptr _U_
, register u_int len
,
1344 u_int16_t op_msk _U_
, int indent _U_
)
1346 u_int dlen
= len
- TLV_HDRL
;
1348 if (dlen
< 4) { /* at least 32 bits must exist */
1349 printf("truncated TLV: %d bytes missing! ", 4 - dlen
);
1359 print_metailv(register const u_char
* pptr
, register u_int len
,
1360 u_int16_t op_msk _U_
, int indent
)
1364 char *ib
= indent_pr(indent
, 0);
1365 /* XXX: check header length */
1366 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
1369 * print_metatlv() has ensured that len (what remains in the
1372 rlen
= EXTRACT_32BITS(&ilv
->length
) - ILV_HDRL
;
1374 printf("%sMetaID 0x%x length %d\n", ib
, EXTRACT_32BITS(&ilv
->type
),
1375 EXTRACT_32BITS(&ilv
->length
));
1377 hex_print_with_offset("\t\t[", ILV_DATA(ilv
), rlen
, 0);
1388 print_metatlv(register const u_char
* pptr
, register u_int len
,
1389 u_int16_t op_msk _U_
, int indent
)
1392 char *ib
= indent_pr(indent
, 0);
1394 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
1398 * redirect_print() has ensured that len (what remains in the
1401 dlen
= len
- TLV_HDRL
;
1403 printf("\n%s METADATA length %d \n", ib
, rlen
);
1406 invilv
= ilv_valid(ilv
, rlen
);
1412 * At this point, ilv_valid() has ensured that the ILV
1413 * length is large enough but not too large (it doesn't
1414 * go past the end of the containing TLV).
1416 print_metailv((u_char
*) ilv
, rlen
, 0, indent
+ 1);
1417 ilv
= GO_NXT_ILV(ilv
, rlen
);
1429 print_reddata(register const u_char
* pptr
, register u_int len
,
1430 u_int16_t op_msk _U_
, int indent _U_
)
1433 char *ib
= indent_pr(indent
, 0);
1436 dlen
= len
- TLV_HDRL
;
1438 printf("\n%s Redirect Data length %d \n", ib
, rlen
);
1442 hex_print_with_offset("\n\t\t", pptr
, rlen
, 0);
1450 redirect_print(register const u_char
* pptr
, register u_int len
,
1451 u_int16_t op_msk _U_
, int indent
)
1453 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
1459 * forces_type_print() has ensured that len (the TLV length)
1462 dlen
= len
- TLV_HDRL
;
1463 if (dlen
<= RD_MIN
) {
1464 printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
1473 invtlv
= tlv_valid(tlv
, rlen
);
1475 printf("Bad Redirect data\n");
1480 * At this point, tlv_valid() has ensured that the TLV
1481 * length is large enough but not too large (it doesn't
1482 * go past the end of the containing TLV).
1484 if (EXTRACT_16BITS(&tlv
->type
) == F_TLV_METD
) {
1485 print_metatlv((u_char
*) TLV_DATA(tlv
),
1486 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
1487 } else if ((EXTRACT_16BITS(&tlv
->type
) == F_TLV_REDD
)) {
1488 print_reddata((u_char
*) TLV_DATA(tlv
),
1489 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
1491 printf("Unknown REDIRECT TLV 0x%x len %d\n",
1492 EXTRACT_16BITS(&tlv
->type
),
1493 EXTRACT_16BITS(&tlv
->length
));
1496 tlv
= GO_NXT_TLV(tlv
, rlen
);
1501 ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1502 EXTRACT_16BITS(&tlv
->type
),
1503 rlen
- EXTRACT_16BITS(&tlv
->length
));
1518 lfbselect_print(register const u_char
* pptr
, register u_int len
,
1519 u_int16_t op_msk
, int indent
)
1521 const struct forces_lfbsh
*lfbs
;
1522 const struct forces_tlv
*otlv
;
1523 char *ib
= indent_pr(indent
, 0);
1529 * forces_type_print() has ensured that len (the TLV length)
1532 dlen
= len
- TLV_HDRL
;
1533 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
1534 printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
1540 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
1541 * we also know that it's > OP_OFF.
1543 rlen
= dlen
- OP_OFF
;
1545 lfbs
= (const struct forces_lfbsh
*)pptr
;
1548 printf("\n%s%s(Classid %x) instance %x\n",
1549 ib
, tok2str(ForCES_LFBs
, NULL
, EXTRACT_32BITS(&lfbs
->class)),
1550 EXTRACT_32BITS(&lfbs
->class),
1551 EXTRACT_32BITS(&lfbs
->instance
));
1554 otlv
= (struct forces_tlv
*)(lfbs
+ 1);
1559 invtlv
= tlv_valid(otlv
, rlen
);
1564 * At this point, tlv_valid() has ensured that the TLV
1565 * length is large enough but not too large (it doesn't
1566 * go past the end of the containing TLV).
1568 if (op_valid(EXTRACT_16BITS(&otlv
->type
), op_msk
)) {
1569 otlv_print(otlv
, 0, indent
);
1574 ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
1575 EXTRACT_16BITS(&otlv
->type
), EXTRACT_16BITS(&otlv
->length
));
1576 invoptlv_print((u_char
*)otlv
, rlen
, 0, indent
);
1578 otlv
= GO_NXT_TLV(otlv
, rlen
);
1583 ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1584 EXTRACT_16BITS(&otlv
->type
), rlen
- EXTRACT_16BITS(&otlv
->length
));
1596 forces_type_print(register const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
1597 register u_int mlen
, const struct tom_h
*tops
)
1599 const struct forces_tlv
*tltlv
;
1606 * forces_print() has already checked that mlen >= ForCES_HDRL
1607 * by calling ForCES_HLN_VALID().
1609 rlen
= mlen
- ForCES_HDRL
;
1611 if (rlen
> TLV_HLN
) {
1612 if (tops
->flags
& ZERO_TTLV
) {
1613 printf("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
1617 if (tops
->flags
& ZERO_MORE_TTLV
)
1619 if (tops
->flags
& ONE_MORE_TTLV
) {
1620 printf("\tTop level TLV Data missing!\n");
1625 if (tops
->flags
& ZERO_TTLV
) {
1629 ttlv
= tops
->flags
>> 4;
1630 tltlv
= GET_TOP_TLV(pptr
);
1632 /*XXX: 15 top level tlvs will probably be fine
1633 You are nuts if you send more ;-> */
1636 invtlv
= tlv_valid(tltlv
, rlen
);
1641 * At this point, tlv_valid() has ensured that the TLV
1642 * length is large enough but not too large (it doesn't
1643 * go past the end of the packet).
1645 if (!ttlv_valid(EXTRACT_16BITS(&tltlv
->type
))) {
1646 printf("\n\tInvalid ForCES Top TLV type=0x%x",
1647 EXTRACT_16BITS(&tltlv
->type
));
1652 printf("\t%s, length %d (data length %d Bytes)",
1653 tok2str(ForCES_TLV
, NULL
, EXTRACT_16BITS(&tltlv
->type
)),
1654 EXTRACT_16BITS(&tltlv
->length
),
1655 EXTRACT_16BITS(&tltlv
->length
) - TLV_HDRL
);
1657 rc
= tops
->print((u_char
*) TLV_DATA(tltlv
),
1658 EXTRACT_16BITS(&tltlv
->length
), tops
->op_msk
, 9);
1662 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1668 * XXX - if ttlv != 0, does that mean that the packet was too
1669 * short, and didn't have *enough* TLVs in it?
1672 printf("\tMess TopTLV header: min %u, total %d advertised %d ",
1673 TLV_HDRL
, rlen
, EXTRACT_16BITS(&tltlv
->length
));
1685 forces_print(register const u_char
* pptr
, register u_int len
)
1687 const struct forcesh
*fhdr
;
1690 const struct tom_h
*tops
;
1693 fhdr
= (const struct forcesh
*)pptr
;
1695 if (!tom_valid(fhdr
->fm_tom
)) {
1696 printf("Invalid ForCES message type %d\n", fhdr
->fm_tom
);
1700 mlen
= ForCES_BLN(fhdr
);
1702 tops
= get_forces_tom(fhdr
->fm_tom
);
1703 if (tops
->v
== TOM_RSVD
) {
1704 printf("\n\tUnknown ForCES message type=0x%x", fhdr
->fm_tom
);
1708 printf("\n\tForCES %s ", tops
->s
);
1709 if (!ForCES_HLN_VALID(mlen
, len
)) {
1711 ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
1712 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1716 TCHECK2(*(pptr
+ 20), 4);
1717 flg_raw
= EXTRACT_32BITS(pptr
+ 20);
1719 printf("\n\tForCES Version %d len %uB flags 0x%08x ",
1720 ForCES_V(fhdr
), mlen
, flg_raw
);
1721 printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1722 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1723 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1724 EXTRACT_64BITS(fhdr
->fm_cor
));
1729 ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1730 ForCES_ACKp(ForCES_ACK(fhdr
)), ForCES_ACK(fhdr
),
1732 ForCES_EMp(ForCES_EM(fhdr
)), ForCES_EM(fhdr
),
1733 ForCES_ATp(ForCES_AT(fhdr
)), ForCES_AT(fhdr
),
1734 ForCES_TPp(ForCES_TP(fhdr
)), ForCES_TP(fhdr
));
1736 ("\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(pptr
, fhdr
, mlen
, tops
);
1742 hex_print_with_offset("\n\t[", pptr
, len
, 0);
1748 printf("\n\t Raw ForCES message\n\t [");
1749 hex_print_with_offset("\n\t ", pptr
, len
, 0);