Move the list of AX.25 protocol IDs to epan/ax25_pids.h. Use it in

packet-ax25.c and packet-arp.c.

Add an "ax25.pid" dissector table for those protocol IDs, use it in the
AX.25 dissector, and have dissectors register in that table with their
protocol IDs.

Get rid of some unneeded includes.

Clean up some "AX25"s in user-visible strings - say "AX.25" instead.

Clean up some indentation.

svn path=/trunk/; revision=44235
This commit is contained in:
Guy Harris 2012-08-03 01:58:12 +00:00
parent ad3c303f16
commit 307e13d9f2
9 changed files with 78 additions and 92 deletions

View File

@ -134,6 +134,7 @@ LIBWIRESHARK_INCLUDES = \
aftypes.h \
arcnet_pids.h \
arptypes.h \
ax25_pids.h \
asn1.h \
atalk-utils.h \
base64.h \

46
epan/ax25_pids.h Normal file
View File

@ -0,0 +1,46 @@
/* ax25_pids.h
*
* Protocol IDs for Amateur Packet Radio protocol dissection
* Copyright 2005,2006,2007,2008,2009,2010,2012 R.W. Stearn <richard@rns-stearn.demon.co.uk>
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __AX25_PIDS_H__
#define __AX25_PIDS_H__
/* AX.25 Layer 3 Protocol ID's (pid) */
#define AX25_P_ROSE 0x01 /* ISO 8208 / CCITT X.25 PLP */
#define AX25_P_RFC1144C 0x06 /* Compressed TCP/IP packet. Van Jacobson RFC1144 */
#define AX25_P_RFC1144 0x07 /* Uncompressed TCP/IP packet. Van Jacobson RFC1144 */
#define AX25_P_SEGMENT 0x08 /* segmentation fragment */
#define AX25_P_TEXNET 0xC3 /* TEXNET datagram */
#define AX25_P_LCP 0xC4 /* Link Quality Protocol */
#define AX25_P_ATALK 0xCA /* AppleTalk */
#define AX25_P_ATALKARP 0xCB /* AppleTalk ARP */
#define AX25_P_IP 0xCC /* ARPA Internet Protocol */
#define AX25_P_ARP 0xCD /* ARPA Address Resolution Protocol */
#define AX25_P_FLEXNET 0xCE /* FlexNet */
#define AX25_P_NETROM 0xCF /* NET/ROM */
#define AX25_P_NO_L3 0xF0 /* No layer 3 protocol */
#define AX25_P_L3_ESC 0xFF /* Escape character. Next octet contains more layer 3 protocol info */
#endif /* __AX25_PIDS_H__ */

View File

