2012-08-02 18:38:40 +00:00
|
|
|
/* packet-netrom.c
|
|
|
|
*
|
|
|
|
* Routines for Amateur Packet Radio protocol dissection
|
2012-08-03 03:44:39 +00:00
|
|
|
* NET/ROM inter-node frames.
|
2012-08-02 18:38:40 +00:00
|
|
|
* Copyright 2005,2006,2007,2008,2009,2010,2012 R.W. Stearn <richard@rns-stearn.demon.co.uk>
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2012-10-22 20:46:47 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2012-08-02 18:38:40 +00:00
|
|
|
* 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
|
2012-10-22 20:46:47 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2012-08-02 18:38:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Information on the protocol drawn from:
|
|
|
|
*
|
2012-08-03 03:44:39 +00:00
|
|
|
* Protocol specification is at:
|
|
|
|
*
|
|
|
|
* ftp://ftp.ucsd.edu/hamradio/packet/tcpip/docs/netrom.ps.gz
|
|
|
|
*
|
|
|
|
* (yes, it's PostScript, and, yes, it's an FTP URL).
|
|
|
|
*
|
2012-08-02 18:38:40 +00:00
|
|
|
* Inspiration on how to build the dissector drawn from
|
|
|
|
* packet-sdlc.c
|
|
|
|
* packet-x25.c
|
|
|
|
* packet-lapb.c
|
|
|
|
* paket-gprs-llc.c
|
|
|
|
* xdlc.c
|
|
|
|
* with the base file built from README.developers.
|
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/emem.h>
|
2012-08-03 01:58:12 +00:00
|
|
|
#include <epan/ax25_pids.h>
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
#include "packet-netrom.h"
|
|
|
|
|
|
|
|
#define STRLEN 80
|
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
#define AX25_ADDR_LEN 7 /* length of an AX.25 address */
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
#define NETROM_MIN_SIZE 7 /* minumum payload for a routing packet */
|
|
|
|
#define NETROM_HEADER_SIZE 20 /* minumum payload for a normal packet */
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
#define NETROM_PROTOEXT 0x00
|
|
|
|
#define NETROM_CONNREQ 0x01
|
|
|
|
#define NETROM_CONNACK 0x02
|
|
|
|
#define NETROM_DISCREQ 0x03
|
|
|
|
#define NETROM_DISCACK 0x04
|
|
|
|
#define NETROM_INFO 0x05
|
|
|
|
#define NETROM_INFOACK 0x06
|
|
|
|
|
|
|
|
#define NETROM_MORE_FLAG 0x20
|
|
|
|
#define NETROM_NAK_FLAG 0x40
|
|
|
|
#define NETROM_CHOKE_FLAG 0x80
|
|
|
|
|
|
|
|
#define NETROM_PROTO_IP 0x0C
|
|
|
|
|
|
|
|
/* Forward declaration we need below */
|
|
|
|
void proto_reg_handoff_netrom(void);
|
|
|
|
|
|
|
|
/* Dissector handles - all the possibles are listed */
|
|
|
|
static dissector_handle_t ip_handle;
|
|
|
|
static dissector_handle_t default_handle;
|
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_netrom = -1;
|
|
|
|
static int hf_netrom_src = -1;
|
|
|
|
static int hf_netrom_dst = -1;
|
|
|
|
static int hf_netrom_ttl = -1;
|
|
|
|
static int hf_netrom_my_cct_index = -1;
|
|
|
|
static int hf_netrom_my_cct_id = -1;
|
|
|
|
static int hf_netrom_your_cct_index = -1;
|
|
|
|
static int hf_netrom_your_cct_id = -1;
|
|
|
|
static int hf_netrom_n_r = -1;
|
|
|
|
static int hf_netrom_n_s = -1;
|
|
|
|
static int hf_netrom_type = -1;
|
|
|
|
static int hf_netrom_op = -1;
|
|
|
|
static int hf_netrom_more = -1;
|
|
|
|
static int hf_netrom_nak = -1;
|
|
|
|
static int hf_netrom_choke = -1;
|
|
|
|
|
|
|
|
static int hf_netrom_user = -1;
|
|
|
|
static int hf_netrom_node = -1;
|
|
|
|
static int hf_netrom_pwindow = -1;
|
|
|
|
static int hf_netrom_awindow = -1;
|
|
|
|
|
|
|
|
static int hf_netrom_mnemonic = -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure containing pointers to hf_ values for various subfields of
|
|
|
|
* the type field.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
int *hf_tf_op;
|
|
|
|
int *hf_tf_more;
|
|
|
|
int *hf_tf_nak;
|
|
|
|
int *hf_tf_choke;
|
|
|
|
} netrom_tf_items;
|
|
|
|
|
|
|
|
static const netrom_tf_items netrom_type_items = {
|
|
|
|
&hf_netrom_op,
|
|
|
|
&hf_netrom_more,
|
|
|
|
&hf_netrom_nak,
|
|
|
|
&hf_netrom_choke
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
const value_string op_code_vals_abbrev[] = {
|
2012-08-02 18:38:40 +00:00
|
|
|
{ NETROM_PROTOEXT , "PROTOEXT"},
|
|
|
|
{ NETROM_CONNREQ , "CONNREQ"},
|
|
|
|
{ NETROM_CONNACK , "CONNACK"},
|
|
|
|
{ NETROM_DISCREQ , "DISCREQ"},
|
|
|
|
{ NETROM_DISCACK , "DISCACK"},
|
|
|
|
{ NETROM_INFO , "INFO"},
|
|
|
|
{ NETROM_INFOACK , "INFOACK"},
|
2012-10-22 20:46:47 +00:00
|
|
|
{ 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}
|
2012-08-02 18:38:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
2012-10-22 20:46:47 +00:00
|
|
|
static gint ett_netrom = -1;
|
2012-08-02 18:38:40 +00:00
|
|
|
static gint ett_netrom_type = -1;
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_netrom_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
|
2012-11-28 22:41:07 +00:00
|
|
|
int hf_netrom_type_param, gint ett_netrom_type_param, const netrom_tf_items *type_items )
|
2012-08-02 18:38:40 +00:00
|
|
|
{
|
|
|
|
proto_tree *tc;
|
|
|
|
proto_tree *type_tree;
|
2012-10-22 20:46:47 +00:00
|
|
|
char *info_buffer;
|
|
|
|
guint8 type;
|
|
|
|
guint8 op_code;
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
type = tvb_get_guint8( tvb, offset );
|
2012-08-02 18:38:40 +00:00
|
|
|
op_code = type &0x0f;
|
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
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 );
|
2012-08-02 19:28:08 +00:00
|
|
|
col_add_str( pinfo->cinfo, COL_INFO, info_buffer );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
|
|
|
tc = proto_tree_add_uint_format( tree,
|
2012-11-28 22:41:07 +00:00
|
|
|
hf_netrom_type_param,
|
2012-08-02 18:38:40 +00:00
|
|
|
tvb,
|
|
|
|
offset,
|
|
|
|
1,
|
|
|
|
type,
|
|
|
|
"Type field: %s",
|
|
|
|
info_buffer
|
|
|
|
);
|
2012-11-28 22:41:07 +00:00
|
|
|
type_tree = proto_item_add_subtree( tc, ett_netrom_type_param );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2013-04-04 15:33:14 +00:00
|
|
|
proto_tree_add_item( type_tree, *type_items->hf_tf_op, tvb, offset, 1, ENC_BIG_ENDIAN );
|
|
|
|
proto_tree_add_item( type_tree, *type_items->hf_tf_choke, tvb, offset, 1, ENC_BIG_ENDIAN );
|
|
|
|
proto_tree_add_item( type_tree, *type_items->hf_tf_nak, tvb, offset, 1, ENC_BIG_ENDIAN );
|
|
|
|
proto_tree_add_item( type_tree, *type_items->hf_tf_more, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_netrom_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *netrom_tree;
|
|
|
|
int offset;
|
2012-08-02 18:38:40 +00:00
|
|
|
const guint8 *src_addr;
|
|
|
|
const guint8 *dst_addr;
|
|
|
|
const guint8 *user_addr;
|
|
|
|
const guint8 *node_addr;
|
2012-10-22 20:46:47 +00:00
|
|
|
#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;
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-08-03 03:44:39 +00:00
|
|
|
col_set_str( pinfo->cinfo, COL_PROTOCOL, "NET/ROM" );
|
2012-08-02 19:28:08 +00:00
|
|
|
col_clear( pinfo->cinfo, COL_INFO );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
/* source */
|
|
|
|
src_addr = tvb_get_ptr( tvb, offset, AX25_ADDR_LEN );
|
|
|
|
SET_ADDRESS(&pinfo->dl_src, AT_AX25, AX25_ADDR_LEN, src_addr);
|
|
|
|
SET_ADDRESS(&pinfo->src, AT_AX25, AX25_ADDR_LEN, src_addr);
|
2012-08-02 19:35:36 +00:00
|
|
|
/* src_ssid = *(src_addr + 6); */
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += AX25_ADDR_LEN; /* step over src addr */
|
|
|
|
|
|
|
|
/* destination */
|
|
|
|
dst_addr = tvb_get_ptr( tvb, offset, AX25_ADDR_LEN );
|
|
|
|
SET_ADDRESS(&pinfo->dl_dst, AT_AX25, AX25_ADDR_LEN, dst_addr);
|
|
|
|
SET_ADDRESS(&pinfo->dst, AT_AX25, AX25_ADDR_LEN, dst_addr);
|
2012-08-02 19:35:36 +00:00
|
|
|
/* dst_ssid = *(dst_addr + 6); */
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += AX25_ADDR_LEN; /* step over dst addr */
|
|
|
|
|
|
|
|
offset += 1; /* step over ttl */
|
|
|
|
cct_index = tvb_get_guint8( tvb, offset );
|
|
|
|
offset += 1; /* step over cct index*/
|
|
|
|
cct_id = tvb_get_guint8( tvb, offset );
|
|
|
|
offset += 1; /* step over cct id */
|
|
|
|
offset += 1; /* step over n_s */
|
|
|
|
offset += 1; /* step over n_r */
|
|
|
|
|
|
|
|
/* frame type */
|
|
|
|
op_code = tvb_get_guint8( tvb, offset ) & 0x0f;
|
|
|
|
offset += 1; /* step over op_code */
|
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
col_add_fstr( pinfo->cinfo, COL_INFO, "%s", val_to_str_const( op_code, op_code_vals_text, "Unknown" ));
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
|
|
|
/* create display subtree for the protocol */
|
|
|
|
|
|
|
|
ti = proto_tree_add_protocol_format( tree, proto_netrom, tvb, 0, NETROM_HEADER_SIZE,
|
2012-08-03 03:44:39 +00:00
|
|
|
"NET/ROM, Src: %s (%s), Dst: %s (%s)",
|
2012-08-02 18:38:40 +00:00
|
|
|
get_ax25_name( src_addr ),
|
|
|
|
ax25_to_str( src_addr ),
|
|
|
|
get_ax25_name( dst_addr ),
|
|
|
|
ax25_to_str( dst_addr ) );
|
|
|
|
|
|
|
|
netrom_tree = proto_item_add_subtree( ti, ett_netrom );
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
/* source */
|
|
|
|
proto_tree_add_ax25( netrom_tree, hf_netrom_src, tvb, offset, AX25_ADDR_LEN, src_addr );
|
|
|
|
offset += AX25_ADDR_LEN;
|
|
|
|
|
|
|
|
/* destination */
|
|
|
|
proto_tree_add_ax25( netrom_tree, hf_netrom_dst, tvb, offset, AX25_ADDR_LEN, dst_addr );
|
|
|
|
offset += AX25_ADDR_LEN;
|
|
|
|
|
|
|
|
/* ttl */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_ttl, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
switch ( op_code )
|
|
|
|
{
|
|
|
|
case NETROM_PROTOEXT :
|
|
|
|
/* cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
break;
|
|
|
|
case NETROM_CONNREQ :
|
|
|
|
/* cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_CONNACK :
|
|
|
|
/* your cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* your cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* my cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* my cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_my_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_DISCREQ :
|
|
|
|
/* your cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* your cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_DISCACK :
|
|
|
|
/* your cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* your cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_INFO :
|
|
|
|
/* your cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* your cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* n_s */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_n_s, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* n_r */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_n_r, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_INFOACK :
|
|
|
|
/* your cct index */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_index, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* your cct id */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_your_cct_id, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* unused */
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* n_r */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_n_r, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
offset += 1;
|
|
|
|
offset += 1;
|
|
|
|
offset += 1;
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* type */
|
|
|
|
dissect_netrom_type( tvb,
|
|
|
|
offset,
|
|
|
|
pinfo,
|
|
|
|
netrom_tree,
|
|
|
|
hf_netrom_type,
|
|
|
|
ett_netrom_type,
|
|
|
|
&netrom_type_items
|
|
|
|
);
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
switch ( op_code )
|
|
|
|
{
|
|
|
|
case NETROM_PROTOEXT :
|
|
|
|
break;
|
|
|
|
case NETROM_CONNREQ :
|
|
|
|
/* proposed window size */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_pwindow, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
user_addr = tvb_get_ptr( tvb, offset, AX25_ADDR_LEN );
|
|
|
|
proto_tree_add_ax25( netrom_tree, hf_netrom_user, tvb, offset, AX25_ADDR_LEN, user_addr );
|
|
|
|
offset += AX25_ADDR_LEN;
|
|
|
|
|
|
|
|
node_addr = tvb_get_ptr( tvb, offset, AX25_ADDR_LEN );
|
|
|
|
proto_tree_add_ax25( netrom_tree, hf_netrom_node, tvb, offset, AX25_ADDR_LEN, node_addr );
|
|
|
|
offset += AX25_ADDR_LEN;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_CONNACK :
|
|
|
|
/* accepted window size */
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_awindow, tvb, offset, 1, ENC_BIG_ENDIAN );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_DISCREQ :
|
|
|
|
break;
|
|
|
|
case NETROM_DISCACK :
|
|
|
|
break;
|
|
|
|
case NETROM_INFO :
|
|
|
|
break;
|
|
|
|
case NETROM_INFOACK :
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call sub-dissectors here */
|
|
|
|
|
|
|
|
saved_private_data = pinfo->private_data;
|
2013-02-19 23:17:07 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
switch ( op_code )
|
|
|
|
{
|
|
|
|
case NETROM_PROTOEXT :
|
|
|
|
if ( cct_index == NETROM_PROTO_IP && cct_id == NETROM_PROTO_IP )
|
|
|
|
call_dissector( ip_handle , next_tvb, pinfo, tree );
|
|
|
|
else
|
|
|
|
call_dissector( default_handle , next_tvb, pinfo, tree );
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_INFO :
|
|
|
|
default :
|
|
|
|
call_dissector( default_handle , next_tvb, pinfo, tree );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pinfo->private_data = saved_private_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_netrom_routing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2012-10-22 20:46:47 +00:00
|
|
|
void *saved_private_data;
|
|
|
|
tvbuff_t *next_tvb;
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-08-03 03:44:39 +00:00
|
|
|
col_set_str( pinfo->cinfo, COL_PROTOCOL, "NET/ROM");
|
|
|
|
col_set_str( pinfo->cinfo, COL_INFO, "routing table frame");
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *netrom_tree;
|
2012-08-02 18:38:40 +00:00
|
|
|
ti = proto_tree_add_protocol_format( tree, proto_netrom, tvb, 0, -1,
|
2012-08-03 03:44:39 +00:00
|
|
|
"NET/ROM, routing table frame, Node: %.6s",
|
2012-08-02 18:38:40 +00:00
|
|
|
tvb_get_ptr( tvb, 1, 6 )
|
|
|
|
);
|
|
|
|
|
|
|
|
netrom_tree = proto_item_add_subtree( ti, ett_netrom );
|
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_mnemonic, tvb, 1, 6, ENC_ASCII|ENC_NA );
|
|
|
|
}
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
saved_private_data = pinfo->private_data;
|
2013-02-19 23:17:07 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, 7);
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
call_dissector( default_handle , next_tvb, pinfo, tree );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
pinfo->private_data = saved_private_data;
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Code to actually dissect the packets */
|
|
|
|
static void
|
|
|
|
dissect_netrom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2012-08-02 19:28:08 +00:00
|
|
|
if ( tvb_get_guint8( tvb, 0 ) == 0xff )
|
|
|
|
dissect_netrom_routing( tvb, pinfo, tree );
|
|
|
|
else
|
|
|
|
dissect_netrom_proto( tvb, pinfo, tree );
|
2012-08-02 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
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++;
|
|
|
|
}
|
|
|
|
|
2012-08-02 18:38:40 +00:00
|
|
|
void
|
|
|
|
proto_register_netrom(void)
|
|
|
|
{
|
|
|
|
static const true_false_string flags_set_truth =
|
|
|
|
{
|
|
|
|
"Set",
|
|
|
|
"Not set"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup list of header fields */
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_netrom_src,
|
|
|
|
{ "Source", "netrom.src",
|
|
|
|
FT_AX25, BASE_NONE, NULL, 0x0,
|
|
|
|
"Source callsign", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_dst,
|
|
|
|
{ "Destination", "netrom.dst",
|
|
|
|
FT_AX25, BASE_NONE, NULL, 0x0,
|
|
|
|
"Destination callsign", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_ttl,
|
|
|
|
{ "TTL", "netrom.ttl",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
{ &hf_netrom_my_cct_index,
|
2012-08-02 21:44:22 +00:00
|
|
|
{ "My circuit index", "netrom.my.cct.index",
|
2012-08-02 18:38:40 +00:00
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
{ &hf_netrom_my_cct_id,
|
2012-08-02 21:44:22 +00:00
|
|
|
{ "My circuit ID", "netrom.my.cct.id",
|
2012-08-02 18:38:40 +00:00
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
{ &hf_netrom_your_cct_index,
|
2012-08-02 21:44:22 +00:00
|
|
|
{ "Your circuit index", "netrom.your.cct.index",
|
2012-08-02 18:38:40 +00:00
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
{ &hf_netrom_your_cct_id,
|
2012-08-02 21:44:22 +00:00
|
|
|
{ "Your circuit ID", "netrom.your.cct.id",
|
2012-08-02 18:38:40 +00:00
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
{ &hf_netrom_n_r,
|
|
|
|
{ "N(r)", "netrom.n_r",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
{ &hf_netrom_n_s,
|
|
|
|
{ "N(s)", "netrom.n_s",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
{ &hf_netrom_type,
|
|
|
|
{ "Type", "netrom.type",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0,
|
|
|
|
"Packet type field", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_op,
|
|
|
|
{ "OP code", "netrom.op",
|
2012-10-22 20:46:47 +00:00
|
|
|
FT_UINT8, BASE_HEX, VALS( op_code_vals_abbrev ), 0x0f,
|
2012-08-02 18:38:40 +00:00
|
|
|
"Protocol operation code", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_more,
|
|
|
|
{ "More", "netrom.flag.more",
|
|
|
|
FT_BOOLEAN, 8, TFS(&flags_set_truth), NETROM_MORE_FLAG,
|
|
|
|
"More flag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_nak,
|
|
|
|
{ "NAK", "netrom.flag.nak",
|
|
|
|
FT_BOOLEAN, 8, TFS(&flags_set_truth), NETROM_NAK_FLAG,
|
|
|
|
"NAK flag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_choke,
|
|
|
|
{ "Choke", "netrom.flag.choke",
|
|
|
|
FT_BOOLEAN, 8, TFS(&flags_set_truth), NETROM_CHOKE_FLAG,
|
|
|
|
"Choke flag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_user,
|
|
|
|
{ "User", "netrom.user",
|
|
|
|
FT_AX25, BASE_NONE, NULL, 0x0,
|
|
|
|
"User callsign", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_node,
|
|
|
|
{ "Node", "netrom.node",
|
|
|
|
FT_AX25, BASE_NONE, NULL, 0x0,
|
|
|
|
"Node callsign", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_pwindow,
|
|
|
|
{ "Window", "netrom.pwindow",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Proposed window", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_awindow,
|
|
|
|
{ "Window", "netrom.awindow",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Accepted window", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_mnemonic,
|
|
|
|
{ "Node name", "netrom.name",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0,
|
2012-08-02 21:44:22 +00:00
|
|
|
NULL, HFILL }
|
2012-08-02 18:38:40 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_netrom,
|
|
|
|
&ett_netrom_type,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Register the protocol name and description */
|
2012-08-03 03:44:39 +00:00
|
|
|
proto_netrom = proto_register_protocol( "Amateur Radio NET/ROM", "NET/ROM", "netrom" );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
/* 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 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_netrom(void)
|
|
|
|
{
|
2012-10-22 20:46:47 +00:00
|
|
|
dissector_add_uint( "ax25.pid", AX25_P_NETROM, create_dissector_handle( dissect_netrom, proto_netrom ) );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
ip_handle = find_dissector( "ip" );
|
|
|
|
default_handle = find_dissector( "data" );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|