]>
The Tcpdump Group git mirrors - tcpdump/blob - print-forces.c
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"
34 prestlv_print(register const u_char
* pptr
, register u_int len
,
35 u_int16_t op_msk _U_
, int indent
)
37 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
38 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
39 struct res_val
*r
= (struct res_val
*)tdp
;
43 * pdatacnt_print() has ensured that len (the TLV length)
46 dlen
= len
- TLV_HDRL
;
48 printf("illegal RESULT-TLV: %d bytes!\n", dlen
);
53 if (r
->result
>= 0x18 && r
->result
<= 0xFE) {
54 printf("illegal reserved result code: 0x%x!\n", r
->result
);
59 char *ib
= indent_pr(indent
, 0);
60 printf("%s Result: %s (code 0x%x)\n", ib
,
61 tok2str(ForCES_errs
, NULL
, r
->result
), r
->result
);
66 fputs("[|forces]", stdout
);
71 fdatatlv_print(register const u_char
* pptr
, register u_int len
,
72 u_int16_t op_msk _U_
, int indent
)
74 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
76 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
80 * pdatacnt_print() or pkeyitlv_print() has ensured that len
81 * (the TLV length) >= TLV_HDRL.
83 rlen
= len
- TLV_HDRL
;
85 type
= EXTRACT_16BITS(&tlv
->type
);
86 if (type
!= F_TLV_FULD
) {
87 printf("Error: expecting FULLDATA!\n");
92 char *ib
= indent_pr(indent
+ 2, 1);
93 printf("%s[", &ib
[1]);
94 hex_print_with_offset(ib
, tdp
, rlen
, 0);
95 printf("\n%s]\n", &ib
[1]);
100 fputs("[|forces]", stdout
);
105 sdatailv_print(register const u_char
* pptr
, register u_int len
,
106 u_int16_t op_msk _U_
, int indent
)
109 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
112 if (len
< ILV_HDRL
) {
113 printf("Error: BAD SPARSEDATA-TLV!\n");
119 char *ib
= indent_pr(indent
, 1);
120 register const u_char
*tdp
= (u_char
*) ILV_DATA(ilv
);
122 invilv
= ilv_valid(ilv
, rlen
);
124 printf("%s[", &ib
[1]);
125 hex_print_with_offset(ib
, tdp
, rlen
, 0);
126 printf("\n%s]\n", &ib
[1]);
130 int ilvl
= EXTRACT_32BITS(&ilv
->length
);
131 printf("\n%s ILV: type %x length %d\n", &ib
[1],
132 EXTRACT_32BITS(&ilv
->type
), ilvl
);
133 hex_print_with_offset("\t\t[", tdp
, ilvl
-ILV_HDRL
, 0);
136 ilv
= GO_NXT_ILV(ilv
, rlen
);
142 fputs("[|forces]", stdout
);
147 sdatatlv_print(register const u_char
* pptr
, register u_int len
,
148 u_int16_t op_msk
, int indent
)
150 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
152 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
156 * pdatacnt_print() has ensured that len (the TLV length)
159 rlen
= len
- TLV_HDRL
;
161 type
= EXTRACT_16BITS(&tlv
->type
);
162 if (type
!= F_TLV_SPAD
) {
163 printf("Error: expecting SPARSEDATA!\n");
167 return sdatailv_print(tdp
, rlen
, op_msk
, indent
);
170 fputs("[|forces]", stdout
);
175 pkeyitlv_print(register const u_char
* pptr
, register u_int len
,
176 u_int16_t op_msk
, int indent
)
178 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
179 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
180 register const u_char
*dp
= tdp
+ 4;
181 const struct forces_tlv
*kdtlv
= (struct forces_tlv
*)dp
;
183 char *ib
= indent_pr(indent
, 0);
188 id
= EXTRACT_32BITS(tdp
);
189 printf("%sKeyinfo: Key 0x%x\n", ib
, id
);
191 type
= EXTRACT_16BITS(&kdtlv
->type
);
192 invtlv
= tlv_valid(kdtlv
, len
);
195 printf("%s TLV type 0x%x len %d\n",
196 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
197 EXTRACT_16BITS(&kdtlv
->length
));
201 * At this point, tlv_valid() has ensured that the TLV
202 * length is large enough but not too large (it doesn't
203 * go past the end of the containing TLV).
205 tll
= EXTRACT_16BITS(&kdtlv
->length
);
206 dp
= (u_char
*) TLV_DATA(kdtlv
);
207 return fdatatlv_print(dp
, tll
, op_msk
, indent
);
210 fputs("[|forces]", stdout
);
215 pdatacnt_print(register const u_char
* pptr
, register u_int len
,
216 u_int16_t IDcnt
, u_int16_t op_msk
, int indent
)
220 char *ib
= indent_pr(indent
, 0);
222 for (i
= 0; i
< IDcnt
; i
++) {
226 id
= EXTRACT_32BITS(pptr
);
228 printf("%s ID#%02u: %d\n", ib
, i
+ 1, id
);
233 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
241 type
= EXTRACT_16BITS(&pdtlv
->type
);
242 invtlv
= tlv_valid(pdtlv
, len
);
245 ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
246 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
247 EXTRACT_16BITS(&pdtlv
->length
));
251 * At this point, tlv_valid() has ensured that the TLV
252 * length is large enough but not too large (it doesn't
253 * go past the end of the containing TLV).
255 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
256 aln
= F_ALN_LEN(EXTRACT_16BITS(&pdtlv
->length
));
257 if (aln
> EXTRACT_16BITS(&pdtlv
->length
)) {
260 ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
261 type
, EXTRACT_16BITS(&pdtlv
->length
), aln
- len
);
263 pad
= aln
- EXTRACT_16BITS(&pdtlv
->length
);
266 if (pd_valid(type
)) {
267 const struct pdata_ops
*ops
= get_forces_pd(type
);
269 if (vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
272 ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
273 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
277 ("%s %s (Length %d DataLen %d Bytes)\n",
278 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
282 chk_op_type(type
, op_msk
, ops
->op_msk
);
284 if (ops
->print((const u_char
*)pdtlv
,
285 tll
+ pad
+ TLV_HDRL
, op_msk
,
288 len
-= (TLV_HDRL
+ pad
+ tll
);
290 printf("Invalid path data content type 0x%x len %d\n",
291 type
, EXTRACT_16BITS(&pdtlv
->length
));
293 if (EXTRACT_16BITS(&pdtlv
->length
)) {
294 hex_print_with_offset("Bad Data val\n\t [",
305 fputs("[|forces]", stdout
);
310 pdata_print(register const u_char
* pptr
, register u_int len
,
311 u_int16_t op_msk
, int indent
)
313 const struct pathdata_h
*pdh
= (struct pathdata_h
*)pptr
;
314 char *ib
= indent_pr(indent
, 0);
320 if (len
< sizeof(struct pathdata_h
))
323 printf("\n%sPathdata: Flags 0x%x ID count %d\n",
324 ib
, EXTRACT_16BITS(&pdh
->pflags
), EXTRACT_16BITS(&pdh
->pIDcnt
));
327 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELKEY
) {
330 pptr
+= sizeof(struct pathdata_h
);
331 len
-= sizeof(struct pathdata_h
);
332 idcnt
= EXTRACT_16BITS(&pdh
->pIDcnt
);
335 printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
337 hex_print_with_offset("\t\t\tID Data[", pptr
, len
, 0);
341 more_pd
= pdatacnt_print(pptr
, len
, idcnt
, op_msk
, indent
);
343 int consumed
= len
- more_pd
;
346 /* XXX: Argh, recurse some more */
347 return recpdoptlv_print(pptr
, len
, op_msk
, indent
+1);
352 fputs("[|forces]", stdout
);
357 genoptlv_print(register const u_char
* pptr
, register u_int len
,
358 u_int16_t op_msk
, int indent
)
360 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
364 char *ib
= indent_pr(indent
, 0);
367 type
= EXTRACT_16BITS(&pdtlv
->type
);
368 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
369 invtlv
= tlv_valid(pdtlv
, len
);
370 printf("genoptlvprint - %s TLV type 0x%x len %d\n",
371 tok2str(ForCES_TLV
, NULL
, type
), type
, EXTRACT_16BITS(&pdtlv
->length
));
374 * At this point, tlv_valid() has ensured that the TLV
375 * length is large enough but not too large (it doesn't
376 * go past the end of the containing TLV).
378 register const u_char
*dp
= (u_char
*) TLV_DATA(pdtlv
);
379 if (!ttlv_valid(type
)) {
380 printf("%s TLV type 0x%x len %d\n",
381 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
382 EXTRACT_16BITS(&pdtlv
->length
));
386 printf("%s%s, length %d (data length %d Bytes)",
387 ib
, tok2str(ForCES_TLV
, NULL
, type
),
388 EXTRACT_16BITS(&pdtlv
->length
), tll
);
390 return pdata_print(dp
, tll
, op_msk
, indent
+ 1);
392 printf("\t\t\tInvalid ForCES TLV type=%x", type
);
397 fputs("[|forces]", stdout
);
402 recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
403 u_int16_t op_msk
, int indent
)
405 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
409 register const u_char
*dp
;
414 invtlv
= tlv_valid(pdtlv
, len
);
420 * At this point, tlv_valid() has ensured that the TLV
421 * length is large enough but not too large (it doesn't
422 * go past the end of the containing TLV).
424 ib
= indent_pr(indent
, 0);
425 type
= EXTRACT_16BITS(&pdtlv
->type
);
426 dp
= (u_char
*) TLV_DATA(pdtlv
);
427 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
431 ("%s%s, length %d (data encapsulated %d Bytes)",
432 ib
, tok2str(ForCES_TLV
, NULL
, type
),
433 EXTRACT_16BITS(&pdtlv
->length
),
434 EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
);
436 if (pdata_print(dp
, tll
, op_msk
, indent
+ 1) == -1)
438 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
443 ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
444 EXTRACT_16BITS(&pdtlv
->type
), len
- EXTRACT_16BITS(&pdtlv
->length
));
451 fputs("[|forces]", stdout
);
456 invoptlv_print(register const u_char
* pptr
, register u_int len
,
457 u_int16_t op_msk _U_
, int indent
)
459 char *ib
= indent_pr(indent
, 1);
462 printf("%sData[", &ib
[1]);
463 hex_print_with_offset(ib
, pptr
, len
, 0);
469 int otlv_print(const struct forces_tlv
*otlv
, u_int16_t op_msk _U_
, int indent
)
472 register const u_char
*dp
= (u_char
*) TLV_DATA(otlv
);
475 char *ib
= indent_pr(indent
, 0);
476 const struct optlv_h
*ops
;
479 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
483 type
= EXTRACT_16BITS(&otlv
->type
);
484 tll
= EXTRACT_16BITS(&otlv
->length
) - TLV_HDRL
;
485 ops
= get_forces_optlv_h(type
);
487 printf("%sOper TLV %s(0x%x) length %d\n", ib
, ops
->s
, type
,
488 EXTRACT_16BITS(&otlv
->length
));
490 /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
491 if (!ops
->flags
& ZERO_TTLV
) {
492 if (tll
!= 0) /* instead of "if (tll)" - for readability .. */
493 printf("%s: Illegal - MUST be empty\n", ops
->s
);
496 /* rest of ops must at least have 12B {pathinfo} */
497 if (tll
< OP_MIN_SIZ
) {
498 printf("\t\tOper TLV %s(0x%x) length %d\n", ops
->s
, type
,
499 EXTRACT_16BITS(&otlv
->length
));
500 printf("\t\tTruncated data size %d minimum required %d\n", tll
,
502 return invoptlv_print(dp
, tll
, ops
->op_msk
, indent
);
506 rc
= ops
->print(dp
, tll
, ops
->op_msk
, indent
+ 1);
510 fputs("[|forces]", stdout
);
517 asttlv_print(register const u_char
* pptr
, register u_int len
,
518 u_int16_t op_msk _U_
, int indent
)
522 char *ib
= indent_pr(indent
, 0);
525 * forces_type_print() has ensured that len (the TLV length)
528 dlen
= len
- TLV_HDRL
;
529 if (dlen
!= ASTDLN
) {
530 printf("illegal ASTresult-TLV: %d bytes!\n", dlen
);
534 rescode
= EXTRACT_32BITS(pptr
);
535 if (rescode
> ASTMCD
) {
536 printf("illegal ASTresult result code: %d!\n", rescode
);
541 printf("Teardown reason:\n%s", ib
);
544 printf("Normal Teardown");
547 printf("Loss of Heartbeats");
550 printf("Out of bandwidth");
553 printf("Out of Memory");
556 printf("Application Crash");
559 printf("Unknown Teardown reason");
562 printf("(%x)\n%s", rescode
, ib
);
567 fputs("[|forces]", stdout
);
574 asrtlv_print(register const u_char
* pptr
, register u_int len
,
575 u_int16_t op_msk _U_
, int indent
)
579 char *ib
= indent_pr(indent
, 0);
582 * forces_type_print() has ensured that len (the TLV length)
585 dlen
= len
- TLV_HDRL
;
586 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
587 printf("illegal ASRresult-TLV: %d bytes!\n", dlen
);
591 rescode
= EXTRACT_32BITS(pptr
);
593 if (rescode
> ASRMCD
) {
594 printf("illegal ASRresult result code: %d!\n", rescode
);
605 printf("FE ID invalid ");
608 printf("permission denied ");
614 printf("(%x)\n%s", rescode
, ib
);
619 fputs("[|forces]", stdout
);
627 gentltlv_print(register const u_char
* pptr _U_
, register u_int len
,
628 u_int16_t op_msk _U_
, int indent _U_
)
630 u_int dlen
= len
- TLV_HDRL
;
632 if (dlen
< 4) { /* at least 32 bits must exist */
633 printf("truncated TLV: %d bytes missing! ", 4 - dlen
);
641 print_metailv(register const u_char
* pptr
, register u_int len
,
642 u_int16_t op_msk _U_
, int indent
)
646 char *ib
= indent_pr(indent
, 0);
647 /* XXX: check header length */
648 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
651 * print_metatlv() has ensured that len (what remains in the
654 dlen
= len
- ILV_HDRL
;
657 printf("\n%sMetaID 0x%x length %d\n", ib
, EXTRACT_32BITS(&ilv
->type
),
658 EXTRACT_32BITS(&ilv
->length
));
659 hex_print_with_offset("\n\t\t\t\t[", ILV_DATA(ilv
), rlen
, 0);
663 fputs("[|forces]", stdout
);
668 print_metatlv(register const u_char
* pptr
, register u_int len
,
669 u_int16_t op_msk _U_
, int indent
)
672 char *ib
= indent_pr(indent
, 0);
674 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
678 * redirect_print() has ensured that len (what remains in the
681 dlen
= len
- TLV_HDRL
;
683 printf("\n%s METADATA\n", ib
);
686 invilv
= ilv_valid(ilv
, rlen
);
691 * At this point, ilv_valid() has ensured that the ILV
692 * length is large enough but not too large (it doesn't
693 * go past the end of the containing TLV).
695 print_metailv((u_char
*) ilv
, rlen
, 0, indent
+ 1);
697 ilv
= GO_NXT_ILV(ilv
, rlen
);
703 fputs("[|forces]", stdout
);
710 print_reddata(register const u_char
* pptr
, register u_int len
,
711 u_int16_t op_msk _U_
, int indent _U_
)
716 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
719 * redirect_print() has ensured that len (what remains in the
722 dlen
= len
- TLV_HDRL
;
723 printf("\n\t\t Redirect DATA\n");
724 if (dlen
<= RD_MIN
) {
725 printf("\n\t\ttruncated Redirect data: %d bytes missing! ",
732 invtlv
= tlv_valid(tlv
, rlen
);
735 printf("Redir data type 0x%x len %d\n", EXTRACT_16BITS(&tlv
->type
),
736 EXTRACT_16BITS(&tlv
->length
));
741 * At this point, tlv_valid() has ensured that the TLV
742 * length is large enough but not too large (it doesn't
743 * go past the end of the containing TLV).
746 hex_print_with_offset("\n\t\t\t[", TLV_DATA(tlv
), rlen
, 0);
750 fputs("[|forces]", stdout
);
755 redirect_print(register const u_char
* pptr
, register u_int len
,
756 u_int16_t op_msk _U_
, int indent
)
758 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
764 * forces_type_print() has ensured that len (the TLV length)
767 dlen
= len
- TLV_HDRL
;
768 if (dlen
<= RD_MIN
) {
769 printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
778 invtlv
= tlv_valid(tlv
, rlen
);
783 * At this point, tlv_valid() has ensured that the TLV
784 * length is large enough but not too large (it doesn't
785 * go past the end of the containing TLV).
787 if (EXTRACT_16BITS(&tlv
->type
) == F_TLV_METD
) {
788 print_metatlv((u_char
*) TLV_DATA(tlv
), rlen
, 0, indent
);
789 } else if ((EXTRACT_16BITS(&tlv
->type
) == F_TLV_REDD
)) {
790 print_reddata((u_char
*) TLV_DATA(tlv
), rlen
, 0, indent
);
792 printf("Unknown REDIRECT TLV 0x%x len %d\n",
793 EXTRACT_16BITS(&tlv
->type
), EXTRACT_16BITS(&tlv
->length
));
796 tlv
= GO_NXT_TLV(tlv
, rlen
);
801 ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
802 EXTRACT_16BITS(&tlv
->type
), rlen
- EXTRACT_16BITS(&tlv
->length
));
809 fputs("[|forces]", stdout
);
817 lfbselect_print(register const u_char
* pptr
, register u_int len
,
818 u_int16_t op_msk
, int indent
)
820 const struct forces_lfbsh
*lfbs
;
821 const struct forces_tlv
*otlv
;
822 char *ib
= indent_pr(indent
, 0);
828 * forces_type_print() has ensured that len (the TLV length)
831 dlen
= len
- TLV_HDRL
;
832 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
833 printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
839 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
840 * we also know that it's > OP_OFF.
842 rlen
= dlen
- OP_OFF
;
844 lfbs
= (const struct forces_lfbsh
*)pptr
;
847 printf("\n%s%s(Classid %x) instance %x\n",
848 ib
, tok2str(ForCES_LFBs
, NULL
, EXTRACT_32BITS(&lfbs
->class)),
849 EXTRACT_32BITS(&lfbs
->class),
850 EXTRACT_32BITS(&lfbs
->instance
));
853 otlv
= (struct forces_tlv
*)(lfbs
+ 1);
858 invtlv
= tlv_valid(otlv
, rlen
);
863 * At this point, tlv_valid() has ensured that the TLV
864 * length is large enough but not too large (it doesn't
865 * go past the end of the containing TLV).
867 if (op_valid(EXTRACT_16BITS(&otlv
->type
), op_msk
)) {
868 otlv_print(otlv
, 0, indent
);
873 ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
874 EXTRACT_16BITS(&otlv
->type
), EXTRACT_16BITS(&otlv
->length
));
875 invoptlv_print((u_char
*)otlv
, rlen
, 0, indent
);
877 otlv
= GO_NXT_TLV(otlv
, rlen
);
882 ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
883 EXTRACT_16BITS(&otlv
->type
), rlen
- EXTRACT_16BITS(&otlv
->length
));
890 fputs("[|forces]", stdout
);
895 forces_type_print(register const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
896 register u_int mlen
, const struct tom_h
*tops
)
898 const struct forces_tlv
*tltlv
;
905 * forces_print() has already checked that mlen >= ForCES_HDRL
906 * by calling ForCES_HLN_VALID().
908 rlen
= mlen
- ForCES_HDRL
;
910 if (rlen
> TLV_HLN
) {
911 if (tops
->flags
& ZERO_TTLV
) {
912 printf("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
916 if (tops
->flags
& ZERO_MORE_TTLV
)
918 if (tops
->flags
& ONE_MORE_TTLV
) {
919 printf("\tTop level TLV Data missing!\n");
924 if (tops
->flags
& ZERO_TTLV
) {
928 ttlv
= tops
->flags
>> 4;
929 tltlv
= GET_TOP_TLV(pptr
);
931 /*XXX: 15 top level tlvs will probably be fine
932 You are nuts if you send more ;-> */
935 invtlv
= tlv_valid(tltlv
, rlen
);
940 * At this point, tlv_valid() has ensured that the TLV
941 * length is large enough but not too large (it doesn't
942 * go past the end of the packet).
944 if (!ttlv_valid(EXTRACT_16BITS(&tltlv
->type
))) {
945 printf("\n\tInvalid ForCES Top TLV type=0x%x",
946 EXTRACT_16BITS(&tltlv
->type
));
951 printf("\t%s, length %d (data length %d Bytes)",
952 tok2str(ForCES_TLV
, NULL
, EXTRACT_16BITS(&tltlv
->type
)),
953 EXTRACT_16BITS(&tltlv
->length
),
954 EXTRACT_16BITS(&tltlv
->length
) - TLV_HDRL
);
956 rc
= tops
->print((u_char
*) TLV_DATA(tltlv
),
957 EXTRACT_16BITS(&tltlv
->length
), tops
->op_msk
, 9);
961 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
967 * XXX - if ttlv != 0, does that mean that the packet was too
968 * short, and didn't have *enough* TLVs in it?
971 printf("\tMess TopTLV header: min %u, total %d advertised %d ",
972 TLV_HDRL
, rlen
, EXTRACT_16BITS(&tltlv
->length
));
979 fputs("[|forces]", stdout
);
983 void forces_print(register const u_char
* pptr
, register u_int len
)
985 const struct forcesh
*fhdr
;
988 const struct tom_h
*tops
;
991 fhdr
= (const struct forcesh
*)pptr
;
993 if (!tom_valid(fhdr
->fm_tom
)) {
994 printf("Invalid ForCES message type %d\n", fhdr
->fm_tom
);
998 mlen
= ForCES_BLN(fhdr
);
1000 tops
= get_forces_tom(fhdr
->fm_tom
);
1001 if (tops
->v
== TOM_RSVD
) {
1002 printf("\n\tUnknown ForCES message type=0x%x", fhdr
->fm_tom
);
1006 printf("\n\tForCES %s ", tops
->s
);
1007 if (!ForCES_HLN_VALID(mlen
, len
)) {
1009 ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
1010 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1014 TCHECK2(*(pptr
+ 20), 4);
1015 flg_raw
= EXTRACT_32BITS(pptr
+ 20);
1017 printf("\n\tForCES Version %d len %uB flags 0x%08x ",
1018 ForCES_V(fhdr
), mlen
, flg_raw
);
1019 printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1020 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1021 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1022 EXTRACT_64BITS(fhdr
->fm_cor
));
1027 ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1028 ForCES_ACKp(ForCES_ACK(fhdr
)), ForCES_ACK(fhdr
),
1030 ForCES_EMp(ForCES_EM(fhdr
)), ForCES_EM(fhdr
),
1031 ForCES_ATp(ForCES_AT(fhdr
)), ForCES_AT(fhdr
),
1032 ForCES_TPp(ForCES_TP(fhdr
)), ForCES_TP(fhdr
));
1034 ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1035 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1037 rc
= forces_type_print(pptr
, fhdr
, mlen
, tops
);
1040 hex_print_with_offset("\n\t[", pptr
, len
, 0);
1046 printf("\n\t Raw ForCES message\n\t [");
1047 hex_print_with_offset("\n\t ", pptr
, len
, 0);
1054 fputs("[|forces]", stdout
);