]>
The Tcpdump Group git mirrors - tcpdump/blob - print-forces.c
673aab9a248d5ae211caea2d8d57a8105c4e124d
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
);
216 pdatacnt_print(register const u_char
* pptr
, register u_int len
,
217 u_int16_t IDcnt
, u_int16_t op_msk
, int indent
)
221 char *ib
= indent_pr(indent
, 0);
223 for (i
= 0; i
< IDcnt
; i
++) {
227 id
= EXTRACT_32BITS(pptr
);
229 printf("%s ID#%02u: %d\n", ib
, i
+ 1, id
);
234 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
242 type
= EXTRACT_16BITS(&pdtlv
->type
);
243 invtlv
= tlv_valid(pdtlv
, len
);
246 ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
247 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
248 EXTRACT_16BITS(&pdtlv
->length
));
252 * At this point, tlv_valid() has ensured that the TLV
253 * length is large enough but not too large (it doesn't
254 * go past the end of the containing TLV).
256 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
257 aln
= F_ALN_LEN(EXTRACT_16BITS(&pdtlv
->length
));
258 if (aln
> EXTRACT_16BITS(&pdtlv
->length
)) {
261 ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
262 type
, EXTRACT_16BITS(&pdtlv
->length
), aln
- len
);
264 pad
= aln
- EXTRACT_16BITS(&pdtlv
->length
);
267 if (pd_valid(type
)) {
268 const struct pdata_ops
*ops
= get_forces_pd(type
);
270 if (vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
273 ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
274 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
278 ("%s %s (Length %d DataLen %d Bytes)\n",
279 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
283 chk_op_type(type
, op_msk
, ops
->op_msk
);
285 if (ops
->print((const u_char
*)pdtlv
,
286 tll
+ pad
+ TLV_HDRL
, op_msk
,
289 len
-= (TLV_HDRL
+ pad
+ tll
);
291 printf("Invalid path data content type 0x%x len %d\n",
292 type
, EXTRACT_16BITS(&pdtlv
->length
));
294 if (EXTRACT_16BITS(&pdtlv
->length
)) {
295 hex_print_with_offset("Bad Data val\n\t [",
306 fputs("[|forces]", stdout
);
311 pdata_print(register const u_char
* pptr
, register u_int len
,
312 u_int16_t op_msk
, int indent
)
314 const struct pathdata_h
*pdh
= (struct pathdata_h
*)pptr
;
315 char *ib
= indent_pr(indent
, 0);
321 if (len
< sizeof(struct pathdata_h
))
324 printf("\n%sPathdata: Flags 0x%x ID count %d\n",
325 ib
, EXTRACT_16BITS(&pdh
->pflags
), EXTRACT_16BITS(&pdh
->pIDcnt
));
328 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELKEY
) {
331 pptr
+= sizeof(struct pathdata_h
);
332 len
-= sizeof(struct pathdata_h
);
333 idcnt
= EXTRACT_16BITS(&pdh
->pIDcnt
);
336 printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
338 hex_print_with_offset("\t\t\tID Data[", pptr
, len
, 0);
342 more_pd
= pdatacnt_print(pptr
, len
, idcnt
, op_msk
, indent
);
344 int consumed
= len
- more_pd
;
347 /* XXX: Argh, recurse some more */
348 return recpdoptlv_print(pptr
, len
, op_msk
, indent
+1);
353 fputs("[|forces]", stdout
);
358 genoptlv_print(register const u_char
* pptr
, register u_int len
,
359 u_int16_t op_msk
, int indent
)
361 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
365 char *ib
= indent_pr(indent
, 0);
368 type
= EXTRACT_16BITS(&pdtlv
->type
);
369 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
370 invtlv
= tlv_valid(pdtlv
, len
);
371 printf("genoptlvprint - %s TLV type 0x%x len %d\n",
372 tok2str(ForCES_TLV
, NULL
, type
), type
, EXTRACT_16BITS(&pdtlv
->length
));
375 * At this point, tlv_valid() has ensured that the TLV
376 * length is large enough but not too large (it doesn't
377 * go past the end of the containing TLV).
379 register const u_char
*dp
= (u_char
*) TLV_DATA(pdtlv
);
380 if (!ttlv_valid(type
)) {
381 printf("%s TLV type 0x%x len %d\n",
382 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
383 EXTRACT_16BITS(&pdtlv
->length
));
387 printf("%s%s, length %d (data length %d Bytes)",
388 ib
, tok2str(ForCES_TLV
, NULL
, type
),
389 EXTRACT_16BITS(&pdtlv
->length
), tll
);
391 return pdata_print(dp
, tll
, op_msk
, indent
+ 1);
393 printf("\t\t\tInvalid ForCES TLV type=%x", type
);
398 fputs("[|forces]", stdout
);
403 recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
404 u_int16_t op_msk
, int indent
)
406 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
410 register const u_char
*dp
;
415 invtlv
= tlv_valid(pdtlv
, len
);
421 * At this point, tlv_valid() has ensured that the TLV
422 * length is large enough but not too large (it doesn't
423 * go past the end of the containing TLV).
425 ib
= indent_pr(indent
, 0);
426 type
= EXTRACT_16BITS(&pdtlv
->type
);
427 dp
= (u_char
*) TLV_DATA(pdtlv
);
428 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
432 ("%s%s, length %d (data encapsulated %d Bytes)",
433 ib
, tok2str(ForCES_TLV
, NULL
, type
),
434 EXTRACT_16BITS(&pdtlv
->length
),
435 EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
);
437 if (pdata_print(dp
, tll
, op_msk
, indent
+ 1) == -1)
439 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
444 ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
445 EXTRACT_16BITS(&pdtlv
->type
), len
- EXTRACT_16BITS(&pdtlv
->length
));
452 fputs("[|forces]", stdout
);
457 invoptlv_print(register const u_char
* pptr
, register u_int len
,
458 u_int16_t op_msk _U_
, int indent
)
460 char *ib
= indent_pr(indent
, 1);
463 printf("%sData[", &ib
[1]);
464 hex_print_with_offset(ib
, pptr
, len
, 0);
470 int otlv_print(const struct forces_tlv
*otlv
, u_int16_t op_msk _U_
, int indent
)
473 register const u_char
*dp
= (u_char
*) TLV_DATA(otlv
);
476 char *ib
= indent_pr(indent
, 0);
477 const struct optlv_h
*ops
;
480 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
484 type
= EXTRACT_16BITS(&otlv
->type
);
485 tll
= EXTRACT_16BITS(&otlv
->length
) - TLV_HDRL
;
486 ops
= get_forces_optlv_h(type
);
488 printf("%sOper TLV %s(0x%x) length %d\n", ib
, ops
->s
, type
,
489 EXTRACT_16BITS(&otlv
->length
));
491 /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
492 if (!ops
->flags
& ZERO_TTLV
) {
493 if (tll
!= 0) /* instead of "if (tll)" - for readability .. */
494 printf("%s: Illegal - MUST be empty\n", ops
->s
);
497 /* rest of ops must at least have 12B {pathinfo} */
498 if (tll
< OP_MIN_SIZ
) {
499 printf("\t\tOper TLV %s(0x%x) length %d\n", ops
->s
, type
,
500 EXTRACT_16BITS(&otlv
->length
));
501 printf("\t\tTruncated data size %d minimum required %d\n", tll
,
503 return invoptlv_print(dp
, tll
, ops
->op_msk
, indent
);
507 rc
= ops
->print(dp
, tll
, ops
->op_msk
, indent
+ 1);
511 fputs("[|forces]", stdout
);
518 asttlv_print(register const u_char
* pptr
, register u_int len
,
519 u_int16_t op_msk _U_
, int indent
)
523 char *ib
= indent_pr(indent
, 0);
526 * forces_type_print() has ensured that len (the TLV length)
529 dlen
= len
- TLV_HDRL
;
530 if (dlen
!= ASTDLN
) {
531 printf("illegal ASTresult-TLV: %d bytes!\n", dlen
);
535 rescode
= EXTRACT_32BITS(pptr
);
536 if (rescode
> ASTMCD
) {
537 printf("illegal ASTresult result code: %d!\n", rescode
);
542 printf("Teardown reason:\n%s", ib
);
545 printf("Normal Teardown");
548 printf("Loss of Heartbeats");
551 printf("Out of bandwidth");
554 printf("Out of Memory");
557 printf("Application Crash");
560 printf("Unknown Teardown reason");
563 printf("(%x)\n%s", rescode
, ib
);
568 fputs("[|forces]", stdout
);
575 asrtlv_print(register const u_char
* pptr
, register u_int len
,
576 u_int16_t op_msk _U_
, int indent
)
580 char *ib
= indent_pr(indent
, 0);
583 * forces_type_print() has ensured that len (the TLV length)
586 dlen
= len
- TLV_HDRL
;
587 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
588 printf("illegal ASRresult-TLV: %d bytes!\n", dlen
);
592 rescode
= EXTRACT_32BITS(pptr
);
594 if (rescode
> ASRMCD
) {
595 printf("illegal ASRresult result code: %d!\n", rescode
);
606 printf("FE ID invalid ");
609 printf("permission denied ");
615 printf("(%x)\n%s", rescode
, ib
);
620 fputs("[|forces]", stdout
);
628 gentltlv_print(register const u_char
* pptr _U_
, register u_int len
,
629 u_int16_t op_msk _U_
, int indent _U_
)
631 u_int dlen
= len
- TLV_HDRL
;
633 if (dlen
< 4) { /* at least 32 bits must exist */
634 printf("truncated TLV: %d bytes missing! ", 4 - dlen
);
643 print_metailv(register const u_char
* pptr
, register u_int len
,
644 u_int16_t op_msk _U_
, int indent
)
648 char *ib
= indent_pr(indent
, 0);
649 /* XXX: check header length */
650 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
653 * print_metatlv() has ensured that len (what remains in the
656 rlen
= EXTRACT_32BITS(&ilv
->length
) - ILV_HDRL
;
658 printf("%sMetaID 0x%x length %d\n", ib
, EXTRACT_32BITS(&ilv
->type
),
659 EXTRACT_32BITS(&ilv
->length
));
661 hex_print_with_offset("\t\t[", ILV_DATA(ilv
), rlen
, 0);
667 fputs("[|forces]", stdout
);
672 print_metatlv(register const u_char
* pptr
, register u_int len
,
673 u_int16_t op_msk _U_
, int indent
)
676 char *ib
= indent_pr(indent
, 0);
678 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
682 * redirect_print() has ensured that len (what remains in the
685 dlen
= len
- TLV_HDRL
;
687 printf("\n%s METADATA length %d \n", ib
, rlen
);
690 invilv
= ilv_valid(ilv
, rlen
);
696 * At this point, ilv_valid() has ensured that the ILV
697 * length is large enough but not too large (it doesn't
698 * go past the end of the containing TLV).
700 print_metailv((u_char
*) ilv
, rlen
, 0, indent
+ 1);
701 ilv
= GO_NXT_ILV(ilv
, rlen
);
707 fputs("[|forces]", stdout
);
713 print_reddata(register const u_char
* pptr
, register u_int len
,
714 u_int16_t op_msk _U_
, int indent _U_
)
717 char *ib
= indent_pr(indent
, 0);
719 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
722 dlen
= len
- TLV_HDRL
;
724 printf("\n%s Redirect Data length %d \n", ib
, rlen
);
728 hex_print_with_offset("\n\t\t", pptr
, rlen
, 0);
736 redirect_print(register const u_char
* pptr
, register u_int len
,
737 u_int16_t op_msk _U_
, int indent
)
739 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
745 * forces_type_print() has ensured that len (the TLV length)
748 dlen
= len
- TLV_HDRL
;
749 if (dlen
<= RD_MIN
) {
750 printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
759 invtlv
= tlv_valid(tlv
, rlen
);
761 printf("Bad Redirect data\n");
766 * At this point, tlv_valid() has ensured that the TLV
767 * length is large enough but not too large (it doesn't
768 * go past the end of the containing TLV).
770 if (EXTRACT_16BITS(&tlv
->type
) == F_TLV_METD
) {
771 print_metatlv((u_char
*) TLV_DATA(tlv
),
772 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
773 } else if ((EXTRACT_16BITS(&tlv
->type
) == F_TLV_REDD
)) {
774 print_reddata((u_char
*) TLV_DATA(tlv
),
775 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
777 printf("Unknown REDIRECT TLV 0x%x len %d\n",
778 EXTRACT_16BITS(&tlv
->type
),
779 EXTRACT_16BITS(&tlv
->length
));
782 tlv
= GO_NXT_TLV(tlv
, rlen
);
787 ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
788 EXTRACT_16BITS(&tlv
->type
),
789 rlen
- EXTRACT_16BITS(&tlv
->length
));
796 fputs("[|forces]", stdout
);
804 lfbselect_print(register const u_char
* pptr
, register u_int len
,
805 u_int16_t op_msk
, int indent
)
807 const struct forces_lfbsh
*lfbs
;
808 const struct forces_tlv
*otlv
;
809 char *ib
= indent_pr(indent
, 0);
815 * forces_type_print() has ensured that len (the TLV length)
818 dlen
= len
- TLV_HDRL
;
819 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
820 printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
826 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
827 * we also know that it's > OP_OFF.
829 rlen
= dlen
- OP_OFF
;
831 lfbs
= (const struct forces_lfbsh
*)pptr
;
834 printf("\n%s%s(Classid %x) instance %x\n",
835 ib
, tok2str(ForCES_LFBs
, NULL
, EXTRACT_32BITS(&lfbs
->class)),
836 EXTRACT_32BITS(&lfbs
->class),
837 EXTRACT_32BITS(&lfbs
->instance
));
840 otlv
= (struct forces_tlv
*)(lfbs
+ 1);
845 invtlv
= tlv_valid(otlv
, rlen
);
850 * At this point, tlv_valid() has ensured that the TLV
851 * length is large enough but not too large (it doesn't
852 * go past the end of the containing TLV).
854 if (op_valid(EXTRACT_16BITS(&otlv
->type
), op_msk
)) {
855 otlv_print(otlv
, 0, indent
);
860 ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
861 EXTRACT_16BITS(&otlv
->type
), EXTRACT_16BITS(&otlv
->length
));
862 invoptlv_print((u_char
*)otlv
, rlen
, 0, indent
);
864 otlv
= GO_NXT_TLV(otlv
, rlen
);
869 ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
870 EXTRACT_16BITS(&otlv
->type
), rlen
- EXTRACT_16BITS(&otlv
->length
));
877 fputs("[|forces]", stdout
);
882 forces_type_print(register const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
883 register u_int mlen
, const struct tom_h
*tops
)
885 const struct forces_tlv
*tltlv
;
892 * forces_print() has already checked that mlen >= ForCES_HDRL
893 * by calling ForCES_HLN_VALID().
895 rlen
= mlen
- ForCES_HDRL
;
897 if (rlen
> TLV_HLN
) {
898 if (tops
->flags
& ZERO_TTLV
) {
899 printf("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
903 if (tops
->flags
& ZERO_MORE_TTLV
)
905 if (tops
->flags
& ONE_MORE_TTLV
) {
906 printf("\tTop level TLV Data missing!\n");
911 if (tops
->flags
& ZERO_TTLV
) {
915 ttlv
= tops
->flags
>> 4;
916 tltlv
= GET_TOP_TLV(pptr
);
918 /*XXX: 15 top level tlvs will probably be fine
919 You are nuts if you send more ;-> */
922 invtlv
= tlv_valid(tltlv
, rlen
);
927 * At this point, tlv_valid() has ensured that the TLV
928 * length is large enough but not too large (it doesn't
929 * go past the end of the packet).
931 if (!ttlv_valid(EXTRACT_16BITS(&tltlv
->type
))) {
932 printf("\n\tInvalid ForCES Top TLV type=0x%x",
933 EXTRACT_16BITS(&tltlv
->type
));
938 printf("\t%s, length %d (data length %d Bytes)",
939 tok2str(ForCES_TLV
, NULL
, EXTRACT_16BITS(&tltlv
->type
)),
940 EXTRACT_16BITS(&tltlv
->length
),
941 EXTRACT_16BITS(&tltlv
->length
) - TLV_HDRL
);
943 rc
= tops
->print((u_char
*) TLV_DATA(tltlv
),
944 EXTRACT_16BITS(&tltlv
->length
), tops
->op_msk
, 9);
948 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
954 * XXX - if ttlv != 0, does that mean that the packet was too
955 * short, and didn't have *enough* TLVs in it?
958 printf("\tMess TopTLV header: min %u, total %d advertised %d ",
959 TLV_HDRL
, rlen
, EXTRACT_16BITS(&tltlv
->length
));
966 fputs("[|forces]", stdout
);
970 void forces_print(register const u_char
* pptr
, register u_int len
)
972 const struct forcesh
*fhdr
;
975 const struct tom_h
*tops
;
978 fhdr
= (const struct forcesh
*)pptr
;
980 if (!tom_valid(fhdr
->fm_tom
)) {
981 printf("Invalid ForCES message type %d\n", fhdr
->fm_tom
);
985 mlen
= ForCES_BLN(fhdr
);
987 tops
= get_forces_tom(fhdr
->fm_tom
);
988 if (tops
->v
== TOM_RSVD
) {
989 printf("\n\tUnknown ForCES message type=0x%x", fhdr
->fm_tom
);
993 printf("\n\tForCES %s ", tops
->s
);
994 if (!ForCES_HLN_VALID(mlen
, len
)) {
996 ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
997 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1001 TCHECK2(*(pptr
+ 20), 4);
1002 flg_raw
= EXTRACT_32BITS(pptr
+ 20);
1004 printf("\n\tForCES Version %d len %uB flags 0x%08x ",
1005 ForCES_V(fhdr
), mlen
, flg_raw
);
1006 printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1007 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1008 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1009 EXTRACT_64BITS(fhdr
->fm_cor
));
1014 ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1015 ForCES_ACKp(ForCES_ACK(fhdr
)), ForCES_ACK(fhdr
),
1017 ForCES_EMp(ForCES_EM(fhdr
)), ForCES_EM(fhdr
),
1018 ForCES_ATp(ForCES_AT(fhdr
)), ForCES_AT(fhdr
),
1019 ForCES_TPp(ForCES_TP(fhdr
)), ForCES_TP(fhdr
));
1021 ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1022 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1024 rc
= forces_type_print(pptr
, fhdr
, mlen
, tops
);
1027 hex_print_with_offset("\n\t[", pptr
, len
, 0);
1033 printf("\n\t Raw ForCES message\n\t [");
1034 hex_print_with_offset("\n\t ", pptr
, len
, 0);
1041 fputs("[|forces]", stdout
);