- Ethereal --> Wireshark;
- gerald@ethereal.com --> gerald@wireshark.org;
- update FSF address;
- remove unneeded #includes;
- Fix ENC args for proto_tree_add_item() & etc;
- simplify/remove proto_reg_handoff...() as appropriate;
- remove some boilerplate comments;
- move proto_register...() and proto_reg_handoff...() to
   the end of the file as per convention;
- remove some unneeded initializers.
- simplify some code;
- replace "" in hf[] blurb by NULL.


svn path=/trunk/; revision=45728
This commit is contained in:
Bill Meier 2012-10-22 20:46:47 +00:00
parent 3b4260cfe0
commit 19d2c33091
11 changed files with 338 additions and 479 deletions

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -21,7 +21,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@ -41,30 +41,18 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <glib.h>
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/address.h>
#include <epan/prefs.h>
#include <epan/emem.h>
#include <epan/ftypes/ftypes.h>
#define AX25_ADDR_LEN 7 /* length of an AX.25 address */
#define STRLEN 100
/* Forward declaration we need below */
void proto_reg_handoff_aprs(void);
/* Dissector handles - all the possibles are listed */
static dissector_handle_t default_handle;
/* Initialize the protocol and registered fields */
static int proto_aprs = -1;
@ -485,7 +473,7 @@ dissect_aprs_msg( tvbuff_t *tvb,
ch = tvb_get_guint8( tvb, offset );
if ( parent_tree ){
tc = proto_tree_add_item( parent_tree, hf_aprs_msg, tvb, offset, 7, ENC_ASCII );
tc = proto_tree_add_item( parent_tree, hf_aprs_msg, tvb, offset, 7, ENC_ASCII|ENC_NA );
msg_tree = proto_item_add_subtree( tc, ett_aprs_msg );
}
if ( isdigit( ch ) )
@ -991,7 +979,7 @@ aprs_timestamp( proto_tree *aprs_tree, tvbuff_t *tvb, int offset )
g_snprintf( info_buffer, STRLEN, "%*.*s", data_len, data_len, tvb_get_ptr( tvb, offset, data_len ) );
if ( isdigit( info_buffer[ 6 ] ) )
{ /* MDHM */
proto_tree_add_item( aprs_tree, hf_aprs_mdhm, tvb, offset, data_len, FALSE );
proto_tree_add_item( aprs_tree, hf_aprs_mdhm, tvb, offset, data_len, ENC_ASCII|ENC_NA );
proto_tree_add_string( aprs_tree, hf_aprs_tz, tvb, offset, data_len, timezone );
}
else
@ -999,7 +987,7 @@ aprs_timestamp( proto_tree *aprs_tree, tvbuff_t *tvb, int offset )
data_len--;
if ( info_buffer[ 6 ] == 'h' )
{ /* HMS */
proto_tree_add_item( aprs_tree, hf_aprs_hms, tvb, offset, data_len, FALSE );
proto_tree_add_item( aprs_tree, hf_aprs_hms, tvb, offset, data_len, ENC_ASCII|ENC_NA );
proto_tree_add_string( aprs_tree, hf_aprs_tz, tvb, offset, data_len, timezone );
}
else
@ -1010,7 +998,7 @@ aprs_timestamp( proto_tree *aprs_tree, tvbuff_t *tvb, int offset )
case '/' : timezone = "local"; break;
default : timezone = "unknown"; break;
}
proto_tree_add_item( aprs_tree, hf_aprs_dhm, tvb, offset, data_len, FALSE );
proto_tree_add_item( aprs_tree, hf_aprs_dhm, tvb, offset, data_len, ENC_ASCII|ENC_NA );
proto_tree_add_string( aprs_tree, hf_aprs_tz, tvb, offset + 6, 1, timezone );
}
}
@ -1072,14 +1060,14 @@ aprs_status( proto_tree *aprs_tree, tvbuff_t *tvb, int offset )
g_snprintf( info_buffer, STRLEN, "%*.*s", data_len, data_len, tvb_get_ptr( tvb, offset, data_len ) );
if ( data_len > 7 && info_buffer[ 6 ] == 'z' )
{
proto_tree_add_item( aprs_tree, hf_aprs_dhm, tvb, offset, 6, FALSE );
proto_tree_add_item( aprs_tree, hf_aprs_dhm, tvb, offset, 6, ENC_ASCII|ENC_NA );
offset += 6;
data_len -= 6;
proto_tree_add_string( aprs_tree, hf_aprs_tz, tvb, offset, 1, "zulu" );
offset += 1;
data_len -= 1;
}
proto_tree_add_item( aprs_tree, hf_aprs_status, tvb, offset, data_len, FALSE );
proto_tree_add_item( aprs_tree, hf_aprs_status, tvb, offset, data_len, ENC_ASCII|ENC_NA );
return offset + data_len;
}
@ -1118,7 +1106,7 @@ aprs_item( proto_tree *aprs_tree, tvbuff_t *tvb, int offset )
static int
aprs_3rd_party( proto_tree *aprs_tree, tvbuff_t *tvb, int offset, int data_len )
{
proto_tree_add_item( aprs_tree, hf_aprs_third_party, tvb, offset, data_len, FALSE );
proto_tree_add_item( aprs_tree, hf_aprs_third_party, tvb, offset, data_len, ENC_NA );
/* tnc-2 */
/* aea */
return offset + data_len;
@ -1344,7 +1332,7 @@ dissect_aprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *d
offset = 0;
dti = tvb_get_guint8( tvb, offset );
proto_tree_add_item( aprs_tree, hf_aprs_dti, tvb, offset, 1, FALSE );
proto_tree_add_item( aprs_tree, hf_aprs_dti, tvb, offset, 1, ENC_ASCII|ENC_NA );
offset += 1;
switch ( dti )
{
@ -1939,7 +1927,7 @@ proto_register_aprs(void)
proto_register_subtree_array( ett, array_length( ett ) );
/* Register preferences module */
aprs_module = prefs_register_protocol( proto_aprs, proto_reg_handoff_aprs);
aprs_module = prefs_register_protocol( proto_aprs, NULL);
/* Register any preference */
prefs_register_bool_preference(aprs_module, "showaprslax",
@ -1949,15 +1937,3 @@ proto_register_aprs(void)
}
void
proto_reg_handoff_aprs(void)
{
static gboolean inited = FALSE;
if( !inited ) {
default_handle = find_dissector( "data" );
inited = TRUE;
}
}

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -21,7 +21,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@ -33,8 +33,8 @@
* and here:
* http://www.ax25.net/kiss.aspx
*
* Linux implementation does not appear to attempt to implement that
* protocol in full. Does provide the ability to send a KISS command via
* The Linux implementation does not appear to attempt to implement that
* protocol in full. It does provide the ability to send a KISS command via
* ax25_kiss_cmd() and internally will send FULLDUPLEX KISS commands if
* DAMA is enabled/disabled.
* i.e.:
@ -103,52 +103,44 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/etypes.h>
#include "packet-ax25-kiss.h"
#include "packet-ax25.h"
#define STRLEN 80
#define KISS_HEADER_SIZE 1 /* length of the KISS type header */
#define KISS_HEADER_SIZE 1 /* length of the KISS type header */
/* KISS frame types */
#define KISS_DATA_FRAME 0
#define KISS_TXDELAY 1
#define KISS_PERSISTENCE 2
#define KISS_SLOT_TIME 3
#define KISS_TXTAIL 4
#define KISS_FULLDUPLEX 5
#define KISS_SETHARDWARE 6
#define KISS_DATA_FRAME 0
#define KISS_TXDELAY 1
#define KISS_PERSISTENCE 2
#define KISS_SLOT_TIME 3
#define KISS_TXTAIL 4
#define KISS_FULLDUPLEX 5
#define KISS_SETHARDWARE 6
#define KISS_RETURN 15
#define KISS_CMD_MASK 0x0f
#define KISS_PORT_MASK 0xf0
/* Forward declaration we need below */
void proto_reg_handoff_ax25_kiss(void);
/* Dissector handles - all the possibles are listed */
static dissector_handle_t ax25_handle;
/* Initialize the protocol and registered fields */
static int proto_ax25_kiss = -1;
static int hf_ax25_kiss_cmd = -1;
static int hf_ax25_kiss_port = -1;
static int hf_ax25_kiss_txdelay = -1;
static int hf_ax25_kiss_txdelay = -1;
static int hf_ax25_kiss_persistence = -1;
static int hf_ax25_kiss_slottime = -1;
static int hf_ax25_kiss_txtail = -1;
static int hf_ax25_kiss_txtail = -1;
static int hf_ax25_kiss_fullduplex = -1;
static int hf_ax25_kiss_sethardware = -1;
@ -156,52 +148,79 @@ static int hf_ax25_kiss_sethardware = -1;
static gint ett_ax25_kiss = -1;
static const value_string kiss_frame_types[] = {
{ KISS_DATA_FRAME, "Data frame" },
{ KISS_TXDELAY, "Tx Delay" },
{ KISS_DATA_FRAME, "Data frame" },
{ KISS_TXDELAY, "Tx Delay" },
{ KISS_PERSISTENCE, "Persistence" },
{ KISS_SLOT_TIME, "Slot time" },
{ KISS_TXTAIL, "Tx tail" },
{ KISS_FULLDUPLEX, "Full duplex" },
{ KISS_SLOT_TIME, "Slot time" },
{ KISS_TXTAIL, "Tx tail" },
{ KISS_FULLDUPLEX, "Full duplex" },
{ KISS_SETHARDWARE, "Set hardware" },
{ KISS_RETURN, "Return" },
{ KISS_RETURN, "Return" },
{ 0, NULL }
};
void
capture_ax25_kiss( const guchar *pd, int offset, int len, packet_counts *ld)
{
int l_offset;
guint8 kiss_cmd;
if ( ! BYTES_ARE_IN_FRAME( offset, len, KISS_HEADER_SIZE ) )
{
ld->other++;
return;
}
l_offset = offset;
kiss_cmd = pd[ l_offset ];
l_offset += KISS_HEADER_SIZE; /* step over kiss header */
switch ( kiss_cmd & KISS_CMD_MASK )
{
case KISS_DATA_FRAME : capture_ax25( pd, l_offset, len, ld ); break;
case KISS_TXDELAY : l_offset += 1; break;
case KISS_PERSISTENCE : l_offset += 1; break;
case KISS_SLOT_TIME : l_offset += 1; break;
case KISS_TXTAIL : l_offset += 1; break;
case KISS_FULLDUPLEX : l_offset += 1; break;
case KISS_SETHARDWARE : l_offset += 1; break;
case KISS_RETURN : break;
default : break;
}
}
/* Code to actually dissect the packets */
static void
dissect_ax25_kiss( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
{
proto_item *ti;
proto_tree *kiss_tree;
int offset;
int kiss_cmd;
int kiss_type;
int kiss_port;
int kiss_param;
int kiss_param_len;
int offset;
int kiss_cmd;
int kiss_type;
int kiss_port;
int kiss_param;
int kiss_param_len;
const char *frame_type_text;
char *info_buffer;
void *saved_private_data;
tvbuff_t *next_tvb = NULL;
char *info_buffer;
void *saved_private_data;
tvbuff_t *next_tvb = NULL;
info_buffer = ep_alloc( STRLEN );
info_buffer[0]='\0';
info_buffer = ep_alloc( STRLEN );
info_buffer[0] = '\0';
col_set_str( pinfo->cinfo, COL_PROTOCOL, "AX.25 KISS" );
col_clear( pinfo->cinfo, COL_INFO );
/* protocol offset for the KISS header */
offset = 0;
kiss_cmd = tvb_get_guint8( tvb, offset ) & 0xff;
kiss_type = kiss_cmd & KISS_CMD_MASK;
kiss_port = (kiss_cmd & KISS_PORT_MASK) >> 4;
offset += KISS_HEADER_SIZE;
kiss_cmd = tvb_get_guint8( tvb, offset ) & 0xff;
kiss_type = kiss_cmd & KISS_CMD_MASK;
kiss_port = (kiss_cmd & KISS_PORT_MASK) >> 4;
offset += KISS_HEADER_SIZE;
kiss_param = 0;
kiss_param_len = 0;
kiss_param = 0;
kiss_param_len = 0;
switch ( kiss_type )
{
case KISS_TXDELAY : kiss_param_len = 1; kiss_param = tvb_get_guint8( tvb, offset ) & 0xff; break;
@ -215,8 +234,7 @@ dissect_ax25_kiss( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
frame_type_text = val_to_str(kiss_type, kiss_frame_types, "Unknown (%u)");
g_snprintf( info_buffer, STRLEN, "%s, Port %u", frame_type_text, kiss_port );
if ( kiss_param_len > 0 )
g_snprintf( info_buffer, STRLEN, "%s %u, Port %u", frame_type_text, kiss_param,
kiss_port );
g_snprintf( info_buffer, STRLEN, "%s %u, Port %u", frame_type_text, kiss_param, kiss_port );
offset += kiss_param_len;
@ -357,47 +375,12 @@ proto_register_ax25_kiss(void)
void
proto_reg_handoff_ax25_kiss(void)
{
static gboolean inited = FALSE;
dissector_handle_t kiss_handle;
if( !inited ) {
kiss_handle = create_dissector_handle( dissect_ax25_kiss, proto_ax25_kiss );
dissector_add_uint( "wtap_encap", WTAP_ENCAP_AX25_KISS, kiss_handle );
dissector_handle_t kiss_handle;
kiss_handle = create_dissector_handle( dissect_ax25_kiss, proto_ax25_kiss );
dissector_add_uint( "wtap_encap", WTAP_ENCAP_AX25_KISS, kiss_handle );
/* only currently implemented for AX.25 */
ax25_handle = find_dissector( "ax25" );
inited = TRUE;
}
/* only currently implemented for AX.25 */
ax25_handle = find_dissector( "ax25" );
}
void
capture_ax25_kiss( const guchar *pd, int offset, int len, packet_counts *ld)
{
int l_offset;
guint8 kiss_cmd;
if ( ! BYTES_ARE_IN_FRAME( offset, len, KISS_HEADER_SIZE ) ) {
ld->other++;
return;
}
l_offset = offset;
kiss_cmd = pd[ l_offset ];
l_offset += KISS_HEADER_SIZE; /* step over kiss header */
switch ( kiss_cmd & KISS_CMD_MASK )
{
case KISS_DATA_FRAME : capture_ax25( pd, l_offset, len, ld ); break;
case KISS_TXDELAY : break;
case KISS_PERSISTENCE : break;
case KISS_SLOT_TIME : break;
case KISS_TXTAIL : break;
case KISS_FULLDUPLEX : break;
case KISS_SETHARDWARE : break;
case KISS_RETURN : break;
default : break;
}
}

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -21,7 +21,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@ -48,15 +48,8 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <glib.h>
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/emem.h>
@ -64,9 +57,6 @@
#define STRLEN 80
/* Forward declaration we need below */
void proto_reg_handoff_ax25_nol3(void);
/* Dissector handles - all the possibles are listed */
static dissector_handle_t aprs_handle;
static dissector_handle_t default_handle;
@ -116,7 +106,7 @@ dissect_dx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
dx_tree = proto_item_add_subtree( ti, ett_dx );
offset = 0;
proto_tree_add_item( dx_tree, hf_dx_report, tvb, offset, data_len, FALSE );
proto_tree_add_item( dx_tree, hf_dx_report, tvb, offset, data_len, ENC_ASCII|ENC_NA );
}
}
@ -127,33 +117,33 @@ isaprs( guint8 dti )
switch ( dti )
{
case '<' :
case '>' :
case '?' :
case '$' :
case '%' :
case 'T' :
case '[' :
case ')' :
case '_' :
case ',' :
case '{' :
case '}' :
case ':' :
case ';' :
case 0x1c :
case 0x1d :
case '\'' :
case '`' :
case '#' :
case '*' :
case '&' :
case '+' :
case '.' :
case '=' :
case '!' :
case '#' :
case '$' :
case '%' :
case '&' :
case ')' :
case '*' :
case '+' :
case ',' :
case '.' :
case '/' :
case ':' :
case ';' :
case '<' :
case '=' :
case '>' :
case '?' :
case '@' :
case '/' : b = TRUE; break;
case 'T' :
case '[' :
case '\'' :
case '_' :
case '`' :
case '{' :
case '}' : b = TRUE; break;
default : break;
}
return b;
@ -271,7 +261,7 @@ proto_register_ax25_nol3(void)
proto_register_subtree_array( ett, array_length( ett ) );
/* Register preferences module */
ax25_nol3_module = prefs_register_protocol( proto_ax25_nol3, proto_reg_handoff_ax25_nol3);
ax25_nol3_module = prefs_register_protocol( proto_ax25_nol3, NULL);
/* Register any preference */
prefs_register_bool_preference(ax25_nol3_module, "showaprs",
@ -300,16 +290,11 @@ proto_register_ax25_nol3(void)
void
proto_reg_handoff_ax25_nol3(void)
{
static gboolean inited = FALSE;
dissector_add_uint( "ax25.pid", AX25_P_NO_L3, create_dissector_handle( dissect_ax25_nol3, proto_ax25_nol3 ) );
if( !inited ) {
dissector_add_uint( "ax25.pid", AX25_P_NO_L3, create_dissector_handle( dissect_ax25_nol3, proto_ax25_nol3 ) );
/*
*/
aprs_handle = find_dissector( "aprs" );
default_handle = find_dissector( "data" );
/*
*/
aprs_handle = find_dissector( "aprs" );
default_handle = find_dissector( "data" );
inited = TRUE;
}
}

View File

@ -6,8 +6,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -22,7 +22,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@ -46,13 +46,8 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/xdlc.h>
@ -65,12 +60,9 @@
#define STRLEN 80
#define AX25_ADDR_LEN 7 /* length of an AX.25 address */
#define AX25_ADDR_LEN 7 /* length of an AX.25 address */
#define AX25_HEADER_SIZE 15 /* length of src_addr + dst_addr + cntl */
#define AX25_MAX_DIGIS 8
/* Forward declaration we need below */
void proto_reg_handoff_ax25(void);
#define AX25_MAX_DIGIS 8
/* Dissector table */
static dissector_table_t ax25_dissector_table;
@ -113,28 +105,26 @@ static const xdlc_cf_items ax25_cf_items = {
};
static const value_string pid_vals[] = {
{ AX25_P_ROSE, "Rose" },
{ AX25_P_ROSE, "Rose" },
{ AX25_P_RFC1144C, "RFC1144 (compressed)" },
{ AX25_P_RFC1144, "RFC1144 (uncompressed)" },
{ AX25_P_SEGMENT, "Segment" },
{ AX25_P_TEXNET, "Texnet" },
{ AX25_P_LCP, "Link Quality protocol" },
{ AX25_P_ATALK, "AppleTalk" },
{ AX25_P_RFC1144, "RFC1144 (uncompressed)" },
{ AX25_P_SEGMENT, "Segment" },
{ AX25_P_TEXNET, "Texnet" },
{ AX25_P_LCP, "Link Quality protocol" },
{ AX25_P_ATALK, "AppleTalk" },
{ AX25_P_ATALKARP, "AppleTalk ARP" },
{ AX25_P_IP, "IP" },
{ AX25_P_ARP, "ARP" },
{ AX25_P_FLEXNET, "FlexNet" },
{ AX25_P_NETROM, "NetRom" },
{ AX25_P_NO_L3, "No L3" },
{ AX25_P_L3_ESC, "L3 esc" },
{ AX25_P_IP, "IP" },
{ AX25_P_ARP, "ARP" },
{ AX25_P_FLEXNET, "FlexNet" },
{ AX25_P_NETROM, "NetRom" },
{ AX25_P_NO_L3, "No L3" },
{ AX25_P_L3_ESC, "L3 esc" },
{ 0, NULL }
};
/* Initialize the subtree pointers */
static gint ett_ax25 = -1;
static gint ett_ax25_ctl = -1;
/* Code to actually dissect the packets */
static void
dissect_ax25( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
{
@ -158,10 +148,9 @@ dissect_ax25( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
info_buffer = ep_alloc( STRLEN );
info_buffer[0]='\0';
info_buffer[0] = '\0';
col_set_str( pinfo->cinfo, COL_PROTOCOL, "AX.25" );
col_clear( pinfo->cinfo, COL_INFO );
/* start at the dst addr */
@ -275,6 +264,44 @@ dissect_ax25( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
proto_item_set_end(ti, tvb, offset);
}
void
capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld)
{
guint8 control;
guint8 pid;
int l_offset;
if ( ! BYTES_ARE_IN_FRAME( offset, len, AX25_HEADER_SIZE ) )
{
ld->other++;
return;
}
l_offset = offset;
l_offset += AX25_ADDR_LEN; /* step over dst addr point at src addr */
l_offset += AX25_ADDR_LEN; /* step over src addr point at either 1st via addr or control byte */
while ( ( pd[ l_offset - 1 ] & 0x01 ) == 0 )
l_offset += AX25_ADDR_LEN; /* step over a via addr */
control = pd[ l_offset ];
/* decode the pid field (if appropriate) */
if ( XDLC_IS_INFORMATION( control ) )
{
l_offset += 1; /* step over control byte point at pid */
pid = pd[ l_offset ];
l_offset += 1; /* step over the pid and point to the first byte of the payload */
switch ( pid & 0x0ff )
{
case AX25_P_NETROM : capture_netrom( pd, l_offset, len, ld ); break;
case AX25_P_IP : capture_ip( pd, l_offset, len, ld ); break;
case AX25_P_ARP : ld->arp++; break;
default : ld->other++; break;
}
}
}
void
proto_register_ax25(void)
{
@ -345,47 +372,47 @@ proto_register_ax25(void)
{ &hf_ax25_n_r,
{ "n(r)", "ax25.ctl.n_r",
FT_UINT8, BASE_DEC, NULL, XDLC_N_R_MASK,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_n_s,
{ "n(s)", "ax25.ctl.n_s",
FT_UINT8, BASE_DEC, NULL, XDLC_N_S_MASK,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_p,
{ "Poll", "ax25.ctl.p",
FT_BOOLEAN, 8, TFS(&flags_set_truth), XDLC_P_F,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_f,
{ "Final", "ax25.ctl.f",
FT_BOOLEAN, 8, TFS(&flags_set_truth), XDLC_P_F,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_ftype_s,
{ "Frame type", "ax25.ctl.ftype_s",
FT_UINT8, BASE_HEX, VALS(stype_vals), XDLC_S_FTYPE_MASK,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_ftype_i,
{ "Frame type", "ax25.ctl.ftype_i",
FT_UINT8, BASE_HEX, VALS(ftype_vals), XDLC_I_MASK,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_ftype_su,
{ "Frame type", "ax25.ctl.ftype_su",
FT_UINT8, BASE_HEX, VALS(ftype_vals), XDLC_S_U_MASK,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_u_cmd,
{ "Frame type", "ax25.ctl.u_cmd",
FT_UINT8, BASE_HEX, VALS(modifier_vals_cmd), XDLC_U_MODIFIER_MASK,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_u_resp,
{ "Frame type", "ax25.ctl.u_resp",
FT_UINT8, BASE_HEX, VALS(modifier_vals_resp), XDLC_U_MODIFIER_MASK,
"", HFILL }
NULL, HFILL }
},
{ &hf_ax25_pid,
{ "Protocol ID", "ax25.pid",
@ -417,56 +444,13 @@ proto_register_ax25(void)
void
proto_reg_handoff_ax25(void)
{
static gboolean inited = FALSE;
dissector_handle_t ax25_handle;
if( !inited ) {
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);
dissector_handle_t ax25_handle;
data_handle = find_dissector( "data" );
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);
data_handle = find_dissector( "data" );
inited = TRUE;
}
}
void
capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld)
{
guint8 control;
guint8 pid;
int l_offset;
if ( ! BYTES_ARE_IN_FRAME( offset, len, AX25_HEADER_SIZE ) )
{
ld->other++;
return;
}
l_offset = offset;
l_offset += AX25_ADDR_LEN; /* step over dst addr point at src addr */
l_offset += AX25_ADDR_LEN; /* step over src addr point at either 1st via addr or control byte */
while ( ( pd[ l_offset - 1 ] & 0x01 ) == 0 )
l_offset += AX25_ADDR_LEN; /* step over a via addr */
control = pd[ l_offset ];
/* decode the pid field (if appropriate) */
if ( XDLC_IS_INFORMATION( control ) )
{
l_offset += 1; /* step over control byte point at pid */
pid = pd[ l_offset ];
l_offset += 1; /* step over the pid and point to the first byte of the payload */
switch ( pid & 0x0ff )
{
case AX25_P_NETROM : capture_netrom( pd, l_offset, len, ld ); break;
case AX25_P_IP : capture_ip( pd, l_offset, len, ld ); break;
case AX25_P_ARP : ld->arp++; break;
default : ld->other++; break;
}
}
}

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark,org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -21,7 +21,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __PACKET_AX25_H__

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -21,7 +21,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@ -37,16 +37,9 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/emem.h>
#include <epan/etypes.h>
#include "packet-bpq.h"
@ -56,29 +49,22 @@
#define BPQ_HEADER_SIZE 2 /* length of bpq_len */
/* Forward declaration we need below */
void proto_reg_handoff_bpq(void);
/* Dissector handles - all the possibles are listed */
static dissector_handle_t ax25_handle;
/* Initialize the protocol and registered fields */
static int proto_bpq = -1;
static int hf_bpq_len = -1;
/* Initialize the subtree pointers */
static gint ett_bpq = -1;
/* Code to actually dissect the packets */
static void
dissect_bpq( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
{
proto_item *ti;
proto_tree *bpq_tree;
int offset;
guint16 bpq_len;
void *saved_private_data;
tvbuff_t *next_tvb = NULL;
int offset;
guint16 bpq_len;
void *saved_private_data;
tvbuff_t *next_tvb;
col_set_str( pinfo->cinfo, COL_PROTOCOL, "BPQ" );
@ -105,10 +91,9 @@ dissect_bpq( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
bpq_tree = proto_item_add_subtree( ti, ett_bpq );
proto_tree_add_item( bpq_tree, hf_bpq_len, tvb, offset, BPQ_HEADER_SIZE, TRUE );
proto_tree_add_item( bpq_tree, hf_bpq_len, tvb, offset, BPQ_HEADER_SIZE, ENC_LITTLE_ENDIAN );
}
/* Call sub-dissectors here */
offset += BPQ_HEADER_SIZE;
@ -119,6 +104,22 @@ dissect_bpq( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
pinfo->private_data = saved_private_data;
}
void
capture_bpq( const guchar *pd, int offset, int len, packet_counts *ld)
{
int l_offset;
if ( ! BYTES_ARE_IN_FRAME( offset, len, BPQ_HEADER_SIZE ) )
{
ld->other++;
return;
}
l_offset = offset;
l_offset += BPQ_HEADER_SIZE; /* step over bpq header to point at the AX.25 packet*/
capture_ax25( pd, l_offset, len, ld );
}
void
proto_register_bpq(void)
{
@ -150,34 +151,12 @@ proto_register_bpq(void)
void
proto_reg_handoff_bpq(void)
{
static gboolean inited = FALSE;
dissector_handle_t bpq_handle;
if(!inited) {
bpq_handle = create_dissector_handle( dissect_bpq, proto_bpq );
dissector_add_uint("ethertype", ETHERTYPE_BPQ, bpq_handle);
dissector_handle_t bpq_handle;
/* BPQ is only implemented for AX.25 */
ax25_handle = find_dissector( "ax25" );
bpq_handle = create_dissector_handle( dissect_bpq, proto_bpq );
dissector_add_uint("ethertype", ETHERTYPE_BPQ, bpq_handle);
/* BPQ is only implemented for AX.25 */
ax25_handle = find_dissector( "ax25" );
inited = TRUE;
}
}
void
capture_bpq( const guchar *pd, int offset, int len, packet_counts *ld)
{
int l_offset;
if ( ! BYTES_ARE_IN_FRAME( offset, len, BPQ_HEADER_SIZE ) )
{
ld->other++;
return;
}
l_offset = offset;
l_offset += BPQ_HEADER_SIZE; /* step over bpq header to point at the AX.25 packet*/
capture_ax25( pd, l_offset, len, ld );
}

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -21,7 +21,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@ -38,53 +38,40 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/ax25_pids.h>
#define FLEXNET_ADRLEN 15
#define FLEXNET_CTLLEN 15
#define FLEXNET_HDRLEN (FLEXNET_ADRLEN + FLEXNET_ADRLEN + FLEXNET_CTLLEN)
/* Forward declaration we need below */
void proto_reg_handoff_flexnet(void);
/* Dissector handles - all the possibles are listed */
static dissector_handle_t default_handle;
/* Initialize the protocol and registered fields */
static int proto_flexnet = -1;
static int hf_flexnet_dst = -1;
static int hf_flexnet_src = -1;
static int hf_flexnet_ctl = -1;
/* Initialize the subtree pointers */
static gint ett_flexnet = -1;
static gint ett_flexnet_ctl = -1;
/* Code to actually dissect the packets */
static void
dissect_flexnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
{
proto_item *ti;
proto_tree *flexnet_tree;
int offset;
void *saved_private_data;
tvbuff_t *next_tvb = NULL;
void *saved_private_data;
tvbuff_t *next_tvb;
col_set_str( pinfo->cinfo, COL_PROTOCOL, "Flexnet");
col_clear( pinfo->cinfo, COL_INFO );
if ( parent_tree )
{
proto_item *ti;
proto_tree *flexnet_tree;
int offset;
/* create display subtree for the protocol */
ti = proto_tree_add_protocol_format( parent_tree, proto_flexnet, tvb, 0, FLEXNET_HDRLEN, "FLEXNET" );
@ -93,14 +80,14 @@ dissect_flexnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
offset = 0;
proto_tree_add_item( flexnet_tree, hf_flexnet_dst, tvb, offset, FLEXNET_ADRLEN, FALSE );
proto_tree_add_item( flexnet_tree, hf_flexnet_dst, tvb, offset, FLEXNET_ADRLEN, ENC_NA );
offset +=FLEXNET_ADRLEN;
proto_tree_add_item( flexnet_tree, hf_flexnet_src, tvb, offset, FLEXNET_ADRLEN, FALSE );
proto_tree_add_item( flexnet_tree, hf_flexnet_src, tvb, offset, FLEXNET_ADRLEN, ENC_NA );
offset +=FLEXNET_ADRLEN;
proto_tree_add_item( flexnet_tree, hf_flexnet_ctl, tvb, offset, FLEXNET_CTLLEN, FALSE );
offset +=FLEXNET_CTLLEN;
proto_tree_add_item( flexnet_tree, hf_flexnet_ctl, tvb, offset, FLEXNET_CTLLEN, ENC_NA );
/* offset +=FLEXNET_CTLLEN; */
}
/* Call sub-dissectors here */
@ -152,15 +139,10 @@ proto_register_flexnet(void)
void
proto_reg_handoff_flexnet(void)
{
static gboolean inited = FALSE;
dissector_add_uint( "ax25.pid", AX25_P_FLEXNET, create_dissector_handle( dissect_flexnet, proto_flexnet ) );
if( !inited ) {
dissector_add_uint( "ax25.pid", AX25_P_FLEXNET, create_dissector_handle( dissect_flexnet, proto_flexnet ) );
/*
*/
default_handle = find_dissector( "data" );
/*
*/
default_handle = find_dissector( "data" );
inited = TRUE;
}
}

View File

@ -6,8 +6,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -22,7 +22,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@ -45,13 +45,8 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/strutil.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/ax25_pids.h>
@ -60,10 +55,10 @@
#define STRLEN 80
#define AX25_ADDR_LEN 7 /* length of an AX.25 address */
#define AX25_ADDR_LEN 7 /* length of an AX.25 address */
#define NETROM_MIN_SIZE 7 /* minumum payload for a routing packet */
#define NETROM_HEADER_SIZE 20 /* minumum payload for a normal packet */
#define NETROM_MIN_SIZE 7 /* minumum payload for a routing packet */
#define NETROM_HEADER_SIZE 20 /* minumum payload for a normal packet */
#define NETROM_PROTOEXT 0x00
#define NETROM_CONNREQ 0x01
@ -129,7 +124,7 @@ static const netrom_tf_items netrom_type_items = {
};
const value_string op_copde_vals[] = {
const value_string op_code_vals_abbrev[] = {
{ NETROM_PROTOEXT , "PROTOEXT"},
{ NETROM_CONNREQ , "CONNREQ"},
{ NETROM_CONNACK , "CONNACK"},
@ -137,11 +132,22 @@ const value_string op_copde_vals[] = {
{ NETROM_DISCACK , "DISCACK"},
{ NETROM_INFO , "INFO"},
{ NETROM_INFOACK , "INFOACK"},
{ 0 , NULL }
{ 0 , NULL}
};
const value_string op_code_vals_text[] = {
{ NETROM_PROTOEXT , "Protocol extension"},
{ NETROM_CONNREQ , "Connect request"},
{ NETROM_CONNACK , "Connect acknowledge"},
{ NETROM_DISCREQ , "Disconnect request"},
{ NETROM_DISCACK , "Disconnect acknowledge"},
{ NETROM_INFO , "Information"},
{ NETROM_INFOACK , "Information acknowledge"},
{ 0 , NULL}
};
/* Initialize the subtree pointers */
static gint ett_netrom = -1;
static gint ett_netrom = -1;
static gint ett_netrom_type = -1;
static void
@ -150,34 +156,19 @@ dissect_netrom_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *t
{
proto_tree *tc;
proto_tree *type_tree;
char *info_buffer;
char *op_text_ptr;
guint8 type;
guint8 op_code;
char *info_buffer;
guint8 type;
guint8 op_code;
info_buffer = ep_alloc( STRLEN );
info_buffer[0] = '\0';
type = tvb_get_guint8( tvb, offset );
type = tvb_get_guint8( tvb, offset );
op_code = type &0x0f;
switch ( op_code )
{
case NETROM_PROTOEXT : op_text_ptr = "Protocol extension" ; break;
case NETROM_CONNREQ : op_text_ptr = "Connect request" ; break;
case NETROM_CONNACK : op_text_ptr = "Connect acknowledge" ; break;
case NETROM_DISCREQ : op_text_ptr = "Disconnect request" ; break;
case NETROM_DISCACK : op_text_ptr = "Disconnect acknowledge" ; break;
case NETROM_INFO : op_text_ptr = "Information" ; break;
case NETROM_INFOACK : op_text_ptr = "Information acknowledge" ; break;
default : op_text_ptr = "Unknown" ; break;
}
g_snprintf( info_buffer, STRLEN, "%s%s%s%s (0x%02x)",
op_text_ptr,
( type & NETROM_MORE_FLAG ) ? ", More" : "",
( type & NETROM_NAK_FLAG ) ? ", NAK" : "",
( type & NETROM_CHOKE_FLAG ) ? ", Choke" : "",
type );
info_buffer = ep_strdup_printf( "%s%s%s%s (0x%02x)",
val_to_str_const( op_code, op_code_vals_text, "Unknown" ),
( type & NETROM_MORE_FLAG ) ? ", More" : "",
( type & NETROM_NAK_FLAG ) ? ", NAK" : "",
( type & NETROM_CHOKE_FLAG ) ? ", Choke" : "",
type );
col_add_str( pinfo->cinfo, COL_INFO, info_buffer );
if ( tree )
@ -203,24 +194,24 @@ dissect_netrom_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *t
static void
dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *netrom_tree;
int offset;
char *op_text_ptr;
proto_item *ti;
proto_tree *netrom_tree;
int offset;
const guint8 *src_addr;
const guint8 *dst_addr;
const guint8 *user_addr;
const guint8 *node_addr;
/* guint8 src_ssid;
guint8 dst_ssid; */
guint8 op_code;
guint8 cct_index;
guint8 cct_id;
void *saved_private_data;
tvbuff_t *next_tvb = NULL;
#if 0
guint8 src_ssid;
guint8 dst_ssid;
#endif
guint8 op_code;
guint8 cct_index;
guint8 cct_id;
void *saved_private_data;
tvbuff_t *next_tvb = NULL;
col_set_str( pinfo->cinfo, COL_PROTOCOL, "NET/ROM" );
col_clear( pinfo->cinfo, COL_INFO );
offset = 0;
@ -251,19 +242,7 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
op_code = tvb_get_guint8( tvb, offset ) & 0x0f;
offset += 1; /* step over op_code */
switch ( op_code )
{
case NETROM_PROTOEXT : op_text_ptr = "Protocol extension" ; break;
case NETROM_CONNREQ : op_text_ptr = "Connect request" ; break;
case NETROM_CONNACK : op_text_ptr = "Connect acknowledge" ; break;
case NETROM_DISCREQ : op_text_ptr = "Disconnect request" ; break;
case NETROM_DISCACK : op_text_ptr = "Disconnect acknowledge" ; break;
case NETROM_INFO : op_text_ptr = "Information" ; break;
case NETROM_INFOACK : op_text_ptr = "Information acknowledge" ; break;
default : op_text_ptr = "Unknown" ; break;
}
col_add_fstr( pinfo->cinfo, COL_INFO, "%s", op_text_ptr );
col_add_fstr( pinfo->cinfo, COL_INFO, "%s", val_to_str_const( op_code, op_code_vals_text, "Unknown" ));
if ( tree )
{
@ -289,18 +268,18 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset += AX25_ADDR_LEN;
/* ttl */
proto_tree_add_item( netrom_tree, hf_netrom_ttl, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_ttl, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
switch ( op_code )
{
case NETROM_PROTOEXT :
/* cct index */
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* cct id */
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* unused */
@ -311,11 +290,11 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
case NETROM_CONNREQ :
/* cct index */
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* cct id */
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* unused */
@ -327,29 +306,29 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
case NETROM_CONNACK :
/* your cct index */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* your cct id */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* my cct index */
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* my cct id */
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
break;
case NETROM_DISCREQ :
/* your cct index */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* your cct id */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* unused */
@ -361,11 +340,11 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
case NETROM_DISCACK :
/* your cct index */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* your cct id */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* unused */
@ -377,36 +356,36 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
case NETROM_INFO :
/* your cct index */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* your cct id */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* n_s */
proto_tree_add_item( netrom_tree, hf_netrom_n_s, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_n_s, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* n_r */
proto_tree_add_item( netrom_tree, hf_netrom_n_r, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_n_r, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
break;
case NETROM_INFOACK :
/* your cct index */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* your cct id */
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
/* unused */
offset += 1;
/* n_r */
proto_tree_add_item( netrom_tree, hf_netrom_n_r, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_n_r, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
break;
@ -436,7 +415,7 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
case NETROM_CONNREQ :
/* proposed window size */
proto_tree_add_item( netrom_tree, hf_netrom_pwindow, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_pwindow, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
user_addr = tvb_get_ptr( tvb, offset, AX25_ADDR_LEN );
@ -450,7 +429,7 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
case NETROM_CONNACK :
/* accepted window size */
proto_tree_add_item( netrom_tree, hf_netrom_awindow, tvb, offset, 1, FALSE );
proto_tree_add_item( netrom_tree, hf_netrom_awindow, tvb, offset, 1, ENC_BIG_ENDIAN );
offset += 1;
break;
@ -493,18 +472,16 @@ dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static void
dissect_netrom_routing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *netrom_tree;
int offset;
void *saved_private_data;
tvbuff_t *next_tvb = NULL;
void *saved_private_data;
tvbuff_t *next_tvb;
col_set_str( pinfo->cinfo, COL_PROTOCOL, "NET/ROM");
col_set_str( pinfo->cinfo, COL_INFO, "routing table frame");
if (tree)
{
proto_item *ti;
proto_tree *netrom_tree;
ti = proto_tree_add_protocol_format( tree, proto_netrom, tvb, 0, -1,
"NET/ROM, routing table frame, Node: %.6s",
tvb_get_ptr( tvb, 1, 6 )
@ -512,19 +489,16 @@ dissect_netrom_routing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
netrom_tree = proto_item_add_subtree( ti, ett_netrom );
offset = 1;
proto_tree_add_item( netrom_tree, hf_netrom_mnemonic, tvb, offset, 6, FALSE );
offset += 6;
saved_private_data = pinfo->private_data;
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
call_dissector( default_handle , next_tvb, pinfo, tree );
pinfo->private_data = saved_private_data;
proto_tree_add_item( netrom_tree, hf_netrom_mnemonic, tvb, 1, 6, ENC_ASCII|ENC_NA );
}
saved_private_data = pinfo->private_data;
next_tvb = tvb_new_subset(tvb, 7, -1, -1);
call_dissector( default_handle , next_tvb, pinfo, tree );
pinfo->private_data = saved_private_data;
}
/* Code to actually dissect the packets */
@ -537,6 +511,18 @@ dissect_netrom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissect_netrom_proto( tvb, pinfo, tree );
}
void
capture_netrom( const guchar *pd _U_, int offset, int len, packet_counts *ld)
{
if ( ! BYTES_ARE_IN_FRAME( offset, len, NETROM_MIN_SIZE ) )
{
ld->other++;
return;
}
/* XXX - check for IP-over-NetROM here! */
ld->other++;
}
void
proto_register_netrom(void)
{
@ -601,7 +587,7 @@ proto_register_netrom(void)
},
{ &hf_netrom_op,
{ "OP code", "netrom.op",
FT_UINT8, BASE_HEX, VALS( op_copde_vals ), 0x0f,
FT_UINT8, BASE_HEX, VALS( op_code_vals_abbrev ), 0x0f,
"Protocol operation code", HFILL }
},
{ &hf_netrom_more,
@ -663,26 +649,10 @@ proto_register_netrom(void)
void
proto_reg_handoff_netrom(void)
{
static gboolean inited = FALSE;
dissector_add_uint( "ax25.pid", AX25_P_NETROM, create_dissector_handle( dissect_netrom, proto_netrom ) );
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" );
ip_handle = find_dissector( "ip" );
default_handle = find_dissector( "data" );
inited = TRUE;
}
}
void
capture_netrom( const guchar *pd _U_, int offset, int len, packet_counts *ld)
{
if ( ! BYTES_ARE_IN_FRAME( offset, len, NETROM_MIN_SIZE ) )
{
ld->other++;
return;
}
/* XXX - check fr IP-over-NetROM here! */
ld->other++;
}

View File

@ -5,8 +5,8 @@
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -21,7 +21,7 @@
*
* 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.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __PACKET_NETROM_H__