2011-04-08 16:53:02 +00:00
|
|
|
/* packet-babel.c
|
|
|
|
* Routines for Babel dissection (RFC 6126)
|
|
|
|
* Copyright 2011 by Juliusz Chroboczek <jch@pps.jussieu.fr>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2011-04-08 16:53:02 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2011-04-08 16:53:02 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2013-11-09 13:41:10 +00:00
|
|
|
#include <epan/to_str.h>
|
2013-03-14 07:37:13 +00:00
|
|
|
void proto_register_babel(void);
|
|
|
|
void proto_reg_handoff_babel(void);
|
|
|
|
|
2011-04-08 16:53:02 +00:00
|
|
|
static int proto_babel = -1;
|
|
|
|
|
|
|
|
static gint ett_babel = -1;
|
|
|
|
static int hf_babel_magic = -1;
|
|
|
|
static int hf_babel_version = -1;
|
|
|
|
static int hf_babel_bodylen = -1;
|
|
|
|
|
|
|
|
static int hf_babel_message = -1;
|
|
|
|
static gint ett_message = -1;
|
|
|
|
static int hf_babel_message_type = -1;
|
|
|
|
static int hf_babel_message_length = -1;
|
|
|
|
static int hf_babel_message_nonce = -1;
|
|
|
|
static int hf_babel_message_interval = -1;
|
|
|
|
static int hf_babel_message_seqno = -1;
|
|
|
|
static int hf_babel_message_ae = -1;
|
|
|
|
static int hf_babel_message_prefix = -1;
|
|
|
|
static int hf_babel_message_rxcost = -1;
|
|
|
|
static int hf_babel_message_routerid = -1;
|
|
|
|
static int hf_babel_message_flags = -1;
|
|
|
|
static int hf_babel_message_plen = -1;
|
|
|
|
static int hf_babel_message_omitted = -1;
|
|
|
|
static int hf_babel_message_metric = -1;
|
|
|
|
static int hf_babel_message_hopcount = -1;
|
|
|
|
|
|
|
|
static gint ett_subtree = -1;
|
|
|
|
|
2016-10-05 20:33:54 +00:00
|
|
|
#define UDP_PORT_RANGE_BABEL "6696-6697" /* 6697 Not IANA registered, 6696 is */
|
2011-04-08 16:53:02 +00:00
|
|
|
|
2012-08-10 22:55:02 +00:00
|
|
|
#define MESSAGE_PAD1 0
|
|
|
|
#define MESSAGE_PADN 1
|
|
|
|
#define MESSAGE_ACK_REQ 2
|
|
|
|
#define MESSAGE_ACK 3
|
|
|
|
#define MESSAGE_HELLO 4
|
|
|
|
#define MESSAGE_IHU 5
|
|
|
|
#define MESSAGE_ROUTER_ID 6
|
|
|
|
#define MESSAGE_NH 7
|
|
|
|
#define MESSAGE_UPDATE 8
|
|
|
|
#define MESSAGE_REQUEST 9
|
2011-04-08 16:53:02 +00:00
|
|
|
#define MESSAGE_MH_REQUEST 10
|
2016-05-19 03:43:19 +00:00
|
|
|
#define MESSAGE_TS_PC 11
|
|
|
|
#define MESSAGE_HMAC 12
|
|
|
|
#define MESSAGE_SRC_UPDATE 13
|
|
|
|
#define MESSAGE_SRC_REQUEST 14
|
|
|
|
#define MESSAGE_SRC_SEQNO 15
|
2011-04-08 16:53:02 +00:00
|
|
|
|
2016-05-19 03:43:19 +00:00
|
|
|
/** message string values listed in rfc7557 */
|
2011-04-08 16:53:02 +00:00
|
|
|
static const value_string messages[] = {
|
2012-08-10 22:55:02 +00:00
|
|
|
{ MESSAGE_PAD1, "pad1"},
|
|
|
|
{ MESSAGE_PADN, "padn"},
|
|
|
|
{ MESSAGE_ACK_REQ, "ack-req"},
|
|
|
|
{ MESSAGE_ACK, "ack"},
|
|
|
|
{ MESSAGE_HELLO, "hello"},
|
|
|
|
{ MESSAGE_IHU, "ihu"},
|
|
|
|
{ MESSAGE_ROUTER_ID, "router-id"},
|
|
|
|
{ MESSAGE_NH, "nh"},
|
|
|
|
{ MESSAGE_UPDATE, "update"},
|
|
|
|
{ MESSAGE_REQUEST, "request"},
|
2011-04-08 16:53:02 +00:00
|
|
|
{ MESSAGE_MH_REQUEST, "mh-request"},
|
2016-05-19 03:43:19 +00:00
|
|
|
{ MESSAGE_TS_PC, "ts/pc"},
|
|
|
|
{ MESSAGE_HMAC, "hmac" },
|
|
|
|
{ MESSAGE_SRC_UPDATE, "source-specific-update"},
|
|
|
|
{ MESSAGE_SRC_REQUEST,"source-specific-req"},
|
|
|
|
{ MESSAGE_SRC_SEQNO, "source-specific-seqno"},
|
2011-04-08 16:53:02 +00:00
|
|
|
{ 0, NULL}
|
|
|
|
};
|
|
|
|
|
2016-05-19 03:43:19 +00:00
|
|
|
|
2011-04-08 16:53:02 +00:00
|
|
|
static const value_string aes[] = {
|
|
|
|
{ 0, "Wildcard" },
|
|
|
|
{ 1, "IPv4" },
|
|
|
|
{ 2, "IPv6" },
|
|
|
|
{ 3, "Link-Local IPv6"},
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2011-04-10 15:01:18 +00:00
|
|
|
/* The prefix for v6-mapped IPv4 addresses. Format_address below
|
2011-04-08 16:53:02 +00:00
|
|
|
returns IPv4 addresses in that format. */
|
|
|
|
|
|
|
|
static const unsigned char v4prefix[16] =
|
|
|
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
/* The following two functions return ephemeral or constant strings, no
|
|
|
|
need to call free. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
format_address(const unsigned char *prefix)
|
|
|
|
{
|
2014-12-21 13:02:26 +00:00
|
|
|
address addr;
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (prefix == NULL)
|
2011-04-08 16:53:02 +00:00
|
|
|
return "corrupt";
|
2012-11-25 23:16:30 +00:00
|
|
|
else if (memcmp(prefix, v4prefix, 12) == 0)
|
2014-12-21 13:02:26 +00:00
|
|
|
{
|
|
|
|
addr.type = AT_IPv4;
|
|
|
|
addr.len = 4;
|
|
|
|
addr.data = prefix + 12;
|
|
|
|
|
|
|
|
return address_to_str(wmem_packet_scope(), &addr);
|
|
|
|
}
|
2011-04-08 16:53:02 +00:00
|
|
|
else
|
2014-12-21 17:38:13 +00:00
|
|
|
{
|
|
|
|
addr.type = AT_IPv6;
|
|
|
|
addr.len = 16;
|
|
|
|
addr.data = prefix;
|
|
|
|
|
|
|
|
return address_to_str(wmem_packet_scope(), &addr);
|
|
|
|
}
|
2011-04-08 16:53:02 +00:00
|
|
|
}
|
|
|
|
|
2012-04-09 19:43:19 +00:00
|
|
|
static const char *
|
2011-04-08 16:53:02 +00:00
|
|
|
format_prefix(const unsigned char *prefix, unsigned char plen)
|
|
|
|
{
|
2013-09-12 22:03:31 +00:00
|
|
|
return wmem_strdup_printf(wmem_packet_scope(), "%s/%u", format_address(prefix), plen);
|
2011-04-08 16:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
network_prefix(int ae, int plen, unsigned int omitted,
|
2015-03-02 04:03:27 +00:00
|
|
|
tvbuff_t *tvb, int offset, const unsigned char *dp,
|
2011-04-08 16:53:02 +00:00
|
|
|
unsigned int len, unsigned char *p_r)
|
|
|
|
{
|
2013-01-04 05:22:43 +00:00
|
|
|
guint pb;
|
2011-04-08 16:53:02 +00:00
|
|
|
unsigned char prefix[16];
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (plen >= 0)
|
2011-04-08 16:53:02 +00:00
|
|
|
pb = (plen + 7) / 8;
|
2012-11-25 23:16:30 +00:00
|
|
|
else if (ae == 1)
|
2011-04-08 16:53:02 +00:00
|
|
|
pb = 4;
|
|
|
|
else
|
|
|
|
pb = 16;
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (pb > 16)
|
2011-04-08 16:53:02 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
memset(prefix, 0, 16);
|
|
|
|
|
|
|
|
switch(ae) {
|
|
|
|
case 0: break;
|
|
|
|
case 1:
|
2012-11-25 23:16:30 +00:00
|
|
|
if (omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted))
|
2011-04-08 16:53:02 +00:00
|
|
|
return -1;
|
|
|
|
memcpy(prefix, v4prefix, 12);
|
2012-11-25 23:16:30 +00:00
|
|
|
if (omitted) {
|
2011-04-08 16:53:02 +00:00
|
|
|
if (dp == NULL) return -1;
|
|
|
|
memcpy(prefix, dp, 12 + omitted);
|
|
|
|
}
|
2015-03-02 04:03:27 +00:00
|
|
|
if (pb > omitted)
|
|
|
|
tvb_memcpy(tvb, prefix + 12 + omitted, offset, pb - omitted);
|
2011-04-08 16:53:02 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-11-25 23:16:30 +00:00
|
|
|
if (omitted > 16 || (pb > omitted && len < pb - omitted))
|
2011-04-08 16:53:02 +00:00
|
|
|
return -1;
|
2012-11-25 23:16:30 +00:00
|
|
|
if (omitted) {
|
2011-04-08 16:53:02 +00:00
|
|
|
if (dp == NULL) return -1;
|
|
|
|
memcpy(prefix, dp, omitted);
|
|
|
|
}
|
2015-03-02 04:03:27 +00:00
|
|
|
if (pb > omitted)
|
|
|
|
tvb_memcpy(tvb, prefix + omitted, offset, pb - omitted);
|
2011-04-08 16:53:02 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-11-25 23:16:30 +00:00
|
|
|
if (pb > 8 && len < pb - 8) return -1;
|
2011-04-08 16:53:02 +00:00
|
|
|
prefix[0] = 0xfe;
|
|
|
|
prefix[1] = 0x80;
|
2015-03-02 04:03:27 +00:00
|
|
|
if (pb > 8)
|
|
|
|
tvb_memcpy(tvb, prefix + 8, offset, pb - 8);
|
2011-04-08 16:53:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(p_r, prefix, 16);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-03-02 04:03:27 +00:00
|
|
|
network_address(int ae, tvbuff_t *tvb, int offset, unsigned int len,
|
2011-04-08 16:53:02 +00:00
|
|
|
unsigned char *a_r)
|
|
|
|
{
|
2015-03-02 04:03:27 +00:00
|
|
|
return network_prefix(ae, -1, 0, tvb, offset, NULL, len, a_r);
|
2011-04-08 16:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-09-10 21:40:21 +00:00
|
|
|
dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
2011-04-08 16:53:02 +00:00
|
|
|
{
|
2012-11-25 23:16:30 +00:00
|
|
|
proto_item *ti;
|
|
|
|
unsigned char v4_prefix[16] = {0}, v6_prefix[16] = {0};
|
|
|
|
int i;
|
|
|
|
proto_tree *babel_tree = NULL;
|
|
|
|
guint8 version;
|
|
|
|
guint16 bodylen;
|
|
|
|
|
2015-04-15 15:20:35 +00:00
|
|
|
if (tvb_captured_length(tvb) < 4)
|
2011-04-08 16:53:02 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (tvb_get_guint8(tvb, 0) != 42)
|
2011-04-08 16:53:02 +00:00
|
|
|
return 0;
|
|
|
|
version = tvb_get_guint8(tvb, 1);
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Babel");
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "Babel");
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (version != 2) {
|
2011-04-08 16:53:02 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Version %u", version);
|
|
|
|
return 2;
|
|
|
|
}
|
2011-04-10 15:01:18 +00:00
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (tree) {
|
2011-04-08 16:53:02 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_babel, tvb, 0, -1, ENC_NA);
|
|
|
|
babel_tree = proto_item_add_subtree(ti, ett_babel);
|
|
|
|
|
2014-12-13 17:52:20 +00:00
|
|
|
proto_tree_add_item(babel_tree, hf_babel_magic, tvb, 0, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(babel_tree, hf_babel_version, tvb, 1, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(babel_tree, hf_babel_bodylen,
|
|
|
|
tvb, 2, 2, ENC_BIG_ENDIAN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bodylen = tvb_get_ntohs(tvb, 2);
|
|
|
|
|
|
|
|
i = 0;
|
2012-11-25 23:16:30 +00:00
|
|
|
while (i < bodylen) {
|
|
|
|
guint8 type, len = 0, total_length;
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree *message_tree = NULL;
|
2012-11-25 23:16:30 +00:00
|
|
|
int message = 4 + i;
|
2011-04-08 16:53:02 +00:00
|
|
|
|
|
|
|
type = tvb_get_guint8(tvb, message);
|
2012-11-25 23:16:30 +00:00
|
|
|
if (type == MESSAGE_PAD1)
|
2011-04-08 16:53:02 +00:00
|
|
|
total_length = 1;
|
|
|
|
else {
|
|
|
|
len = tvb_get_guint8(tvb, message + 1);
|
|
|
|
total_length = len + 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
|
2012-08-10 22:55:02 +00:00
|
|
|
val_to_str_const(type, messages, "unknown"));
|
2011-04-08 16:53:02 +00:00
|
|
|
|
|
|
|
ti = proto_tree_add_uint_format(babel_tree, hf_babel_message,
|
|
|
|
tvb, message, total_length, type,
|
|
|
|
"Message %s (%u)",
|
2012-08-10 22:55:02 +00:00
|
|
|
val_to_str_const(type, messages, "unknown"),
|
2011-04-08 16:53:02 +00:00
|
|
|
type);
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (tree) {
|
2011-04-08 16:53:02 +00:00
|
|
|
message_tree = proto_item_add_subtree(ti, ett_message);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_type,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
}
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (type == MESSAGE_PAD1) {
|
2011-04-08 16:53:02 +00:00
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (tree) {
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_length,
|
|
|
|
tvb, message + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
|
2012-11-25 23:16:30 +00:00
|
|
|
if (type == MESSAGE_PADN) {
|
|
|
|
} else if (type == MESSAGE_ACK_REQ) {
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_nonce,
|
|
|
|
tvb, message + 4, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_interval,
|
|
|
|
tvb, message + 6, 2, ENC_BIG_ENDIAN);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_ACK) {
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_nonce,
|
|
|
|
tvb, message + 2, 2, ENC_BIG_ENDIAN);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_HELLO) {
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_seqno,
|
|
|
|
tvb, message + 4, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_interval,
|
|
|
|
tvb, message + 6, 2, ENC_BIG_ENDIAN);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_IHU) {
|
2012-08-10 22:55:02 +00:00
|
|
|
proto_tree *subtree;
|
2012-11-25 23:16:30 +00:00
|
|
|
unsigned char addr_str[16];
|
2011-04-08 16:53:02 +00:00
|
|
|
int rc =
|
|
|
|
network_address(tvb_get_guint8(tvb, message + 2),
|
2015-03-02 04:03:27 +00:00
|
|
|
tvb, message + 8, len - 6, addr_str);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_rxcost,
|
|
|
|
tvb, message + 4, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_interval,
|
|
|
|
tvb, message + 6, 2, ENC_BIG_ENDIAN);
|
2014-08-01 14:08:57 +00:00
|
|
|
subtree = proto_tree_add_subtree_format(message_tree,
|
2011-04-08 16:53:02 +00:00
|
|
|
tvb, message + 4, len - 2,
|
2014-08-01 14:08:57 +00:00
|
|
|
ett_subtree, NULL, "Address: %s",
|
2011-04-08 16:53:02 +00:00
|
|
|
format_address(rc < 0 ?
|
2012-11-25 23:16:30 +00:00
|
|
|
NULL : addr_str));
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_ae,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 2, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_prefix,
|
|
|
|
tvb, message + 4, len - 2, ENC_NA);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_ROUTER_ID) {
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_routerid,
|
|
|
|
tvb, message + 4, 8, ENC_NA);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_NH) {
|
2012-08-10 22:55:02 +00:00
|
|
|
proto_tree *subtree;
|
|
|
|
unsigned char nh[16];
|
2011-04-08 16:53:02 +00:00
|
|
|
int rc =
|
|
|
|
network_address(tvb_get_guint8(tvb, message + 2),
|
2015-03-02 04:03:27 +00:00
|
|
|
tvb, message + 4, len - 2, nh);
|
2014-06-22 20:01:36 +00:00
|
|
|
subtree = proto_tree_add_subtree_format(message_tree,
|
2011-04-08 16:53:02 +00:00
|
|
|
tvb, message + 4, len - 2,
|
2014-06-22 20:01:36 +00:00
|
|
|
ett_subtree, NULL,
|
2011-04-08 16:53:02 +00:00
|
|
|
"NH: %s",
|
|
|
|
format_address(rc < 0 ? NULL : nh));
|
|
|
|
proto_tree_add_item(subtree, hf_babel_message_ae,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 2, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_prefix,
|
|
|
|
tvb, message + 4, len - 2, ENC_NA);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_UPDATE) {
|
2012-08-10 22:55:02 +00:00
|
|
|
|
|
|
|
proto_tree *subtree;
|
|
|
|
unsigned char p[16];
|
|
|
|
guint8 ae = tvb_get_guint8(tvb, message + 2);
|
|
|
|
guint8 flags = tvb_get_guint8(tvb, message + 3);
|
|
|
|
guint8 plen = tvb_get_guint8(tvb, message + 4);
|
2011-04-08 16:53:02 +00:00
|
|
|
int rc =
|
|
|
|
network_prefix(ae, plen,
|
|
|
|
tvb_get_guint8(tvb, message + 5),
|
2015-03-02 04:03:27 +00:00
|
|
|
tvb, message + 12,
|
2011-04-08 16:53:02 +00:00
|
|
|
ae == 1 ? v4_prefix : v6_prefix,
|
|
|
|
len - 10, p);
|
2012-11-25 23:16:30 +00:00
|
|
|
if (rc >= 0 && (flags & 0x80)) {
|
|
|
|
if (ae == 1)
|
2011-04-08 16:53:02 +00:00
|
|
|
memcpy(v4_prefix, p, 16);
|
|
|
|
else
|
|
|
|
memcpy(v6_prefix, p, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_flags,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 3, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_interval,
|
|
|
|
tvb, message + 6, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_seqno,
|
|
|
|
tvb, message + 8, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_metric,
|
|
|
|
tvb, message + 10, 2, ENC_BIG_ENDIAN);
|
2014-06-22 20:01:36 +00:00
|
|
|
subtree = proto_tree_add_subtree_format(message_tree,
|
2011-04-08 16:53:02 +00:00
|
|
|
tvb, message + 12, len - 10,
|
2014-06-22 20:01:36 +00:00
|
|
|
ett_subtree, NULL,
|
2011-04-08 16:53:02 +00:00
|
|
|
"Prefix: %s",
|
|
|
|
format_prefix(rc < 0 ? NULL : p,
|
|
|
|
plen));
|
|
|
|
proto_tree_add_item(subtree, hf_babel_message_ae,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 2, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_plen,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 4, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_omitted,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 5, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_prefix,
|
|
|
|
tvb, message + 12, len - 10, ENC_NA);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_REQUEST) {
|
2012-08-10 22:55:02 +00:00
|
|
|
proto_tree *subtree;
|
|
|
|
unsigned char p[16];
|
|
|
|
guint8 plen = tvb_get_guint8(tvb, message + 3);
|
2011-04-08 16:53:02 +00:00
|
|
|
int rc =
|
|
|
|
network_prefix(tvb_get_guint8(tvb, message + 2), plen,
|
2015-03-02 04:03:27 +00:00
|
|
|
0, tvb, message + 4, NULL,
|
2011-04-08 16:53:02 +00:00
|
|
|
len - 2, p);
|
2014-06-22 20:01:36 +00:00
|
|
|
subtree = proto_tree_add_subtree_format(message_tree,
|
2011-04-08 16:53:02 +00:00
|
|
|
tvb, message + 4, len - 2,
|
2014-06-22 20:01:36 +00:00
|
|
|
ett_subtree, NULL,
|
2011-04-08 16:53:02 +00:00
|
|
|
"Prefix: %s",
|
|
|
|
format_prefix(rc < 0 ? NULL : p,
|
|
|
|
plen));
|
|
|
|
proto_tree_add_item(subtree, hf_babel_message_ae,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 2, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_plen,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 3, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_prefix,
|
|
|
|
tvb, message + 4, len - 2, ENC_NA);
|
2012-11-25 23:16:30 +00:00
|
|
|
} else if (type == MESSAGE_MH_REQUEST) {
|
2012-08-10 22:55:02 +00:00
|
|
|
proto_tree *subtree;
|
|
|
|
unsigned char p[16];
|
|
|
|
guint8 plen = tvb_get_guint8(tvb, message + 3);
|
2011-04-08 16:53:02 +00:00
|
|
|
int rc =
|
|
|
|
network_prefix(tvb_get_guint8(tvb, message + 2), plen,
|
2015-03-02 04:03:27 +00:00
|
|
|
0, tvb, message + 16, NULL,
|
2011-04-08 16:53:02 +00:00
|
|
|
len - 14, p);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_seqno,
|
|
|
|
tvb, message + 4, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_hopcount,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 6, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(message_tree, hf_babel_message_routerid,
|
|
|
|
tvb, message + 8, 8, ENC_NA);
|
2014-06-22 20:01:36 +00:00
|
|
|
subtree = proto_tree_add_subtree_format(message_tree,
|
2011-04-08 16:53:02 +00:00
|
|
|
tvb, message + 16, len - 14,
|
2014-06-22 20:01:36 +00:00
|
|
|
ett_subtree, NULL,
|
2011-04-08 16:53:02 +00:00
|
|
|
"Prefix: %s",
|
|
|
|
format_prefix(rc < 0 ? NULL : p,
|
|
|
|
plen));
|
|
|
|
proto_tree_add_item(subtree, hf_babel_message_ae,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 2, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_plen,
|
2014-12-13 17:52:20 +00:00
|
|
|
tvb, message + 3, 1, ENC_BIG_ENDIAN);
|
2011-04-08 16:53:02 +00:00
|
|
|
proto_tree_add_item(subtree, hf_babel_message_prefix,
|
|
|
|
tvb, message + 16, len - 14, ENC_NA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i += len + 2;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_babel(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_babel_magic,
|
|
|
|
{ "Magic", "babel.magic", FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0, "Magic value 42", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_version,
|
|
|
|
{ "Version", "babel.version", FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0, "Version of the Babel protocol", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_bodylen,
|
|
|
|
{ "Body Length", "babel.bodylen", FT_UINT16, BASE_DEC,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message,
|
|
|
|
{ "Message", "babel.message", FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0, "Babel Message", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_type,
|
|
|
|
{ "Message Type", "babel.message.type", FT_UINT8, BASE_DEC,
|
|
|
|
VALS(messages), 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_length,
|
|
|
|
{ "Message Length", "babel.message.length", FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_nonce,
|
|
|
|
{ "Nonce", "babel.message.nonce", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_interval,
|
|
|
|
{ "Interval", "babel.message.interval", FT_UINT16, BASE_DEC,
|
|
|
|
NULL, 0, "Interval (in centiseconds)", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_seqno,
|
|
|
|
{ "Seqno", "babel.message.seqno", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_ae,
|
|
|
|
{ "Address Encoding", "babel.message.ae", FT_UINT8, BASE_DEC,
|
|
|
|
VALS(aes), 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_prefix,
|
|
|
|
{ "Raw Prefix", "babel.message.prefix", FT_BYTES, BASE_NONE,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_rxcost,
|
|
|
|
{ "Rxcost", "babel.message.rxcost", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0, "Rxcost (from the point of vue of the sender)", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_routerid,
|
|
|
|
{ "Router ID", "babel.message.routerid", FT_BYTES, BASE_NONE,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_flags,
|
|
|
|
{ "Flags", "babel.message.flags", FT_UINT8, BASE_HEX,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_plen,
|
|
|
|
{ "Prefix Length", "babel.message.plen", FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_omitted,
|
|
|
|
{ "Omitted Bytes", "babel.message.omitted", FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0, "Number of bytes omitted from the prefix", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_metric,
|
|
|
|
{ "Metric", "babel.message.metric", FT_UINT16, BASE_DEC,
|
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_babel_message_hopcount,
|
2012-01-18 21:07:53 +00:00
|
|
|
{ "Hop Count", "babel.message.hopcount", FT_UINT8, BASE_DEC,
|
2011-04-08 16:53:02 +00:00
|
|
|
NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_babel,
|
|
|
|
&ett_message,
|
|
|
|
&ett_subtree,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_babel =
|
|
|
|
proto_register_protocol("Babel Routing Protocol", "Babel", "babel");
|
|
|
|
|
|
|
|
proto_register_field_array(proto_babel, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_babel(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t babel_handle;
|
|
|
|
|
2015-12-09 03:49:44 +00:00
|
|
|
babel_handle = create_dissector_handle(dissect_babel, proto_babel);
|
2016-10-05 20:33:54 +00:00
|
|
|
dissector_add_uint_range_with_preference("udp.port", UDP_PORT_RANGE_BABEL, babel_handle);
|
2011-04-08 16:53:02 +00:00
|
|
|
}
|
2014-09-28 23:25:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|