2 * Copyright (c) 1998-2006 The TCPDUMP project
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code
6 * distributions retain the above copyright notice and this paragraph
7 * in its entirety, and (2) distributions including binary code include
8 * the above copyright notice and this paragraph in its entirety in
9 * the documentation or other materials provided with the distribution.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
15 * support for the Cisco prop. VQP Protocol
17 * Original code by Carles Kishimoto <Carles.Kishimoto@bsc.es>
20 #define NETDISSECT_REWORKED
25 #include <tcpdump-stdinc.h>
27 #include "interface.h"
29 #include "addrtoname.h"
32 #define VQP_EXTRACT_VERSION(x) ((x)&0xFF)
38 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 * | Constant | Packet type | Error Code | nitems |
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | Packet Sequence Number (4 bytes) |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 struct vqp_common_header_t
{
54 struct vqp_obj_tlv_t
{
56 u_int8_t obj_length
[2];
59 #define VQP_OBJ_REQ_JOIN_PORT 0x01
60 #define VQP_OBJ_RESP_VLAN 0x02
61 #define VQP_OBJ_REQ_RECONFIRM 0x03
62 #define VQP_OBJ_RESP_RECONFIRM 0x04
64 static const struct tok vqp_msg_type_values
[] = {
65 { VQP_OBJ_REQ_JOIN_PORT
, "Request, Join Port"},
66 { VQP_OBJ_RESP_VLAN
, "Response, VLAN"},
67 { VQP_OBJ_REQ_RECONFIRM
, "Request, Reconfirm"},
68 { VQP_OBJ_RESP_RECONFIRM
, "Response, Reconfirm"},
72 static const struct tok vqp_error_code_values
[] = {
74 { 0x03, "Access denied"},
75 { 0x04, "Shutdown port"},
76 { 0x05, "Wrong VTP domain"},
80 /* FIXME the heading 0x0c looks ugly - those must be flags etc. */
81 #define VQP_OBJ_IP_ADDRESS 0x0c01
82 #define VQP_OBJ_PORT_NAME 0x0c02
83 #define VQP_OBJ_VLAN_NAME 0x0c03
84 #define VQP_OBJ_VTP_DOMAIN 0x0c04
85 #define VQP_OBJ_ETHERNET_PKT 0x0c05
86 #define VQP_OBJ_MAC_NULL 0x0c06
87 #define VQP_OBJ_MAC_ADDRESS 0x0c08
89 static const struct tok vqp_obj_values
[] = {
90 { VQP_OBJ_IP_ADDRESS
, "Client IP Address" },
91 { VQP_OBJ_PORT_NAME
, "Port Name" },
92 { VQP_OBJ_VLAN_NAME
, "VLAN Name" },
93 { VQP_OBJ_VTP_DOMAIN
, "VTP Domain" },
94 { VQP_OBJ_ETHERNET_PKT
, "Ethernet Packet" },
95 { VQP_OBJ_MAC_NULL
, "MAC Null" },
96 { VQP_OBJ_MAC_ADDRESS
, "MAC Address" },
101 vqp_print(netdissect_options
*ndo
, register const u_char
*pptr
, register u_int len
)
103 const struct vqp_common_header_t
*vqp_common_header
;
104 const struct vqp_obj_tlv_t
*vqp_obj_tlv
;
107 u_int16_t vqp_obj_len
;
108 u_int32_t vqp_obj_type
;
114 vqp_common_header
= (const struct vqp_common_header_t
*)pptr
;
115 ND_TCHECK(*vqp_common_header
);
118 * Sanity checking of the header.
120 if (VQP_EXTRACT_VERSION(vqp_common_header
->version
) != VQP_VERSION
) {
121 ND_PRINT((ndo
, "VQP version %u packet not supported",
122 VQP_EXTRACT_VERSION(vqp_common_header
->version
)));
126 /* in non-verbose mode just lets print the basic Message Type */
127 if (ndo
->ndo_vflag
< 1) {
128 ND_PRINT((ndo
, "VQPv%u %s Message, error-code %s (%u), length %u",
129 VQP_EXTRACT_VERSION(vqp_common_header
->version
),
130 tok2str(vqp_msg_type_values
, "unknown (%u)",vqp_common_header
->msg_type
),
131 tok2str(vqp_error_code_values
, "unknown (%u)",vqp_common_header
->error_code
),
132 vqp_common_header
->error_code
,
137 /* ok they seem to want to know everything - lets fully decode it */
138 nitems
= vqp_common_header
->nitems
;
139 ND_PRINT((ndo
, "\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
140 VQP_EXTRACT_VERSION(vqp_common_header
->version
),
141 tok2str(vqp_msg_type_values
, "unknown (%u)",vqp_common_header
->msg_type
),
142 tok2str(vqp_error_code_values
, "unknown (%u)",vqp_common_header
->error_code
),
143 vqp_common_header
->error_code
,
144 EXTRACT_32BITS(&vqp_common_header
->sequence
),
148 /* skip VQP Common header */
149 tptr
+=sizeof(const struct vqp_common_header_t
);
150 tlen
-=sizeof(const struct vqp_common_header_t
);
152 while (nitems
> 0 && tlen
> 0) {
154 vqp_obj_tlv
= (const struct vqp_obj_tlv_t
*)tptr
;
155 vqp_obj_type
= EXTRACT_32BITS(vqp_obj_tlv
->obj_type
);
156 vqp_obj_len
= EXTRACT_16BITS(vqp_obj_tlv
->obj_length
);
157 tptr
+=sizeof(struct vqp_obj_tlv_t
);
158 tlen
-=sizeof(struct vqp_obj_tlv_t
);
160 ND_PRINT((ndo
, "\n\t %s Object (0x%08x), length %u, value: ",
161 tok2str(vqp_obj_values
, "Unknown", vqp_obj_type
),
162 vqp_obj_type
, vqp_obj_len
));
164 /* basic sanity check */
165 if (vqp_obj_type
== 0 || vqp_obj_len
==0) {
169 /* did we capture enough for fully decoding the object ? */
170 if (!ND_TTEST2(*tptr
, vqp_obj_len
))
173 switch(vqp_obj_type
) {
174 case VQP_OBJ_IP_ADDRESS
:
175 ND_PRINT((ndo
, "%s (0x%08x)", ipaddr_string(tptr
), EXTRACT_32BITS(tptr
)));
177 /* those objects have similar semantics - fall through */
178 case VQP_OBJ_PORT_NAME
:
179 case VQP_OBJ_VLAN_NAME
:
180 case VQP_OBJ_VTP_DOMAIN
:
181 case VQP_OBJ_ETHERNET_PKT
:
182 safeputs(ndo
, tptr
, vqp_obj_len
);
184 /* those objects have similar semantics - fall through */
185 case VQP_OBJ_MAC_ADDRESS
:
186 case VQP_OBJ_MAC_NULL
:
187 ND_PRINT((ndo
, "%s", etheraddr_string(tptr
)));
190 if (ndo
->ndo_vflag
<= 1)
191 print_unknown_data(ndo
,tptr
, "\n\t ", vqp_obj_len
);
200 ND_PRINT((ndo
, "\n\t[|VQP]"));