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>
24 #include <tcpdump-stdinc.h>
30 #include "interface.h"
32 #include "addrtoname.h"
35 #define VQP_EXTRACT_VERSION(x) ((x)&0xFF)
41 * 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
42 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 * | Constant | Packet type | Error Code | nitems |
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * | Packet Sequence Number (4 bytes) |
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 struct vqp_common_header_t
{
57 struct vqp_obj_tlv_t
{
59 u_int8_t obj_length
[2];
62 #define VQP_OBJ_REQ_JOIN_PORT 0x01
63 #define VQP_OBJ_RESP_VLAN 0x02
64 #define VQP_OBJ_REQ_RECONFIRM 0x03
65 #define VQP_OBJ_RESP_RECONFIRM 0x04
67 static const struct tok vqp_msg_type_values
[] = {
68 { VQP_OBJ_REQ_JOIN_PORT
, "Request, Join Port"},
69 { VQP_OBJ_RESP_VLAN
, "Response, VLAN"},
70 { VQP_OBJ_REQ_RECONFIRM
, "Request, Reconfirm"},
71 { VQP_OBJ_RESP_RECONFIRM
, "Response, Reconfirm"},
75 static const struct tok vqp_error_code_values
[] = {
77 { 0x03, "Access denied"},
78 { 0x04, "Shutdown port"},
79 { 0x05, "Wrong VTP domain"},
83 /* FIXME the heading 0x0c looks ugly - those must be flags etc. */
84 #define VQP_OBJ_IP_ADDRESS 0x0c01
85 #define VQP_OBJ_PORT_NAME 0x0c02
86 #define VQP_OBJ_VLAN_NAME 0x0c03
87 #define VQP_OBJ_VTP_DOMAIN 0x0c04
88 #define VQP_OBJ_ETHERNET_PKT 0x0c05
89 #define VQP_OBJ_MAC_NULL 0x0c06
90 #define VQP_OBJ_MAC_ADDRESS 0x0c08
92 static const struct tok vqp_obj_values
[] = {
93 { VQP_OBJ_IP_ADDRESS
, "Client IP Address" },
94 { VQP_OBJ_PORT_NAME
, "Port Name" },
95 { VQP_OBJ_VLAN_NAME
, "VLAN Name" },
96 { VQP_OBJ_VTP_DOMAIN
, "VTP Domain" },
97 { VQP_OBJ_ETHERNET_PKT
, "Ethernet Packet" },
98 { VQP_OBJ_MAC_NULL
, "MAC Null" },
99 { VQP_OBJ_MAC_ADDRESS
, "MAC Address" },
104 vqp_print(register const u_char
*pptr
, register u_int len
)
106 const struct vqp_common_header_t
*vqp_common_header
;
107 const struct vqp_obj_tlv_t
*vqp_obj_tlv
;
110 u_int16_t vqp_obj_len
;
111 u_int32_t vqp_obj_type
;
117 vqp_common_header
= (const struct vqp_common_header_t
*)pptr
;
118 TCHECK(*vqp_common_header
);
121 * Sanity checking of the header.
123 if (VQP_EXTRACT_VERSION(vqp_common_header
->version
) != VQP_VERSION
) {
124 printf("VQP version %u packet not supported",
125 VQP_EXTRACT_VERSION(vqp_common_header
->version
));
129 /* in non-verbose mode just lets print the basic Message Type */
131 printf("VQPv%u %s Message, error-code %s (%u), length %u",
132 VQP_EXTRACT_VERSION(vqp_common_header
->version
),
133 tok2str(vqp_msg_type_values
, "unknown (%u)",vqp_common_header
->msg_type
),
134 tok2str(vqp_error_code_values
, "unknown (%u)",vqp_common_header
->error_code
),
135 vqp_common_header
->error_code
,
140 /* ok they seem to want to know everything - lets fully decode it */
141 nitems
= vqp_common_header
->nitems
;
142 printf("\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
143 VQP_EXTRACT_VERSION(vqp_common_header
->version
),
144 tok2str(vqp_msg_type_values
, "unknown (%u)",vqp_common_header
->msg_type
),
145 tok2str(vqp_error_code_values
, "unknown (%u)",vqp_common_header
->error_code
),
146 vqp_common_header
->error_code
,
147 EXTRACT_32BITS(&vqp_common_header
->sequence
),
151 /* skip VQP Common header */
152 tptr
+=sizeof(const struct vqp_common_header_t
);
153 tlen
-=sizeof(const struct vqp_common_header_t
);
155 while (nitems
> 0 && tlen
> 0) {
157 vqp_obj_tlv
= (const struct vqp_obj_tlv_t
*)tptr
;
158 vqp_obj_type
= EXTRACT_32BITS(vqp_obj_tlv
->obj_type
);
159 vqp_obj_len
= EXTRACT_16BITS(vqp_obj_tlv
->obj_length
);
160 tptr
+=sizeof(struct vqp_obj_tlv_t
);
161 tlen
-=sizeof(struct vqp_obj_tlv_t
);
163 printf("\n\t %s Object (0x%08x), length %u, value: ",
164 tok2str(vqp_obj_values
, "Unknown", vqp_obj_type
),
165 vqp_obj_type
, vqp_obj_len
);
167 /* basic sanity check */
168 if (vqp_obj_type
== 0 || vqp_obj_len
==0) {
172 /* did we capture enough for fully decoding the object ? */
173 if (!TTEST2(*tptr
, vqp_obj_len
))
176 switch(vqp_obj_type
) {
177 case VQP_OBJ_IP_ADDRESS
:
178 printf("%s (0x%08x)", ipaddr_string(tptr
), EXTRACT_32BITS(tptr
));
180 /* those objects have similar semantics - fall through */
181 case VQP_OBJ_PORT_NAME
:
182 case VQP_OBJ_VLAN_NAME
:
183 case VQP_OBJ_VTP_DOMAIN
:
184 case VQP_OBJ_ETHERNET_PKT
:
185 safeputs((const char *)tptr
, vqp_obj_len
);
187 /* those objects have similar semantics - fall through */
188 case VQP_OBJ_MAC_ADDRESS
:
189 case VQP_OBJ_MAC_NULL
:
190 printf("%s", etheraddr_string(tptr
));
194 print_unknown_data(gndo
,tptr
, "\n\t ", vqp_obj_len
);
203 printf("\n\t[|VQP]");