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 const struct tok ForCES_ACKs
[] = {
132 static const struct tok ForCES_EMs
[] = {
134 {0x1, "execute-all-or-none"},
135 {0x2, "execute-until-failure"},
136 {0x3, "continue-execute-on-failure"},
140 static const struct tok ForCES_ATs
[] = {
142 {0x1, "2PCtransaction"},
146 static const struct tok ForCES_TPs
[] = {
147 {0x0, "StartofTransaction"},
148 {0x1, "MiddleofTransaction"},
149 {0x2, "EndofTransaction"},
155 * Structure of forces header, naked of TLVs.
158 u_int8_t fm_vrsvd
; /* version and reserved */
159 #define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
160 u_int8_t fm_tom
; /* type of message */
161 u_int16_t fm_len
; /* total length * 4 bytes */
162 #define ForCES_BLN(forcesh) ((u_int32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
163 u_int32_t fm_sid
; /* Source ID */
164 #define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
165 u_int32_t fm_did
; /* Destination ID */
166 #define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
167 u_int8_t fm_cor
[8]; /* correlator */
168 u_int32_t fm_flags
; /* flags */
169 #define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
170 #define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
171 #define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
172 #define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
173 #define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
174 #define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
175 #define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
178 #define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
179 (fhl) >= ForCES_HDRL && \
182 #define F_LFB_RSVD 0x0
183 #define F_LFB_FEO 0x1
184 #define F_LFB_FEPO 0x2
185 static const struct tok ForCES_LFBs
[] = {
186 {F_LFB_RSVD
, "Invalid TLV"},
187 {F_LFB_FEO
, "FEObj LFB"},
188 {F_LFB_FEPO
, "FEProtoObj LFB"},
211 #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
) (register const u_char
* pptr
, register u_int len
,
234 u_int16_t op_msk
, int indent
);
237 static int genoptlv_print(register const u_char
* pptr
, register u_int len
,
238 u_int16_t op_msk
, int indent
);
239 static int recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
240 u_int16_t op_msk
, int indent
);
241 static int invoptlv_print(register const u_char
* pptr
, register u_int len
,
242 u_int16_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(u_int16_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 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(u_int16_t op
, u_int16_t mask
)
316 int opb
= 1 << (op
- 1);
322 /* I guess we should allow vendor operations? */
328 #define F_TLV_RSVD 0x0000
329 #define F_TLV_REDR 0x0001
330 #define F_TLV_ASRS 0x0010
331 #define F_TLV_ASRT 0x0011
332 #define F_TLV_LFBS 0x1000
333 #define F_TLV_PDAT 0x0110
334 #define F_TLV_KEYI 0x0111
335 #define F_TLV_FULD 0x0112
336 #define F_TLV_SPAD 0x0113
337 #define F_TLV_REST 0x0114
338 #define F_TLV_METD 0x0115
339 #define F_TLV_REDD 0x0116
340 #define F_TLV_TRNG 0x0117
343 #define F_TLV_VNST 0x8000
345 static const struct tok ForCES_TLV
[] = {
346 {F_TLV_RSVD
, "Invalid TLV"},
347 {F_TLV_REDR
, "REDIRECT TLV"},
348 {F_TLV_ASRS
, "ASResult TLV"},
349 {F_TLV_ASRT
, "ASTreason TLV"},
350 {F_TLV_LFBS
, "LFBselect TLV"},
351 {F_TLV_PDAT
, "PATH-DATA TLV"},
352 {F_TLV_KEYI
, "KEYINFO TLV"},
353 {F_TLV_FULD
, "FULLDATA TLV"},
354 {F_TLV_SPAD
, "SPARSEDATA TLV"},
355 {F_TLV_REST
, "RESULT TLV"},
356 {F_TLV_METD
, "METADATA TLV"},
357 {F_TLV_REDD
, "REDIRECTDATA TLV"},
362 static inline int ttlv_valid(u_int16_t ttlv
)
365 if (ttlv
== 1 || ttlv
== 0x1000)
367 if (ttlv
>= 0x10 && ttlv
<= 0x11)
369 if (ttlv
>= 0x110 && ttlv
<= 0x116)
388 #define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
389 #define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
390 #define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
391 #define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
392 #define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
393 #define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0)))
394 #define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
395 (struct forces_tlv*)(((char*)(tlv)) \
396 + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
397 #define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
398 #define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
399 #define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
400 #define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0)))
401 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
402 (struct forces_ilv *)(((char*)(ilv)) \
403 + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
404 #define INVALID_RLEN 1
405 #define INVALID_STLN 2
406 #define INVALID_LTLN 3
407 #define INVALID_ALEN 4
409 static const struct tok ForCES_TLV_err
[] = {
410 {INVALID_RLEN
, "Invalid total length"},
411 {INVALID_STLN
, "xLV too short"},
412 {INVALID_LTLN
, "xLV too long"},
413 {INVALID_ALEN
, "data padding missing"},
417 static inline u_int
tlv_valid(const struct forces_tlv
*tlv
, u_int rlen
)
421 if (EXTRACT_16BITS(&tlv
->length
) < TLV_HDRL
)
423 if (EXTRACT_16BITS(&tlv
->length
) > rlen
)
425 if (rlen
< F_ALN_LEN(EXTRACT_16BITS(&tlv
->length
)))
431 static inline int ilv_valid(const struct forces_ilv
*ilv
, u_int rlen
)
435 if (EXTRACT_32BITS(&ilv
->length
) < ILV_HDRL
)
437 if (EXTRACT_32BITS(&ilv
->length
) > rlen
)
439 if (rlen
< F_ALN_LEN(EXTRACT_32BITS(&ilv
->length
)))
445 static int lfbselect_print(register const u_char
* pptr
, register u_int len
,
446 u_int16_t op_msk
, int indent
);
447 static int redirect_print(register const u_char
* pptr
, register u_int len
,
448 u_int16_t op_msk
, int indent
);
449 static int asrtlv_print(register const u_char
* pptr
, register u_int len
,
450 u_int16_t op_msk
, int indent
);
451 static int asttlv_print(register const u_char
* pptr
, register u_int len
,
452 u_int16_t op_msk
, int indent
);
454 struct forces_lfbsh
{
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 inline const struct tom_h
*get_forces_tom(u_int8_t tom
)
490 for (i
= TOM_RSV_I
; i
<= TOM_MAX_IND
; i
++) {
491 const struct tom_h
*th
= &ForCES_msg
[i
];
495 return &ForCES_msg
[TOM_RSV_I
];
503 int (*print
) (register const u_char
* pptr
, register u_int len
,
504 u_int16_t op_msk
, int indent
);
516 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
518 static inline int pd_valid(u_int16_t pd
)
520 if (pd
>= F_TLV_PDAT
&& pd
<= F_TLV_REST
)
525 static inline void chk_op_type(u_int16_t type
, u_int16_t msk
, u_int16_t omsk
)
527 if (type
!= F_TLV_PDAT
) {
529 if (type
!= F_TLV_KEYI
) {
531 ("Based on flags expected KEYINFO TLV!\n");
536 ("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
545 #define F_SELTABRANGE 2
546 #define F_TABAPPEND 4
554 static int prestlv_print(register const u_char
* pptr
, register u_int len
,
555 u_int16_t op_msk
, int indent
);
556 static int pkeyitlv_print(register const u_char
* pptr
, register u_int len
,
557 u_int16_t op_msk
, int indent
);
558 static int fdatatlv_print(register const u_char
* pptr
, register u_int len
,
559 u_int16_t op_msk
, int indent
);
560 static int sdatatlv_print(register const u_char
* pptr
, register u_int len
,
561 u_int16_t op_msk
, int indent
);
563 static const struct pdata_ops ForCES_pdata
[PD_MAX_IND
+ 1] = {
564 /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL
},
565 /* PD_SEL_I */ {F_TLV_KEYI
, 0, 0, "KEYINFO TLV", pkeyitlv_print
},
566 /* PD_FDT_I */ {F_TLV_FULD
, 0, B_FULLD
, "FULLDATA TLV", fdatatlv_print
},
567 /* PD_SDT_I */ {F_TLV_SPAD
, 0, B_SPARD
, "SPARSEDATA TLV", sdatatlv_print
},
568 /* PD_RES_I */ {F_TLV_REST
, 0, B_RESTV
, "RESULT TLV", prestlv_print
},
570 {F_TLV_PDAT
, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print
},
573 static inline const struct pdata_ops
*get_forces_pd(u_int16_t pd
)
576 for (i
= PD_RSV_I
+ 1; i
<= PD_MAX_IND
; i
++) {
577 const struct pdata_ops
*pdo
= &ForCES_pdata
[i
];
581 return &ForCES_pdata
[TOM_RSV_I
];
589 E_INVALID_DESTINATION_PID
,
592 E_LFB_INSTANCE_ID_NOT_FOUND
,
594 E_COMPONENT_DOES_NOT_EXIST
,
598 E_INVALID_ARRAY_CREATION
,
599 E_VALUE_OUT_OF_RANGE
,
601 E_INVALID_PARAMETERS
,
602 E_INVALID_MESSAGE_TYPE
,
609 /* 0x18-0xFE are reserved .. */
610 E_UNSPECIFIED_ERROR
= 0XFF
613 static const struct tok ForCES_errs
[] = {
614 {E_SUCCESS
, "SUCCESS"},
615 {E_INVALID_HEADER
, "INVALID HEADER"},
616 {E_LENGTH_MISMATCH
, "LENGTH MISMATCH"},
617 {E_VERSION_MISMATCH
, "VERSION MISMATCH"},
618 {E_INVALID_DESTINATION_PID
, "INVALID DESTINATION PID"},
619 {E_LFB_UNKNOWN
, "LFB UNKNOWN"},
620 {E_LFB_NOT_FOUND
, "LFB NOT FOUND"},
621 {E_LFB_INSTANCE_ID_NOT_FOUND
, "LFB INSTANCE ID NOT FOUND"},
622 {E_INVALID_PATH
, "INVALID PATH"},
623 {E_COMPONENT_DOES_NOT_EXIST
, "COMPONENT DOES NOT EXIST"},
624 {E_EXISTS
, "EXISTS ALREADY"},
625 {E_NOT_FOUND
, "NOT FOUND"},
626 {E_READ_ONLY
, "READ ONLY"},
627 {E_INVALID_ARRAY_CREATION
, "INVALID ARRAY CREATION"},
628 {E_VALUE_OUT_OF_RANGE
, "VALUE OUT OF RANGE"},
629 {E_CONTENTS_TOO_LONG
, "CONTENTS TOO LONG"},
630 {E_INVALID_PARAMETERS
, "INVALID PARAMETERS"},
631 {E_INVALID_MESSAGE_TYPE
, "INVALID MESSAGE TYPE"},
632 {E_INVALID_FLAGS
, "INVALID FLAGS"},
633 {E_INVALID_TLV
, "INVALID TLV"},
634 {E_EVENT_ERROR
, "EVENT ERROR"},
635 {E_NOT_SUPPORTED
, "NOT SUPPORTED"},
636 {E_MEMORY_ERROR
, "MEMORY ERROR"},
637 {E_INTERNAL_ERROR
, "INTERNAL ERROR"},
638 {E_UNSPECIFIED_ERROR
, "UNSPECIFIED ERROR"},
645 prestlv_print(register const u_char
* pptr
, register u_int len
,
646 u_int16_t op_msk _U_
, int indent
)
648 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
649 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
650 struct res_val
*r
= (struct res_val
*)tdp
;
654 * pdatacnt_print() has ensured that len (the TLV length)
657 dlen
= len
- TLV_HDRL
;
658 if (dlen
!= RESLEN
) {
659 printf("illegal RESULT-TLV: %d bytes!\n", dlen
);
664 if (r
->result
>= 0x18 && r
->result
<= 0xFE) {
665 printf("illegal reserved result code: 0x%x!\n", r
->result
);
670 char *ib
= indent_pr(indent
, 0);
671 printf("%s Result: %s (code 0x%x)\n", ib
,
672 tok2str(ForCES_errs
, NULL
, r
->result
), r
->result
);
682 fdatatlv_print(register const u_char
* pptr
, register u_int len
,
683 u_int16_t op_msk _U_
, int indent
)
685 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
687 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
691 * pdatacnt_print() or pkeyitlv_print() has ensured that len
692 * (the TLV length) >= TLV_HDRL.
694 rlen
= len
- TLV_HDRL
;
696 type
= EXTRACT_16BITS(&tlv
->type
);
697 if (type
!= F_TLV_FULD
) {
698 printf("Error: expecting FULLDATA!\n");
703 char *ib
= indent_pr(indent
+ 2, 1);
704 printf("%s[", &ib
[1]);
705 hex_print_with_offset(gndo
,ib
, tdp
, rlen
, 0);
706 printf("\n%s]\n", &ib
[1]);
716 sdatailv_print(register const u_char
* pptr
, register u_int len
,
717 u_int16_t op_msk _U_
, int indent
)
720 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
723 if (len
< ILV_HDRL
) {
724 printf("Error: BAD SPARSEDATA-TLV!\n");
731 printf("Jamal - outstanding length <%d>\n", rlen
);
733 char *ib
= indent_pr(indent
, 1);
734 register const u_char
*tdp
= (u_char
*) ILV_DATA(ilv
);
736 invilv
= ilv_valid(ilv
, rlen
);
738 printf("%s[", &ib
[1]);
739 hex_print_with_offset(gndo
,ib
, tdp
, rlen
, 0);
740 printf("\n%s]\n", &ib
[1]);
744 int ilvl
= EXTRACT_32BITS(&ilv
->length
);
745 printf("\n%s ILV: type %x length %d\n", &ib
[1],
746 EXTRACT_32BITS(&ilv
->type
), ilvl
);
747 hex_print_with_offset(gndo
,"\t\t[", tdp
, ilvl
-ILV_HDRL
, 0);
750 ilv
= GO_NXT_ILV(ilv
, rlen
);
761 sdatatlv_print(register const u_char
* pptr
, register u_int len
,
762 u_int16_t op_msk
, int indent
)
764 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
766 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
770 * pdatacnt_print() has ensured that len (the TLV length)
773 rlen
= len
- TLV_HDRL
;
775 type
= EXTRACT_16BITS(&tlv
->type
);
776 if (type
!= F_TLV_SPAD
) {
777 printf("Error: expecting SPARSEDATA!\n");
781 return sdatailv_print(tdp
, rlen
, op_msk
, indent
);
789 pkeyitlv_print(register const u_char
* pptr
, register u_int len
,
790 u_int16_t op_msk
, int indent
)
792 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
793 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
794 register const u_char
*dp
= tdp
+ 4;
795 const struct forces_tlv
*kdtlv
= (struct forces_tlv
*)dp
;
797 char *ib
= indent_pr(indent
, 0);
802 id
= EXTRACT_32BITS(tdp
);
803 printf("%sKeyinfo: Key 0x%x\n", ib
, id
);
805 type
= EXTRACT_16BITS(&kdtlv
->type
);
806 invtlv
= tlv_valid(kdtlv
, len
);
809 printf("%s TLV type 0x%x len %d\n",
810 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
811 EXTRACT_16BITS(&kdtlv
->length
));
815 * At this point, tlv_valid() has ensured that the TLV
816 * length is large enough but not too large (it doesn't
817 * go past the end of the containing TLV).
819 tll
= EXTRACT_16BITS(&kdtlv
->length
);
820 dp
= (u_char
*) TLV_DATA(kdtlv
);
821 return fdatatlv_print(dp
, tll
, op_msk
, indent
);
828 #define PTH_DESC_SIZE 12
831 pdatacnt_print(register const u_char
* pptr
, register u_int len
,
832 u_int16_t IDcnt
, u_int16_t op_msk
, int indent
)
836 char *ib
= indent_pr(indent
, 0);
838 if ((op_msk
& B_APPND
) && vflag
>= 3) {
839 printf("%sTABLE APPEND\n", ib
);
841 for (i
= 0; i
< IDcnt
; i
++) {
845 id
= EXTRACT_32BITS(pptr
);
847 printf("%sID#%02u: %d\n", ib
, i
+ 1, id
);
852 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
853 if (op_msk
& B_TRNG
) {
854 u_int32_t starti
, endi
;
856 if (len
< PTH_DESC_SIZE
) {
857 printf("pathlength %d with key/range too short %d\n",
862 pptr
+= sizeof(struct forces_tlv
);
863 len
-= sizeof(struct forces_tlv
);
865 starti
= EXTRACT_32BITS(pptr
);
869 endi
= EXTRACT_32BITS(pptr
);
874 printf("%sTable range: [%d,%d]\n", ib
, starti
, endi
);
877 if (op_msk
& B_KEYIN
) {
878 struct forces_tlv
*keytlv
;
881 if (len
< PTH_DESC_SIZE
) {
882 printf("pathlength %d with key/range too short %d\n",
890 keytlv
= (struct forces_tlv
*)pptr
;
892 pptr
+= sizeof(struct forces_tlv
);
893 len
-= sizeof(struct forces_tlv
);
894 /* skip key content */
895 tll
= EXTRACT_16BITS(&keytlv
->length
);
896 if (tll
< TLV_HDRL
) {
897 printf("key content length %u < %u\n",
903 printf("key content too short\n");
913 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
921 type
= EXTRACT_16BITS(&pdtlv
->type
);
922 invtlv
= tlv_valid(pdtlv
, len
);
925 ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
926 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
927 EXTRACT_16BITS(&pdtlv
->length
));
931 * At this point, tlv_valid() has ensured that the TLV
932 * length is large enough but not too large (it doesn't
933 * go past the end of the containing TLV).
935 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
936 aln
= F_ALN_LEN(EXTRACT_16BITS(&pdtlv
->length
));
937 if (aln
> EXTRACT_16BITS(&pdtlv
->length
)) {
940 ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
941 type
, EXTRACT_16BITS(&pdtlv
->length
), aln
- len
);
943 pad
= aln
- EXTRACT_16BITS(&pdtlv
->length
);
946 if (pd_valid(type
)) {
947 const struct pdata_ops
*ops
= get_forces_pd(type
);
949 if (vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
952 ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
953 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
957 ("%s %s (Length %d DataLen %d Bytes)\n",
958 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
962 chk_op_type(type
, op_msk
, ops
->op_msk
);
964 if (ops
->print((const u_char
*)pdtlv
,
965 tll
+ pad
+ TLV_HDRL
, op_msk
,
968 len
-= (TLV_HDRL
+ pad
+ tll
);
970 printf("Invalid path data content type 0x%x len %d\n",
971 type
, EXTRACT_16BITS(&pdtlv
->length
));
973 if (EXTRACT_16BITS(&pdtlv
->length
)) {
974 hex_print_with_offset(gndo
,"Bad Data val\n\t [",
990 pdata_print(register const u_char
* pptr
, register u_int len
,
991 u_int16_t op_msk
, int indent
)
993 const struct pathdata_h
*pdh
= (struct pathdata_h
*)pptr
;
994 char *ib
= indent_pr(indent
, 0);
1000 if (len
< sizeof(struct pathdata_h
))
1003 printf("\n%sPathdata: Flags 0x%x ID count %d\n",
1004 ib
, EXTRACT_16BITS(&pdh
->pflags
), EXTRACT_16BITS(&pdh
->pIDcnt
));
1007 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELKEY
) {
1011 /* Table GET Range operation */
1012 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELTABRANGE
) {
1015 /* Table SET append operation */
1016 if (EXTRACT_16BITS(&pdh
->pflags
) & F_TABAPPEND
) {
1020 pptr
+= sizeof(struct pathdata_h
);
1021 len
-= sizeof(struct pathdata_h
);
1022 idcnt
= EXTRACT_16BITS(&pdh
->pIDcnt
);
1023 minsize
= idcnt
* 4;
1024 if (len
< minsize
) {
1025 printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
1027 hex_print_with_offset(gndo
,"\t\t\tID Data[", pptr
, len
, 0);
1032 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
1033 printf("\t\t\tIllegal to have both Table ranges and keys\n");
1037 more_pd
= pdatacnt_print(pptr
, len
, idcnt
, op_msk
, indent
);
1039 int consumed
= len
- more_pd
;
1042 /* XXX: Argh, recurse some more */
1043 return recpdoptlv_print(pptr
, len
, op_msk
, indent
+1);
1053 genoptlv_print(register const u_char
* pptr
, register u_int len
,
1054 u_int16_t op_msk
, int indent
)
1056 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
1060 char *ib
= indent_pr(indent
, 0);
1063 type
= EXTRACT_16BITS(&pdtlv
->type
);
1064 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
1065 invtlv
= tlv_valid(pdtlv
, len
);
1066 printf("genoptlvprint - %s TLV type 0x%x len %d\n",
1067 tok2str(ForCES_TLV
, NULL
, type
), type
, EXTRACT_16BITS(&pdtlv
->length
));
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 register const u_char
*dp
= (u_char
*) TLV_DATA(pdtlv
);
1075 if (!ttlv_valid(type
)) {
1076 printf("%s TLV type 0x%x len %d\n",
1077 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
1078 EXTRACT_16BITS(&pdtlv
->length
));
1082 printf("%s%s, length %d (data length %d Bytes)",
1083 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1084 EXTRACT_16BITS(&pdtlv
->length
), tll
);
1086 return pdata_print(dp
, tll
, op_msk
, indent
+ 1);
1088 printf("\t\t\tInvalid ForCES TLV type=%x", type
);
1098 recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
1099 u_int16_t op_msk
, int indent
)
1101 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
1105 register const u_char
*dp
;
1110 invtlv
= tlv_valid(pdtlv
, len
);
1116 * At this point, tlv_valid() has ensured that the TLV
1117 * length is large enough but not too large (it doesn't
1118 * go past the end of the containing TLV).
1120 ib
= indent_pr(indent
, 0);
1121 type
= EXTRACT_16BITS(&pdtlv
->type
);
1122 dp
= (u_char
*) TLV_DATA(pdtlv
);
1123 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
1127 ("%s%s, length %d (data encapsulated %d Bytes)",
1128 ib
, tok2str(ForCES_TLV
, NULL
, type
),
1129 EXTRACT_16BITS(&pdtlv
->length
),
1130 EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
);
1132 if (pdata_print(dp
, tll
, op_msk
, indent
+ 1) == -1)
1134 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
1139 ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1140 EXTRACT_16BITS(&pdtlv
->type
), len
- EXTRACT_16BITS(&pdtlv
->length
));
1152 invoptlv_print(register const u_char
* pptr
, register u_int len
,
1153 u_int16_t op_msk _U_
, int indent
)
1155 char *ib
= indent_pr(indent
, 1);
1158 printf("%sData[", &ib
[1]);
1159 hex_print_with_offset(gndo
,ib
, pptr
, len
, 0);
1160 printf("%s]\n", ib
);
1166 otlv_print(const struct forces_tlv
*otlv
, u_int16_t op_msk _U_
, int indent
)
1169 register const u_char
*dp
= (u_char
*) TLV_DATA(otlv
);
1172 char *ib
= indent_pr(indent
, 0);
1173 const struct optlv_h
*ops
;
1176 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
1180 type
= EXTRACT_16BITS(&otlv
->type
);
1181 tll
= EXTRACT_16BITS(&otlv
->length
) - TLV_HDRL
;
1182 ops
= get_forces_optlv_h(type
);
1184 printf("%sOper TLV %s(0x%x) length %d\n", ib
, ops
->s
, type
,
1185 EXTRACT_16BITS(&otlv
->length
));
1187 /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
1188 if (!ops
->flags
& ZERO_TTLV
) {
1189 if (tll
!= 0) /* instead of "if (tll)" - for readability .. */
1190 printf("%s: Illegal - MUST be empty\n", ops
->s
);
1193 /* rest of ops must at least have 12B {pathinfo} */
1194 if (tll
< OP_MIN_SIZ
) {
1195 printf("\t\tOper TLV %s(0x%x) length %d\n", ops
->s
, type
,
1196 EXTRACT_16BITS(&otlv
->length
));
1197 printf("\t\tTruncated data size %d minimum required %d\n", tll
,
1199 return invoptlv_print(dp
, tll
, ops
->op_msk
, indent
);
1203 rc
= ops
->print(dp
, tll
, ops
->op_msk
, indent
+ 1);
1214 asttlv_print(register const u_char
* pptr
, register u_int len
,
1215 u_int16_t op_msk _U_
, int indent
)
1219 char *ib
= indent_pr(indent
, 0);
1222 * forces_type_print() has ensured that len (the TLV length)
1225 dlen
= len
- TLV_HDRL
;
1226 if (dlen
!= ASTDLN
) {
1227 printf("illegal ASTresult-TLV: %d bytes!\n", dlen
);
1231 rescode
= EXTRACT_32BITS(pptr
);
1232 if (rescode
> ASTMCD
) {
1233 printf("illegal ASTresult result code: %d!\n", rescode
);
1238 printf("Teardown reason:\n%s", ib
);
1241 printf("Normal Teardown");
1244 printf("Loss of Heartbeats");
1247 printf("Out of bandwidth");
1250 printf("Out of Memory");
1253 printf("Application Crash");
1256 printf("Unknown Teardown reason");
1259 printf("(%x)\n%s", rescode
, ib
);
1271 asrtlv_print(register const u_char
* pptr
, register u_int len
,
1272 u_int16_t op_msk _U_
, int indent
)
1276 char *ib
= indent_pr(indent
, 0);
1279 * forces_type_print() has ensured that len (the TLV length)
1282 dlen
= len
- TLV_HDRL
;
1283 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
1284 printf("illegal ASRresult-TLV: %d bytes!\n", dlen
);
1288 rescode
= EXTRACT_32BITS(pptr
);
1290 if (rescode
> ASRMCD
) {
1291 printf("illegal ASRresult result code: %d!\n", rescode
);
1302 printf("FE ID invalid ");
1305 printf("permission denied ");
1311 printf("(%x)\n%s", rescode
, ib
);
1325 gentltlv_print(register const u_char
* pptr _U_
, register u_int len
,
1326 u_int16_t op_msk _U_
, int indent _U_
)
1328 u_int dlen
= len
- TLV_HDRL
;
1330 if (dlen
< 4) { /* at least 32 bits must exist */
1331 printf("truncated TLV: %d bytes missing! ", 4 - dlen
);
1341 print_metailv(register const u_char
* pptr
, u_int16_t op_msk _U_
, int indent
)
1344 char *ib
= indent_pr(indent
, 0);
1345 /* XXX: check header length */
1346 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
1349 * print_metatlv() has ensured that len (what remains in the
1352 rlen
= EXTRACT_32BITS(&ilv
->length
) - ILV_HDRL
;
1354 printf("%sMetaID 0x%x length %d\n", ib
, EXTRACT_32BITS(&ilv
->type
),
1355 EXTRACT_32BITS(&ilv
->length
));
1357 hex_print_with_offset(gndo
,"\t\t[", ILV_DATA(ilv
), rlen
, 0);
1368 print_metatlv(register const u_char
* pptr
, register u_int len
,
1369 u_int16_t op_msk _U_
, int indent
)
1372 char *ib
= indent_pr(indent
, 0);
1374 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
1378 * redirect_print() has ensured that len (what remains in the
1381 dlen
= len
- TLV_HDRL
;
1383 printf("\n%s METADATA length %d \n", ib
, rlen
);
1386 invilv
= ilv_valid(ilv
, rlen
);
1392 * At this point, ilv_valid() has ensured that the ILV
1393 * length is large enough but not too large (it doesn't
1394 * go past the end of the containing TLV).
1396 print_metailv((u_char
*) ilv
, 0, indent
+ 1);
1397 ilv
= GO_NXT_ILV(ilv
, rlen
);
1409 print_reddata(register const u_char
* pptr
, register u_int len
,
1410 u_int16_t op_msk _U_
, int indent _U_
)
1413 char *ib
= indent_pr(indent
, 0);
1416 dlen
= len
- TLV_HDRL
;
1418 printf("\n%s Redirect Data length %d \n", ib
, rlen
);
1422 hex_print_with_offset(gndo
,"\n\t\t", pptr
, rlen
, 0);
1430 redirect_print(register const u_char
* pptr
, register u_int len
,
1431 u_int16_t op_msk _U_
, int indent
)
1433 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
1439 * forces_type_print() has ensured that len (the TLV length)
1442 dlen
= len
- TLV_HDRL
;
1443 if (dlen
<= RD_MIN
) {
1444 printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
1453 invtlv
= tlv_valid(tlv
, rlen
);
1455 printf("Bad Redirect data\n");
1460 * At this point, tlv_valid() has ensured that the TLV
1461 * length is large enough but not too large (it doesn't
1462 * go past the end of the containing TLV).
1464 if (EXTRACT_16BITS(&tlv
->type
) == F_TLV_METD
) {
1465 print_metatlv((u_char
*) TLV_DATA(tlv
),
1466 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
1467 } else if ((EXTRACT_16BITS(&tlv
->type
) == F_TLV_REDD
)) {
1468 print_reddata((u_char
*) TLV_DATA(tlv
),
1469 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
1471 printf("Unknown REDIRECT TLV 0x%x len %d\n",
1472 EXTRACT_16BITS(&tlv
->type
),
1473 EXTRACT_16BITS(&tlv
->length
));
1476 tlv
= GO_NXT_TLV(tlv
, rlen
);
1481 ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1482 EXTRACT_16BITS(&tlv
->type
),
1483 rlen
- EXTRACT_16BITS(&tlv
->length
));
1498 lfbselect_print(register const u_char
* pptr
, register u_int len
,
1499 u_int16_t op_msk
, int indent
)
1501 const struct forces_lfbsh
*lfbs
;
1502 const struct forces_tlv
*otlv
;
1503 char *ib
= indent_pr(indent
, 0);
1509 * forces_type_print() has ensured that len (the TLV length)
1512 dlen
= len
- TLV_HDRL
;
1513 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
1514 printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
1520 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
1521 * we also know that it's > OP_OFF.
1523 rlen
= dlen
- OP_OFF
;
1525 lfbs
= (const struct forces_lfbsh
*)pptr
;
1528 printf("\n%s%s(Classid %x) instance %x\n",
1529 ib
, tok2str(ForCES_LFBs
, NULL
, EXTRACT_32BITS(&lfbs
->class)),
1530 EXTRACT_32BITS(&lfbs
->class),
1531 EXTRACT_32BITS(&lfbs
->instance
));
1534 otlv
= (struct forces_tlv
*)(lfbs
+ 1);
1539 invtlv
= tlv_valid(otlv
, rlen
);
1544 * At this point, tlv_valid() has ensured that the TLV
1545 * length is large enough but not too large (it doesn't
1546 * go past the end of the containing TLV).
1548 if (op_valid(EXTRACT_16BITS(&otlv
->type
), op_msk
)) {
1549 otlv_print(otlv
, 0, indent
);
1554 ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
1555 EXTRACT_16BITS(&otlv
->type
), EXTRACT_16BITS(&otlv
->length
));
1556 invoptlv_print((u_char
*)otlv
, rlen
, 0, indent
);
1558 otlv
= GO_NXT_TLV(otlv
, rlen
);
1563 ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
1564 EXTRACT_16BITS(&otlv
->type
), rlen
- EXTRACT_16BITS(&otlv
->length
));
1576 forces_type_print(register const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
1577 register u_int mlen
, const struct tom_h
*tops
)
1579 const struct forces_tlv
*tltlv
;
1586 * forces_print() has already checked that mlen >= ForCES_HDRL
1587 * by calling ForCES_HLN_VALID().
1589 rlen
= mlen
- ForCES_HDRL
;
1591 if (rlen
> TLV_HLN
) {
1592 if (tops
->flags
& ZERO_TTLV
) {
1593 printf("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
1597 if (tops
->flags
& ZERO_MORE_TTLV
)
1599 if (tops
->flags
& ONE_MORE_TTLV
) {
1600 printf("\tTop level TLV Data missing!\n");
1605 if (tops
->flags
& ZERO_TTLV
) {
1609 ttlv
= tops
->flags
>> 4;
1610 tltlv
= GET_TOP_TLV(pptr
);
1612 /*XXX: 15 top level tlvs will probably be fine
1613 You are nuts if you send more ;-> */
1616 invtlv
= tlv_valid(tltlv
, rlen
);
1621 * At this point, tlv_valid() has ensured that the TLV
1622 * length is large enough but not too large (it doesn't
1623 * go past the end of the packet).
1625 if (!ttlv_valid(EXTRACT_16BITS(&tltlv
->type
))) {
1626 printf("\n\tInvalid ForCES Top TLV type=0x%x",
1627 EXTRACT_16BITS(&tltlv
->type
));
1632 printf("\t%s, length %d (data length %d Bytes)",
1633 tok2str(ForCES_TLV
, NULL
, EXTRACT_16BITS(&tltlv
->type
)),
1634 EXTRACT_16BITS(&tltlv
->length
),
1635 EXTRACT_16BITS(&tltlv
->length
) - TLV_HDRL
);
1637 rc
= tops
->print((u_char
*) TLV_DATA(tltlv
),
1638 EXTRACT_16BITS(&tltlv
->length
), tops
->op_msk
, 9);
1642 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1648 * XXX - if ttlv != 0, does that mean that the packet was too
1649 * short, and didn't have *enough* TLVs in it?
1652 printf("\tMess TopTLV header: min %u, total %d advertised %d ",
1653 TLV_HDRL
, rlen
, EXTRACT_16BITS(&tltlv
->length
));
1665 forces_print(register const u_char
* pptr
, register u_int len
)
1667 const struct forcesh
*fhdr
;
1670 const struct tom_h
*tops
;
1673 fhdr
= (const struct forcesh
*)pptr
;
1675 if (!tom_valid(fhdr
->fm_tom
)) {
1676 printf("Invalid ForCES message type %d\n", fhdr
->fm_tom
);
1680 mlen
= ForCES_BLN(fhdr
);
1682 tops
= get_forces_tom(fhdr
->fm_tom
);
1683 if (tops
->v
== TOM_RSVD
) {
1684 printf("\n\tUnknown ForCES message type=0x%x", fhdr
->fm_tom
);
1688 printf("\n\tForCES %s ", tops
->s
);
1689 if (!ForCES_HLN_VALID(mlen
, len
)) {
1691 ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
1692 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1696 TCHECK2(*(pptr
+ 20), 4);
1697 flg_raw
= EXTRACT_32BITS(pptr
+ 20);
1699 printf("\n\tForCES Version %d len %uB flags 0x%08x ",
1700 ForCES_V(fhdr
), mlen
, flg_raw
);
1701 printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1702 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1703 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1704 EXTRACT_64BITS(fhdr
->fm_cor
));
1709 ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1710 tok2str(ForCES_ACKs
, "ACKUnknown", ForCES_ACK(fhdr
)),
1713 tok2str(ForCES_EMs
, "EMUnknown", ForCES_EM(fhdr
)),
1715 tok2str(ForCES_ATs
, "ATUnknown", ForCES_AT(fhdr
)),
1717 tok2str(ForCES_TPs
, "TPUnknown", ForCES_TP(fhdr
)),
1720 ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1721 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1723 rc
= forces_type_print(pptr
, fhdr
, mlen
, tops
);
1726 hex_print_with_offset(gndo
,"\n\t[", pptr
, len
, 0);
1732 printf("\n\t Raw ForCES message\n\t [");
1733 hex_print_with_offset(gndo
,"\n\t ", pptr
, len
, 0);
1744 * c-style: whitesmith