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>
|
|
|
|
*
|
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
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
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 <epan/packet.h>
|
2013-11-09 13:41:10 +00:00
|
|
|
#include <epan/to_str.h>
|
2015-12-14 13:48:59 +00:00
|
|
|
#include <epan/capture_dissectors.h>
|
2012-08-03 01:58:12 +00:00
|
|
|
#include <epan/ax25_pids.h>
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2013-12-14 16:09:57 +00:00
|
|
|
void proto_register_netrom(void);
|
|
|
|
void proto_reg_handoff_netrom(void);
|
|
|
|
|
2012-08-02 18:38:40 +00:00
|
|
|
#define STRLEN 80
|
|
|
|
|
2016-01-06 00:58:42 +00:00
|
|
|
#define NETROM_MIN_SIZE 7 /* minimum payload for a routing packet */
|
|
|
|
#define NETROM_HEADER_SIZE 20 /* minimum 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
|
|
|
|
|
2015-01-30 18:49:59 +00:00
|
|
|
/* Dissector handles */
|
2012-08-02 18:38:40 +00:00
|
|
|
static dissector_handle_t ip_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;
|
|
|
|
|
2013-09-15 15:11:11 +00:00
|
|
|
info_buffer = wmem_strdup_printf( wmem_packet_scope(), "%s%s%s%s (0x%02x)",
|
2012-10-22 20:46:47 +00:00
|
|
|
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;
|
|
|
|
#if 0
|
|
|
|
guint8 src_ssid;
|
|
|
|
guint8 dst_ssid;
|
|
|
|
#endif
|
|
|
|
guint8 op_code;
|
|
|
|
guint8 cct_index;
|
|
|
|
guint8 cct_id;
|
2015-01-30 18:49:59 +00:00
|
|
|
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" );
|
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 */
|
2015-10-29 03:12:53 +00:00
|
|
|
set_address_tvb(&pinfo->dl_src, AT_AX25, AX25_ADDR_LEN, tvb, offset);
|
|
|
|
set_address_tvb(&pinfo->src, AT_AX25, AX25_ADDR_LEN, tvb, offset);
|
2015-01-08 21:16:56 +00:00
|
|
|
/* src_ssid = tvb_get_guint8(tvb, offset+6); */
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += AX25_ADDR_LEN; /* step over src addr */
|
|
|
|
|
|
|
|
/* destination */
|
2015-10-29 03:12:53 +00:00
|
|
|
set_address_tvb(&pinfo->dl_dst, AT_AX25, AX25_ADDR_LEN, tvb, offset);
|
|
|
|
set_address_tvb(&pinfo->dst, AT_AX25, AX25_ADDR_LEN, tvb, offset);
|
2015-01-08 21:16:56 +00:00
|
|
|
/* dst_ssid = tvb_get_guint8(tvb, offset+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;
|
2015-01-27 14:14:47 +00:00
|
|
|
/*offset += 1;*/ /* step over op_code */
|
2012-08-02 18:38:40 +00:00
|
|
|
|
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
|
|
|
|
2015-01-25 20:51:01 +00:00
|
|
|
/* if ( tree ) */
|
2012-08-02 18:38:40 +00:00
|
|
|
{
|
|
|
|
/* create display subtree for the protocol */
|
|
|
|
|
|
|
|
ti = proto_tree_add_protocol_format( tree, proto_netrom, tvb, 0, NETROM_HEADER_SIZE,
|
2014-12-19 23:13:17 +00:00
|
|
|
"NET/ROM, Src: %s, Dst: %s",
|
|
|
|
address_to_str(wmem_packet_scope(), &pinfo->src),
|
|
|
|
address_to_str(wmem_packet_scope(), &pinfo->dst));
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
netrom_tree = proto_item_add_subtree( ti, ett_netrom );
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
/* source */
|
2015-01-08 21:16:56 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_src, tvb, offset, AX25_ADDR_LEN, ENC_NA );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += AX25_ADDR_LEN;
|
|
|
|
|
|
|
|
/* destination */
|
2015-01-08 21:16:56 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_dst, tvb, offset, AX25_ADDR_LEN, ENC_NA );
|
2012-08-02 18:38:40 +00:00
|
|
|
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;
|
|
|
|
|
2015-01-08 21:16:56 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_user, tvb, offset, AX25_ADDR_LEN, ENC_NA );
|
2012-08-02 18:38:40 +00:00
|
|
|
offset += AX25_ADDR_LEN;
|
|
|
|
|
2015-01-08 21:16:56 +00:00
|
|
|
proto_tree_add_item( netrom_tree, hf_netrom_node, tvb, offset, AX25_ADDR_LEN, ENC_NA );
|
2012-08-02 18:38:40 +00:00
|
|
|
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 */
|
|
|
|
|
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
|
2016-03-20 00:33:14 +00:00
|
|
|
call_data_dissector(next_tvb, pinfo, tree );
|
2012-08-02 18:38:40 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case NETROM_INFO :
|
|
|
|
default :
|
2016-03-20 00:33:14 +00:00
|
|
|
call_data_dissector(next_tvb, pinfo, tree );
|
2012-08-02 18:38:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_netrom_routing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2012-10-22 20:46:47 +00:00
|
|
|
tvbuff_t *next_tvb;
|
2016-05-17 02:21:39 +00:00
|
|
|
const guint8* mnemonic;
|
|
|
|
gint mnemonic_len;
|
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)
|
2016-05-17 02:21:39 +00:00
|
|
|
{
|
2012-10-22 20:46:47 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *netrom_tree;
|
2016-05-17 02:21:39 +00:00
|
|
|
ti = proto_tree_add_item( tree, proto_netrom, tvb, 0, -1, ENC_NA);
|
2012-08-02 18:38:40 +00:00
|
|
|
netrom_tree = proto_item_add_subtree( ti, ett_netrom );
|
|
|
|
|
2016-05-17 02:21:39 +00:00
|
|
|
proto_tree_add_item_ret_string_and_length(netrom_tree, hf_netrom_mnemonic, tvb, 1, 6, ENC_ASCII|ENC_NA,
|
|
|
|
wmem_packet_scope(), &mnemonic, &mnemonic_len);
|
|
|
|
proto_item_append_text(ti, ", routing table frame, Node: %.6s", mnemonic);
|
|
|
|
}
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2013-02-19 23:17:07 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, 7);
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2016-03-20 00:33:14 +00:00
|
|
|
call_data_dissector(next_tvb, pinfo, tree );
|
2012-08-02 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Code to actually dissect the packets */
|
2015-11-15 21:51:45 +00:00
|
|
|
static int
|
|
|
|
dissect_netrom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2012-08-02 18:38:40 +00:00
|
|
|
{
|
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 );
|
2015-11-15 21:51:45 +00:00
|
|
|
|
|
|
|
return tvb_captured_length(tvb);
|
2012-08-02 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2015-12-14 13:48:59 +00:00
|
|
|
static gboolean
|
2015-12-15 00:25:31 +00:00
|
|
|
capture_netrom( const guchar *pd _U_, int offset, int len, capture_packet_info_t *cpinfo _U_, const union wtap_pseudo_header *pseudo_header _U_)
|
2012-10-22 20:46:47 +00:00
|
|
|
{
|
|
|
|
if ( ! BYTES_ARE_IN_FRAME( offset, len, NETROM_MIN_SIZE ) )
|
2015-12-13 21:54:16 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-10-22 20:46:47 +00:00
|
|
|
/* XXX - check for IP-over-NetROM here! */
|
2015-12-13 21:54:16 +00:00
|
|
|
return FALSE;
|
2012-10-22 20:46:47 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 18:38:40 +00:00
|
|
|
void
|
|
|
|
proto_register_netrom(void)
|
|
|
|
{
|
|
|
|
/* 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",
|
2015-12-20 01:56:15 +00:00
|
|
|
FT_BOOLEAN, 8, TFS(&tfs_set_notset), NETROM_MORE_FLAG,
|
2012-08-02 18:38:40 +00:00
|
|
|
"More flag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_nak,
|
|
|
|
{ "NAK", "netrom.flag.nak",
|
2015-12-20 01:56:15 +00:00
|
|
|
FT_BOOLEAN, 8, TFS(&tfs_set_notset), NETROM_NAK_FLAG,
|
2012-08-02 18:38:40 +00:00
|
|
|
"NAK flag", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_netrom_choke,
|
|
|
|
{ "Choke", "netrom.flag.choke",
|
2015-12-20 01:56:15 +00:00
|
|
|
FT_BOOLEAN, 8, TFS(&tfs_set_notset), NETROM_CHOKE_FLAG,
|
2012-08-02 18:38:40 +00:00
|
|
|
"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)
|
|
|
|
{
|
2016-10-26 16:07:47 +00:00
|
|
|
capture_dissector_handle_t netrom_cap_handle;
|
|
|
|
|
2015-12-09 03:49:44 +00:00
|
|
|
dissector_add_uint( "ax25.pid", AX25_P_NETROM, create_dissector_handle( dissect_netrom, proto_netrom ) );
|
2016-10-26 16:07:47 +00:00
|
|
|
netrom_cap_handle = create_capture_dissector_handle(capture_netrom, proto_netrom);
|
|
|
|
capture_dissector_add_uint("ax25.pid", AX25_P_NETROM, netrom_cap_handle);
|
2012-08-02 18:38:40 +00:00
|
|
|
|
2016-03-16 13:02:52 +00:00
|
|
|
ip_handle = find_dissector_add_dependency( "ip", proto_netrom );
|
2012-08-02 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2014-09-30 20:59:17 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|