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>
21 static const char rcsid
[] _U_
=
22 "@(#) $Header: /tcpdump/master/tcpdump/print-vqp.c,v 1.1 2006-03-03 22:31:16 hannes Exp $";
29 #include <tcpdump-stdinc.h>
35 #include "interface.h"
37 #include "addrtoname.h"
40 #define VQP_EXTRACT_VERSION(x) ((x)&0xFF)
46 * 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
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * | Constant | Packet type | Error Code | nitems |
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | Packet Sequence Number (4 bytes) |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 struct vqp_common_header_t
{
62 struct vqp_tlv_reqjoinport_t
{
64 u_int8_t obj_length
[2];
67 struct vqp_tlv_respvlan_t
{
69 u_int8_t unknown1
[8]; /* XXX */
70 u_int8_t obj_length
[2];
71 u_int8_t unknown2
[4]; /* XXX */
74 #define VQP_OBJ_REQ_JOIN_PORT 0x01
75 #define VQP_OBJ_RESP_VLAN 0x02
76 #define VQP_OBJ_REQ_RECONFIRM 0x03
77 #define VQP_OBJ_RESP_RECONFIRM 0x04
79 static const struct tok vqp_msg_type_values
[] = {
80 { VQP_OBJ_REQ_JOIN_PORT
, "Request, Join Port"},
81 { VQP_OBJ_RESP_VLAN
, "Response, VLAN"},
82 { VQP_OBJ_REQ_RECONFIRM
, "Request, Reconfirm"},
83 { VQP_OBJ_RESP_RECONFIRM
, "Response, Reconfirm"},
87 static const struct tok vqp_error_code_values
[] = {
89 { 0x03, "Access denied"},
90 { 0x04, "Shutdown port"},
91 { 0x05, "Wrong VTP domain"},
95 /* FIXME the heading 0x0c looks ugly - those must be flags etc. */
96 #define VQP_OBJ_IP_ADDRESS 0x0c01
97 #define VQP_OBJ_PORT_NAME 0x0c02
98 #define VQP_OBJ_VLAN_NAME 0x0c03
99 #define VQP_OBJ_VTP_DOMAIN 0x0c04
100 #define VQP_OBJ_ETHERNET_PKT 0x0c05
101 #define VQP_OBJ_MAC_NULL 0x0c06
102 #define VQP_OBJ_MAC_ADDRESS 0x0c08
104 static const struct tok vqp_obj_values
[] = {
105 { VQP_OBJ_IP_ADDRESS
, "Client IP Address" },
106 { VQP_OBJ_PORT_NAME
, "Port Name" },
107 { VQP_OBJ_VLAN_NAME
, "VLAN Name" },
108 { VQP_OBJ_VTP_DOMAIN
, "VTP Domain" },
109 { VQP_OBJ_ETHERNET_PKT
, "Ethernet Packet" },
110 { VQP_OBJ_MAC_NULL
, "MAC Null" },
111 { VQP_OBJ_MAC_ADDRESS
, "MAC Address" },
119 vqp_print(register const u_char
*pptr
, register u_int len
)
121 const struct vqp_common_header_t
*vqp_common_header
;
123 const struct vqp_tlv_reqjoinport_t
*reqjoinport
;
124 const struct vqp_tlv_respvlan_t
*respvlan
;
128 u_int16_t vqp_obj_len
;
129 u_int32_t vqp_obj_type
;
135 vqp_common_header
= (const struct vqp_common_header_t
*)pptr
;
136 TCHECK(*vqp_common_header
);
139 * Sanity checking of the header.
141 if (VQP_EXTRACT_VERSION(vqp_common_header
->version
) != VQP_VERSION
) {
142 printf("VQP version %u packet not supported",
143 VQP_EXTRACT_VERSION(vqp_common_header
->version
));
147 /* in non-verbose mode just lets print the basic Message Type */
149 printf("VQPv%u %s Message, error-code %s (%u), length %u",
150 VQP_EXTRACT_VERSION(vqp_common_header
->version
),
151 tok2str(vqp_msg_type_values
, "unknown (%u)",vqp_common_header
->msg_type
),
152 tok2str(vqp_error_code_values
, "unknown (%u)",vqp_common_header
->error_code
),
153 vqp_common_header
->error_code
,
158 /* ok they seem to want to know everything - lets fully decode it */
159 nitems
= vqp_common_header
->nitems
;
160 printf("\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
161 VQP_EXTRACT_VERSION(vqp_common_header
->version
),
162 tok2str(vqp_msg_type_values
, "unknown (%u)",vqp_common_header
->msg_type
),
163 tok2str(vqp_error_code_values
, "unknown (%u)",vqp_common_header
->error_code
),
164 vqp_common_header
->error_code
,
165 EXTRACT_32BITS(&vqp_common_header
->sequence
),
169 /* skip VQP Common header */
170 tptr
+=sizeof(const struct vqp_common_header_t
);
171 tlen
-=sizeof(const struct vqp_common_header_t
);
175 switch (vqp_common_header
->msg_type
) {
176 case VQP_OBJ_REQ_JOIN_PORT
:
177 vqp_tlv
.reqjoinport
= (const struct vqp_tlv_reqjoinport_t
*)tptr
;
178 vqp_obj_type
= EXTRACT_32BITS(vqp_tlv
.reqjoinport
->obj_type
);
179 vqp_obj_len
= EXTRACT_16BITS(vqp_tlv
.reqjoinport
->obj_length
);
180 tptr
+=sizeof(struct vqp_tlv_reqjoinport_t
);
181 tlen
-=sizeof(struct vqp_tlv_reqjoinport_t
);
183 case VQP_OBJ_RESP_VLAN
:
184 vqp_tlv
.respvlan
= (const struct vqp_tlv_respvlan_t
*)tptr
;
185 vqp_obj_type
= EXTRACT_32BITS(vqp_tlv
.respvlan
->obj_type
);
186 vqp_obj_len
= EXTRACT_16BITS(vqp_tlv
.respvlan
->obj_length
);
187 tptr
+=sizeof(struct vqp_tlv_respvlan_t
);
188 tlen
-=sizeof(struct vqp_tlv_respvlan_t
);
191 /* bail - don't know the TLV format of the message type */
195 /* did we capture enough for fully decoding the object ? */
196 if (!TTEST2(*tptr
, vqp_obj_len
))
200 printf("\n\t %s Object (0x%08x), length %u, value: ",
201 tok2str(vqp_obj_values
, "Unknown", vqp_obj_type
),
202 vqp_obj_type
, vqp_obj_len
);
204 /* basic sanity check */
205 if (vqp_obj_type
== 0 || vqp_obj_len
==0) {
209 switch(vqp_obj_type
) {
210 case VQP_OBJ_IP_ADDRESS
:
211 printf("%s (0x%08x)", ipaddr_string(tptr
), EXTRACT_32BITS(tptr
));
213 /* those objects have similar semantics - fall through */
214 case VQP_OBJ_PORT_NAME
:
215 case VQP_OBJ_VLAN_NAME
:
216 case VQP_OBJ_VTP_DOMAIN
:
217 case VQP_OBJ_ETHERNET_PKT
:
218 safeputs(tptr
, vqp_obj_len
);
220 /* those objects have similar semantics - fall through */
221 case VQP_OBJ_MAC_ADDRESS
:
222 case VQP_OBJ_MAC_NULL
:
223 printf("%s", etheraddr_string(tptr
));
227 print_unknown_data(tptr
, "\n\t ", vqp_obj_len
);
236 printf("\n\t[|VQP]");