aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-xip.c
diff options
context:
space:
mode:
authorCody Doucette <doucette@bu.edu>2015-08-29 14:05:14 -0400
committerAnders Broman <a.broman58@gmail.com>2015-09-04 14:39:51 +0000
commitf5ac9f55c48212578f9da46eef26581ce20d5577 (patch)
treeceba587581c77f9717f5222e26e9c4320a500cf7 /epan/dissectors/packet-xip.c
parent3ca6bde92f5c9740abfad4fe612a64abb24d8ec0 (diff)
xip-serval: add support for XIP Serval packets
Serval is a service-centric architecture that has been ported to XIA to allow applications to communicate using service names. This change adds a dissector for XIP Serval, which sits between layers 3 and 4, and also amends the XIP dissector to be able to invoke it. Bug: 11491 Change-Id: I11299ddbd0fb9eaf8728f8b3fde2a63656963114 Reviewed-on: https://code.wireshark.org/review/10315 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-xip.c')
-rw-r--r--epan/dissectors/packet-xip.c65
1 files changed, 48 insertions, 17 deletions
diff --git a/epan/dissectors/packet-xip.c b/epan/dissectors/packet-xip.c
index e9408a155c..86d2cf879d 100644
--- a/epan/dissectors/packet-xip.c
+++ b/epan/dissectors/packet-xip.c
@@ -44,6 +44,7 @@ void proto_reg_handoff_xip(void);
/* Next dissector handles. */
static dissector_handle_t data_handle;
+static dissector_handle_t xip_serval_handle;
static gint proto_xip = -1;
@@ -453,6 +454,42 @@ construct_dag(tvbuff_t *tvb, proto_tree *xip_tree,
XIA_NODE_SIZE * num_nodes, dag_str, "%s", dag_str);
}
+static gint
+dissect_xip_sink_node(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
+ gint offset, guint8 sink_node)
+{
+ tvbuff_t *next_tvb;
+
+ switch (sink_node) {
+ /* Serval XID types. */
+ case XIDTYPE_FLOWID:
+ case XIDTYPE_SRVCID:
+ next_tvb = tvb_new_subset_remaining(tvb, offset);
+ return call_dissector(xip_serval_handle, next_tvb, pinfo, tree);
+ /* No special sink processing. */
+ default:
+ return 0;
+ }
+}
+
+static gint
+dissect_xip_next_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
+ proto_item *next_ti, gint offset)
+{
+ tvbuff_t *next_tvb;
+ guint8 next_header = tvb_get_guint8(tvb, XIPH_NXTH);
+
+ switch (next_header) {
+ case XIA_NEXT_HEADER_DATA:
+ next_tvb = tvb_new_subset_remaining(tvb, offset);
+ return call_dissector(data_handle, next_tvb, pinfo, tree);
+ default:
+ expert_add_info_format(pinfo, next_ti, &ei_xip_next_header,
+ "Unrecognized next header type: 0x%02x", next_header);
+ return 0;
+ }
+}
+
static void
display_xip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
@@ -463,11 +500,9 @@ display_xip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_item *next_ti = NULL;
proto_item *num_ti = NULL;
- tvbuff_t *next_tvb;
-
+ gint offset;
guint16 xiph_len, payload_len;
- guint8 num_dst_nodes, num_src_nodes, last_node,
- next_header, next_header_offset;
+ guint8 num_dst_nodes, num_src_nodes, last_node;
num_dst_nodes = tvb_get_guint8(tvb, XIPH_NDST);
num_src_nodes = tvb_get_guint8(tvb, XIPH_NSRC);
@@ -539,20 +574,15 @@ display_xip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
num_src_nodes,
XIPH_DSTD + num_dst_nodes * XIA_NODE_SIZE);
- next_header_offset = XIPH_DSTD + XIA_NODE_SIZE *
- (num_dst_nodes + num_src_nodes);
+ /* First byte after XIP header. */
+ offset = XIPH_DSTD + XIA_NODE_SIZE * (num_dst_nodes + num_src_nodes);
- next_header = tvb_get_guint8(tvb, XIPH_NXTH);
- switch (next_header) {
- case XIA_NEXT_HEADER_DATA:
- next_tvb = tvb_new_subset(tvb, next_header_offset, -1, -1);
- call_dissector(data_handle, next_tvb, pinfo, tree);
- break;
- default:
- expert_add_info_format(pinfo, next_ti, &ei_xip_next_header,
- "Unrecognized next header type: 0x%02x", next_header);
- break;
- }
+ /* Dissect other headers according to the sink node, if needed. */
+ offset += dissect_xip_sink_node(tvb, pinfo, tree, offset,
+ tvb_get_ntohl(tvb, XIPH_DSTD +
+ (num_dst_nodes - 1) * XIA_NODE_SIZE));
+
+ dissect_xip_next_header(tvb, pinfo, tree, next_ti, offset);
}
static gint
@@ -669,6 +699,7 @@ proto_reg_handoff_xip(void)
xip_handle = new_create_dissector_handle(dissect_xip, proto_xip);
dissector_add_uint("ethertype", ETHERTYPE_XIP, xip_handle);
+ xip_serval_handle = find_dissector("xipserval");
data_handle = find_dissector("data");
}