2010-01-11 03:49:46 +08:00
|
|
|
/*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code
|
|
|
|
* distributions retain the above copyright notice and this paragraph
|
|
|
|
* in its entirety, and (2) distributions including binary code include
|
|
|
|
* the above copyright notice and this paragraph in its entirety in
|
|
|
|
* the documentation or other materials provided with the distribution.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND
|
|
|
|
* WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
|
|
|
|
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Mojatatu Networks, Inc
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <tcpdump-stdinc.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "interface.h"
|
|
|
|
#include "extract.h"
|
|
|
|
|
|
|
|
#include "forces.h"
|
|
|
|
|
|
|
|
#define RESLEN 4
|
|
|
|
|
|
|
|
int
|
|
|
|
prestlv_print(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
struct forces_tlv *tlv = (struct forces_tlv *)pptr;
|
|
|
|
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
|
|
|
|
struct res_val *r = (struct res_val *)tdp;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
if (dlen != RESLEN) {
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("illegal RESULT-TLV: %d bytes!\n", dlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*r);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (r->result >= 0x18 && r->result <= 0xFE) {
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("illegal reserved result code: 0x%x!\n", r->result);
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vflag >= 3) {
|
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
printf("%s Result: %s (code 0x%x)\n", ib,
|
|
|
|
tok2str(ForCES_errs, NULL, r->result), r->result);
|
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
fdatatlv_print(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
struct forces_tlv *tlv = (struct forces_tlv *)pptr;
|
|
|
|
u_int tll = len - TLV_HDRL;
|
|
|
|
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int16_t type;
|
|
|
|
|
|
|
|
TCHECK(*tlv);
|
|
|
|
type = EXTRACT_16BITS(&tlv->type);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (type != F_TLV_FULD) {
|
|
|
|
printf("Error: expecting FULLDATA!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vflag >= 3) {
|
|
|
|
char *ib = indent_pr(indent + 2, 1);
|
|
|
|
printf("%s[", &ib[1]);
|
|
|
|
hex_print_with_offset(ib, tdp, tll, 0);
|
|
|
|
printf("\n%s]\n", &ib[1]);
|
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sdatailv_print(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int tll = len - ILV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
struct forces_ilv *ilv = (struct forces_ilv *)pptr;
|
|
|
|
int invilv;
|
|
|
|
|
|
|
|
indent += 1;
|
|
|
|
while (1) {
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*ilv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invilv = ilv_valid(ilv, tll);
|
|
|
|
if (invilv) {
|
|
|
|
printf("Error: BAD ILV!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (vflag >= 3) {
|
|
|
|
register const u_char *tdp = (u_char *) ILV_DATA(ilv);
|
|
|
|
char *ib = indent_pr(indent, 1);
|
|
|
|
printf("\n%s SPARSEDATA: type %x length %d\n", &ib[1],
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_32BITS(&ilv->type),
|
|
|
|
EXTRACT_32BITS(&ilv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
printf("%s[", &ib[1]);
|
|
|
|
hex_print_with_offset(ib, tdp, tll, 0);
|
|
|
|
printf("\n%s]\n", &ib[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ilv = GO_NXT_ILV(ilv, tll);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sdatatlv_print(register const u_char * pptr, register u_int len,
|
|
|
|
u_int16_t op_msk, int indent)
|
|
|
|
{
|
|
|
|
struct forces_tlv *tlv = (struct forces_tlv *)pptr;
|
|
|
|
u_int tll = len - TLV_HDRL;
|
|
|
|
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int16_t type;
|
|
|
|
|
|
|
|
TCHECK(*tlv);
|
|
|
|
type = EXTRACT_16BITS(&tlv->type);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (type != F_TLV_SPAD) {
|
|
|
|
printf("Error: expecting SPARSEDATA!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sdatailv_print(tdp, tll, op_msk, indent);
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pkeyitlv_print(register const u_char * pptr, register u_int len,
|
|
|
|
u_int16_t op_msk, int indent)
|
|
|
|
{
|
|
|
|
struct forces_tlv *tlv = (struct forces_tlv *)pptr;
|
|
|
|
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
|
|
|
|
register const u_char *dp = tdp + 4;
|
|
|
|
struct forces_tlv *kdtlv = (struct forces_tlv *)dp;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int32_t id;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
u_int16_t type, tll;
|
|
|
|
int invtlv;
|
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*tdp);
|
|
|
|
id = EXTRACT_32BITS(tdp);
|
2010-01-11 03:49:46 +08:00
|
|
|
printf("%sKeyinfo: Key 0x%x\n", ib, id);
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*kdtlv);
|
2010-01-27 09:56:36 +08:00
|
|
|
type = EXTRACT_16BITS(&kdtlv->type);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(kdtlv, len);
|
|
|
|
|
|
|
|
if (invtlv) {
|
|
|
|
printf("%s TLV type 0x%x len %d\n",
|
|
|
|
tok2str(ForCES_TLV_err, NULL, invtlv), type,
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&kdtlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2010-01-27 09:56:36 +08:00
|
|
|
tll = EXTRACT_16BITS(&kdtlv->length);
|
2010-01-11 03:49:46 +08:00
|
|
|
dp = (u_char *) TLV_DATA(kdtlv);
|
|
|
|
return fdatatlv_print(dp, tll, op_msk, indent);
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pdatacnt_print(register const u_char * pptr, register u_int len,
|
|
|
|
u_int32_t IDcnt, u_int16_t op_msk, int indent)
|
|
|
|
{
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int i;
|
2010-01-11 03:49:46 +08:00
|
|
|
int rc;
|
|
|
|
u_int32_t id;
|
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
|
|
|
|
for (i = 0; i < IDcnt; i++) {
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK2(*pptr, 4);
|
2010-01-11 03:49:46 +08:00
|
|
|
id = EXTRACT_32BITS(pptr);
|
|
|
|
if (vflag >= 3)
|
2010-01-11 06:16:41 +08:00
|
|
|
printf("%s ID#%02u: %d\n", ib, i + 1, id);
|
2010-01-11 03:49:46 +08:00
|
|
|
len -= 4;
|
|
|
|
pptr += 4;
|
|
|
|
}
|
|
|
|
if (len) {
|
|
|
|
struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int16_t type;
|
|
|
|
u_int16_t tll;
|
2010-01-11 03:49:46 +08:00
|
|
|
int pad = 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int aln;
|
|
|
|
int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*pdtlv);
|
|
|
|
type = EXTRACT_16BITS(&pdtlv->type);
|
|
|
|
tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
|
|
|
|
aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length));
|
|
|
|
invtlv = tlv_valid(pdtlv, len);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (invtlv) {
|
|
|
|
printf
|
|
|
|
("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
|
|
|
|
tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&pdtlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
goto pd_err;
|
|
|
|
}
|
2010-01-27 09:56:36 +08:00
|
|
|
if (aln > EXTRACT_16BITS(&pdtlv->length)) {
|
2010-01-11 03:49:46 +08:00
|
|
|
if (aln > len) {
|
|
|
|
printf
|
|
|
|
("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
type, EXTRACT_16BITS(&pdtlv->length), aln - len);
|
2010-01-11 03:49:46 +08:00
|
|
|
} else {
|
2010-01-27 09:56:36 +08:00
|
|
|
pad = aln - EXTRACT_16BITS(&pdtlv->length);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pd_valid(type)) {
|
|
|
|
struct pdata_ops *ops = get_forces_pd(type);
|
|
|
|
|
|
|
|
if (vflag >= 3 && ops->v != F_TLV_PDAT) {
|
|
|
|
if (pad)
|
|
|
|
printf
|
|
|
|
("%s %s (Length %d DataLen %d pad %d Bytes)\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
|
2010-01-11 03:49:46 +08:00
|
|
|
tll, pad);
|
|
|
|
else
|
|
|
|
printf
|
|
|
|
("%s %s (Length %d DataLen %d Bytes)\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
|
2010-01-11 03:49:46 +08:00
|
|
|
tll);
|
|
|
|
}
|
|
|
|
|
|
|
|
chk_op_type(type, op_msk, ops->op_msk);
|
|
|
|
|
|
|
|
rc = ops->print((const u_char *)pdtlv,
|
|
|
|
tll + pad + TLV_HDRL, op_msk,
|
|
|
|
indent + 2);
|
|
|
|
} else {
|
|
|
|
printf("Invalid path data content type 0x%x len %d\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
type, EXTRACT_16BITS(&pdtlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
pd_err:
|
2010-01-27 09:56:36 +08:00
|
|
|
if (EXTRACT_16BITS(&pdtlv->length)) {
|
2010-01-11 03:49:46 +08:00
|
|
|
hex_print_with_offset("Bad Data val\n\t [",
|
|
|
|
pptr, len, 0);
|
|
|
|
printf("]\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pdata_print(register const u_char * pptr, register u_int len,
|
|
|
|
u_int16_t op_msk, int indent)
|
|
|
|
{
|
|
|
|
struct pathdata_h *pdh = (struct pathdata_h *)pptr;
|
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int minsize = 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
TCHECK(*pdh);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (vflag >= 3) {
|
|
|
|
printf("\n%sPathdata: Flags 0x%x ID count %d\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2010-01-27 09:56:36 +08:00
|
|
|
if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) {
|
2010-01-11 03:49:46 +08:00
|
|
|
op_msk |= B_KEYIN;
|
|
|
|
}
|
|
|
|
pptr += sizeof(struct pathdata_h);
|
|
|
|
len -= sizeof(struct pathdata_h);
|
2010-01-27 09:56:36 +08:00
|
|
|
minsize = EXTRACT_16BITS(&pdh->pIDcnt) * 4;
|
2010-01-11 03:49:46 +08:00
|
|
|
if (len < minsize) {
|
2010-01-11 06:16:41 +08:00
|
|
|
printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
|
2010-01-11 03:49:46 +08:00
|
|
|
len);
|
|
|
|
hex_print_with_offset("\t\t\tID Data[", pptr, len, 0);
|
|
|
|
printf("]\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2010-01-27 09:56:36 +08:00
|
|
|
return pdatacnt_print(pptr, len, EXTRACT_16BITS(&pdh->pIDcnt), op_msk, indent);
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
genoptlv_print(register const u_char * pptr, register u_int len,
|
|
|
|
u_int16_t op_msk, int indent)
|
|
|
|
{
|
|
|
|
struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int16_t type;
|
|
|
|
int tll;
|
|
|
|
int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*pdtlv);
|
|
|
|
type = EXTRACT_16BITS(&pdtlv->type);
|
|
|
|
tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
|
|
|
|
invtlv = tlv_valid(pdtlv, len);
|
2010-01-11 03:49:46 +08:00
|
|
|
printf("genoptlvprint - %s TLV type 0x%x len %d\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
if (!invtlv) {
|
|
|
|
register const u_char *dp = (u_char *) TLV_DATA(pdtlv);
|
|
|
|
if (!ttlv_valid(type)) {
|
|
|
|
printf("%s TLV type 0x%x len %d\n",
|
|
|
|
tok2str(ForCES_TLV_err, NULL, invtlv), type,
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&pdtlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (vflag >= 3)
|
|
|
|
printf("%s%s, length %d (data length %d Bytes)",
|
|
|
|
ib, tok2str(ForCES_TLV, NULL, type),
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&pdtlv->length), tll);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
return pdata_print(dp, tll, op_msk, indent + 1);
|
|
|
|
} else {
|
|
|
|
printf("\t\t\tInvalid ForCES TLV type=%x", type);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
recpdoptlv_print(register const u_char * pptr, register u_int len,
|
|
|
|
u_int16_t op_msk, int indent)
|
|
|
|
{
|
|
|
|
struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
|
|
|
|
int tll = len;
|
|
|
|
int rc = 0;
|
|
|
|
int invtlv;
|
|
|
|
u_int16_t type;
|
|
|
|
register const u_char *dp;
|
|
|
|
char *ib;
|
|
|
|
|
|
|
|
while (1) {
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*pdtlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(pdtlv, len);
|
|
|
|
if (invtlv) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ib = indent_pr(indent, 0);
|
2010-01-27 09:56:36 +08:00
|
|
|
type = EXTRACT_16BITS(&pdtlv->type);
|
2010-01-11 03:49:46 +08:00
|
|
|
dp = (u_char *) TLV_DATA(pdtlv);
|
2010-01-27 09:56:36 +08:00
|
|
|
tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
if (vflag >= 3)
|
|
|
|
printf
|
|
|
|
("%s%s, length %d (data encapsulated %d Bytes)",
|
|
|
|
ib, tok2str(ForCES_TLV, NULL, type),
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&pdtlv->length),
|
|
|
|
EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
rc = pdata_print(dp, tll, op_msk, indent + 1);
|
|
|
|
pdtlv = GO_NXT_TLV(pdtlv, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len) {
|
|
|
|
printf
|
2010-01-27 10:43:22 +08:00
|
|
|
("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&pdtlv->type), tll - EXTRACT_16BITS(&pdtlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
invoptlv_print(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
char *ib = indent_pr(indent, 1);
|
|
|
|
if (vflag >= 3) {
|
|
|
|
printf("%sData[", &ib[1]);
|
|
|
|
hex_print_with_offset(ib, pptr, len, 0);
|
|
|
|
printf("%s]\n", ib);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-01-11 06:16:41 +08:00
|
|
|
int otlv_print(struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
register const u_char *dp = (u_char *) TLV_DATA(otlv);
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int16_t type;
|
|
|
|
int tll;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
struct optlv_h *ops;
|
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*otlv);
|
|
|
|
type = EXTRACT_16BITS(&otlv->type);
|
|
|
|
tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
ops = get_forces_optlv_h(type);
|
|
|
|
if (vflag >= 3) {
|
|
|
|
printf("%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&otlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
2010-01-11 06:16:41 +08:00
|
|
|
/* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
|
2010-01-11 03:49:46 +08:00
|
|
|
if (!ops->flags & ZERO_TTLV) {
|
2010-01-11 06:16:41 +08:00
|
|
|
if (tll != 0) /* instead of "if (tll)" - for readability .. */
|
2010-01-11 03:49:46 +08:00
|
|
|
printf("%s: Illegal - MUST be empty\n", ops->s);
|
|
|
|
return rc;
|
|
|
|
}
|
2010-01-11 06:16:41 +08:00
|
|
|
/* rest of ops must at least have 12B {pathinfo} */
|
2010-01-11 03:49:46 +08:00
|
|
|
if (tll < OP_MIN_SIZ) {
|
|
|
|
printf("\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&otlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
printf("\t\tTruncated data size %d minimum required %d\n", tll,
|
|
|
|
OP_MIN_SIZ);
|
|
|
|
return invoptlv_print(dp, tll, ops->op_msk, indent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = ops->print(dp, tll, ops->op_msk, indent + 1);
|
|
|
|
return rc;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ASTDLN 4
|
|
|
|
#define ASTMCD 255
|
|
|
|
int
|
|
|
|
asttlv_print(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
u_int32_t rescode;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
if (dlen != ASTDLN) {
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("illegal ASTresult-TLV: %d bytes!\n", dlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK2(*pptr, 4);
|
2010-01-11 03:49:46 +08:00
|
|
|
rescode = EXTRACT_32BITS(pptr);
|
|
|
|
if (rescode > ASTMCD) {
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("illegal ASTresult result code: %d!\n", rescode);
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vflag >= 3) {
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("Teardown reason:\n%s", ib);
|
2010-01-11 03:49:46 +08:00
|
|
|
switch (rescode) {
|
|
|
|
case 0:
|
|
|
|
printf("Normal Teardown");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
printf("Loss of Heartbeats");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
printf("Out of bandwidth");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
printf("Out of Memory");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
printf("Application Crash");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Unknown Teardown reason");
|
|
|
|
break;
|
|
|
|
}
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("(%x)\n%s", rescode, ib);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ASRDLN 4
|
|
|
|
#define ASRMCD 3
|
|
|
|
int
|
|
|
|
asrtlv_print(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
u_int32_t rescode;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
|
2010-01-11 06:16:41 +08:00
|
|
|
if (dlen != ASRDLN) { /* id, instance, oper tlv */
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("illegal ASRresult-TLV: %d bytes!\n", dlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK2(*pptr, 4);
|
2010-01-11 03:49:46 +08:00
|
|
|
rescode = EXTRACT_32BITS(pptr);
|
|
|
|
|
|
|
|
if (rescode > ASRMCD) {
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("illegal ASRresult result code: %d!\n", rescode);
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vflag >= 3) {
|
|
|
|
printf("\n%s", ib);
|
|
|
|
switch (rescode) {
|
|
|
|
case 0:
|
|
|
|
printf("Success ");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
printf("FE ID invalid ");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
printf("permission denied ");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Unknown ");
|
|
|
|
break;
|
|
|
|
}
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("(%x)\n%s", rescode, ib);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-01-11 06:16:41 +08:00
|
|
|
gentltlv_print(register const u_char * pptr _U_, register u_int len,
|
|
|
|
u_int16_t op_msk _U_, int indent _U_)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
if (dlen < 4) { /* at least 32 bits must exist */
|
|
|
|
printf("truncated TLV: %d bytes missing! ", 4 - dlen);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RD_MIN 8
|
|
|
|
int
|
|
|
|
print_metailv(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - ILV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
int tll = dlen;
|
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-11 06:16:41 +08:00
|
|
|
/* XXX: check header length */
|
2010-01-11 03:49:46 +08:00
|
|
|
struct forces_ilv *ilv = (struct forces_ilv *)pptr;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
TCHECK(*ilv);
|
2010-01-27 09:56:36 +08:00
|
|
|
printf("\n%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
|
|
|
|
EXTRACT_32BITS(&ilv->length));
|
2010-01-11 06:16:41 +08:00
|
|
|
hex_print_with_offset("\n\t\t\t\t[", ILV_DATA(ilv), tll, 0);
|
2010-01-11 03:49:46 +08:00
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
print_metatlv(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int tll = dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
struct forces_ilv *ilv = (struct forces_ilv *)pptr;
|
|
|
|
int invilv;
|
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("\n%s METADATA\n", ib);
|
2010-01-11 03:49:46 +08:00
|
|
|
while (1) {
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*ilv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invilv = ilv_valid(ilv, tll);
|
|
|
|
if (invilv)
|
|
|
|
break;
|
|
|
|
print_metailv((u_char *) ilv, tll, 0, indent + 1);
|
|
|
|
|
|
|
|
ilv = GO_NXT_ILV(ilv, tll);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
print_reddata(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent _U_)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int tll = dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
int invtlv;
|
|
|
|
struct forces_tlv *tlv = (struct forces_tlv *)pptr;
|
|
|
|
|
|
|
|
printf("\n\t\t Redirect DATA\n");
|
|
|
|
if (dlen <= RD_MIN) {
|
|
|
|
printf("\n\t\ttruncated Redirect data: %d bytes missing! ",
|
|
|
|
RD_MIN - dlen);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*tlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(tlv, tll);
|
|
|
|
|
|
|
|
if (invtlv) {
|
2010-01-27 09:56:36 +08:00
|
|
|
printf("Redir data type 0x%x len %d\n", EXTRACT_16BITS(&tlv->type),
|
|
|
|
EXTRACT_16BITS(&tlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
tll -= TLV_HDRL;
|
2010-01-11 06:16:41 +08:00
|
|
|
hex_print_with_offset("\n\t\t\t[", TLV_DATA(tlv), tll, 0);
|
2010-01-11 03:49:46 +08:00
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
redirect_print(register const u_char * pptr, register u_int len,
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
struct forces_tlv *tlv = (struct forces_tlv *)pptr;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int tll = dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
int invtlv;
|
|
|
|
|
|
|
|
if (dlen <= RD_MIN) {
|
|
|
|
printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
|
|
|
|
RD_MIN - dlen);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
indent += 1;
|
|
|
|
while (1) {
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*tlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(tlv, tll);
|
|
|
|
if (invtlv)
|
|
|
|
break;
|
2010-01-27 09:56:36 +08:00
|
|
|
if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) {
|
2010-01-11 03:49:46 +08:00
|
|
|
print_metatlv((u_char *) TLV_DATA(tlv), tll, 0, indent);
|
2010-01-27 09:56:36 +08:00
|
|
|
} else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) {
|
2010-01-11 03:49:46 +08:00
|
|
|
print_reddata((u_char *) TLV_DATA(tlv), tll, 0, indent);
|
|
|
|
} else {
|
|
|
|
printf("Unknown REDIRECT TLV 0x%x len %d\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&tlv->type), EXTRACT_16BITS(&tlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tlv = GO_NXT_TLV(tlv, tll);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tll) {
|
|
|
|
printf
|
2010-01-27 10:43:22 +08:00
|
|
|
("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&tlv->type), tll - EXTRACT_16BITS(&tlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define OP_OFF 8
|
|
|
|
#define OP_MIN 12
|
|
|
|
|
|
|
|
int
|
|
|
|
lfbselect_print(register const u_char * pptr, register u_int len,
|
|
|
|
u_int16_t op_msk, int indent)
|
|
|
|
{
|
|
|
|
const struct forces_lfbsh *lfbs;
|
|
|
|
struct forces_tlv *otlv;
|
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int dlen = len - TLV_HDRL;
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int tll = dlen - OP_OFF;
|
2010-01-11 03:49:46 +08:00
|
|
|
int invtlv;
|
|
|
|
|
2010-01-11 06:16:41 +08:00
|
|
|
if (dlen <= OP_MIN) { /* id, instance, oper tlv header .. */
|
2010-01-11 03:49:46 +08:00
|
|
|
printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
|
|
|
|
OP_MIN - dlen);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
lfbs = (const struct forces_lfbsh *)pptr;
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*lfbs);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (vflag >= 3) {
|
|
|
|
printf("\n%s%s(Classid %x) instance %x\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)),
|
|
|
|
EXTRACT_32BITS(&lfbs->class),
|
|
|
|
EXTRACT_32BITS(&lfbs->instance));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
otlv = (struct forces_tlv *)(lfbs + 1);
|
|
|
|
|
|
|
|
indent += 1;
|
|
|
|
while (1) {
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*otlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(otlv, tll);
|
|
|
|
if (invtlv)
|
|
|
|
break;
|
2010-01-27 09:56:36 +08:00
|
|
|
if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) {
|
2010-01-11 03:49:46 +08:00
|
|
|
otlv_print(otlv, 0, indent);
|
|
|
|
} else {
|
|
|
|
if (vflag < 3)
|
|
|
|
printf("\n");
|
|
|
|
printf
|
|
|
|
("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length));
|
2010-01-11 06:16:41 +08:00
|
|
|
invoptlv_print((u_char *)otlv, tll, 0, indent);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
otlv = GO_NXT_TLV(otlv, tll);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tll) {
|
|
|
|
printf
|
2010-01-27 10:43:22 +08:00
|
|
|
("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&otlv->type), tll - EXTRACT_16BITS(&otlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-01-11 06:16:41 +08:00
|
|
|
forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
|
2010-01-11 03:49:46 +08:00
|
|
|
register u_int mlen, struct tom_h *tops)
|
|
|
|
{
|
|
|
|
struct forces_tlv *tltlv;
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int tll;
|
2010-01-11 03:49:46 +08:00
|
|
|
int invtlv;
|
|
|
|
int rc = 0;
|
|
|
|
int ttlv = 0;
|
|
|
|
|
|
|
|
tll = mlen - sizeof(struct forcesh);
|
|
|
|
|
|
|
|
if (tll > TLV_HLN) {
|
|
|
|
if (tops->flags & ZERO_TTLV) {
|
|
|
|
printf("<0x%x>Illegal Top level TLV!\n", tops->flags);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (tops->flags & ZERO_MORE_TTLV)
|
|
|
|
return 0;
|
|
|
|
if (tops->flags & ONE_MORE_TTLV) {
|
|
|
|
printf("\tTop level TLV Data missing!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tops->flags & ZERO_TTLV) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ttlv = tops->flags >> 4;
|
|
|
|
tltlv = GET_TOP_TLV(pptr);
|
|
|
|
|
|
|
|
/*XXX: 15 top level tlvs will probably be fine
|
|
|
|
You are nuts if you send more ;-> */
|
|
|
|
while (1) {
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*tltlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(tltlv, tll);
|
|
|
|
if (invtlv)
|
|
|
|
break;
|
2010-01-27 09:56:36 +08:00
|
|
|
if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) {
|
2010-01-11 03:49:46 +08:00
|
|
|
printf("\n\tInvalid ForCES Top TLV type=0x%x",
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&tltlv->type));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vflag >= 3)
|
|
|
|
printf("\t%s, length %d (data length %d Bytes)",
|
2010-01-27 09:56:36 +08:00
|
|
|
tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)),
|
|
|
|
EXTRACT_16BITS(&tltlv->length), EXTRACT_16BITS(&tltlv->length) - 4);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
rc = tops->print((u_char *) TLV_DATA(tltlv),
|
2010-01-27 09:56:36 +08:00
|
|
|
EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (rc < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
tltlv = GO_NXT_TLV(tltlv, tll);
|
|
|
|
ttlv--;
|
|
|
|
if (ttlv <= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tll) {
|
2010-01-11 10:36:45 +08:00
|
|
|
printf("\tMess TopTLV header: min %lu, total %d advertised %d ",
|
|
|
|
(unsigned long)sizeof(struct forces_tlv),
|
2010-01-27 09:56:36 +08:00
|
|
|
tll, EXTRACT_16BITS(&tltlv->length));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void forces_print(register const u_char * pptr, register u_int len)
|
|
|
|
{
|
|
|
|
const struct forcesh *fhdr;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int mlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
u_int32_t flg_raw;
|
|
|
|
struct tom_h *tops;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
fhdr = (const struct forcesh *)pptr;
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK(*fhdr);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (!tom_valid(fhdr->fm_tom)) {
|
|
|
|
printf("Invalid ForCES message type %d\n", fhdr->fm_tom);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
mlen = ForCES_BLN(fhdr);
|
|
|
|
|
|
|
|
tops = get_forces_tom(fhdr->fm_tom);
|
|
|
|
if (tops->v == TOM_RSVD) {
|
|
|
|
printf("\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\tForCES %s ", tops->s);
|
|
|
|
if (!ForCES_HLN_VALID(mlen, len)) {
|
|
|
|
printf
|
2010-01-11 10:36:45 +08:00
|
|
|
("Illegal ForCES pkt len - min %lu, total recvd %d, advertised %d ",
|
|
|
|
(unsigned long)sizeof(struct forcesh), len, ForCES_BLN(fhdr));
|
2010-01-11 03:49:46 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-01-27 10:43:22 +08:00
|
|
|
TCHECK2(*(pptr + 20), 4);
|
2010-01-11 03:49:46 +08:00
|
|
|
flg_raw = EXTRACT_32BITS(pptr + 20);
|
|
|
|
if (vflag >= 1) {
|
2010-01-11 06:16:41 +08:00
|
|
|
printf("\n\tForCES Version %d len %uB flags 0x%08x ",
|
2010-01-11 03:49:46 +08:00
|
|
|
ForCES_V(fhdr), mlen, flg_raw);
|
|
|
|
printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%"
|
|
|
|
PRIu64, ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)),
|
|
|
|
ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)),
|
|
|
|
EXTRACT_64BITS(fhdr->fm_cor));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (vflag >= 2) {
|
|
|
|
printf
|
|
|
|
("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
|
2010-01-11 09:56:49 +08:00
|
|
|
ForCES_ACKp(ForCES_ACK(fhdr)), ForCES_ACK(fhdr),
|
|
|
|
ForCES_PRI(fhdr),
|
|
|
|
ForCES_EMp(ForCES_EM(fhdr)), ForCES_EM(fhdr),
|
|
|
|
ForCES_ATp(ForCES_AT(fhdr)), ForCES_AT(fhdr),
|
|
|
|
ForCES_TPp(ForCES_TP(fhdr)), ForCES_TP(fhdr));
|
2010-01-11 03:49:46 +08:00
|
|
|
printf
|
2010-01-11 09:56:49 +08:00
|
|
|
("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
|
|
|
|
ForCES_RS1(fhdr), ForCES_RS2(fhdr));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
rc = forces_type_print(pptr, fhdr, mlen, tops);
|
|
|
|
if (rc < 0) {
|
|
|
|
error:
|
|
|
|
hex_print_with_offset("\n\t[", pptr, len, 0);
|
|
|
|
printf("\n\t]");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vflag >= 4) {
|
2010-01-27 10:43:22 +08:00
|
|
|
printf("\n\t Raw ForCES message\n\t [");
|
2010-01-11 03:49:46 +08:00
|
|
|
hex_print_with_offset("\n\t ", pptr, len, 0);
|
|
|
|
printf("\n\t ]");
|
|
|
|
}
|
|
|
|
printf("\n");
|
2010-01-27 10:43:22 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
|
|
|
fputs("[|forces]", stdout);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|