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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-08-15 21:27:28 +08:00
|
|
|
/* \summary: Forwarding and Control Element Separation (ForCES) Protocol printer */
|
|
|
|
|
|
|
|
/* specification: RFC 5810 */
|
|
|
|
|
2010-01-11 03:49:46 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-10 04:42:38 +08:00
|
|
|
#include <netdissect-stdinc.h>
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
2010-01-11 03:49:46 +08:00
|
|
|
#include "extract.h"
|
|
|
|
|
2013-12-26 22:08:06 +08:00
|
|
|
static const char tstr[] = "[|forces]";
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
#define ForCES_VERS 1
|
|
|
|
#define ForCES_HDRL 24
|
|
|
|
#define ForCES_ALNL 4U
|
|
|
|
#define TLV_HDRL 4
|
|
|
|
#define ILV_HDRL 8
|
|
|
|
|
|
|
|
#define TOM_RSVD 0x0
|
|
|
|
#define TOM_ASSNSETUP 0x1
|
|
|
|
#define TOM_ASSNTEARD 0x2
|
|
|
|
#define TOM_CONFIG 0x3
|
|
|
|
#define TOM_QUERY 0x4
|
|
|
|
#define TOM_EVENTNOT 0x5
|
|
|
|
#define TOM_PKTREDIR 0x6
|
|
|
|
#define TOM_HEARTBT 0x0F
|
|
|
|
#define TOM_ASSNSETREP 0x11
|
|
|
|
#define TOM_CONFIGREP 0x13
|
|
|
|
#define TOM_QUERYREP 0x14
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
|
|
|
|
*/
|
|
|
|
#define ZERO_TTLV 0x01
|
|
|
|
#define ZERO_MORE_TTLV 0x02
|
|
|
|
#define ONE_MORE_TTLV 0x04
|
|
|
|
#define ZERO_TLV 0x00
|
|
|
|
#define ONE_TLV 0x10
|
|
|
|
#define TWO_TLV 0x20
|
|
|
|
#define MAX_TLV 0xF0
|
|
|
|
|
|
|
|
#define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
|
|
|
|
#define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
|
|
|
|
|
|
|
|
struct tom_h {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t v;
|
|
|
|
uint16_t flags;
|
|
|
|
uint16_t op_msk;
|
2013-07-24 04:12:54 +08:00
|
|
|
const char *s;
|
2014-03-27 18:58:23 +08:00
|
|
|
int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
TOM_RSV_I,
|
|
|
|
TOM_ASS_I,
|
|
|
|
TOM_AST_I,
|
|
|
|
TOM_CFG_I,
|
|
|
|
TOM_QRY_I,
|
|
|
|
TOM_EVN_I,
|
|
|
|
TOM_RED_I,
|
|
|
|
TOM_HBT_I,
|
|
|
|
TOM_ASR_I,
|
|
|
|
TOM_CNR_I,
|
|
|
|
TOM_QRR_I,
|
|
|
|
_TOM_RSV_MAX
|
|
|
|
};
|
|
|
|
#define TOM_MAX_IND (_TOM_RSV_MAX - 1)
|
|
|
|
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline int tom_valid(uint8_t tom)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
if (tom > 0) {
|
|
|
|
if (tom >= 0x7 && tom <= 0xe)
|
|
|
|
return 0;
|
|
|
|
if (tom == 0x10)
|
|
|
|
return 0;
|
|
|
|
if (tom > 0x14)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline const char *ForCES_node(uint32_t node)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
if (node <= 0x3FFFFFFF)
|
|
|
|
return "FE";
|
|
|
|
if (node >= 0x40000000 && node <= 0x7FFFFFFF)
|
|
|
|
return "CE";
|
|
|
|
if (node >= 0xC0000000 && node <= 0xFFFFFFEF)
|
|
|
|
return "AllMulticast";
|
|
|
|
if (node == 0xFFFFFFFD)
|
|
|
|
return "AllCEsBroadcast";
|
|
|
|
if (node == 0xFFFFFFFE)
|
|
|
|
return "AllFEsBroadcast";
|
|
|
|
if (node == 0xFFFFFFFF)
|
|
|
|
return "AllBroadcast";
|
|
|
|
|
|
|
|
return "ForCESreserved";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-01 03:59:18 +08:00
|
|
|
static const struct tok ForCES_ACKs[] = {
|
|
|
|
{0x0, "NoACK"},
|
|
|
|
{0x1, "SuccessACK"},
|
|
|
|
{0x2, "FailureACK"},
|
|
|
|
{0x3, "AlwaysACK"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
2013-07-24 04:12:54 +08:00
|
|
|
|
2014-01-01 03:59:18 +08:00
|
|
|
static const struct tok ForCES_EMs[] = {
|
|
|
|
{0x0, "EMReserved"},
|
|
|
|
{0x1, "execute-all-or-none"},
|
|
|
|
{0x2, "execute-until-failure"},
|
|
|
|
{0x3, "continue-execute-on-failure"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
2013-07-24 04:12:54 +08:00
|
|
|
|
2014-01-01 03:59:18 +08:00
|
|
|
static const struct tok ForCES_ATs[] = {
|
|
|
|
{0x0, "Standalone"},
|
|
|
|
{0x1, "2PCtransaction"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
2013-07-24 04:12:54 +08:00
|
|
|
|
2014-01-01 03:59:18 +08:00
|
|
|
static const struct tok ForCES_TPs[] = {
|
|
|
|
{0x0, "StartofTransaction"},
|
|
|
|
{0x1, "MiddleofTransaction"},
|
|
|
|
{0x2, "EndofTransaction"},
|
|
|
|
{0x3, "abort"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure of forces header, naked of TLVs.
|
|
|
|
*/
|
|
|
|
struct forcesh {
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint8_t fm_vrsvd; /* version and reserved */
|
2013-07-24 04:12:54 +08:00
|
|
|
#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint8_t fm_tom; /* type of message */
|
|
|
|
nd_uint16_t fm_len; /* total length * 4 bytes */
|
2017-11-18 18:52:52 +08:00
|
|
|
#define ForCES_BLN(forcesh) ((uint32_t)(EXTRACT_BE_16BITS(&(forcesh)->fm_len) << 2))
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint32_t fm_sid; /* Source ID */
|
2017-11-18 18:52:52 +08:00
|
|
|
#define ForCES_SID(forcesh) EXTRACT_BE_32BITS(&(forcesh)->fm_sid)
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint32_t fm_did; /* Destination ID */
|
2017-11-18 18:52:52 +08:00
|
|
|
#define ForCES_DID(forcesh) EXTRACT_BE_32BITS(&(forcesh)->fm_did)
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint8_t fm_cor[8]; /* correlator */
|
|
|
|
nd_uint32_t fm_flags; /* flags */
|
2017-11-18 18:52:52 +08:00
|
|
|
#define ForCES_ACK(forcesh) ((EXTRACT_BE_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
|
|
|
|
#define ForCES_PRI(forcesh) ((EXTRACT_BE_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
|
|
|
|
#define ForCES_RS1(forcesh) ((EXTRACT_BE_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
|
|
|
|
#define ForCES_EM(forcesh) ((EXTRACT_BE_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
|
|
|
|
#define ForCES_AT(forcesh) ((EXTRACT_BE_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
|
|
|
|
#define ForCES_TP(forcesh) ((EXTRACT_BE_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
|
|
|
|
#define ForCES_RS2(forcesh) ((EXTRACT_BE_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
|
|
|
|
(fhl) >= ForCES_HDRL && \
|
|
|
|
(fhl) == (tlen))
|
|
|
|
|
|
|
|
#define F_LFB_RSVD 0x0
|
|
|
|
#define F_LFB_FEO 0x1
|
|
|
|
#define F_LFB_FEPO 0x2
|
2013-09-25 00:46:24 +08:00
|
|
|
static const struct tok ForCES_LFBs[] = {
|
2013-07-24 04:12:54 +08:00
|
|
|
{F_LFB_RSVD, "Invalid TLV"},
|
|
|
|
{F_LFB_FEO, "FEObj LFB"},
|
|
|
|
{F_LFB_FEPO, "FEProtoObj LFB"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
2015-02-17 02:25:25 +08:00
|
|
|
/* this is defined in RFC5810 section A.2 */
|
|
|
|
/* http://www.iana.org/assignments/forces/forces.xhtml#oper-tlv-types */
|
2013-07-24 04:12:54 +08:00
|
|
|
enum {
|
2015-02-17 02:25:25 +08:00
|
|
|
F_OP_RSV = 0,
|
|
|
|
F_OP_SET = 1,
|
|
|
|
F_OP_SETPROP = 2,
|
|
|
|
F_OP_SETRESP = 3,
|
|
|
|
F_OP_SETPRESP = 4,
|
|
|
|
F_OP_DEL = 5,
|
|
|
|
F_OP_DELRESP = 6,
|
|
|
|
F_OP_GET = 7,
|
|
|
|
F_OP_GETPROP = 8,
|
|
|
|
F_OP_GETRESP = 9,
|
|
|
|
F_OP_GETPRESP = 10,
|
|
|
|
F_OP_REPORT = 11,
|
|
|
|
F_OP_COMMIT = 12,
|
|
|
|
F_OP_RCOMMIT = 13,
|
|
|
|
F_OP_RTRCOMP = 14,
|
2013-07-24 04:12:54 +08:00
|
|
|
_F_OP_MAX
|
|
|
|
};
|
|
|
|
#define F_OP_MAX (_F_OP_MAX - 1)
|
2015-02-17 02:25:25 +08:00
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
enum {
|
|
|
|
B_OP_SET = 1 << (F_OP_SET - 1),
|
|
|
|
B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
|
|
|
|
B_OP_SETRESP = 1 << (F_OP_SETRESP - 1),
|
|
|
|
B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1),
|
|
|
|
B_OP_DEL = 1 << (F_OP_DEL - 1),
|
|
|
|
B_OP_DELRESP = 1 << (F_OP_DELRESP - 1),
|
|
|
|
B_OP_GET = 1 << (F_OP_GET - 1),
|
|
|
|
B_OP_GETPROP = 1 << (F_OP_GETPROP - 1),
|
|
|
|
B_OP_GETRESP = 1 << (F_OP_GETRESP - 1),
|
|
|
|
B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1),
|
|
|
|
B_OP_REPORT = 1 << (F_OP_REPORT - 1),
|
|
|
|
B_OP_COMMIT = 1 << (F_OP_COMMIT - 1),
|
|
|
|
B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1),
|
2015-08-19 22:44:52 +08:00
|
|
|
B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1)
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct optlv_h {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t flags;
|
|
|
|
uint16_t op_msk;
|
2013-07-24 04:12:54 +08:00
|
|
|
const char *s;
|
2014-03-27 18:58:23 +08:00
|
|
|
int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
static int genoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int recpdoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int invoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
#define OP_MIN_SIZ 8
|
|
|
|
struct pathdata_h {
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint16_t pflags;
|
|
|
|
nd_uint16_t pIDcnt;
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define B_FULLD 0x1
|
|
|
|
#define B_SPARD 0x2
|
|
|
|
#define B_RESTV 0x4
|
|
|
|
#define B_KEYIN 0x8
|
|
|
|
#define B_APPND 0x10
|
|
|
|
#define B_TRNG 0x20
|
|
|
|
|
|
|
|
static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
|
|
|
|
/* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
|
|
|
|
/* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
|
|
|
|
/* F_OP_SETPROP */
|
|
|
|
{TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print},
|
|
|
|
/* F_OP_SETRESP */ {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print},
|
|
|
|
/* F_OP_SETPRESP */ {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print},
|
|
|
|
/* F_OP_DEL */ {ZERO_TTLV, 0, " Del", recpdoptlv_print},
|
|
|
|
/* F_OP_DELRESP */ {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print},
|
|
|
|
/* F_OP_GET */ {ZERO_TTLV, 0, " Get", recpdoptlv_print},
|
|
|
|
/* F_OP_GETPROP */ {ZERO_TTLV, 0, " GetProp", recpdoptlv_print},
|
|
|
|
/* F_OP_GETRESP */
|
|
|
|
{TTLV_T2, B_FULLD | B_SPARD | B_RESTV, " GetResp", recpdoptlv_print},
|
|
|
|
/* F_OP_GETPRESP */
|
|
|
|
{TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print},
|
|
|
|
/* F_OP_REPORT */
|
|
|
|
{TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print},
|
|
|
|
/* F_OP_COMMIT */ {ZERO_TTLV, 0, " Commit", NULL},
|
|
|
|
/* F_OP_RCOMMIT */ {TTLV_T1, B_RESTV, " RCommit", genoptlv_print},
|
|
|
|
/* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
|
|
|
|
};
|
|
|
|
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline const struct optlv_h *get_forces_optlv_h(uint16_t opt)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
2017-09-06 07:31:29 +08:00
|
|
|
if (opt > F_OP_MAX || opt == F_OP_RSV)
|
2013-07-24 04:12:54 +08:00
|
|
|
return &OPTLV_msg[F_OP_RSV];
|
|
|
|
|
|
|
|
return &OPTLV_msg[opt];
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IND_SIZE 256
|
|
|
|
#define IND_CHR ' '
|
|
|
|
#define IND_PREF '\n'
|
|
|
|
#define IND_SUF 0x0
|
2016-09-12 03:45:26 +08:00
|
|
|
static char ind_buf[IND_SIZE];
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
static inline char *indent_pr(int indent, int nlpref)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
char *r = ind_buf;
|
|
|
|
|
|
|
|
if (indent > (IND_SIZE - 1))
|
|
|
|
indent = IND_SIZE - 1;
|
|
|
|
|
|
|
|
if (nlpref) {
|
|
|
|
r[i] = IND_PREF;
|
|
|
|
i++;
|
|
|
|
indent--;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (--indent >= 0)
|
|
|
|
r[i++] = IND_CHR;
|
|
|
|
|
|
|
|
r[i] = IND_SUF;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline int op_valid(uint16_t op, uint16_t mask)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
if (op == 0)
|
|
|
|
return 0;
|
2017-09-06 07:34:33 +08:00
|
|
|
if (op <= F_OP_MAX)
|
|
|
|
return (1 << (op - 1)) & mask; /* works only for 0x0001 through 0x0010 */
|
2013-07-24 04:12:54 +08:00
|
|
|
/* I guess we should allow vendor operations? */
|
|
|
|
if (op >= 0x8000)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define F_TLV_RSVD 0x0000
|
|
|
|
#define F_TLV_REDR 0x0001
|
|
|
|
#define F_TLV_ASRS 0x0010
|
|
|
|
#define F_TLV_ASRT 0x0011
|
|
|
|
#define F_TLV_LFBS 0x1000
|
|
|
|
#define F_TLV_PDAT 0x0110
|
|
|
|
#define F_TLV_KEYI 0x0111
|
|
|
|
#define F_TLV_FULD 0x0112
|
|
|
|
#define F_TLV_SPAD 0x0113
|
|
|
|
#define F_TLV_REST 0x0114
|
|
|
|
#define F_TLV_METD 0x0115
|
|
|
|
#define F_TLV_REDD 0x0116
|
|
|
|
#define F_TLV_TRNG 0x0117
|
|
|
|
|
|
|
|
|
|
|
|
#define F_TLV_VNST 0x8000
|
|
|
|
|
|
|
|
static const struct tok ForCES_TLV[] = {
|
|
|
|
{F_TLV_RSVD, "Invalid TLV"},
|
|
|
|
{F_TLV_REDR, "REDIRECT TLV"},
|
|
|
|
{F_TLV_ASRS, "ASResult TLV"},
|
|
|
|
{F_TLV_ASRT, "ASTreason TLV"},
|
|
|
|
{F_TLV_LFBS, "LFBselect TLV"},
|
|
|
|
{F_TLV_PDAT, "PATH-DATA TLV"},
|
|
|
|
{F_TLV_KEYI, "KEYINFO TLV"},
|
|
|
|
{F_TLV_FULD, "FULLDATA TLV"},
|
|
|
|
{F_TLV_SPAD, "SPARSEDATA TLV"},
|
|
|
|
{F_TLV_REST, "RESULT TLV"},
|
|
|
|
{F_TLV_METD, "METADATA TLV"},
|
|
|
|
{F_TLV_REDD, "REDIRECTDATA TLV"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TLV_HLN 4
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline int ttlv_valid(uint16_t ttlv)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
if (ttlv > 0) {
|
|
|
|
if (ttlv == 1 || ttlv == 0x1000)
|
|
|
|
return 1;
|
|
|
|
if (ttlv >= 0x10 && ttlv <= 0x11)
|
|
|
|
return 1;
|
|
|
|
if (ttlv >= 0x110 && ttlv <= 0x116)
|
|
|
|
return 1;
|
|
|
|
if (ttlv >= 0x8000)
|
|
|
|
return 0; /* XXX: */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct forces_ilv {
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint32_t type;
|
|
|
|
nd_uint32_t length;
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct forces_tlv {
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint16_t type;
|
|
|
|
nd_uint16_t length;
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
|
2015-04-27 08:24:42 +08:00
|
|
|
#define GET_TOP_TLV(fhdr) ((const struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
|
2013-07-24 04:12:54 +08:00
|
|
|
#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
|
|
|
|
#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
|
|
|
|
#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
|
2015-04-27 08:24:42 +08:00
|
|
|
#define TLV_DATA(tlvp) ((const void*)(((const char*)(tlvp)) + TLV_SET_LEN(0)))
|
2017-11-18 18:52:52 +08:00
|
|
|
#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_BE_16BITS(&(tlv)->length)), \
|
2015-04-27 08:24:42 +08:00
|
|
|
(const struct forces_tlv*)(((const char*)(tlv)) \
|
2017-11-18 18:52:52 +08:00
|
|
|
+ F_ALN_LEN(EXTRACT_BE_16BITS(&(tlv)->length))))
|
2013-07-24 04:12:54 +08:00
|
|
|
#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
|
|
|
|
#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
|
2017-11-18 18:52:52 +08:00
|
|
|
#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_BE_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
|
2015-04-27 08:24:42 +08:00
|
|
|
#define ILV_DATA(ilvp) ((const void*)(((const char*)(ilvp)) + ILV_SET_LEN(0)))
|
2017-11-18 18:52:52 +08:00
|
|
|
#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_BE_32BITS(&(ilv)->length)), \
|
2015-04-27 08:24:42 +08:00
|
|
|
(const struct forces_ilv *)(((const char*)(ilv)) \
|
2017-11-18 18:52:52 +08:00
|
|
|
+ F_ALN_LEN(EXTRACT_BE_32BITS(&(ilv)->length))))
|
2014-02-26 20:15:28 +08:00
|
|
|
#define INVALID_RLEN 1
|
|
|
|
#define INVALID_STLN 2
|
|
|
|
#define INVALID_LTLN 3
|
|
|
|
#define INVALID_ALEN 4
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
static const struct tok ForCES_TLV_err[] = {
|
|
|
|
{INVALID_RLEN, "Invalid total length"},
|
|
|
|
{INVALID_STLN, "xLV too short"},
|
|
|
|
{INVALID_LTLN, "xLV too long"},
|
|
|
|
{INVALID_ALEN, "data padding missing"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
2014-02-26 20:15:28 +08:00
|
|
|
static inline u_int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
if (rlen < TLV_HDRL)
|
|
|
|
return INVALID_RLEN;
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_16BITS(&tlv->length) < TLV_HDRL)
|
2013-07-24 04:12:54 +08:00
|
|
|
return INVALID_STLN;
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_16BITS(&tlv->length) > rlen)
|
2013-07-24 04:12:54 +08:00
|
|
|
return INVALID_LTLN;
|
2017-11-18 18:52:52 +08:00
|
|
|
if (rlen < F_ALN_LEN(EXTRACT_BE_16BITS(&tlv->length)))
|
2013-07-24 04:12:54 +08:00
|
|
|
return INVALID_ALEN;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
|
|
|
|
{
|
|
|
|
if (rlen < ILV_HDRL)
|
|
|
|
return INVALID_RLEN;
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_32BITS(&ilv->length) < ILV_HDRL)
|
2013-07-24 04:12:54 +08:00
|
|
|
return INVALID_STLN;
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_32BITS(&ilv->length) > rlen)
|
2013-07-24 04:12:54 +08:00
|
|
|
return INVALID_LTLN;
|
2017-11-18 18:52:52 +08:00
|
|
|
if (rlen < F_ALN_LEN(EXTRACT_BE_32BITS(&ilv->length)))
|
2013-07-24 04:12:54 +08:00
|
|
|
return INVALID_ALEN;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
static int lfbselect_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int redirect_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int asrtlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int asttlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
struct forces_lfbsh {
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint32_t class;
|
|
|
|
nd_uint32_t instance;
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ASSNS_OPS (B_OP_REPORT)
|
|
|
|
#define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
|
|
|
|
#define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
|
|
|
|
#define CFG_QY (B_OP_GET|B_OP_GETPROP)
|
|
|
|
#define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
|
|
|
|
#define CFG_EVN (B_OP_REPORT)
|
|
|
|
|
|
|
|
static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
|
|
|
|
/* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
|
|
|
|
/* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
|
|
|
|
"Association Setup", lfbselect_print},
|
|
|
|
/* TOM_AST_I */
|
|
|
|
{TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print},
|
|
|
|
/* TOM_CFG_I */ {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print},
|
|
|
|
/* TOM_QRY_I */ {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print},
|
|
|
|
/* TOM_EVN_I */ {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification",
|
|
|
|
lfbselect_print},
|
|
|
|
/* TOM_RED_I */
|
|
|
|
{TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print},
|
|
|
|
/* TOM_HBT_I */ {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL},
|
|
|
|
/* TOM_ASR_I */
|
|
|
|
{TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print},
|
|
|
|
/* TOM_CNR_I */ {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response",
|
|
|
|
lfbselect_print},
|
|
|
|
/* TOM_QRR_I */
|
|
|
|
{TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
|
|
|
|
};
|
|
|
|
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline const struct tom_h *get_forces_tom(uint8_t tom)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
|
|
|
|
const struct tom_h *th = &ForCES_msg[i];
|
|
|
|
if (th->v == tom)
|
|
|
|
return th;
|
|
|
|
}
|
|
|
|
return &ForCES_msg[TOM_RSV_I];
|
|
|
|
}
|
|
|
|
|
|
|
|
struct pdata_ops {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t v;
|
|
|
|
uint16_t flags;
|
|
|
|
uint16_t op_msk;
|
2013-07-24 04:12:54 +08:00
|
|
|
const char *s;
|
2014-03-27 18:58:23 +08:00
|
|
|
int (*print) (netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PD_RSV_I,
|
|
|
|
PD_SEL_I,
|
|
|
|
PD_FDT_I,
|
|
|
|
PD_SDT_I,
|
|
|
|
PD_RES_I,
|
|
|
|
PD_PDT_I,
|
|
|
|
_PD_RSV_MAX
|
|
|
|
};
|
|
|
|
#define PD_MAX_IND (_TOM_RSV_MAX - 1)
|
|
|
|
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline int pd_valid(uint16_t pd)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
static inline void
|
|
|
|
chk_op_type(netdissect_options *ndo,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type, uint16_t msk, uint16_t omsk)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
if (type != F_TLV_PDAT) {
|
|
|
|
if (msk & B_KEYIN) {
|
|
|
|
if (type != F_TLV_KEYI) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Based on flags expected KEYINFO TLV!\n"));
|
2013-07-24 04:12:54 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!(msk & omsk)) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Illegal DATA encoding for type 0x%x programmed %x got %x \n",
|
|
|
|
type, omsk, msk));
|
2013-07-24 04:12:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#define F_SELKEY 1
|
|
|
|
#define F_SELTABRANGE 2
|
|
|
|
#define F_TABAPPEND 4
|
|
|
|
|
|
|
|
struct res_val {
|
fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 18:42:48 +08:00
|
|
|
nd_uint8_t result;
|
|
|
|
nd_uint8_t resv1;
|
|
|
|
nd_uint16_t resv2;
|
2013-07-24 04:12:54 +08:00
|
|
|
};
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
static int prestlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int pkeyitlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int fdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2014-03-27 18:58:23 +08:00
|
|
|
static int sdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent);
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
|
|
|
|
/* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
|
|
|
|
/* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
|
|
|
|
/* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
|
|
|
|
/* PD_SDT_I */ {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print},
|
|
|
|
/* PD_RES_I */ {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print},
|
|
|
|
/* PD_PDT_I */
|
|
|
|
{F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
|
|
|
|
};
|
|
|
|
|
2014-04-23 15:20:40 +08:00
|
|
|
static inline const struct pdata_ops *get_forces_pd(uint16_t pd)
|
2013-07-24 04:12:54 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
|
|
|
|
const struct pdata_ops *pdo = &ForCES_pdata[i];
|
|
|
|
if (pdo->v == pd)
|
|
|
|
return pdo;
|
|
|
|
}
|
|
|
|
return &ForCES_pdata[TOM_RSV_I];
|
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
E_SUCCESS,
|
|
|
|
E_INVALID_HEADER,
|
|
|
|
E_LENGTH_MISMATCH,
|
|
|
|
E_VERSION_MISMATCH,
|
|
|
|
E_INVALID_DESTINATION_PID,
|
|
|
|
E_LFB_UNKNOWN,
|
|
|
|
E_LFB_NOT_FOUND,
|
|
|
|
E_LFB_INSTANCE_ID_NOT_FOUND,
|
|
|
|
E_INVALID_PATH,
|
|
|
|
E_COMPONENT_DOES_NOT_EXIST,
|
|
|
|
E_EXISTS,
|
|
|
|
E_NOT_FOUND,
|
|
|
|
E_READ_ONLY,
|
|
|
|
E_INVALID_ARRAY_CREATION,
|
|
|
|
E_VALUE_OUT_OF_RANGE,
|
|
|
|
E_CONTENTS_TOO_LONG,
|
|
|
|
E_INVALID_PARAMETERS,
|
|
|
|
E_INVALID_MESSAGE_TYPE,
|
|
|
|
E_INVALID_FLAGS,
|
|
|
|
E_INVALID_TLV,
|
|
|
|
E_EVENT_ERROR,
|
|
|
|
E_NOT_SUPPORTED,
|
|
|
|
E_MEMORY_ERROR,
|
|
|
|
E_INTERNAL_ERROR,
|
|
|
|
/* 0x18-0xFE are reserved .. */
|
|
|
|
E_UNSPECIFIED_ERROR = 0XFF
|
|
|
|
};
|
|
|
|
|
2013-09-25 00:46:24 +08:00
|
|
|
static const struct tok ForCES_errs[] = {
|
2013-07-24 04:12:54 +08:00
|
|
|
{E_SUCCESS, "SUCCESS"},
|
|
|
|
{E_INVALID_HEADER, "INVALID HEADER"},
|
|
|
|
{E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
|
|
|
|
{E_VERSION_MISMATCH, "VERSION MISMATCH"},
|
|
|
|
{E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"},
|
|
|
|
{E_LFB_UNKNOWN, "LFB UNKNOWN"},
|
|
|
|
{E_LFB_NOT_FOUND, "LFB NOT FOUND"},
|
|
|
|
{E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"},
|
|
|
|
{E_INVALID_PATH, "INVALID PATH"},
|
|
|
|
{E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"},
|
|
|
|
{E_EXISTS, "EXISTS ALREADY"},
|
|
|
|
{E_NOT_FOUND, "NOT FOUND"},
|
|
|
|
{E_READ_ONLY, "READ ONLY"},
|
|
|
|
{E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"},
|
|
|
|
{E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"},
|
|
|
|
{E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"},
|
|
|
|
{E_INVALID_PARAMETERS, "INVALID PARAMETERS"},
|
|
|
|
{E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"},
|
|
|
|
{E_INVALID_FLAGS, "INVALID FLAGS"},
|
|
|
|
{E_INVALID_TLV, "INVALID TLV"},
|
|
|
|
{E_EVENT_ERROR, "EVENT ERROR"},
|
|
|
|
{E_NOT_SUPPORTED, "NOT SUPPORTED"},
|
|
|
|
{E_MEMORY_ERROR, "MEMORY ERROR"},
|
|
|
|
{E_INTERNAL_ERROR, "INTERNAL ERROR"},
|
|
|
|
{E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
#define RESLEN 4
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
prestlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
|
|
|
|
register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
|
|
|
|
const struct res_val *r = (const struct res_val *)tdp;
|
2010-02-08 09:47:31 +08:00
|
|
|
u_int dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* pdatacnt_print() has ensured that len (the TLV length)
|
|
|
|
* >= TLV_HDRL.
|
|
|
|
*/
|
|
|
|
dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
if (dlen != RESLEN) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "illegal RESULT-TLV: %d bytes!\n", dlen));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*r);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (r->result >= 0x18 && r->result <= 0xFE) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", r->result));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s Result: %s (code 0x%x)\n", ib,
|
|
|
|
tok2str(ForCES_errs, NULL, r->result), r->result));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
fdatatlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2015-04-27 08:24:42 +08:00
|
|
|
register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* pdatacnt_print() or pkeyitlv_print() has ensured that len
|
|
|
|
* (the TLV length) >= TLV_HDRL.
|
|
|
|
*/
|
2010-02-08 10:02:41 +08:00
|
|
|
rlen = len - TLV_HDRL;
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*tlv);
|
2017-11-18 18:52:52 +08:00
|
|
|
type = EXTRACT_BE_16BITS(&tlv->type);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (type != F_TLV_FULD) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Error: expecting FULLDATA!\n"));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent + 2, 1);
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s[", &ib[1]));
|
|
|
|
hex_print_with_offset(ndo, ib, tdp, rlen, 0);
|
|
|
|
ND_PRINT((ndo, "\n%s]\n", &ib[1]));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
sdatailv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_ilv *ilv = (const struct forces_ilv *)pptr;
|
2010-01-11 03:49:46 +08:00
|
|
|
int invilv;
|
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
if (len < ILV_HDRL) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Error: BAD SPARSEDATA-TLV!\n"));
|
2010-02-08 09:47:31 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2012-03-29 22:08:35 +08:00
|
|
|
rlen = len;
|
2010-01-11 03:49:46 +08:00
|
|
|
indent += 1;
|
2010-02-08 10:02:41 +08:00
|
|
|
while (rlen != 0) {
|
2013-10-17 03:54:06 +08:00
|
|
|
#if 0
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Jamal - outstanding length <%d>\n", rlen));
|
2013-10-17 03:54:06 +08:00
|
|
|
#endif
|
2012-03-29 22:08:35 +08:00
|
|
|
char *ib = indent_pr(indent, 1);
|
2015-04-27 08:24:42 +08:00
|
|
|
register const u_char *tdp = (const u_char *) ILV_DATA(ilv);
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*ilv);
|
2010-02-08 10:02:41 +08:00
|
|
|
invilv = ilv_valid(ilv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (invilv) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s[", &ib[1]));
|
|
|
|
hex_print_with_offset(ndo, ib, tdp, rlen, 0);
|
|
|
|
ND_PRINT((ndo, "\n%s]\n", &ib[1]));
|
2012-03-29 22:08:35 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
2017-11-18 18:52:52 +08:00
|
|
|
int ilvl = EXTRACT_BE_32BITS(&ilv->length);
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n%s ILV: type %x length %d\n", &ib[1],
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_32BITS(&ilv->type), ilvl));
|
2014-03-27 18:58:23 +08:00
|
|
|
hex_print_with_offset(ndo, "\t\t[", tdp, ilvl-ILV_HDRL, 0);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2010-02-08 10:02:41 +08:00
|
|
|
ilv = GO_NXT_ILV(ilv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
sdatatlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2015-04-27 08:24:42 +08:00
|
|
|
register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* pdatacnt_print() has ensured that len (the TLV length)
|
|
|
|
* >= TLV_HDRL.
|
|
|
|
*/
|
2010-02-08 10:02:41 +08:00
|
|
|
rlen = len - TLV_HDRL;
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*tlv);
|
2017-11-18 18:52:52 +08:00
|
|
|
type = EXTRACT_BE_16BITS(&tlv->type);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (type != F_TLV_SPAD) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Error: expecting SPARSEDATA!\n"));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
return sdatailv_print(ndo, tdp, rlen, op_msk, indent);
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
pkeyitlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
|
|
|
|
register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
register const u_char *dp = tdp + 4;
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *kdtlv = (const struct forces_tlv *)dp;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t id;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type, tll;
|
2014-02-26 20:15:28 +08:00
|
|
|
u_int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*tdp);
|
2017-11-18 18:52:52 +08:00
|
|
|
id = EXTRACT_BE_32BITS(tdp);
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%sKeyinfo: Key 0x%x\n", ib, id));
|
|
|
|
ND_TCHECK(*kdtlv);
|
2017-11-18 18:52:52 +08:00
|
|
|
type = EXTRACT_BE_16BITS(&kdtlv->type);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(kdtlv, len);
|
|
|
|
|
|
|
|
if (invtlv) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
|
2010-01-11 03:49:46 +08:00
|
|
|
tok2str(ForCES_TLV_err, NULL, invtlv), type,
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&kdtlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* At this point, tlv_valid() has ensured that the TLV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the containing TLV).
|
|
|
|
*/
|
2017-11-18 18:52:52 +08:00
|
|
|
tll = EXTRACT_BE_16BITS(&kdtlv->length);
|
2015-04-27 08:24:42 +08:00
|
|
|
dp = (const u_char *) TLV_DATA(kdtlv);
|
2014-03-27 18:58:23 +08:00
|
|
|
return fdatatlv_print(ndo, dp, tll, op_msk, indent);
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-16 06:28:36 +08:00
|
|
|
#define PTH_DESC_SIZE 12
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
pdatacnt_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t IDcnt, uint16_t op_msk, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int i;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t id;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if ((op_msk & B_APPND) && ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "%sTABLE APPEND\n", ib));
|
2013-07-16 06:28:37 +08:00
|
|
|
}
|
2010-01-11 03:49:46 +08:00
|
|
|
for (i = 0; i < IDcnt; i++) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK2(*pptr, 4);
|
2010-02-08 09:47:31 +08:00
|
|
|
if (len < 4)
|
|
|
|
goto trunc;
|
2017-11-18 18:52:52 +08:00
|
|
|
id = EXTRACT_BE_32BITS(pptr);
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3)
|
|
|
|
ND_PRINT((ndo, "%sID#%02u: %d\n", ib, i + 1, id));
|
2010-01-11 03:49:46 +08:00
|
|
|
len -= 4;
|
|
|
|
pptr += 4;
|
|
|
|
}
|
2013-07-16 06:28:36 +08:00
|
|
|
|
|
|
|
if ((op_msk & B_TRNG) || (op_msk & B_KEYIN)) {
|
|
|
|
if (op_msk & B_TRNG) {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t starti, endi;
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
if (len < PTH_DESC_SIZE) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
|
|
|
|
len, PTH_DESC_SIZE));
|
2013-07-24 04:12:54 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-07-16 06:28:36 +08:00
|
|
|
pptr += sizeof(struct forces_tlv);
|
|
|
|
len -= sizeof(struct forces_tlv);
|
|
|
|
|
2017-11-18 18:52:52 +08:00
|
|
|
starti = EXTRACT_BE_32BITS(pptr);
|
2013-07-16 06:28:36 +08:00
|
|
|
pptr += 4;
|
|
|
|
len -= 4;
|
|
|
|
|
2017-11-18 18:52:52 +08:00
|
|
|
endi = EXTRACT_BE_32BITS(pptr);
|
2013-07-16 06:28:36 +08:00
|
|
|
pptr += 4;
|
|
|
|
len -= 4;
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3)
|
|
|
|
ND_PRINT((ndo, "%sTable range: [%d,%d]\n", ib, starti, endi));
|
2013-07-16 06:28:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (op_msk & B_KEYIN) {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *keytlv;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t tll;
|
2013-07-24 04:12:54 +08:00
|
|
|
|
|
|
|
if (len < PTH_DESC_SIZE) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
|
|
|
|
len, PTH_DESC_SIZE));
|
2013-07-24 04:12:54 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-07-16 06:28:36 +08:00
|
|
|
/* skip keyid */
|
|
|
|
pptr += 4;
|
|
|
|
len -= 4;
|
2015-04-27 08:24:42 +08:00
|
|
|
keytlv = (const struct forces_tlv *)pptr;
|
2013-07-16 06:28:36 +08:00
|
|
|
/* skip header */
|
|
|
|
pptr += sizeof(struct forces_tlv);
|
|
|
|
len -= sizeof(struct forces_tlv);
|
|
|
|
/* skip key content */
|
2017-11-18 18:52:52 +08:00
|
|
|
tll = EXTRACT_BE_16BITS(&keytlv->length);
|
2013-07-24 04:12:54 +08:00
|
|
|
if (tll < TLV_HDRL) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "key content length %u < %u\n",
|
|
|
|
tll, TLV_HDRL));
|
2013-07-16 06:28:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2013-07-24 04:12:54 +08:00
|
|
|
tll -= TLV_HDRL;
|
|
|
|
if (len < tll) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "key content too short\n"));
|
2013-07-24 04:12:54 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
pptr += tll;
|
|
|
|
len -= tll;
|
2013-07-16 06:28:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-01-11 03:49:46 +08:00
|
|
|
if (len) {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type;
|
|
|
|
uint16_t tll;
|
2010-01-11 03:49:46 +08:00
|
|
|
int pad = 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int aln;
|
2014-02-26 20:15:28 +08:00
|
|
|
u_int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*pdtlv);
|
2017-11-18 18:52:52 +08:00
|
|
|
type = EXTRACT_BE_16BITS(&pdtlv->type);
|
2010-01-27 10:43:22 +08:00
|
|
|
invtlv = tlv_valid(pdtlv, len);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (invtlv) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
|
|
|
|
tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&pdtlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
goto pd_err;
|
|
|
|
}
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* At this point, tlv_valid() has ensured that the TLV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the containing TLV).
|
|
|
|
*/
|
2017-11-18 18:52:52 +08:00
|
|
|
tll = EXTRACT_BE_16BITS(&pdtlv->length) - TLV_HDRL;
|
|
|
|
aln = F_ALN_LEN(EXTRACT_BE_16BITS(&pdtlv->length));
|
|
|
|
if (aln > EXTRACT_BE_16BITS(&pdtlv->length)) {
|
2010-01-11 03:49:46 +08:00
|
|
|
if (aln > len) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo,
|
|
|
|
"Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
type, EXTRACT_BE_16BITS(&pdtlv->length), aln - len));
|
2010-01-11 03:49:46 +08:00
|
|
|
} else {
|
2017-11-18 18:52:52 +08:00
|
|
|
pad = aln - EXTRACT_BE_16BITS(&pdtlv->length);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pd_valid(type)) {
|
2010-01-27 12:14:23 +08:00
|
|
|
const struct pdata_ops *ops = get_forces_pd(type);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3 && ops->v != F_TLV_PDAT) {
|
2010-01-11 03:49:46 +08:00
|
|
|
if (pad)
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s %s (Length %d DataLen %d pad %d Bytes)\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
ib, ops->s, EXTRACT_BE_16BITS(&pdtlv->length), tll, pad));
|
2010-01-11 03:49:46 +08:00
|
|
|
else
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s %s (Length %d DataLen %d Bytes)\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
ib, ops->s, EXTRACT_BE_16BITS(&pdtlv->length), tll));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
chk_op_type(ndo, type, op_msk, ops->op_msk);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ops->print(ndo, (const u_char *)pdtlv,
|
2010-01-11 03:49:46 +08:00
|
|
|
tll + pad + TLV_HDRL, op_msk,
|
2012-06-09 10:14:06 +08:00
|
|
|
indent + 2) == -1)
|
|
|
|
return -1;
|
2011-01-25 21:16:15 +08:00
|
|
|
len -= (TLV_HDRL + pad + tll);
|
2010-01-11 03:49:46 +08:00
|
|
|
} else {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Invalid path data content type 0x%x len %d\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
type, EXTRACT_BE_16BITS(&pdtlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
pd_err:
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_16BITS(&pdtlv->length)) {
|
2014-03-27 18:58:23 +08:00
|
|
|
hex_print_with_offset(ndo, "Bad Data val\n\t [",
|
2010-01-11 03:49:46 +08:00
|
|
|
pptr, len, 0);
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "]\n"));
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-25 21:16:15 +08:00
|
|
|
return len;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
pdata_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct pathdata_h *pdh = (const struct pathdata_h *)pptr;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-11 06:16:41 +08:00
|
|
|
u_int minsize = 0;
|
2011-01-25 21:16:15 +08:00
|
|
|
int more_pd = 0;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t idcnt = 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*pdh);
|
2010-02-08 09:47:31 +08:00
|
|
|
if (len < sizeof(struct pathdata_h))
|
|
|
|
goto trunc;
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "\n%sPathdata: Flags 0x%x ID count %d\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
ib, EXTRACT_BE_16BITS(&pdh->pflags), EXTRACT_BE_16BITS(&pdh->pIDcnt)));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_16BITS(&pdh->pflags) & F_SELKEY) {
|
2010-01-11 03:49:46 +08:00
|
|
|
op_msk |= B_KEYIN;
|
|
|
|
}
|
2013-07-16 06:28:36 +08:00
|
|
|
|
|
|
|
/* Table GET Range operation */
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_16BITS(&pdh->pflags) & F_SELTABRANGE) {
|
2013-07-16 06:28:36 +08:00
|
|
|
op_msk |= B_TRNG;
|
|
|
|
}
|
2013-07-16 06:28:37 +08:00
|
|
|
/* Table SET append operation */
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_16BITS(&pdh->pflags) & F_TABAPPEND) {
|
2013-07-16 06:28:37 +08:00
|
|
|
op_msk |= B_APPND;
|
|
|
|
}
|
2013-07-16 06:28:36 +08:00
|
|
|
|
2010-01-11 03:49:46 +08:00
|
|
|
pptr += sizeof(struct pathdata_h);
|
|
|
|
len -= sizeof(struct pathdata_h);
|
2017-11-18 18:52:52 +08:00
|
|
|
idcnt = EXTRACT_BE_16BITS(&pdh->pIDcnt);
|
2011-01-25 21:16:15 +08:00
|
|
|
minsize = idcnt * 4;
|
2010-01-11 03:49:46 +08:00
|
|
|
if (len < minsize) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
|
|
|
|
len));
|
|
|
|
hex_print_with_offset(ndo, "\t\t\tID Data[", pptr, len, 0);
|
|
|
|
ND_PRINT((ndo, "]\n"));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2013-07-16 06:28:36 +08:00
|
|
|
|
|
|
|
if ((op_msk & B_TRNG) && (op_msk & B_KEYIN)) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\t\t\tIllegal to have both Table ranges and keys\n"));
|
2013-07-16 06:28:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
more_pd = pdatacnt_print(ndo, pptr, len, idcnt, op_msk, indent);
|
2011-01-25 21:16:15 +08:00
|
|
|
if (more_pd > 0) {
|
|
|
|
int consumed = len - more_pd;
|
|
|
|
pptr += consumed;
|
2014-01-02 10:27:54 +08:00
|
|
|
len = more_pd;
|
2011-01-25 21:16:15 +08:00
|
|
|
/* XXX: Argh, recurse some more */
|
2014-03-27 18:58:23 +08:00
|
|
|
return recpdoptlv_print(ndo, pptr, len, op_msk, indent+1);
|
2011-01-25 21:16:15 +08:00
|
|
|
} else
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
genoptlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type;
|
2010-01-27 10:43:22 +08:00
|
|
|
int tll;
|
2014-02-26 20:15:28 +08:00
|
|
|
u_int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*pdtlv);
|
2017-11-18 18:52:52 +08:00
|
|
|
type = EXTRACT_BE_16BITS(&pdtlv->type);
|
|
|
|
tll = EXTRACT_BE_16BITS(&pdtlv->length) - TLV_HDRL;
|
2010-01-27 10:43:22 +08:00
|
|
|
invtlv = tlv_valid(pdtlv, len);
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "genoptlvprint - %s TLV type 0x%x len %d\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
tok2str(ForCES_TLV, NULL, type), type, EXTRACT_BE_16BITS(&pdtlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
if (!invtlv) {
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* At this point, tlv_valid() has ensured that the TLV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the containing TLV).
|
|
|
|
*/
|
2015-04-27 08:24:42 +08:00
|
|
|
register const u_char *dp = (const u_char *) TLV_DATA(pdtlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (!ttlv_valid(type)) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
|
2010-01-11 03:49:46 +08:00
|
|
|
tok2str(ForCES_TLV_err, NULL, invtlv), type,
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&pdtlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3)
|
|
|
|
ND_PRINT((ndo, "%s%s, length %d (data length %d Bytes)",
|
2010-01-11 03:49:46 +08:00
|
|
|
ib, tok2str(ForCES_TLV, NULL, type),
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&pdtlv->length), tll));
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
return pdata_print(ndo, dp, tll, op_msk, indent + 1);
|
2010-01-11 03:49:46 +08:00
|
|
|
} else {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\t\t\tInvalid ForCES TLV type=%x", type));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
recpdoptlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
|
2010-02-08 09:47:31 +08:00
|
|
|
int tll;
|
2014-02-26 20:15:28 +08:00
|
|
|
u_int invtlv;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type;
|
2010-01-11 03:49:46 +08:00
|
|
|
register const u_char *dp;
|
|
|
|
char *ib;
|
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
while (len != 0) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*pdtlv);
|
2010-01-11 03:49:46 +08:00
|
|
|
invtlv = tlv_valid(pdtlv, len);
|
|
|
|
if (invtlv) {
|
|
|
|
break;
|
|
|
|
}
|
2010-02-08 09:47:31 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, tlv_valid() has ensured that the TLV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the containing TLV).
|
|
|
|
*/
|
2010-01-11 03:49:46 +08:00
|
|
|
ib = indent_pr(indent, 0);
|
2017-11-18 18:52:52 +08:00
|
|
|
type = EXTRACT_BE_16BITS(&pdtlv->type);
|
2015-04-27 08:24:42 +08:00
|
|
|
dp = (const u_char *) TLV_DATA(pdtlv);
|
2017-11-18 18:52:52 +08:00
|
|
|
tll = EXTRACT_BE_16BITS(&pdtlv->length) - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3)
|
|
|
|
ND_PRINT((ndo, "%s%s, length %d (data encapsulated %d Bytes)",
|
|
|
|
ib, tok2str(ForCES_TLV, NULL, type),
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&pdtlv->length),
|
|
|
|
EXTRACT_BE_16BITS(&pdtlv->length) - TLV_HDRL));
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (pdata_print(ndo, dp, tll, op_msk, indent + 1) == -1)
|
2012-06-09 10:14:06 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
pdtlv = GO_NXT_TLV(pdtlv, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo,
|
|
|
|
"\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&pdtlv->type), len - EXTRACT_BE_16BITS(&pdtlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
invoptlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
char *ib = indent_pr(indent, 1);
|
2010-01-27 12:14:23 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "%sData[", &ib[1]));
|
|
|
|
hex_print_with_offset(ndo, ib, pptr, len, 0);
|
|
|
|
ND_PRINT((ndo, "%s]\n", ib));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
otlv_print(netdissect_options *ndo,
|
2014-04-23 15:20:40 +08:00
|
|
|
const struct forces_tlv *otlv, uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
int rc = 0;
|
2015-04-27 08:24:42 +08:00
|
|
|
register const u_char *dp = (const u_char *) TLV_DATA(otlv);
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t type;
|
2010-01-27 10:43:22 +08:00
|
|
|
int tll;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-27 12:14:23 +08:00
|
|
|
const struct optlv_h *ops;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
|
|
|
|
* >= TLV_HDRL.
|
|
|
|
*/
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*otlv);
|
2017-11-18 18:52:52 +08:00
|
|
|
type = EXTRACT_BE_16BITS(&otlv->type);
|
|
|
|
tll = EXTRACT_BE_16BITS(&otlv->length) - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
ops = get_forces_optlv_h(type);
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&otlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
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) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&otlv->length)));
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll,
|
|
|
|
OP_MIN_SIZ));
|
|
|
|
return invoptlv_print(ndo, dp, tll, ops->op_msk, indent);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-01-09 05:22:13 +08:00
|
|
|
/* XXX - do anything with ops->flags? */
|
2015-02-17 02:25:25 +08:00
|
|
|
if(ops->print) {
|
|
|
|
rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
|
|
|
|
}
|
2010-01-11 03:49:46 +08:00
|
|
|
return rc;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ASTDLN 4
|
|
|
|
#define ASTMCD 255
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
asttlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t rescode;
|
2010-02-08 09:47:31 +08:00
|
|
|
u_int dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-27 12:14:23 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* forces_type_print() has ensured that len (the TLV length)
|
|
|
|
* >= TLV_HDRL.
|
|
|
|
*/
|
|
|
|
dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
if (dlen != ASTDLN) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK2(*pptr, 4);
|
2017-11-18 18:52:52 +08:00
|
|
|
rescode = EXTRACT_BE_32BITS(pptr);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (rescode > ASTMCD) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "Teardown reason:\n%s", ib));
|
2010-01-11 03:49:46 +08:00
|
|
|
switch (rescode) {
|
|
|
|
case 0:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Normal Teardown"));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Loss of Heartbeats"));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Out of bandwidth"));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Out of Memory"));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Application Crash"));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Unknown Teardown reason"));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ASRDLN 4
|
|
|
|
#define ASRMCD 3
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
asrtlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t rescode;
|
2010-02-08 09:47:31 +08:00
|
|
|
u_int dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* forces_type_print() has ensured that len (the TLV length)
|
|
|
|
* >= TLV_HDRL.
|
|
|
|
*/
|
|
|
|
dlen = len - TLV_HDRL;
|
2010-01-11 06:16:41 +08:00
|
|
|
if (dlen != ASRDLN) { /* id, instance, oper tlv */
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK2(*pptr, 4);
|
2017-11-18 18:52:52 +08:00
|
|
|
rescode = EXTRACT_BE_32BITS(pptr);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
if (rescode > ASRMCD) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "illegal ASRresult result code: %d!\n", rescode));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "\n%s", ib));
|
2010-01-11 03:49:46 +08:00
|
|
|
switch (rescode) {
|
|
|
|
case 0:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Success "));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "FE ID invalid "));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "permission denied "));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Unknown "));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
#if 0
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* XXX - not used.
|
|
|
|
*/
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
gentltlv_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr _U_, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_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-27 12:14:23 +08:00
|
|
|
|
2010-01-11 03:49:46 +08:00
|
|
|
if (dlen < 4) { /* at least 32 bits must exist */
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "truncated TLV: %d bytes missing! ", 4 - dlen));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-24 04:12:54 +08:00
|
|
|
#endif
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
#define RD_MIN 8
|
2013-07-16 06:28:34 +08:00
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
print_metailv(netdissect_options *ndo,
|
2014-04-23 15:20:40 +08:00
|
|
|
register const u_char * pptr, uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-01-11 06:16:41 +08:00
|
|
|
/* XXX: check header length */
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_ilv *ilv = (const struct forces_ilv *)pptr;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* print_metatlv() has ensured that len (what remains in the
|
|
|
|
* ILV) >= ILV_HDRL.
|
|
|
|
*/
|
2017-11-18 18:52:52 +08:00
|
|
|
rlen = EXTRACT_BE_32BITS(&ilv->length) - ILV_HDRL;
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*ilv);
|
2017-11-18 18:52:52 +08:00
|
|
|
ND_PRINT((ndo, "%sMetaID 0x%x length %d\n", ib, EXTRACT_BE_32BITS(&ilv->type),
|
|
|
|
EXTRACT_BE_32BITS(&ilv->length)));
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
hex_print_with_offset(ndo, "\t\t[", ILV_DATA(ilv), rlen, 0);
|
|
|
|
ND_PRINT((ndo, " ]\n"));
|
2013-07-16 06:28:35 +08:00
|
|
|
}
|
2010-01-11 03:49:46 +08:00
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
print_metatlv(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-02-08 09:47:31 +08:00
|
|
|
u_int dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_ilv *ilv = (const struct forces_ilv *)pptr;
|
2010-01-11 03:49:46 +08:00
|
|
|
int invilv;
|
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* redirect_print() has ensured that len (what remains in the
|
|
|
|
* TLV) >= TLV_HDRL.
|
|
|
|
*/
|
|
|
|
dlen = len - TLV_HDRL;
|
2010-02-08 10:02:41 +08:00
|
|
|
rlen = dlen;
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n%s METADATA length %d \n", ib, rlen));
|
2010-02-08 10:02:41 +08:00
|
|
|
while (rlen != 0) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*ilv);
|
2010-02-08 10:02:41 +08:00
|
|
|
invilv = ilv_valid(ilv, rlen);
|
2013-07-16 06:28:33 +08:00
|
|
|
if (invilv) {
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
2013-07-16 06:28:33 +08:00
|
|
|
}
|
2010-02-08 09:47:31 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, ilv_valid() has ensured that the ILV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the containing TLV).
|
|
|
|
*/
|
2015-04-27 08:24:42 +08:00
|
|
|
print_metailv(ndo, (const u_char *) ilv, 0, indent + 1);
|
2010-02-08 10:02:41 +08:00
|
|
|
ilv = GO_NXT_ILV(ilv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-16 06:28:34 +08:00
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
print_reddata(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2016-08-19 07:58:35 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-02-08 09:47:31 +08:00
|
|
|
u_int dlen;
|
2013-07-16 06:28:34 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
dlen = len - TLV_HDRL;
|
2010-02-08 10:02:41 +08:00
|
|
|
rlen = dlen;
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n%s Redirect Data length %d \n", ib, rlen));
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "\t\t["));
|
|
|
|
hex_print_with_offset(ndo, "\n\t\t", pptr, rlen, 0);
|
|
|
|
ND_PRINT((ndo, "\n\t\t]"));
|
2013-07-16 06:28:35 +08:00
|
|
|
}
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
redirect_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk _U_, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
|
2010-02-08 09:47:31 +08:00
|
|
|
u_int dlen;
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2014-02-26 20:15:28 +08:00
|
|
|
u_int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* forces_type_print() has ensured that len (the TLV length)
|
|
|
|
* >= TLV_HDRL.
|
|
|
|
*/
|
|
|
|
dlen = len - TLV_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
if (dlen <= RD_MIN) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n\t\ttruncated Redirect TLV: %d bytes missing! ",
|
|
|
|
RD_MIN - dlen));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-02-08 10:02:41 +08:00
|
|
|
rlen = dlen;
|
2010-01-11 03:49:46 +08:00
|
|
|
indent += 1;
|
2010-02-08 10:02:41 +08:00
|
|
|
while (rlen != 0) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*tlv);
|
2010-02-08 10:02:41 +08:00
|
|
|
invtlv = tlv_valid(tlv, rlen);
|
2013-07-16 06:28:33 +08:00
|
|
|
if (invtlv) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Bad Redirect data\n"));
|
2010-01-11 03:49:46 +08:00
|
|
|
break;
|
2013-07-16 06:28:33 +08:00
|
|
|
}
|
2010-02-08 09:47:31 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, tlv_valid() has ensured that the TLV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the containing TLV).
|
|
|
|
*/
|
2017-11-18 18:52:52 +08:00
|
|
|
if (EXTRACT_BE_16BITS(&tlv->type) == F_TLV_METD) {
|
2015-04-27 08:24:42 +08:00
|
|
|
print_metatlv(ndo, (const u_char *) TLV_DATA(tlv),
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&tlv->length), 0,
|
|
|
|
indent);
|
|
|
|
} else if ((EXTRACT_BE_16BITS(&tlv->type) == F_TLV_REDD)) {
|
2015-04-27 08:24:42 +08:00
|
|
|
print_reddata(ndo, (const u_char *) TLV_DATA(tlv),
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&tlv->length), 0,
|
|
|
|
indent);
|
2010-01-11 03:49:46 +08:00
|
|
|
} else {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Unknown REDIRECT TLV 0x%x len %d\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&tlv->type),
|
|
|
|
EXTRACT_BE_16BITS(&tlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2010-02-08 10:02:41 +08:00
|
|
|
tlv = GO_NXT_TLV(tlv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2010-02-08 10:02:41 +08:00
|
|
|
if (rlen) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo,
|
|
|
|
"\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&tlv->type),
|
|
|
|
rlen - EXTRACT_BE_16BITS(&tlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define OP_OFF 8
|
|
|
|
#define OP_MIN 12
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
lfbselect_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len,
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t op_msk, int indent)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
const struct forces_lfbsh *lfbs;
|
2010-01-27 12:14:23 +08:00
|
|
|
const struct forces_tlv *otlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
char *ib = indent_pr(indent, 0);
|
2010-02-08 09:47:31 +08:00
|
|
|
u_int dlen;
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2014-02-26 20:15:28 +08:00
|
|
|
u_int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* forces_type_print() has ensured that len (the TLV length)
|
|
|
|
* >= TLV_HDRL.
|
|
|
|
*/
|
|
|
|
dlen = len - TLV_HDRL;
|
2010-01-11 06:16:41 +08:00
|
|
|
if (dlen <= OP_MIN) { /* id, instance, oper tlv header .. */
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n\t\ttruncated lfb selector: %d bytes missing! ",
|
|
|
|
OP_MIN - dlen));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
|
|
|
|
* we also know that it's > OP_OFF.
|
|
|
|
*/
|
2010-02-08 10:02:41 +08:00
|
|
|
rlen = dlen - OP_OFF;
|
2010-02-08 09:47:31 +08:00
|
|
|
|
2010-01-11 03:49:46 +08:00
|
|
|
lfbs = (const struct forces_lfbsh *)pptr;
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*lfbs);
|
|
|
|
if (ndo->ndo_vflag >= 3) {
|
|
|
|
ND_PRINT((ndo, "\n%s%s(Classid %x) instance %x\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
ib, tok2str(ForCES_LFBs, NULL, EXTRACT_BE_32BITS(&lfbs->class)),
|
|
|
|
EXTRACT_BE_32BITS(&lfbs->class),
|
|
|
|
EXTRACT_BE_32BITS(&lfbs->instance)));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
otlv = (const struct forces_tlv *)(lfbs + 1);
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
indent += 1;
|
2010-02-08 10:02:41 +08:00
|
|
|
while (rlen != 0) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*otlv);
|
2010-02-08 10:02:41 +08:00
|
|
|
invtlv = tlv_valid(otlv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (invtlv)
|
|
|
|
break;
|
2010-02-08 09:47:31 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, tlv_valid() has ensured that the TLV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the containing TLV).
|
|
|
|
*/
|
2017-11-18 18:52:52 +08:00
|
|
|
if (op_valid(EXTRACT_BE_16BITS(&otlv->type), op_msk)) {
|
2014-03-27 18:58:23 +08:00
|
|
|
otlv_print(ndo, otlv, 0, indent);
|
2010-01-11 03:49:46 +08:00
|
|
|
} else {
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag < 3)
|
|
|
|
ND_PRINT((ndo, "\n"));
|
|
|
|
ND_PRINT((ndo,
|
|
|
|
"\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&otlv->type), EXTRACT_BE_16BITS(&otlv->length)));
|
2015-04-27 08:24:42 +08:00
|
|
|
invoptlv_print(ndo, (const u_char *)otlv, rlen, 0, indent);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
2010-02-08 10:02:41 +08:00
|
|
|
otlv = GO_NXT_TLV(otlv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2010-02-08 10:02:41 +08:00
|
|
|
if (rlen) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo,
|
|
|
|
"\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&otlv->type), rlen - EXTRACT_BE_16BITS(&otlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
static int
|
2014-03-27 18:58:23 +08:00
|
|
|
forces_type_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, const struct forcesh *fhdr _U_,
|
|
|
|
register u_int mlen, const struct tom_h *tops)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
2010-01-27 12:14:23 +08:00
|
|
|
const struct forces_tlv *tltlv;
|
2010-02-08 10:02:41 +08:00
|
|
|
u_int rlen;
|
2014-02-26 20:15:28 +08:00
|
|
|
u_int invtlv;
|
2010-01-11 03:49:46 +08:00
|
|
|
int rc = 0;
|
|
|
|
int ttlv = 0;
|
|
|
|
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* forces_print() has already checked that mlen >= ForCES_HDRL
|
|
|
|
* by calling ForCES_HLN_VALID().
|
|
|
|
*/
|
2010-02-08 10:02:41 +08:00
|
|
|
rlen = mlen - ForCES_HDRL;
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2010-02-08 10:02:41 +08:00
|
|
|
if (rlen > TLV_HLN) {
|
2010-01-11 03:49:46 +08:00
|
|
|
if (tops->flags & ZERO_TTLV) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "<0x%x>Illegal Top level TLV!\n", tops->flags));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (tops->flags & ZERO_MORE_TTLV)
|
|
|
|
return 0;
|
|
|
|
if (tops->flags & ONE_MORE_TTLV) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\tTop level TLV Data missing!\n"));
|
2010-01-11 03:49:46 +08:00
|
|
|
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 ;-> */
|
2010-02-08 10:02:41 +08:00
|
|
|
while (rlen != 0) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*tltlv);
|
2010-02-08 10:02:41 +08:00
|
|
|
invtlv = tlv_valid(tltlv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (invtlv)
|
|
|
|
break;
|
2010-02-08 09:47:31 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, tlv_valid() has ensured that the TLV
|
|
|
|
* length is large enough but not too large (it doesn't
|
|
|
|
* go past the end of the packet).
|
|
|
|
*/
|
2017-11-18 18:52:52 +08:00
|
|
|
if (!ttlv_valid(EXTRACT_BE_16BITS(&tltlv->type))) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n\tInvalid ForCES Top TLV type=0x%x",
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&tltlv->type)));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 3)
|
|
|
|
ND_PRINT((ndo, "\t%s, length %d (data length %d Bytes)",
|
2017-11-18 18:52:52 +08:00
|
|
|
tok2str(ForCES_TLV, NULL, EXTRACT_BE_16BITS(&tltlv->type)),
|
|
|
|
EXTRACT_BE_16BITS(&tltlv->length),
|
|
|
|
EXTRACT_BE_16BITS(&tltlv->length) - TLV_HDRL));
|
2010-01-11 03:49:46 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
rc = tops->print(ndo, (const u_char *) TLV_DATA(tltlv),
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_16BITS(&tltlv->length),
|
|
|
|
tops->op_msk, 9);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (rc < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2010-02-08 10:02:41 +08:00
|
|
|
tltlv = GO_NXT_TLV(tltlv, rlen);
|
2010-01-11 03:49:46 +08:00
|
|
|
ttlv--;
|
|
|
|
if (ttlv <= 0)
|
|
|
|
break;
|
|
|
|
}
|
2010-02-08 09:47:31 +08:00
|
|
|
/*
|
|
|
|
* XXX - if ttlv != 0, does that mean that the packet was too
|
|
|
|
* short, and didn't have *enough* TLVs in it?
|
|
|
|
*/
|
2010-02-08 10:02:41 +08:00
|
|
|
if (rlen) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\tMess TopTLV header: min %u, total %d advertised %d ",
|
2017-11-18 18:52:52 +08:00
|
|
|
TLV_HDRL, rlen, EXTRACT_BE_16BITS(&tltlv->length)));
|
2010-01-11 03:49:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-01-27 10:43:22 +08:00
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-27 10:43:22 +08:00
|
|
|
return -1;
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-07-24 04:12:54 +08:00
|
|
|
void
|
2014-03-27 18:58:23 +08:00
|
|
|
forces_print(netdissect_options *ndo,
|
|
|
|
register const u_char * pptr, register u_int len)
|
2010-01-11 03:49:46 +08:00
|
|
|
{
|
|
|
|
const struct forcesh *fhdr;
|
2010-01-27 10:43:22 +08:00
|
|
|
u_int mlen;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t flg_raw;
|
2010-01-27 12:14:23 +08:00
|
|
|
const struct tom_h *tops;
|
2010-01-11 03:49:46 +08:00
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
fhdr = (const struct forcesh *)pptr;
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK(*fhdr);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (!tom_valid(fhdr->fm_tom)) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "Invalid ForCES message type %d\n", fhdr->fm_tom));
|
2010-01-11 03:49:46 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
mlen = ForCES_BLN(fhdr);
|
|
|
|
|
|
|
|
tops = get_forces_tom(fhdr->fm_tom);
|
|
|
|
if (tops->v == TOM_RSVD) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom));
|
2010-01-11 03:49:46 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n\tForCES %s ", tops->s));
|
2010-01-11 03:49:46 +08:00
|
|
|
if (!ForCES_HLN_VALID(mlen, len)) {
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo,
|
|
|
|
"Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
|
|
|
|
ForCES_HDRL, len, ForCES_BLN(fhdr)));
|
2010-01-11 03:49:46 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_TCHECK2(*(pptr + 20), 4);
|
2017-11-18 18:52:52 +08:00
|
|
|
flg_raw = EXTRACT_BE_32BITS(pptr + 20);
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 1) {
|
|
|
|
ND_PRINT((ndo, "\n\tForCES Version %d len %uB flags 0x%08x ",
|
|
|
|
ForCES_V(fhdr), mlen, flg_raw));
|
|
|
|
ND_PRINT((ndo,
|
|
|
|
"\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
|
2010-01-27 10:50:53 +08:00
|
|
|
ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)),
|
2010-01-11 03:49:46 +08:00
|
|
|
ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)),
|
2017-11-18 18:52:52 +08:00
|
|
|
EXTRACT_BE_64BITS(fhdr->fm_cor)));
|
2010-01-11 03:49:46 +08:00
|
|
|
|
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 2) {
|
|
|
|
ND_PRINT((ndo,
|
|
|
|
"\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
|
2014-01-01 03:59:18 +08:00
|
|
|
tok2str(ForCES_ACKs, "ACKUnknown", ForCES_ACK(fhdr)),
|
|
|
|
ForCES_ACK(fhdr),
|
2010-01-11 09:56:49 +08:00
|
|
|
ForCES_PRI(fhdr),
|
2014-01-01 03:59:18 +08:00
|
|
|
tok2str(ForCES_EMs, "EMUnknown", ForCES_EM(fhdr)),
|
|
|
|
ForCES_EM(fhdr),
|
|
|
|
tok2str(ForCES_ATs, "ATUnknown", ForCES_AT(fhdr)),
|
|
|
|
ForCES_AT(fhdr),
|
|
|
|
tok2str(ForCES_TPs, "TPUnknown", ForCES_TP(fhdr)),
|
2014-03-27 18:58:23 +08:00
|
|
|
ForCES_TP(fhdr)));
|
|
|
|
ND_PRINT((ndo,
|
|
|
|
"\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
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
rc = forces_type_print(ndo, pptr, fhdr, mlen, tops);
|
2010-01-11 03:49:46 +08:00
|
|
|
if (rc < 0) {
|
|
|
|
error:
|
2014-03-27 18:58:23 +08:00
|
|
|
hex_print_with_offset(ndo, "\n\t[", pptr, len, 0);
|
|
|
|
ND_PRINT((ndo, "\n\t]"));
|
2010-01-11 03:49:46 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-27 18:58:23 +08:00
|
|
|
if (ndo->ndo_vflag >= 4) {
|
|
|
|
ND_PRINT((ndo, "\n\t Raw ForCES message\n\t ["));
|
|
|
|
hex_print_with_offset(ndo, "\n\t ", pptr, len, 0);
|
|
|
|
ND_PRINT((ndo, "\n\t ]"));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "\n"));
|
2010-01-27 10:43:22 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
2014-03-27 18:58:23 +08:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
2010-01-11 03:49:46 +08:00
|
|
|
}
|
2014-01-02 09:43:45 +08:00
|
|
|
/*
|
|
|
|
* Local Variables:
|
|
|
|
* c-style: whitesmith
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|