@ -39,6 +39,7 @@
#include "packet-arp.h"
#include <epan/etypes.h>
#include <epan/arcnet_pids.h>
#include <epan/ax25_pids.h>
#include <epan/prefs.h>
#include <epan/expert.h>
@ -345,7 +346,6 @@ static const value_string atmop_vals[] = {
*/
#define ARP_HW_IS_AX25(ar_hrd, ar_hln) \
((ar_hrd) == ARPHRD_AX25 && (ar_hln) == 7)
#define AX25_P_IP 0xCC /* ARPA Internet Protocol on AX.25 */
/*
* Given the protocol address type and length, check whether an address
@ -2051,4 +2051,5 @@ proto_reg_handoff_arp(void)
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_ARP_1051, arp_handle);
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_ARP_1201, arp_handle);
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_RARP_1201, arp_handle);
dissector_add_uint("ax25.pid", AX25_P_ARP, arp_handle);
}

View File

@ -62,6 +62,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/emem.h>
#include <epan/ax25_pids.h>
#define STRLEN 80
@ -265,10 +266,7 @@ proto_register_ax25_nol3(void)
};
/* Register the protocol name and description */
proto_ax25_nol3 = proto_register_protocol("AX25 no Layer 3", "AX25 no L3", "ax25_nol3");
/* Register the dissector */
register_dissector( "ax25_nol3", dissect_ax25_nol3, proto_ax25_nol3 );
proto_ax25_nol3 = proto_register_protocol("AX.25 no Layer 3", "AX.25 no L3", "ax25_nol3");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array( proto_ax25_nol3, hf, array_length(hf ) );
@ -307,6 +305,7 @@ proto_reg_handoff_ax25_nol3(void)
static gboolean inited = FALSE;
if( !inited ) {
dissector_add_uint( "ax25.pid", AX25_P_NO_L3, create_dissector_handle( dissect_ax25_nol3, proto_ax25_nol3 ) );
/*
*/

View File

@ -54,7 +54,7 @@
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/xdlc.h>
#include <epan/etypes.h>
#include <epan/ax25_pids.h>
#include <epan/ipproto.h>
#include <packet-ip.h>
@ -67,44 +67,16 @@
#define AX25_HEADER_SIZE 15 /* length of src_addr + dst_addr + cntl */
#define AX25_MAX_DIGIS 8
/* Layer 3 Protocol ID's (pid) */
#define AX25_P_ROSE 0x01 /* ISO 8208 / CCITT X.25 PLP */
#define AX25_P_RFC1144C 0x06 /* Compressed TCP/IP packet. Van Jacobson RFC1144 */
#define AX25_P_RFC1144 0x07 /* Uncompressed TCP/IP packet. Van Jacobson RFC1144 */
#define AX25_P_SEGMENT 0x08 /* segmentation fragment */
#define AX25_P_TEXNET 0xC3 /* TEXNET datagram */
#define AX25_P_LCP 0xC4 /* Link Quality Protocol */
#define AX25_P_ATALK 0xCA /* AppleTalk */
#define AX25_P_ATALKARP 0xCB /* AppleTalk ARP */
#define AX25_P_IP 0xCC /* ARPA Internet Protocol */
#define AX25_P_ARP 0xCD /* ARPA Address Resolution Protocol */
#define AX25_P_FLEXNET 0xCE /* FlexNet */
#define AX25_P_NETROM 0xCF /* NET/ROM */
#define AX25_P_NO_L3 0xF0 /* No layer 3 protocol */
#define AX25_P_L3_ESC 0xFF /* Escape character. Next octet contains more layer 3 protocol info */
#define I_FRAME( control ) ( ( control & 0x01) == 0 )
#define UI_FRAME( control ) ( ( ( control & 0x03) == 3 ) && ( ( ( ( ( control >> 5 ) & 0x07) << 2) | ( ( control >> 2 ) & 0x03) ) == 0 ) )
/* Forward declaration we need below */
void proto_reg_handoff_ax25(void);
/* Dissector handles - all the possibles are listed */
static dissector_handle_t x25_handle;
static dissector_handle_t rfc1144c_handle;
static dissector_handle_t rfc1144_handle;
static dissector_handle_t segment_handle;
static dissector_handle_t texnet_handle;
static dissector_handle_t lcp_handle;
static dissector_handle_t atalk_handle;
static dissector_handle_t atalkarp_handle;
static dissector_handle_t ip_handle;
static dissector_handle_t arp_handle;
static dissector_handle_t flexnet_handle;
static dissector_handle_t netrom_handle;
static dissector_handle_t no_l3_handle;
static dissector_handle_t l3_esc_handle;
static dissector_handle_t default_handle;
/* Dissector table */
static dissector_table_t ax25_dissector_table;
static dissector_handle_t data_handle;
/* Initialize the protocol and registered fields */
static int proto_ax25 = -1;
@ -311,24 +283,11 @@ dissect_ax25( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
switch ( pid )
if (!dissector_try_uint(ax25_dissector_table, pid, next_tvb, pinfo, parent_tree))
{
case AX25_P_ROSE : call_dissector( x25_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_RFC1144C : call_dissector( rfc1144c_handle, next_tvb, pinfo, parent_tree ); break;
case AX25_P_RFC1144 : call_dissector( rfc1144_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_SEGMENT : call_dissector( segment_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_TEXNET : call_dissector( texnet_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_LCP : call_dissector( lcp_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_ATALK : call_dissector( atalk_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_ATALKARP : call_dissector( atalkarp_handle, next_tvb, pinfo, parent_tree ); break;
case AX25_P_IP : call_dissector( ip_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_ARP : call_dissector( arp_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_FLEXNET : call_dissector( flexnet_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_NETROM : call_dissector( netrom_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_NO_L3 : call_dissector( no_l3_handle , next_tvb, pinfo, parent_tree ); break;
case AX25_P_L3_ESC : call_dissector( l3_esc_handle , next_tvb, pinfo, parent_tree ); break;
default : call_dissector( default_handle , next_tvb, pinfo, parent_tree ); break;
call_dissector(data_handle, next_tvb, pinfo, parent_tree);
}
pinfo->private_data = saved_private_data;
}
}
@ -459,7 +418,7 @@ proto_register_ax25(void)
};
/* Register the protocol name and description */
proto_ax25 = proto_register_protocol("Amateur Radio AX.25", "AX25", "ax25");
proto_ax25 = proto_register_protocol("Amateur Radio AX.25", "AX.25", "ax25");
/* Register the dissector */
register_dissector( "ax25", dissect_ax25, proto_ax25 );
@ -467,6 +426,9 @@ proto_register_ax25(void)
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array( proto_ax25, hf, array_length(hf ) );
proto_register_subtree_array(ett, array_length(ett ) );
/* Register dissector table for protocol IDs */
ax25_dissector_table = register_dissector_table("ax25.pid", "AX.25 protocol ID", FT_UINT8, BASE_HEX);
}
void
@ -476,36 +438,15 @@ proto_reg_handoff_ax25(void)
if( !inited ) {
dissector_handle_t ax25_handle;
dissector_handle_t ax25_handle;
ax25_handle = create_dissector_handle( dissect_ax25, proto_ax25 );
dissector_add_uint("wtap_encap", WTAP_ENCAP_AX25, ax25_handle);
dissector_add_uint("ip.proto", IP_PROTO_AX25, ax25_handle);
ax25_handle = create_dissector_handle( dissect_ax25, proto_ax25 );
dissector_add_uint("wtap_encap", WTAP_ENCAP_AX25, ax25_handle);
dissector_add_uint("ip.proto", IP_PROTO_AX25, ax25_handle);
/*
I have added the "data" dissector for all the currently known PID's
This is so at least we have an entry in the tree that allows the
payload to be hightlighted.
When a new dissector is available all that needs to be done is to
replace the current dissector name "data" with the new dissector name.
*/
x25_handle = find_dissector( "x.25" );
rfc1144c_handle = find_dissector( "data" /* "rfc1144c" */ );
rfc1144_handle = find_dissector( "data" /* "rfc1144" */ );
segment_handle = find_dissector( "data" /* "segment" */ );
texnet_handle = find_dissector( "data" /* "texnet" */ );
lcp_handle = find_dissector( "data" /* "lcp" */ );
atalk_handle = find_dissector( "data" /* "atalk" */ );
atalkarp_handle = find_dissector( "data" /* "atalkarp" */ );
ip_handle = find_dissector( "ip" );
arp_handle = find_dissector( "arp" );
flexnet_handle = find_dissector( "flexnet" );
netrom_handle = find_dissector( "netrom" );
no_l3_handle = find_dissector( "ax25_nol3" );
l3_esc_handle = find_dissector( "data" /* "l3_esc" */ );
default_handle = find_dissector( "data" );
data_handle = find_dissector( "data" );
inited = TRUE;
inited = TRUE;
}
}

View File

@ -49,8 +49,7 @@
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/xdlc.h>
#include <packet-ip.h>
#include <epan/ax25_pids.h>
#define FLEXNET_ADRLEN 15
#define FLEXNET_CTLLEN 15
@ -147,9 +146,6 @@ proto_register_flexnet(void)
/* Register the protocol name and description */
proto_flexnet = proto_register_protocol("FlexNet", "FLEXNET", "flexnet");
/* Register the dissector */
register_dissector( "flexnet", dissect_flexnet, proto_flexnet );
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array( proto_flexnet, hf, array_length( hf ) );
proto_register_subtree_array( ett, array_length( ett ) );
@ -161,6 +157,7 @@ proto_reg_handoff_flexnet(void)
static gboolean inited = FALSE;
if( !inited ) {
dissector_add_uint( "ax25.pid", AX25_P_FLEXNET, create_dissector_handle( dissect_flexnet, proto_flexnet ) );
/*
*/

View File

@ -48,6 +48,7 @@
#include <epan/arcnet_pids.h>
#include <epan/in_cksum.h>
#include <epan/nlpid.h>
#include <epan/ax25_pids.h>
#include <epan/tap.h>
#include <epan/emem.h>
#include <epan/expert.h>
@ -2929,6 +2930,7 @@ proto_reg_handoff_ip(void)
dissector_add_uint("x.25.spi", NLPID_IP, ip_handle);
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_IP_1051, ip_handle);
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_IP_1201, ip_handle);
dissector_add_uint("ax25.pid", AX25_P_IP, ip_handle);
dissector_add_handle("udp.port", ip_handle);
}

View File

@ -49,8 +49,7 @@
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/xdlc.h>
#include <packet-ip.h>
#include <epan/ax25_pids.h>
#include "packet-netrom.h"
@ -656,9 +655,6 @@ proto_register_netrom(void)
/* Register the protocol name and description */
proto_netrom = proto_register_protocol( "Amateur Radio Net/ROM", "Net/ROM", "netrom" );
/* Register the dissector */
register_dissector( "netrom", dissect_netrom, proto_netrom );
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array( proto_netrom, hf, array_length(hf ) );
proto_register_subtree_array( ett, array_length( ett ) );
@ -670,6 +666,7 @@ proto_reg_handoff_netrom(void)
static gboolean inited = FALSE;
if( !inited ) {
dissector_add_uint( "ax25.pid", AX25_P_NETROM, create_dissector_handle( dissect_netrom, proto_netrom ) );
ip_handle = find_dissector( "ip" );
default_handle = find_dissector( "data" );

View File

@ -32,6 +32,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/ax25_pids.h>
#include <epan/llcsaps.h>
#include <epan/circuit.h>
#include <epan/reassemble.h>
@ -2770,4 +2771,5 @@ proto_reg_handoff_x25(void)
x25_handle = find_dissector("x.25");
dissector_add_uint("llc.dsap", SAP_X25, x25_handle);
dissector_add_uint("lapd.sapi", LAPD_SAPI_X25, x25_handle);
dissector_add_uint("ax25.pid", AX25_P_ROSE, x25_handle);
}