]>
The Tcpdump Group git mirrors - tcpdump/blob - print-forces.c
d8a9d1a8fb347604289d62ce983b28ed094e3d00
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 //printf("Jamal - outstanding length <%d>\n", rlen);
120 char *ib
= indent_pr(indent
, 1);
121 register const u_char
*tdp
= (u_char
*) ILV_DATA(ilv
);
123 invilv
= ilv_valid(ilv
, rlen
);
125 printf("%s[", &ib
[1]);
126 hex_print_with_offset(ib
, tdp
, rlen
, 0);
127 printf("\n%s]\n", &ib
[1]);
131 int ilvl
= EXTRACT_32BITS(&ilv
->length
);
132 printf("\n%s ILV: type %x length %d\n", &ib
[1],
133 EXTRACT_32BITS(&ilv
->type
), ilvl
);
134 hex_print_with_offset("\t\t[", tdp
, ilvl
-ILV_HDRL
, 0);
137 ilv
= GO_NXT_ILV(ilv
, rlen
);
143 fputs("[|forces]", stdout
);
148 sdatatlv_print(register const u_char
* pptr
, register u_int len
,
149 u_int16_t op_msk
, int indent
)
151 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
153 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
157 * pdatacnt_print() has ensured that len (the TLV length)
160 rlen
= len
- TLV_HDRL
;
162 type
= EXTRACT_16BITS(&tlv
->type
);
163 if (type
!= F_TLV_SPAD
) {
164 printf("Error: expecting SPARSEDATA!\n");
168 return sdatailv_print(tdp
, rlen
, op_msk
, indent
);
171 fputs("[|forces]", stdout
);
176 pkeyitlv_print(register const u_char
* pptr
, register u_int len
,
177 u_int16_t op_msk
, int indent
)
179 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
180 register const u_char
*tdp
= (u_char
*) TLV_DATA(tlv
);
181 register const u_char
*dp
= tdp
+ 4;
182 const struct forces_tlv
*kdtlv
= (struct forces_tlv
*)dp
;
184 char *ib
= indent_pr(indent
, 0);
189 id
= EXTRACT_32BITS(tdp
);
190 printf("%sKeyinfo: Key 0x%x\n", ib
, id
);
192 type
= EXTRACT_16BITS(&kdtlv
->type
);
193 invtlv
= tlv_valid(kdtlv
, len
);
196 printf("%s TLV type 0x%x len %d\n",
197 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
198 EXTRACT_16BITS(&kdtlv
->length
));
202 * At this point, tlv_valid() has ensured that the TLV
203 * length is large enough but not too large (it doesn't
204 * go past the end of the containing TLV).
206 tll
= EXTRACT_16BITS(&kdtlv
->length
);
207 dp
= (u_char
*) TLV_DATA(kdtlv
);
208 return fdatatlv_print(dp
, tll
, op_msk
, indent
);
211 fputs("[|forces]", stdout
);
215 #define PTH_DESC_SIZE 12
218 pdatacnt_print(register const u_char
* pptr
, register u_int len
,
219 u_int16_t IDcnt
, u_int16_t op_msk
, int indent
)
223 char *ib
= indent_pr(indent
, 0);
225 if ((op_msk
& B_APPND
) && vflag
>= 3) {
226 printf("%sTABLE APPEND\n", ib
);
228 for (i
= 0; i
< IDcnt
; i
++) {
232 id
= EXTRACT_32BITS(pptr
);
234 printf("%sID#%02u: %d\n", ib
, i
+ 1, id
);
239 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
240 if (len
< PTH_DESC_SIZE
) {
241 printf("pathlength %d with key/range too short %d\n",
246 if (op_msk
& B_TRNG
) {
247 u_int32_t starti
, endi
;
248 pptr
+= sizeof(struct forces_tlv
);
249 len
-= sizeof(struct forces_tlv
);
251 starti
= EXTRACT_32BITS(pptr
);
255 endi
= EXTRACT_32BITS(pptr
);
260 printf("%sTable range: [%d,%d]\n", ib
, starti
, endi
);
263 if (op_msk
& B_KEYIN
) {
264 struct forces_tlv
*keytlv
;
266 u_int32_t keyid
= EXTRACT_32BITS(pptr
);
270 keytlv
= (struct forces_tlv
*)pptr
;
272 pptr
+= sizeof(struct forces_tlv
);
273 len
-= sizeof(struct forces_tlv
);
274 /* skip key content */
275 tll
= EXTRACT_16BITS(&keytlv
->length
) - TLV_HDRL
;
279 printf("Key content too short\n");
287 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
295 type
= EXTRACT_16BITS(&pdtlv
->type
);
296 invtlv
= tlv_valid(pdtlv
, len
);
299 ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
300 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
301 EXTRACT_16BITS(&pdtlv
->length
));
305 * At this point, tlv_valid() has ensured that the TLV
306 * length is large enough but not too large (it doesn't
307 * go past the end of the containing TLV).
309 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
310 aln
= F_ALN_LEN(EXTRACT_16BITS(&pdtlv
->length
));
311 if (aln
> EXTRACT_16BITS(&pdtlv
->length
)) {
314 ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
315 type
, EXTRACT_16BITS(&pdtlv
->length
), aln
- len
);
317 pad
= aln
- EXTRACT_16BITS(&pdtlv
->length
);
320 if (pd_valid(type
)) {
321 const struct pdata_ops
*ops
= get_forces_pd(type
);
323 if (vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
326 ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
327 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
331 ("%s %s (Length %d DataLen %d Bytes)\n",
332 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
336 chk_op_type(type
, op_msk
, ops
->op_msk
);
338 if (ops
->print((const u_char
*)pdtlv
,
339 tll
+ pad
+ TLV_HDRL
, op_msk
,
342 len
-= (TLV_HDRL
+ pad
+ tll
);
344 printf("Invalid path data content type 0x%x len %d\n",
345 type
, EXTRACT_16BITS(&pdtlv
->length
));
347 if (EXTRACT_16BITS(&pdtlv
->length
)) {
348 hex_print_with_offset("Bad Data val\n\t [",
359 fputs("[|forces]", stdout
);
364 pdata_print(register const u_char
* pptr
, register u_int len
,
365 u_int16_t op_msk
, int indent
)
367 const struct pathdata_h
*pdh
= (struct pathdata_h
*)pptr
;
368 char *ib
= indent_pr(indent
, 0);
374 if (len
< sizeof(struct pathdata_h
))
377 printf("\n%sPathdata: Flags 0x%x ID count %d\n",
378 ib
, EXTRACT_16BITS(&pdh
->pflags
), EXTRACT_16BITS(&pdh
->pIDcnt
));
381 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELKEY
) {
385 /* Table GET Range operation */
386 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELTABRANGE
) {
389 /* Table SET append operation */
390 if (EXTRACT_16BITS(&pdh
->pflags
) & F_TABAPPEND
) {
394 pptr
+= sizeof(struct pathdata_h
);
395 len
-= sizeof(struct pathdata_h
);
396 idcnt
= EXTRACT_16BITS(&pdh
->pIDcnt
);
399 printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
401 hex_print_with_offset("\t\t\tID Data[", pptr
, len
, 0);
406 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
407 printf("\t\t\tIllegal to have both Table ranges and keys\n");
411 more_pd
= pdatacnt_print(pptr
, len
, idcnt
, op_msk
, indent
);
413 int consumed
= len
- more_pd
;
416 /* XXX: Argh, recurse some more */
417 return recpdoptlv_print(pptr
, len
, op_msk
, indent
+1);
422 fputs("[|forces]", stdout
);
427 genoptlv_print(register const u_char
* pptr
, register u_int len
,
428 u_int16_t op_msk
, int indent
)
430 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
434 char *ib
= indent_pr(indent
, 0);
437 type
= EXTRACT_16BITS(&pdtlv
->type
);
438 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
439 invtlv
= tlv_valid(pdtlv
, len
);
440 printf("genoptlvprint - %s TLV type 0x%x len %d\n",
441 tok2str(ForCES_TLV
, NULL
, type
), type
, EXTRACT_16BITS(&pdtlv
->length
));
444 * At this point, tlv_valid() has ensured that the TLV
445 * length is large enough but not too large (it doesn't
446 * go past the end of the containing TLV).
448 register const u_char
*dp
= (u_char
*) TLV_DATA(pdtlv
);
449 if (!ttlv_valid(type
)) {
450 printf("%s TLV type 0x%x len %d\n",
451 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
452 EXTRACT_16BITS(&pdtlv
->length
));
456 printf("%s%s, length %d (data length %d Bytes)",
457 ib
, tok2str(ForCES_TLV
, NULL
, type
),
458 EXTRACT_16BITS(&pdtlv
->length
), tll
);
460 return pdata_print(dp
, tll
, op_msk
, indent
+ 1);
462 printf("\t\t\tInvalid ForCES TLV type=%x", type
);
467 fputs("[|forces]", stdout
);
472 recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
473 u_int16_t op_msk
, int indent
)
475 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
479 register const u_char
*dp
;
484 invtlv
= tlv_valid(pdtlv
, len
);
490 * At this point, tlv_valid() has ensured that the TLV
491 * length is large enough but not too large (it doesn't
492 * go past the end of the containing TLV).
494 ib
= indent_pr(indent
, 0);
495 type
= EXTRACT_16BITS(&pdtlv
->type
);
496 dp
= (u_char
*) TLV_DATA(pdtlv
);
497 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
501 ("%s%s, length %d (data encapsulated %d Bytes)",
502 ib
, tok2str(ForCES_TLV
, NULL
, type
),
503 EXTRACT_16BITS(&pdtlv
->length
),
504 EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
);
506 if (pdata_print(dp
, tll
, op_msk
, indent
+ 1) == -1)
508 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
513 ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
514 EXTRACT_16BITS(&pdtlv
->type
), len
- EXTRACT_16BITS(&pdtlv
->length
));
521 fputs("[|forces]", stdout
);
526 invoptlv_print(register const u_char
* pptr
, register u_int len
,
527 u_int16_t op_msk _U_
, int indent
)
529 char *ib
= indent_pr(indent
, 1);
532 printf("%sData[", &ib
[1]);
533 hex_print_with_offset(ib
, pptr
, len
, 0);
539 int otlv_print(const struct forces_tlv
*otlv
, u_int16_t op_msk _U_
, int indent
)
542 register const u_char
*dp
= (u_char
*) TLV_DATA(otlv
);
545 char *ib
= indent_pr(indent
, 0);
546 const struct optlv_h
*ops
;
549 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
553 type
= EXTRACT_16BITS(&otlv
->type
);
554 tll
= EXTRACT_16BITS(&otlv
->length
) - TLV_HDRL
;
555 ops
= get_forces_optlv_h(type
);
557 printf("%sOper TLV %s(0x%x) length %d\n", ib
, ops
->s
, type
,
558 EXTRACT_16BITS(&otlv
->length
));
560 /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
561 if (!ops
->flags
& ZERO_TTLV
) {
562 if (tll
!= 0) /* instead of "if (tll)" - for readability .. */
563 printf("%s: Illegal - MUST be empty\n", ops
->s
);
566 /* rest of ops must at least have 12B {pathinfo} */
567 if (tll
< OP_MIN_SIZ
) {
568 printf("\t\tOper TLV %s(0x%x) length %d\n", ops
->s
, type
,
569 EXTRACT_16BITS(&otlv
->length
));
570 printf("\t\tTruncated data size %d minimum required %d\n", tll
,
572 return invoptlv_print(dp
, tll
, ops
->op_msk
, indent
);
576 rc
= ops
->print(dp
, tll
, ops
->op_msk
, indent
+ 1);
580 fputs("[|forces]", stdout
);
587 asttlv_print(register const u_char
* pptr
, register u_int len
,
588 u_int16_t op_msk _U_
, int indent
)
592 char *ib
= indent_pr(indent
, 0);
595 * forces_type_print() has ensured that len (the TLV length)
598 dlen
= len
- TLV_HDRL
;
599 if (dlen
!= ASTDLN
) {
600 printf("illegal ASTresult-TLV: %d bytes!\n", dlen
);
604 rescode
= EXTRACT_32BITS(pptr
);
605 if (rescode
> ASTMCD
) {
606 printf("illegal ASTresult result code: %d!\n", rescode
);
611 printf("Teardown reason:\n%s", ib
);
614 printf("Normal Teardown");
617 printf("Loss of Heartbeats");
620 printf("Out of bandwidth");
623 printf("Out of Memory");
626 printf("Application Crash");
629 printf("Unknown Teardown reason");
632 printf("(%x)\n%s", rescode
, ib
);
637 fputs("[|forces]", stdout
);
644 asrtlv_print(register const u_char
* pptr
, register u_int len
,
645 u_int16_t op_msk _U_
, int indent
)
649 char *ib
= indent_pr(indent
, 0);
652 * forces_type_print() has ensured that len (the TLV length)
655 dlen
= len
- TLV_HDRL
;
656 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
657 printf("illegal ASRresult-TLV: %d bytes!\n", dlen
);
661 rescode
= EXTRACT_32BITS(pptr
);
663 if (rescode
> ASRMCD
) {
664 printf("illegal ASRresult result code: %d!\n", rescode
);
675 printf("FE ID invalid ");
678 printf("permission denied ");
684 printf("(%x)\n%s", rescode
, ib
);
689 fputs("[|forces]", stdout
);
697 gentltlv_print(register const u_char
* pptr _U_
, register u_int len
,
698 u_int16_t op_msk _U_
, int indent _U_
)
700 u_int dlen
= len
- TLV_HDRL
;
702 if (dlen
< 4) { /* at least 32 bits must exist */
703 printf("truncated TLV: %d bytes missing! ", 4 - dlen
);
712 print_metailv(register const u_char
* pptr
, register u_int len
,
713 u_int16_t op_msk _U_
, int indent
)
717 char *ib
= indent_pr(indent
, 0);
718 /* XXX: check header length */
719 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
722 * print_metatlv() has ensured that len (what remains in the
725 rlen
= EXTRACT_32BITS(&ilv
->length
) - ILV_HDRL
;
727 printf("%sMetaID 0x%x length %d\n", ib
, EXTRACT_32BITS(&ilv
->type
),
728 EXTRACT_32BITS(&ilv
->length
));
730 hex_print_with_offset("\t\t[", ILV_DATA(ilv
), rlen
, 0);
736 fputs("[|forces]", stdout
);
741 print_metatlv(register const u_char
* pptr
, register u_int len
,
742 u_int16_t op_msk _U_
, int indent
)
745 char *ib
= indent_pr(indent
, 0);
747 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
751 * redirect_print() has ensured that len (what remains in the
754 dlen
= len
- TLV_HDRL
;
756 printf("\n%s METADATA length %d \n", ib
, rlen
);
759 invilv
= ilv_valid(ilv
, rlen
);
765 * At this point, ilv_valid() has ensured that the ILV
766 * length is large enough but not too large (it doesn't
767 * go past the end of the containing TLV).
769 print_metailv((u_char
*) ilv
, rlen
, 0, indent
+ 1);
770 ilv
= GO_NXT_ILV(ilv
, rlen
);
776 fputs("[|forces]", stdout
);
782 print_reddata(register const u_char
* pptr
, register u_int len
,
783 u_int16_t op_msk _U_
, int indent _U_
)
786 char *ib
= indent_pr(indent
, 0);
788 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
791 dlen
= len
- TLV_HDRL
;
793 printf("\n%s Redirect Data length %d \n", ib
, rlen
);
797 hex_print_with_offset("\n\t\t", pptr
, rlen
, 0);
805 redirect_print(register const u_char
* pptr
, register u_int len
,
806 u_int16_t op_msk _U_
, int indent
)
808 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
814 * forces_type_print() has ensured that len (the TLV length)
817 dlen
= len
- TLV_HDRL
;
818 if (dlen
<= RD_MIN
) {
819 printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
828 invtlv
= tlv_valid(tlv
, rlen
);
830 printf("Bad Redirect data\n");
835 * At this point, tlv_valid() has ensured that the TLV
836 * length is large enough but not too large (it doesn't
837 * go past the end of the containing TLV).
839 if (EXTRACT_16BITS(&tlv
->type
) == F_TLV_METD
) {
840 print_metatlv((u_char
*) TLV_DATA(tlv
),
841 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
842 } else if ((EXTRACT_16BITS(&tlv
->type
) == F_TLV_REDD
)) {
843 print_reddata((u_char
*) TLV_DATA(tlv
),
844 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
846 printf("Unknown REDIRECT TLV 0x%x len %d\n",
847 EXTRACT_16BITS(&tlv
->type
),
848 EXTRACT_16BITS(&tlv
->length
));
851 tlv
= GO_NXT_TLV(tlv
, rlen
);
856 ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
857 EXTRACT_16BITS(&tlv
->type
),
858 rlen
- EXTRACT_16BITS(&tlv
->length
));
865 fputs("[|forces]", stdout
);
873 lfbselect_print(register const u_char
* pptr
, register u_int len
,
874 u_int16_t op_msk
, int indent
)
876 const struct forces_lfbsh
*lfbs
;
877 const struct forces_tlv
*otlv
;
878 char *ib
= indent_pr(indent
, 0);
884 * forces_type_print() has ensured that len (the TLV length)
887 dlen
= len
- TLV_HDRL
;
888 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
889 printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
895 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
896 * we also know that it's > OP_OFF.
898 rlen
= dlen
- OP_OFF
;
900 lfbs
= (const struct forces_lfbsh
*)pptr
;
903 printf("\n%s%s(Classid %x) instance %x\n",
904 ib
, tok2str(ForCES_LFBs
, NULL
, EXTRACT_32BITS(&lfbs
->class)),
905 EXTRACT_32BITS(&lfbs
->class),
906 EXTRACT_32BITS(&lfbs
->instance
));
909 otlv
= (struct forces_tlv
*)(lfbs
+ 1);
914 invtlv
= tlv_valid(otlv
, rlen
);
919 * At this point, tlv_valid() has ensured that the TLV
920 * length is large enough but not too large (it doesn't
921 * go past the end of the containing TLV).
923 if (op_valid(EXTRACT_16BITS(&otlv
->type
), op_msk
)) {
924 otlv_print(otlv
, 0, indent
);
929 ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
930 EXTRACT_16BITS(&otlv
->type
), EXTRACT_16BITS(&otlv
->length
));
931 invoptlv_print((u_char
*)otlv
, rlen
, 0, indent
);
933 otlv
= GO_NXT_TLV(otlv
, rlen
);
938 ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
939 EXTRACT_16BITS(&otlv
->type
), rlen
- EXTRACT_16BITS(&otlv
->length
));
946 fputs("[|forces]", stdout
);
951 forces_type_print(register const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
952 register u_int mlen
, const struct tom_h
*tops
)
954 const struct forces_tlv
*tltlv
;
961 * forces_print() has already checked that mlen >= ForCES_HDRL
962 * by calling ForCES_HLN_VALID().
964 rlen
= mlen
- ForCES_HDRL
;
966 if (rlen
> TLV_HLN
) {
967 if (tops
->flags
& ZERO_TTLV
) {
968 printf("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
972 if (tops
->flags
& ZERO_MORE_TTLV
)
974 if (tops
->flags
& ONE_MORE_TTLV
) {
975 printf("\tTop level TLV Data missing!\n");
980 if (tops
->flags
& ZERO_TTLV
) {
984 ttlv
= tops
->flags
>> 4;
985 tltlv
= GET_TOP_TLV(pptr
);
987 /*XXX: 15 top level tlvs will probably be fine
988 You are nuts if you send more ;-> */
991 invtlv
= tlv_valid(tltlv
, rlen
);
996 * At this point, tlv_valid() has ensured that the TLV
997 * length is large enough but not too large (it doesn't
998 * go past the end of the packet).
1000 if (!ttlv_valid(EXTRACT_16BITS(&tltlv
->type
))) {
1001 printf("\n\tInvalid ForCES Top TLV type=0x%x",
1002 EXTRACT_16BITS(&tltlv
->type
));
1007 printf("\t%s, length %d (data length %d Bytes)",
1008 tok2str(ForCES_TLV
, NULL
, EXTRACT_16BITS(&tltlv
->type
)),
1009 EXTRACT_16BITS(&tltlv
->length
),
1010 EXTRACT_16BITS(&tltlv
->length
) - TLV_HDRL
);
1012 rc
= tops
->print((u_char
*) TLV_DATA(tltlv
),
1013 EXTRACT_16BITS(&tltlv
->length
), tops
->op_msk
, 9);
1017 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1023 * XXX - if ttlv != 0, does that mean that the packet was too
1024 * short, and didn't have *enough* TLVs in it?
1027 printf("\tMess TopTLV header: min %u, total %d advertised %d ",
1028 TLV_HDRL
, rlen
, EXTRACT_16BITS(&tltlv
->length
));
1035 fputs("[|forces]", stdout
);
1039 void forces_print(register const u_char
* pptr
, register u_int len
)
1041 const struct forcesh
*fhdr
;
1044 const struct tom_h
*tops
;
1047 fhdr
= (const struct forcesh
*)pptr
;
1049 if (!tom_valid(fhdr
->fm_tom
)) {
1050 printf("Invalid ForCES message type %d\n", fhdr
->fm_tom
);
1054 mlen
= ForCES_BLN(fhdr
);
1056 tops
= get_forces_tom(fhdr
->fm_tom
);
1057 if (tops
->v
== TOM_RSVD
) {
1058 printf("\n\tUnknown ForCES message type=0x%x", fhdr
->fm_tom
);
1062 printf("\n\tForCES %s ", tops
->s
);
1063 if (!ForCES_HLN_VALID(mlen
, len
)) {
1065 ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
1066 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1070 TCHECK2(*(pptr
+ 20), 4);
1071 flg_raw
= EXTRACT_32BITS(pptr
+ 20);
1073 printf("\n\tForCES Version %d len %uB flags 0x%08x ",
1074 ForCES_V(fhdr
), mlen
, flg_raw
);
1075 printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1076 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1077 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1078 EXTRACT_64BITS(fhdr
->fm_cor
));
1083 ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1084 ForCES_ACKp(ForCES_ACK(fhdr
)), ForCES_ACK(fhdr
),
1086 ForCES_EMp(ForCES_EM(fhdr
)), ForCES_EM(fhdr
),
1087 ForCES_ATp(ForCES_AT(fhdr
)), ForCES_AT(fhdr
),
1088 ForCES_TPp(ForCES_TP(fhdr
)), ForCES_TP(fhdr
));
1090 ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1091 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1093 rc
= forces_type_print(pptr
, fhdr
, mlen
, tops
);
1096 hex_print_with_offset("\n\t[", pptr
, len
, 0);
1102 printf("\n\t Raw ForCES message\n\t [");
1103 hex_print_with_offset("\n\t ", pptr
, len
, 0);
1110 fputs("[|forces]", stdout
);