* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Support for the Light Weight Access Point Protocol as per draft-ohara-capwap-lwapp-04
- *
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lwapp.c,v 1.1 2007-07-24 16:07:30 hannes Exp $";
-#endif
+/* \summary: Light Weight Access Point Protocol (LWAPP) printer */
+
+/* specification: RFC 5412 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
*/
struct lwapp_transport_header {
- u_int8_t version;
- u_int8_t frag_id;
- u_int8_t length[2];
- u_int16_t status;
+ uint8_t version;
+ uint8_t frag_id;
+ uint8_t length[2];
+ uint16_t status;
};
/*
*/
struct lwapp_control_header {
- u_int8_t msg_type;
- u_int8_t seq_num;
- u_int8_t len[2];
- u_int8_t session_id[4];
+ uint8_t msg_type;
+ uint8_t seq_num;
+ uint8_t len[2];
+ uint8_t session_id[4];
};
#define LWAPP_VERSION 0
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lwapp_message_header {
- u_int8_t type;
- u_int8_t length[2];
+ uint8_t type;
+ uint8_t length[2];
};
void
-lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
-
+lwapp_control_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len, int has_ap_ident)
+{
const struct lwapp_transport_header *lwapp_trans_header;
const struct lwapp_control_header *lwapp_control_header;
const u_char *tptr;
if (has_ap_ident) {
/* check if enough bytes for AP identity */
- if (!TTEST2(*tptr, 6))
- goto trunc;
+ ND_TCHECK2(*tptr, 6);
lwapp_trans_header = (const struct lwapp_transport_header *)(pptr+6);
} else {
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
}
- TCHECK(*lwapp_trans_header);
+ ND_TCHECK(*lwapp_trans_header);
/*
* Sanity checking of the header.
*/
if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) {
- printf("LWAPP version %u packet not supported",
- LWAPP_EXTRACT_VERSION(lwapp_trans_header->version));
+ ND_PRINT((ndo, "LWAPP version %u packet not supported",
+ LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)));
return;
}
/* non-verbose */
- if (vflag < 1) {
- printf("LWAPPv%u, %s frame, Flags [%s], length %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
- len);
+ len));
return;
}
/* ok they seem to want to know everything - lets fully decode it */
tlen=EXTRACT_16BITS(lwapp_trans_header->length);
- printf("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
LWAPP_EXTRACT_RID(lwapp_trans_header->version),
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
lwapp_trans_header->frag_id,
- tlen);
+ tlen));
if (has_ap_ident) {
- printf("\n\tAP identity: %s",
- etheraddr_string(tptr));
+ ND_PRINT((ndo, "\n\tAP identity: %s", etheraddr_string(ndo, tptr)));
tptr+=sizeof(const struct lwapp_transport_header)+6;
} else {
tptr+=sizeof(const struct lwapp_transport_header);
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
- if (!TTEST2(*tptr, sizeof(struct lwapp_control_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lwapp_control_header));
lwapp_control_header = (const struct lwapp_control_header *)tptr;
msg_tlen = EXTRACT_16BITS(lwapp_control_header->len);
/* print message header */
- printf("\n\t Msg type: %s (%u), Seqnum: %u, Msg len: %d, Session: 0x%08x",
+ ND_PRINT((ndo, "\n\t Msg type: %s (%u), Seqnum: %u, Msg len: %d, Session: 0x%08x",
tok2str(lwapp_msg_type_values,"Unknown",lwapp_control_header->msg_type),
lwapp_control_header->msg_type,
lwapp_control_header->seq_num,
msg_tlen,
- EXTRACT_32BITS(lwapp_control_header->session_id));
+ EXTRACT_32BITS(lwapp_control_header->session_id)));
/* did we capture enough for fully decoding the message */
- if (!TTEST2(*tptr, msg_tlen))
- goto trunc;
+ ND_TCHECK2(*tptr, msg_tlen);
/* XXX - Decode sub messages for each message */
switch(lwapp_control_header->msg_type) {
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
void
-lwapp_data_print(const u_char *pptr, u_int len) {
-
+lwapp_data_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len)
+{
const struct lwapp_transport_header *lwapp_trans_header;
const u_char *tptr;
int tlen;
tptr=pptr;
/* check if enough bytes for AP identity */
- if (!TTEST2(*tptr, 6))
- goto trunc;
+ ND_TCHECK2(*tptr, 6);
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
- TCHECK(*lwapp_trans_header);
+ ND_TCHECK(*lwapp_trans_header);
/*
* Sanity checking of the header.
*/
if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) {
- printf("LWAPP version %u packet not supported",
- LWAPP_EXTRACT_VERSION(lwapp_trans_header->version));
+ ND_PRINT((ndo, "LWAPP version %u packet not supported",
+ LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)));
return;
}
/* non-verbose */
- if (vflag < 1) {
- printf("LWAPPv%u, %s frame, Flags [%s], length %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
- len);
+ len));
return;
}
/* ok they seem to want to know everything - lets fully decode it */
tlen=EXTRACT_16BITS(lwapp_trans_header->length);
- printf("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
LWAPP_EXTRACT_RID(lwapp_trans_header->version),
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
lwapp_trans_header->frag_id,
- tlen);
+ tlen));
tptr+=sizeof(const struct lwapp_transport_header);
tlen-=sizeof(const struct lwapp_transport_header);
/* FIX - An IEEE 802.11 frame follows - hexdump for now */
- print_unknown_data(gndo,tptr, "\n\t", tlen);
+ print_unknown_data(ndo, tptr, "\n\t", tlen);
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
/*