]>
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 //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 for (i
= 0; i
< IDcnt
; i
++) {
229 id
= EXTRACT_32BITS(pptr
);
231 printf("%sID#%02u: %d\n", ib
, i
+ 1, id
);
236 if ((op_msk
& B_TRNG
) || (op_msk
& B_KEYIN
)) {
237 if (len
< PTH_DESC_SIZE
) {
238 printf("pathlength %d with key/range too short %d\n",
243 if (op_msk
& B_TRNG
) {
244 u_int32_t starti
, endi
;
245 pptr
+= sizeof(struct forces_tlv
);
246 len
-= sizeof(struct forces_tlv
);
248 starti
= EXTRACT_32BITS(pptr
);
252 endi
= EXTRACT_32BITS(pptr
);
257 printf("%sTable range: [%d,%d]\n", ib
, starti
, endi
);
260 if (op_msk
& B_KEYIN
) {
261 struct forces_tlv
*keytlv
;
263 u_int32_t keyid
= EXTRACT_32BITS(pptr
);
267 keytlv
= (struct forces_tlv
*)pptr
;
269 pptr
+= sizeof(struct forces_tlv
);
270 len
-= sizeof(struct forces_tlv
);
271 /* skip key content */
272 tll
= EXTRACT_16BITS(&keytlv
->length
) - TLV_HDRL
;
276 printf("Key content too short\n");
284 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
292 type
= EXTRACT_16BITS(&pdtlv
->type
);
293 invtlv
= tlv_valid(pdtlv
, len
);
296 ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
297 tok2str(ForCES_TLV_err
, NULL
, invtlv
), len
, type
,
298 EXTRACT_16BITS(&pdtlv
->length
));
302 * At this point, tlv_valid() has ensured that the TLV
303 * length is large enough but not too large (it doesn't
304 * go past the end of the containing TLV).
306 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
307 aln
= F_ALN_LEN(EXTRACT_16BITS(&pdtlv
->length
));
308 if (aln
> EXTRACT_16BITS(&pdtlv
->length
)) {
311 ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
312 type
, EXTRACT_16BITS(&pdtlv
->length
), aln
- len
);
314 pad
= aln
- EXTRACT_16BITS(&pdtlv
->length
);
317 if (pd_valid(type
)) {
318 const struct pdata_ops
*ops
= get_forces_pd(type
);
320 if (vflag
>= 3 && ops
->v
!= F_TLV_PDAT
) {
323 ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
324 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
328 ("%s %s (Length %d DataLen %d Bytes)\n",
329 ib
, ops
->s
, EXTRACT_16BITS(&pdtlv
->length
),
333 chk_op_type(type
, op_msk
, ops
->op_msk
);
335 if (ops
->print((const u_char
*)pdtlv
,
336 tll
+ pad
+ TLV_HDRL
, op_msk
,
339 len
-= (TLV_HDRL
+ pad
+ tll
);
341 printf("Invalid path data content type 0x%x len %d\n",
342 type
, EXTRACT_16BITS(&pdtlv
->length
));
344 if (EXTRACT_16BITS(&pdtlv
->length
)) {
345 hex_print_with_offset("Bad Data val\n\t [",
356 fputs("[|forces]", stdout
);
361 pdata_print(register const u_char
* pptr
, register u_int len
,
362 u_int16_t op_msk
, int indent
)
364 const struct pathdata_h
*pdh
= (struct pathdata_h
*)pptr
;
365 char *ib
= indent_pr(indent
, 0);
371 if (len
< sizeof(struct pathdata_h
))
374 printf("\n%sPathdata: Flags 0x%x ID count %d\n",
375 ib
, EXTRACT_16BITS(&pdh
->pflags
), EXTRACT_16BITS(&pdh
->pIDcnt
));
378 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELKEY
) {
382 /* Table GET Range operation */
383 if (EXTRACT_16BITS(&pdh
->pflags
) & F_SELTABRANGE
) {
387 pptr
+= sizeof(struct pathdata_h
);
388 len
-= sizeof(struct pathdata_h
);
389 idcnt
= EXTRACT_16BITS(&pdh
->pIDcnt
);
392 printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize
,
394 hex_print_with_offset("\t\t\tID Data[", pptr
, len
, 0);
399 if ((op_msk
& B_TRNG
) && (op_msk
& B_KEYIN
)) {
400 printf("\t\t\tIllegal to have both Table ranges and keys\n");
404 more_pd
= pdatacnt_print(pptr
, len
, idcnt
, op_msk
, indent
);
406 int consumed
= len
- more_pd
;
409 /* XXX: Argh, recurse some more */
410 return recpdoptlv_print(pptr
, len
, op_msk
, indent
+1);
415 fputs("[|forces]", stdout
);
420 genoptlv_print(register const u_char
* pptr
, register u_int len
,
421 u_int16_t op_msk
, int indent
)
423 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
427 char *ib
= indent_pr(indent
, 0);
430 type
= EXTRACT_16BITS(&pdtlv
->type
);
431 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
432 invtlv
= tlv_valid(pdtlv
, len
);
433 printf("genoptlvprint - %s TLV type 0x%x len %d\n",
434 tok2str(ForCES_TLV
, NULL
, type
), type
, EXTRACT_16BITS(&pdtlv
->length
));
437 * At this point, tlv_valid() has ensured that the TLV
438 * length is large enough but not too large (it doesn't
439 * go past the end of the containing TLV).
441 register const u_char
*dp
= (u_char
*) TLV_DATA(pdtlv
);
442 if (!ttlv_valid(type
)) {
443 printf("%s TLV type 0x%x len %d\n",
444 tok2str(ForCES_TLV_err
, NULL
, invtlv
), type
,
445 EXTRACT_16BITS(&pdtlv
->length
));
449 printf("%s%s, length %d (data length %d Bytes)",
450 ib
, tok2str(ForCES_TLV
, NULL
, type
),
451 EXTRACT_16BITS(&pdtlv
->length
), tll
);
453 return pdata_print(dp
, tll
, op_msk
, indent
+ 1);
455 printf("\t\t\tInvalid ForCES TLV type=%x", type
);
460 fputs("[|forces]", stdout
);
465 recpdoptlv_print(register const u_char
* pptr
, register u_int len
,
466 u_int16_t op_msk
, int indent
)
468 const struct forces_tlv
*pdtlv
= (struct forces_tlv
*)pptr
;
472 register const u_char
*dp
;
477 invtlv
= tlv_valid(pdtlv
, len
);
483 * At this point, tlv_valid() has ensured that the TLV
484 * length is large enough but not too large (it doesn't
485 * go past the end of the containing TLV).
487 ib
= indent_pr(indent
, 0);
488 type
= EXTRACT_16BITS(&pdtlv
->type
);
489 dp
= (u_char
*) TLV_DATA(pdtlv
);
490 tll
= EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
;
494 ("%s%s, length %d (data encapsulated %d Bytes)",
495 ib
, tok2str(ForCES_TLV
, NULL
, type
),
496 EXTRACT_16BITS(&pdtlv
->length
),
497 EXTRACT_16BITS(&pdtlv
->length
) - TLV_HDRL
);
499 if (pdata_print(dp
, tll
, op_msk
, indent
+ 1) == -1)
501 pdtlv
= GO_NXT_TLV(pdtlv
, len
);
506 ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
507 EXTRACT_16BITS(&pdtlv
->type
), len
- EXTRACT_16BITS(&pdtlv
->length
));
514 fputs("[|forces]", stdout
);
519 invoptlv_print(register const u_char
* pptr
, register u_int len
,
520 u_int16_t op_msk _U_
, int indent
)
522 char *ib
= indent_pr(indent
, 1);
525 printf("%sData[", &ib
[1]);
526 hex_print_with_offset(ib
, pptr
, len
, 0);
532 int otlv_print(const struct forces_tlv
*otlv
, u_int16_t op_msk _U_
, int indent
)
535 register const u_char
*dp
= (u_char
*) TLV_DATA(otlv
);
538 char *ib
= indent_pr(indent
, 0);
539 const struct optlv_h
*ops
;
542 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
546 type
= EXTRACT_16BITS(&otlv
->type
);
547 tll
= EXTRACT_16BITS(&otlv
->length
) - TLV_HDRL
;
548 ops
= get_forces_optlv_h(type
);
550 printf("%sOper TLV %s(0x%x) length %d\n", ib
, ops
->s
, type
,
551 EXTRACT_16BITS(&otlv
->length
));
553 /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
554 if (!ops
->flags
& ZERO_TTLV
) {
555 if (tll
!= 0) /* instead of "if (tll)" - for readability .. */
556 printf("%s: Illegal - MUST be empty\n", ops
->s
);
559 /* rest of ops must at least have 12B {pathinfo} */
560 if (tll
< OP_MIN_SIZ
) {
561 printf("\t\tOper TLV %s(0x%x) length %d\n", ops
->s
, type
,
562 EXTRACT_16BITS(&otlv
->length
));
563 printf("\t\tTruncated data size %d minimum required %d\n", tll
,
565 return invoptlv_print(dp
, tll
, ops
->op_msk
, indent
);
569 rc
= ops
->print(dp
, tll
, ops
->op_msk
, indent
+ 1);
573 fputs("[|forces]", stdout
);
580 asttlv_print(register const u_char
* pptr
, register u_int len
,
581 u_int16_t op_msk _U_
, int indent
)
585 char *ib
= indent_pr(indent
, 0);
588 * forces_type_print() has ensured that len (the TLV length)
591 dlen
= len
- TLV_HDRL
;
592 if (dlen
!= ASTDLN
) {
593 printf("illegal ASTresult-TLV: %d bytes!\n", dlen
);
597 rescode
= EXTRACT_32BITS(pptr
);
598 if (rescode
> ASTMCD
) {
599 printf("illegal ASTresult result code: %d!\n", rescode
);
604 printf("Teardown reason:\n%s", ib
);
607 printf("Normal Teardown");
610 printf("Loss of Heartbeats");
613 printf("Out of bandwidth");
616 printf("Out of Memory");
619 printf("Application Crash");
622 printf("Unknown Teardown reason");
625 printf("(%x)\n%s", rescode
, ib
);
630 fputs("[|forces]", stdout
);
637 asrtlv_print(register const u_char
* pptr
, register u_int len
,
638 u_int16_t op_msk _U_
, int indent
)
642 char *ib
= indent_pr(indent
, 0);
645 * forces_type_print() has ensured that len (the TLV length)
648 dlen
= len
- TLV_HDRL
;
649 if (dlen
!= ASRDLN
) { /* id, instance, oper tlv */
650 printf("illegal ASRresult-TLV: %d bytes!\n", dlen
);
654 rescode
= EXTRACT_32BITS(pptr
);
656 if (rescode
> ASRMCD
) {
657 printf("illegal ASRresult result code: %d!\n", rescode
);
668 printf("FE ID invalid ");
671 printf("permission denied ");
677 printf("(%x)\n%s", rescode
, ib
);
682 fputs("[|forces]", stdout
);
690 gentltlv_print(register const u_char
* pptr _U_
, register u_int len
,
691 u_int16_t op_msk _U_
, int indent _U_
)
693 u_int dlen
= len
- TLV_HDRL
;
695 if (dlen
< 4) { /* at least 32 bits must exist */
696 printf("truncated TLV: %d bytes missing! ", 4 - dlen
);
705 print_metailv(register const u_char
* pptr
, register u_int len
,
706 u_int16_t op_msk _U_
, int indent
)
710 char *ib
= indent_pr(indent
, 0);
711 /* XXX: check header length */
712 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
715 * print_metatlv() has ensured that len (what remains in the
718 rlen
= EXTRACT_32BITS(&ilv
->length
) - ILV_HDRL
;
720 printf("%sMetaID 0x%x length %d\n", ib
, EXTRACT_32BITS(&ilv
->type
),
721 EXTRACT_32BITS(&ilv
->length
));
723 hex_print_with_offset("\t\t[", ILV_DATA(ilv
), rlen
, 0);
729 fputs("[|forces]", stdout
);
734 print_metatlv(register const u_char
* pptr
, register u_int len
,
735 u_int16_t op_msk _U_
, int indent
)
738 char *ib
= indent_pr(indent
, 0);
740 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
744 * redirect_print() has ensured that len (what remains in the
747 dlen
= len
- TLV_HDRL
;
749 printf("\n%s METADATA length %d \n", ib
, rlen
);
752 invilv
= ilv_valid(ilv
, rlen
);
758 * At this point, ilv_valid() has ensured that the ILV
759 * length is large enough but not too large (it doesn't
760 * go past the end of the containing TLV).
762 print_metailv((u_char
*) ilv
, rlen
, 0, indent
+ 1);
763 ilv
= GO_NXT_ILV(ilv
, rlen
);
769 fputs("[|forces]", stdout
);
775 print_reddata(register const u_char
* pptr
, register u_int len
,
776 u_int16_t op_msk _U_
, int indent _U_
)
779 char *ib
= indent_pr(indent
, 0);
781 const struct forces_ilv
*ilv
= (struct forces_ilv
*)pptr
;
784 dlen
= len
- TLV_HDRL
;
786 printf("\n%s Redirect Data length %d \n", ib
, rlen
);
790 hex_print_with_offset("\n\t\t", pptr
, rlen
, 0);
798 redirect_print(register const u_char
* pptr
, register u_int len
,
799 u_int16_t op_msk _U_
, int indent
)
801 const struct forces_tlv
*tlv
= (struct forces_tlv
*)pptr
;
807 * forces_type_print() has ensured that len (the TLV length)
810 dlen
= len
- TLV_HDRL
;
811 if (dlen
<= RD_MIN
) {
812 printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
821 invtlv
= tlv_valid(tlv
, rlen
);
823 printf("Bad Redirect data\n");
828 * At this point, tlv_valid() has ensured that the TLV
829 * length is large enough but not too large (it doesn't
830 * go past the end of the containing TLV).
832 if (EXTRACT_16BITS(&tlv
->type
) == F_TLV_METD
) {
833 print_metatlv((u_char
*) TLV_DATA(tlv
),
834 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
835 } else if ((EXTRACT_16BITS(&tlv
->type
) == F_TLV_REDD
)) {
836 print_reddata((u_char
*) TLV_DATA(tlv
),
837 EXTRACT_16BITS(&tlv
->length
), 0, indent
);
839 printf("Unknown REDIRECT TLV 0x%x len %d\n",
840 EXTRACT_16BITS(&tlv
->type
),
841 EXTRACT_16BITS(&tlv
->length
));
844 tlv
= GO_NXT_TLV(tlv
, rlen
);
849 ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
850 EXTRACT_16BITS(&tlv
->type
),
851 rlen
- EXTRACT_16BITS(&tlv
->length
));
858 fputs("[|forces]", stdout
);
866 lfbselect_print(register const u_char
* pptr
, register u_int len
,
867 u_int16_t op_msk
, int indent
)
869 const struct forces_lfbsh
*lfbs
;
870 const struct forces_tlv
*otlv
;
871 char *ib
= indent_pr(indent
, 0);
877 * forces_type_print() has ensured that len (the TLV length)
880 dlen
= len
- TLV_HDRL
;
881 if (dlen
<= OP_MIN
) { /* id, instance, oper tlv header .. */
882 printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
888 * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
889 * we also know that it's > OP_OFF.
891 rlen
= dlen
- OP_OFF
;
893 lfbs
= (const struct forces_lfbsh
*)pptr
;
896 printf("\n%s%s(Classid %x) instance %x\n",
897 ib
, tok2str(ForCES_LFBs
, NULL
, EXTRACT_32BITS(&lfbs
->class)),
898 EXTRACT_32BITS(&lfbs
->class),
899 EXTRACT_32BITS(&lfbs
->instance
));
902 otlv
= (struct forces_tlv
*)(lfbs
+ 1);
907 invtlv
= tlv_valid(otlv
, rlen
);
912 * At this point, tlv_valid() has ensured that the TLV
913 * length is large enough but not too large (it doesn't
914 * go past the end of the containing TLV).
916 if (op_valid(EXTRACT_16BITS(&otlv
->type
), op_msk
)) {
917 otlv_print(otlv
, 0, indent
);
922 ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
923 EXTRACT_16BITS(&otlv
->type
), EXTRACT_16BITS(&otlv
->length
));
924 invoptlv_print((u_char
*)otlv
, rlen
, 0, indent
);
926 otlv
= GO_NXT_TLV(otlv
, rlen
);
931 ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
932 EXTRACT_16BITS(&otlv
->type
), rlen
- EXTRACT_16BITS(&otlv
->length
));
939 fputs("[|forces]", stdout
);
944 forces_type_print(register const u_char
* pptr
, const struct forcesh
*fhdr _U_
,
945 register u_int mlen
, const struct tom_h
*tops
)
947 const struct forces_tlv
*tltlv
;
954 * forces_print() has already checked that mlen >= ForCES_HDRL
955 * by calling ForCES_HLN_VALID().
957 rlen
= mlen
- ForCES_HDRL
;
959 if (rlen
> TLV_HLN
) {
960 if (tops
->flags
& ZERO_TTLV
) {
961 printf("<0x%x>Illegal Top level TLV!\n", tops
->flags
);
965 if (tops
->flags
& ZERO_MORE_TTLV
)
967 if (tops
->flags
& ONE_MORE_TTLV
) {
968 printf("\tTop level TLV Data missing!\n");
973 if (tops
->flags
& ZERO_TTLV
) {
977 ttlv
= tops
->flags
>> 4;
978 tltlv
= GET_TOP_TLV(pptr
);
980 /*XXX: 15 top level tlvs will probably be fine
981 You are nuts if you send more ;-> */
984 invtlv
= tlv_valid(tltlv
, rlen
);
989 * At this point, tlv_valid() has ensured that the TLV
990 * length is large enough but not too large (it doesn't
991 * go past the end of the packet).
993 if (!ttlv_valid(EXTRACT_16BITS(&tltlv
->type
))) {
994 printf("\n\tInvalid ForCES Top TLV type=0x%x",
995 EXTRACT_16BITS(&tltlv
->type
));
1000 printf("\t%s, length %d (data length %d Bytes)",
1001 tok2str(ForCES_TLV
, NULL
, EXTRACT_16BITS(&tltlv
->type
)),
1002 EXTRACT_16BITS(&tltlv
->length
),
1003 EXTRACT_16BITS(&tltlv
->length
) - TLV_HDRL
);
1005 rc
= tops
->print((u_char
*) TLV_DATA(tltlv
),
1006 EXTRACT_16BITS(&tltlv
->length
), tops
->op_msk
, 9);
1010 tltlv
= GO_NXT_TLV(tltlv
, rlen
);
1016 * XXX - if ttlv != 0, does that mean that the packet was too
1017 * short, and didn't have *enough* TLVs in it?
1020 printf("\tMess TopTLV header: min %u, total %d advertised %d ",
1021 TLV_HDRL
, rlen
, EXTRACT_16BITS(&tltlv
->length
));
1028 fputs("[|forces]", stdout
);
1032 void forces_print(register const u_char
* pptr
, register u_int len
)
1034 const struct forcesh
*fhdr
;
1037 const struct tom_h
*tops
;
1040 fhdr
= (const struct forcesh
*)pptr
;
1042 if (!tom_valid(fhdr
->fm_tom
)) {
1043 printf("Invalid ForCES message type %d\n", fhdr
->fm_tom
);
1047 mlen
= ForCES_BLN(fhdr
);
1049 tops
= get_forces_tom(fhdr
->fm_tom
);
1050 if (tops
->v
== TOM_RSVD
) {
1051 printf("\n\tUnknown ForCES message type=0x%x", fhdr
->fm_tom
);
1055 printf("\n\tForCES %s ", tops
->s
);
1056 if (!ForCES_HLN_VALID(mlen
, len
)) {
1058 ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
1059 ForCES_HDRL
, len
, ForCES_BLN(fhdr
));
1063 TCHECK2(*(pptr
+ 20), 4);
1064 flg_raw
= EXTRACT_32BITS(pptr
+ 20);
1066 printf("\n\tForCES Version %d len %uB flags 0x%08x ",
1067 ForCES_V(fhdr
), mlen
, flg_raw
);
1068 printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64
,
1069 ForCES_SID(fhdr
), ForCES_node(ForCES_SID(fhdr
)),
1070 ForCES_DID(fhdr
), ForCES_node(ForCES_DID(fhdr
)),
1071 EXTRACT_64BITS(fhdr
->fm_cor
));
1076 ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
1077 ForCES_ACKp(ForCES_ACK(fhdr
)), ForCES_ACK(fhdr
),
1079 ForCES_EMp(ForCES_EM(fhdr
)), ForCES_EM(fhdr
),
1080 ForCES_ATp(ForCES_AT(fhdr
)), ForCES_AT(fhdr
),
1081 ForCES_TPp(ForCES_TP(fhdr
)), ForCES_TP(fhdr
));
1083 ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
1084 ForCES_RS1(fhdr
), ForCES_RS2(fhdr
));
1086 rc
= forces_type_print(pptr
, fhdr
, mlen
, tops
);
1089 hex_print_with_offset("\n\t[", pptr
, len
, 0);
1095 printf("\n\t Raw ForCES message\n\t [");
1096 hex_print_with_offset("\n\t ", pptr
, len
, 0);
1103 fputs("[|forces]", stdout
);