aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dtn.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-08-13 11:37:27 +0000
committerMichael Mann <mmann78@netscape.net>2013-08-13 11:37:27 +0000
commit077675448889b8576c854ca2e4148d38bf5e1cb9 (patch)
tree79bc442760874ab7dbde6f6df68261c56d75228b /epan/dissectors/packet-dtn.c
parentab8f63d76ca8a864dfb3dcbf525fecdb7b8bdef1 (diff)
Some improvements to the bundle protocol:
1. Cleanly break out Convergence Layer Protocol (TCPCL) into its own (new-style) pure dissector. 2. Make Bundle dissection into a new style dissector and clean so that it can be called using call_disssector. 3. Use tcp_dissect_pdus for TCPCL protocol instead of "manual" while loop. This allows contact header to benefit from TCP fragmentation. 4. Make time fields use time field types so they can be filterable. 5. A few functions were move to remove need for static declaration at top of file. 6. Remove pri_hdr_procflags global variable. Next up - making more fields filterable. svn path=/trunk/; revision=51337
Diffstat (limited to 'epan/dissectors/packet-dtn.c')
-rw-r--r--epan/dissectors/packet-dtn.c1721
1 files changed, 836 insertions, 885 deletions
diff --git a/epan/dissectors/packet-dtn.c b/epan/dissectors/packet-dtn.c
index 517ea220b7..8582abbef5 100644
--- a/epan/dissectors/packet-dtn.c
+++ b/epan/dissectors/packet-dtn.c
@@ -42,23 +42,10 @@
#include <epan/reassemble.h>
#include <epan/expert.h>
#include "packet-dtn.h"
+#include "packet-tcp.h"
-void proto_register_bundle(void);
-void proto_reg_handoff_bundle(void);
-static int dissect_primary_header(packet_info *pinfo, proto_tree *primary_tree, tvbuff_t *tvb);
-static int dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int payload_length);
-static int dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, int bundle_offset, gboolean *lastheader);
-static int display_metadata_block(proto_tree *tree, tvbuff_t *tvb, int bundle_offset, gboolean *lastheader);
-static int dissect_contact_header(tvbuff_t *tvb, packet_info *pinfo,
- proto_tree *conv_tree, proto_item *conv_item);
-static int dissect_tcp_convergence_data_header(tvbuff_t *tvb, proto_tree *tree);
-static int dissect_version_4_primary_header(packet_info *pinfo,
- proto_tree *primary_tree, tvbuff_t *tvb);
-static int dissect_version_5_and_6_primary_header(packet_info *pinfo,
- proto_tree *primary_tree, tvbuff_t *tvb);
-static int add_sdnv_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, const char *field_id);
-static int add_dtn_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, const char *field_id);
-static int add_sdnv_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, const char *field_id);
+static int dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, packet_info *pinfo,
+ int offset, int payload_length, gboolean* success);
/* For Reassembling TCP Convergence Layer segments */
static reassembly_table msg_reassembly_table;
@@ -73,17 +60,26 @@ static int hf_bundle_pdu_version = -1;
static gchar *bundle_custodian = NULL;
/* TCP Convergence Header Variables */
+static int hf_tcp_convergence_pkt_type = -1;
+
static int hf_contact_hdr_version = -1;
static int hf_contact_hdr_flags = -1;
static int hf_contact_hdr_keep_alive = -1;
static int hf_contact_hdr_flags_ack_req = -1;
static int hf_contact_hdr_flags_frag_enable = -1;
static int hf_contact_hdr_flags_nak = -1;
+static int hf_contact_hdr_magic = -1;
+static int hf_contact_hdr_local_eid_length = -1;
+static int hf_contact_hdr_local_eid = -1;
/* TCP Convergence Data Header Variables */
static int hf_tcp_convergence_data_procflags = -1;
static int hf_tcp_convergence_data_procflags_start = -1;
static int hf_tcp_convergence_data_procflags_end = -1;
+static int hf_tcp_convergence_data_segment_length = -1;
+
+/* TCP Convergence Ack Variables */
+static int hf_tcp_convergence_ack_length = -1;
/* TCP Convergence Shutdown Header Variables */
static int hf_tcp_convergence_shutdown_flags = -1;
@@ -105,8 +101,6 @@ static int hf_msg_reassembled_in = -1;
static int hf_msg_reassembled_length = -1;
/* Primary Header Processing Flag Variables */
-static guint8 pri_hdr_procflags; /*This is global to allow processing Payload Header*/
-
static int hf_bundle_procflags = -1;
static int hf_bundle_procflags_fragment = -1;
static int hf_bundle_procflags_admin = -1;
@@ -117,9 +111,11 @@ static int hf_bundle_procflags_application_ack = -1;
/* Additions for Version 5 */
static int hf_bundle_control_flags = -1;
-/* static int hf_bundle_procflags_general = -1; */
-/* static int hf_bundle_procflags_cos = -1; */
-/* static int hf_bundle_procflags_status = -1; */
+#if 0
+static int hf_bundle_procflags_general = -1;
+static int hf_bundle_procflags_cos = -1;
+static int hf_bundle_procflags_status = -1;
+#endif
/* Primary Header COS Flag Variables */
static int hf_bundle_cosflags = -1;
@@ -134,8 +130,11 @@ static int hf_bundle_srrflags_report_delivery = -1;
static int hf_bundle_srrflags_report_deletion = -1;
static int hf_bundle_srrflags_report_ack = -1;
-/* Primary Header Length Fields*/
+/* Primary Header Fields*/
/* static int hf_bundle_primary_header_len = -1; */
+static int hf_bundle_primary_timestamp = -1;
+
+
static int hf_bundle_dest_scheme_offset = -1;
static int hf_bundle_dest_ssp_offset = -1;
static int hf_bundle_source_scheme_offset = -1;
@@ -160,6 +159,7 @@ static int hf_bundle_creation_timestamp = -1;
static int hf_bundle_lifetime = -1;
/* Secondary Header Processing Flag Variables */
+static int hf_bundle_payload_length = -1;
static int hf_bundle_payload_flags = -1;
static int hf_bundle_payload_flags_replicate_hdr = -1;
static int hf_bundle_payload_flags_xmit_report = -1;
@@ -188,6 +188,8 @@ static int hf_ecos_flags_ordinal = -1;
static int hf_ecos_ordinal = -1;
/* Administrative Record Variables */
+static int hf_bundle_admin_record_type = -1;
+static int hf_bundle_admin_record_fragment = -1;
static int hf_bundle_admin_statflags = -1;
static int hf_bundle_admin_rcvd = -1;
static int hf_bundle_admin_accepted = -1;
@@ -195,7 +197,11 @@ static int hf_bundle_admin_forwarded = -1;
static int hf_bundle_admin_delivered = -1;
static int hf_bundle_admin_deleted = -1;
static int hf_bundle_admin_acked = -1;
-#if 0
+static int hf_bundle_admin_fragment_offset = -1;
+static int hf_bundle_admin_fragment_length = -1;
+static int hf_bundle_admin_timestamp_seq_num64 = -1;
+static int hf_bundle_admin_timestamp_seq_num32 = -1;
+
static int hf_bundle_admin_receipt_time = -1;
static int hf_bundle_admin_accept_time = -1;
static int hf_bundle_admin_forward_time = -1;
@@ -204,19 +210,14 @@ static int hf_bundle_admin_delete_time = -1;
static int hf_bundle_admin_ack_time = -1;
static int hf_bundle_admin_timestamp_copy = -1;
static int hf_bundle_admin_signal_time = -1;
-#endif
static int hf_bundle_status_report_reason_code = -1;
static int hf_bundle_custody_trf_succ_flg = -1;
static int hf_bundle_custody_signal_reason = -1;
/* Tree Node Variables */
static gint ett_bundle = -1;
-static gint ett_tcp_conv = -1;
-static gint ett_tcp_conv_hdr = -1;
static gint ett_conv_flags = -1;
static gint ett_shutdown_flags = -1;
-static gint ett_msg_fragment = -1;
-static gint ett_msg_fragments = -1;
static gint ett_bundle_hdr = -1;
static gint ett_primary_hdr = -1;
static gint ett_proc_flags = -1;
@@ -232,11 +233,45 @@ static gint ett_admin_record = -1;
static gint ett_admin_rec_status = -1;
static gint ett_metadata_hdr = -1;
+static gint ett_tcp_conv = -1;
+static gint ett_tcp_conv_hdr = -1;
+static gint ett_msg_fragment = -1;
+static gint ett_msg_fragments = -1;
+
+
+static expert_field ei_bundle_payload_length = EI_INIT;
static expert_field ei_bundle_control_flags_length = EI_INIT;
+static expert_field ei_bundle_sdnv_length = EI_INIT;
+static expert_field ei_bundle_timestamp_seq_num = EI_INIT;
+
+static expert_field ei_tcp_convergence_data_flags = EI_INIT;
+static expert_field ei_tcp_convergence_segment_length = EI_INIT;
+static expert_field ei_tcp_convergence_ack_length = EI_INIT;
+
+
+static dissector_handle_t bundle_handle;
+static dissector_handle_t data_handle;
static guint bundle_tcp_port = 4556;
static guint bundle_udp_port = 4556;
+static const value_string packet_type_vals[] = {
+ {((TCP_CONVERGENCE_DATA_SEGMENT>>4) & 0x0F), "Data"},
+ {((TCP_CONVERGENCE_ACK_SEGMENT>>4) & 0x0F), "Ack"},
+ {((TCP_CONVERGENCE_REFUSE_BUNDLE>>4) & 0x0F), "Refuse Bundle"},
+ {((TCP_CONVERGENCE_KEEP_ALIVE>>4) & 0x0F), "Keep Alive"},
+ {((TCP_CONVERGENCE_SHUTDOWN>>4) & 0x0F), "Shutdown"},
+ {0, NULL}
+};
+
+static const value_string admin_record_type_vals[] = {
+ {ADMIN_REC_TYPE_STATUS_REPORT, "Bundle Status Report"},
+ {ADMIN_REC_TYPE_CUSTODY_SIGNAL, "Custody Signal"},
+ {ADMIN_REC_TYPE_AGGREGATE_CUSTODY_SIGNAL, "Aggregate Custody Signal"},
+ {ADMIN_REC_TYPE_ANNOUNCE_BUNDLE, "Announce Record (Contact)"},
+ {0, NULL}
+};
+
static const value_string custody_signal_reason_codes[] = {
{0x0, "No Additional Information"},
{0x3, "Redundant Reception"},
@@ -286,6 +321,16 @@ static const value_string ecos_flags[] = {
{0, NULL}
};
+/*
+ * SDNV has a zero in high-order bit position of last byte. The high-order
+ * bit of all preceding bytes is set to one. This returns the numeric value
+ * in an integer and sets the value of the second argument to the number of
+ * bytes used to code the SDNV. A -1 is returned if the evaluation fails
+ * (value exceeds maximum for signed integer). 0 is an acceptable value.
+ */
+
+#define SDNV_MASK 0x7f
+
static const fragment_items msg_frag_items = {
/*Fragment subtrees*/
&ett_msg_fragment,
@@ -309,430 +354,81 @@ static const fragment_items msg_frag_items = {
"Message fragments"
};
-static void
-dissect_tcp_bundle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
-{
-
- int buffer_size; /*Number of bytes in buffer that can be processed*/
- int frame_offset; /*To handle the case of > 1 bundle in an Ethernet Frame*/
-
- buffer_size = tvb_reported_length(tvb);
- frame_offset = 0;
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bundle");
- col_clear(pinfo->cinfo,COL_INFO); /* Clear out stuff in the info column */
-
- while(frame_offset < buffer_size) {
- guint8 conv_hdr;
-
- conv_hdr = tvb_get_guint8(tvb, frame_offset);
- if((conv_hdr & TCP_CONVERGENCE_TYPE_MASK) == TCP_CONVERGENCE_DATA_SEGMENT) {
- fragment_head *frag_msg;
- tvbuff_t *new_tvb;
- proto_tree *bundle_tree;
- proto_tree *conv_proto_tree;
- proto_item *ci;
- int segment_length;
- gboolean more_frags;
- int sdnv_length;
- int convergence_hdr_size;
- int fixed;
-
- /* Only Start and End flags (bits 0 & 1) are valid in Data Segment */
- if((conv_hdr & ~(TCP_CONVERGENCE_TYPE_MASK | TCP_CONVERGENCE_DATA_FLAGS)) != 0) {
- col_set_str(pinfo->cinfo, COL_INFO, "Invalid TCP CL Data Segment Flags");
- return;
- }
- fixed = 1;
- segment_length = evaluate_sdnv(tvb, fixed + frame_offset, &sdnv_length);
- if(segment_length < 0) {
- col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error (Length)");
- return;
- }
- convergence_hdr_size = sdnv_length + fixed;
- if((buffer_size - frame_offset - convergence_hdr_size) < segment_length) {
- /*Segment not complete -- wait for the rest of it*/
- pinfo->desegment_len =
- segment_length - (buffer_size - frame_offset
- - convergence_hdr_size);
- pinfo->desegment_offset = frame_offset;
- return;
- }
-
- /*
- * 1/11/2006 - If I got here, I should have a complete convergence layer
- * "segment" beginning at frame_offset. However that might not be a
- * complete bundle. Or there might be a complete bundle plus one or more
- * additional convergence layer headers.
- */
-
- bundle_tree = NULL;
- new_tvb = NULL;
- if((conv_hdr & TCP_CONVERGENCE_DATA_END_FLAG) == TCP_CONVERGENCE_DATA_END_FLAG) {
- more_frags = FALSE;
- }
- else {
- more_frags = TRUE;
- }
- ci = proto_tree_add_item(tree, proto_tcp_conv, tvb,
- frame_offset, -1, ENC_NA);
- conv_proto_tree = proto_item_add_subtree(ci, ett_tcp_conv);
- dissect_tcp_convergence_data_header(tvb, conv_proto_tree);
-
- /*
- * Note: The reassembled bundle will only include the first
- * Convergence layer header.
- */
-
- frag_msg = fragment_add_seq_next(&msg_reassembly_table,
- tvb, frame_offset + convergence_hdr_size,
- pinfo, 0, NULL,
- segment_length, more_frags);
- if(frag_msg && !more_frags) {
- proto_item *ti;
-
- ti = proto_tree_add_item(tree, proto_bundle, tvb,
- frame_offset, -1, ENC_NA);
- bundle_tree = proto_item_add_subtree(ti, ett_bundle);
- new_tvb = process_reassembled_data(tvb,
- frame_offset + convergence_hdr_size,
- pinfo, "Reassembled DTN", frag_msg,
- &msg_frag_items, NULL, bundle_tree);
- }
- if(new_tvb) {
- int bundle_size;
- bundle_size = dissect_complete_bundle(new_tvb, pinfo, bundle_tree);
- if(bundle_size == 0) { /*Couldn't parse bundle*/
- col_set_str(pinfo->cinfo, COL_INFO, "Dissection Failed");
- return; /*Give up*/
- }
- }
- else {
-
- /*
- * If there are 2 segments, the second of which is very short, this
- * gets displayed instead of the usual Source EID/Destination EID in
- * the Bundle Dissection frame. If these statements are left out entirely,
- * nothing is displayed, i.e., there seems to be no way to get the
- * Source/Destination in the 2-segment case. I'll leave it in because I
- * think it is informative in the multi-segment case although confusing in the
- * 2-segment case.
- */
-
- col_set_str(pinfo->cinfo, COL_INFO, "[Reassembled Segment of a Bundle]");
- }
-
- /*
- * If we could be sure that the current tvb buffer ended with the CL segment,
- * we could return here. But the buffer could contain multiple complete segments
- * or bundles or a bundle plus other CL messages. In order to process whatever
- * follow the current segment, we have to continue through the buffer until
- * frame_offset indicates everything in the buffer has been processed.
- */
-
- frame_offset += (segment_length + convergence_hdr_size);
- }
- else { /*Else this is not a Data Segment*/
-
- proto_tree *conv_proto_tree = NULL;
- proto_item *conv_item;
- proto_tree *conv_tree;
- proto_item *ci;
- char *sptr;
-
- if(frame_offset == 0) {
- ci = proto_tree_add_item(tree, proto_tcp_conv, tvb,
- frame_offset, -1, ENC_NA);
- conv_proto_tree = proto_item_add_subtree(ci, ett_tcp_conv);
- }
-
- /*
- * Other Convergence Layer messages are short; assume they won't need
- * reassembly. Start with the Convergence Layer Tree.
- */
-
- conv_item = proto_tree_add_text(conv_proto_tree, tvb, frame_offset, -1,
- "TCP Convergence Header");
- conv_tree = proto_item_add_subtree(conv_item, ett_tcp_conv_hdr);
-
- if(conv_hdr == (guint8)magic[0]) {
- sptr = (char *) tvb_get_ephemeral_string(tvb, frame_offset, 4);
- if(!memcmp(sptr, magic, 4)){
- dissect_contact_header(tvb, pinfo, conv_tree, conv_item);
- return; /*Assumes Contact Header is alone in segment*/
- }
- }
- if(conv_hdr == TCP_CONVERGENCE_ACK_SEGMENT) { /*No valid flags in Ack*/
- int ack_length;
- int sdnv_length;
- int fixed;
-
- proto_tree_add_text(conv_tree, tvb, frame_offset, 1, "Pkt Type: Ack");
- fixed = 1;
- ack_length = evaluate_sdnv(tvb, frame_offset + fixed, &sdnv_length);
- if(ack_length < 0) {
- proto_tree_add_text(conv_tree, tvb, frame_offset + fixed, sdnv_length,
- "Ack Length: Error");
- return;
- }
- proto_tree_add_text(conv_tree, tvb, frame_offset + fixed, sdnv_length,
- "Ack Length: %d", ack_length);
-
- /*return (sdnv_length + fixed);*/
- frame_offset += (sdnv_length + fixed);
- proto_item_set_len(conv_item, sdnv_length + fixed);
- }
- else if(conv_hdr == TCP_CONVERGENCE_KEEP_ALIVE) { /*No valid flags in Keep Alive*/
- proto_item_set_len(conv_item, 1);
- proto_tree_add_text(conv_tree, tvb, frame_offset, 1, "Pkt Type: Keep Alive");
- frame_offset += 1;
- }
- else if((conv_hdr & TCP_CONVERGENCE_TYPE_MASK) == TCP_CONVERGENCE_SHUTDOWN) {
- proto_item *shutdown_flag_item;
- proto_tree *shutdown_flag_tree;
- guint8 shutdown_flags;
- int field_length;
-
- if((conv_hdr &
- ~(TCP_CONVERGENCE_TYPE_MASK | TCP_CONVERGENCE_SHUTDOWN_FLAGS)) != 0) {
- proto_tree_add_text(conv_tree, tvb, frame_offset,
- -1, "Invalid Convergence Layer Shutdown Packet");
- return;
- }
- proto_item_set_len(conv_item, 1);
- proto_tree_add_text(conv_tree, tvb, 0, 1, "Pkt Type: Shutdown");
-
- /* Add tree for Shutdown Flags */
- shutdown_flags = conv_hdr;
- shutdown_flag_item = proto_tree_add_item(conv_tree,
- hf_tcp_convergence_shutdown_flags, tvb,
- frame_offset, 1, ENC_BIG_ENDIAN);
- shutdown_flag_tree = proto_item_add_subtree(shutdown_flag_item,
- ett_shutdown_flags);
- proto_tree_add_boolean(shutdown_flag_tree,
- hf_tcp_convergence_shutdown_flags_reason,
- tvb, frame_offset, 1, shutdown_flags);
- proto_tree_add_boolean(shutdown_flag_tree,
- hf_tcp_convergence_shutdown_flags_delay,
- tvb, frame_offset, 1, shutdown_flags);
-
- frame_offset += 1;
- field_length = 1;
- if(conv_hdr & TCP_CONVERGENCE_SHUTDOWN_REASON) {
- proto_tree_add_item(conv_tree,
- hf_tcp_convergence_shutdown_reason, tvb,
- frame_offset, 1, ENC_BIG_ENDIAN);
- frame_offset += 1;
- field_length += 1;
- }
- if(conv_hdr & TCP_CONVERGENCE_SHUTDOWN_DELAY) {
- proto_tree_add_item(conv_tree,
- hf_tcp_convergence_shutdown_delay, tvb,
- frame_offset, 2, ENC_BIG_ENDIAN);
- frame_offset += 2;
- field_length += 2;
- }
- proto_item_set_len(conv_item, field_length);
- }
- else if(conv_hdr == TCP_CONVERGENCE_REFUSE_BUNDLE) { /*No valid flags*/
- proto_item_set_len(conv_item, 1);
- proto_tree_add_text(conv_tree, tvb, frame_offset,
- 1, "Pkt Type: Refuse Bundle");
- frame_offset += 1;
- }
- else {
- proto_tree_add_text(conv_tree, tvb, frame_offset,
- -1, "Invalid/Partial Convergence Layer Packet");
- return;
- }
- }
- } /*end while()*/
- return;
-}
-
-static void
-dissect_udp_bundle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+/*
+ * Adds the result of 2 SDNVs to tree: First SDNV is seconds, next is nanoseconds.
+ * Returns bytes in both SDNVs or 0 if something goes wrong.
+ */
+static int
+add_dtn_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_dtn_time)
{
+ nstime_t dtn_time;
+ int sdnv_length, sdnv2_length;
+ int sdnv_value;
- int buffer_size; /*Number of bytes in buffer that can be processed*/
- int hdr_offset;
- int lasthdrflag;
- guint8 next_header_type;
- proto_item *ti;
- proto_tree *bundle_tree;
- proto_item *primary_item;
- proto_tree *primary_tree;
-
- buffer_size = tvb_reported_length_remaining(tvb, 0);
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bundle");
- /* Clear out stuff in the info column */
- col_clear(pinfo->cinfo,COL_INFO);
-
- ti = proto_tree_add_item(tree, proto_bundle, tvb, 0, -1, ENC_NA);
- bundle_tree = proto_item_add_subtree(ti, ett_bundle);
-
- primary_item = proto_tree_add_text(bundle_tree, tvb, 0, -1,
- "Primary Bundle Header");
- primary_tree = proto_item_add_subtree(primary_item, ett_primary_hdr);
- hdr_offset = dissect_primary_header(pinfo, primary_tree, tvb);
- if(hdr_offset == 0) {
- col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
- return;
+ sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
+ if(sdnv_value < 0) {
+ return 0;
}
- proto_item_set_len(primary_item, hdr_offset);
- /*
- * Done with primary header; decode the remaining headers
- */
-
- lasthdrflag = 0;
- while((hdr_offset > 0) && (buffer_size > hdr_offset)) {
- gint payload_size;
+ dtn_time.secs = (time_t)(sdnv_value + 946684800);
+ offset += sdnv_length;
- next_header_type = tvb_get_guint8(tvb, hdr_offset);
- if(next_header_type == BUNDLE_BLOCK_TYPE_PAYLOAD) {
- payload_size =
- dissect_payload_header(bundle_tree, tvb, hdr_offset, &lasthdrflag);
- }
- else { /*Assume anything else is a Metadata Block*/
- payload_size = display_metadata_block(bundle_tree, tvb,
- hdr_offset, &lasthdrflag);
- }
- if(payload_size == 0) {
- col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
- return;
- }
- hdr_offset += payload_size;
- if(lasthdrflag) {
- return;
- }
+ dtn_time.nsecs = evaluate_sdnv(tvb, offset, &sdnv2_length);
+ if(dtn_time.nsecs < 0) {
+ return 0;
}
- return;
-}
-static int
-dissect_tcp_convergence_data_header(tvbuff_t *tvb, proto_tree *tree)
-{
- proto_item *conv_item;
- proto_tree *conv_tree;
- int buflen;
- int sdnv_length;
- int segment_length;
- proto_item *conv_flag_item;
- proto_tree *conv_flag_tree;
- guint8 tcp_convergence_hdr_procflags;
+ proto_tree_add_time(tree, hf_dtn_time, tvb, offset, sdnv_length + sdnv2_length, &dtn_time);
- buflen = tvb_length(tvb);
- conv_item = proto_tree_add_text(tree, tvb, 0, -1, "TCP Convergence Header");
- conv_tree = proto_item_add_subtree(conv_item, ett_tcp_conv_hdr);
- proto_tree_add_text(conv_tree, tvb, 0, 1, "Pkt Type: Data");
-
- /* Add tree for Start/End bits */
- tcp_convergence_hdr_procflags = tvb_get_guint8(tvb, 0);
- conv_flag_item = proto_tree_add_item(conv_tree, hf_tcp_convergence_data_procflags, tvb,
- 0, 1, ENC_BIG_ENDIAN);
- conv_flag_tree = proto_item_add_subtree(conv_flag_item, ett_conv_flags);
- proto_tree_add_boolean(conv_flag_tree, hf_tcp_convergence_data_procflags_start,
- tvb, 0, 1, tcp_convergence_hdr_procflags);
- proto_tree_add_boolean(conv_flag_tree, hf_tcp_convergence_data_procflags_end,
- tvb, 0, 1, tcp_convergence_hdr_procflags);
-
- segment_length = evaluate_sdnv(tvb, 1, &sdnv_length);
- proto_tree_add_text(conv_tree, tvb, 1, sdnv_length, "Segment Length: %d", segment_length);
- proto_item_set_len(conv_item, sdnv_length + 1);
- return buflen;
+ return (sdnv_length + sdnv2_length);
}
/*
- * Dissect a complete bundle starting at offset 0 in tvb. Return 0 on failure,
- * otherwise the length of the bundle.
+ * Adds the result of SDNV which is a time since 2000 to tree.
+ * Returns bytes in SDNV or 0 if something goes wrong.
*/
-
-int
-dissect_complete_bundle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int
+add_sdnv_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_sdnv_time)
{
- proto_item *primary_item;
- proto_tree *primary_tree;
- int primary_header_size;
- gboolean lastheader = FALSE;
- int offset;
+ nstime_t dtn_time;
+ int sdnv_length;
+ int sdnv_value;
- primary_item = proto_tree_add_text(tree, tvb, 0, -1,
- "Primary Bundle Header");
- primary_tree = proto_item_add_subtree(primary_item, ett_primary_hdr);
- primary_header_size = dissect_primary_header(pinfo, primary_tree, tvb);
- if(primary_header_size == 0) { /*Couldn't parse primary header*/
- col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
- return(0); /*Give up*/
+ sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
+ if(sdnv_value < 0) {
+ return 0;
}
- proto_item_set_len(primary_item, primary_header_size);
- offset = primary_header_size;
-
- /*
- * Done with primary header; decode the remaining headers
- */
- while(lastheader == FALSE) {
- guint8 next_header_type;
- int payload_size;
-
- next_header_type = tvb_get_guint8(tvb, offset);
- if(next_header_type == BUNDLE_BLOCK_TYPE_PAYLOAD) {
+ dtn_time.secs = (time_t)(sdnv_value + 946684800);
+ dtn_time.nsecs = 0;
+ proto_tree_add_time(tree, hf_sdnv_time, tvb, offset, sdnv_length, &dtn_time);
- /*
- * Returns payload size or 0 if can't parse payload
- */
- payload_size = dissect_payload_header(tree, tvb, offset, &lastheader);
- }
- else { /*Assume anything else is a Metadata Block*/
- payload_size = display_metadata_block(tree, tvb, offset, &lastheader);
- }
- if(payload_size == 0) { /*Payload header parse failed*/
- col_set_str(pinfo->cinfo, COL_INFO, "Dissection Failed");
- return (0);
- }
- offset += payload_size;
- }
- return(offset);
+ return sdnv_length;
}
-/*
- * This routine returns 0 if header decoding fails, otherwise the length of the primary
- * header. The bundle starts right at the beginning of the tvbuff.
- */
-
static int
-dissect_primary_header(packet_info *pinfo, proto_tree *primary_tree, tvbuff_t *tvb)
+add_sdnv_to_tree(proto_tree *tree, tvbuff_t *tvb, packet_info* pinfo, int offset, int hf_sdnv)
{
- gint offset;
- guint8 version;
-
- offset = 0;
-
- version = tvb_get_guint8(tvb, 0); /* Primary Header Version */
+ proto_item* ti;
+ int sdnv_length;
+ int sdnv_value;
- if((version != 4) && (version != 5) && (version != 6)) {
- proto_tree_add_text(primary_tree, tvb, offset, 1, "Invalid Version Number");
+ sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
+ ti = proto_tree_add_int(tree, hf_sdnv, tvb, offset, sdnv_length, sdnv_value);
+ if(sdnv_value < 0) {
+ expert_add_info(pinfo, ti, &ei_bundle_sdnv_length);
return 0;
}
-
- proto_tree_add_item(primary_tree, hf_bundle_pdu_version, tvb, offset, 1, ENC_BIG_ENDIAN);
- if (version == 4) {
- return dissect_version_4_primary_header(pinfo, primary_tree, tvb);
- }
- else {
- return dissect_version_5_and_6_primary_header(pinfo, primary_tree, tvb);
- }
+ return sdnv_length;
}
/* XXX: Consider common functions for use by dissect_version_4_primary_header() and
dissect_version_5_and_6_primary_header() since there's much identical code
between the two.
*/
-
static int
-dissect_version_4_primary_header(packet_info *pinfo, proto_tree *primary_tree, tvbuff_t *tvb)
+dissect_version_4_primary_header(packet_info *pinfo, proto_tree *primary_tree, tvbuff_t *tvb, guint8* pri_hdr_procflags)
{
- guint8 cosflags;
int bundle_header_length;
int bundle_header_dict_length;
int offset; /*Total offset into frame (frame_offset + convergence layer size)*/
@@ -760,29 +456,28 @@ dissect_version_4_primary_header(packet_info *pinfo, proto_tree *primary_tree, t
offset = 1; /* Version Number already displayed*/
/* Primary Header Processing Flags */
- pri_hdr_procflags = tvb_get_guint8(tvb, offset);
+ *pri_hdr_procflags = tvb_get_guint8(tvb, offset);
proc_flag_item = proto_tree_add_item(primary_tree, hf_bundle_procflags, tvb,
offset, 1, ENC_BIG_ENDIAN);
proc_flag_tree = proto_item_add_subtree(proc_flag_item, ett_proc_flags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_procflags_fragment,
- tvb, offset, 1, pri_hdr_procflags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_procflags_admin,
- tvb, offset, 1, pri_hdr_procflags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_procflags_dont_fragment,
- tvb, offset, 1, pri_hdr_procflags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_procflags_cust_xfer_req,
- tvb, offset, 1, pri_hdr_procflags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_procflags_dest_singleton,
- tvb, offset, 1, pri_hdr_procflags);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_fragment,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_admin,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_dont_fragment,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_cust_xfer_req,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_dest_singleton,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
/* Primary Header COS Flags */
++offset;
- cosflags = tvb_get_guint8(tvb, offset);
cos_flag_item = proto_tree_add_item(primary_tree, hf_bundle_cosflags, tvb,
offset, 1, ENC_BIG_ENDIAN);
cos_flag_tree = proto_item_add_subtree(cos_flag_item, ett_cos_flags);
proto_tree_add_uint(cos_flag_tree, hf_bundle_cosflags_priority,
- tvb, offset, 1, cosflags);
+ tvb, offset, 1, ENC_BIG_ENDIAN);
/* Status Report Request Flags */
++offset;
srrflags = tvb_get_guint8(tvb, offset);
@@ -1049,7 +744,7 @@ dissect_version_4_primary_header(packet_info *pinfo, proto_tree *primary_tree, t
* Do this only if Fragment Flag is set
*/
- if(pri_hdr_procflags & BUNDLE_PROCFLAGS_FRAG_MASK) {
+ if(*pri_hdr_procflags & BUNDLE_PROCFLAGS_FRAG_MASK) {
fragment_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
if(fragment_offset < 0) {
return 0;
@@ -1077,7 +772,7 @@ dissect_version_4_primary_header(packet_info *pinfo, proto_tree *primary_tree, t
static int
dissect_version_5_and_6_primary_header(packet_info *pinfo,
- proto_tree *primary_tree, tvbuff_t *tvb)
+ proto_tree *primary_tree, tvbuff_t *tvb, guint8* pri_hdr_procflags)
{
guint64 bundle_processing_control_flags;
guint8 cosflags;
@@ -1091,11 +786,8 @@ dissect_version_5_and_6_primary_header(packet_info *pinfo,
int dest_scheme_len, source_scheme_len, report_scheme_len, cust_scheme_len;
int dest_ssp_len, source_ssp_len, report_ssp_len, cust_ssp_len;
int fragment_offset, total_adu_length;
- int timestamp;
- time_t time_since_2000;
int timestamp_sequence;
int lifetime;
- char *time_string;
const gchar *src_node;
const gchar *dst_node;
guint8 srrflags;
@@ -1116,7 +808,7 @@ dissect_version_5_and_6_primary_header(packet_info *pinfo,
bundle_processing_control_flags = evaluate_sdnv_64(tvb, offset, &sdnv_length);
/* Primary Header Processing Flags */
- pri_hdr_procflags = (guint8) (bundle_processing_control_flags & 0x7f);
+ *pri_hdr_procflags = (guint8) (bundle_processing_control_flags & 0x7f);
if (sdnv_length < 1 || sdnv_length > 8) {
expert_add_info_format_text(pinfo, primary_tree, &ei_bundle_control_flags_length,
@@ -1132,17 +824,17 @@ dissect_version_5_and_6_primary_header(packet_info *pinfo,
gen_flag_tree = proto_item_add_subtree(gen_flag_item, ett_gen_flags);
proto_tree_add_boolean(gen_flag_tree, hf_bundle_procflags_fragment,
- tvb, offset, sdnv_length, pri_hdr_procflags);
+ tvb, offset, sdnv_length, *pri_hdr_procflags);
proto_tree_add_boolean(gen_flag_tree, hf_bundle_procflags_admin,
- tvb, offset, sdnv_length, pri_hdr_procflags);
+ tvb, offset, sdnv_length, *pri_hdr_procflags);
proto_tree_add_boolean(gen_flag_tree, hf_bundle_procflags_dont_fragment,
- tvb, offset, sdnv_length, pri_hdr_procflags);
+ tvb, offset, sdnv_length, *pri_hdr_procflags);
proto_tree_add_boolean(gen_flag_tree, hf_bundle_procflags_cust_xfer_req,
- tvb, offset, sdnv_length, pri_hdr_procflags);
+ tvb, offset, sdnv_length, *pri_hdr_procflags);
proto_tree_add_boolean(gen_flag_tree, hf_bundle_procflags_dest_singleton,
- tvb, offset, sdnv_length, pri_hdr_procflags);
+ tvb, offset, sdnv_length, *pri_hdr_procflags);
proto_tree_add_boolean(gen_flag_tree, hf_bundle_procflags_application_ack,
- tvb, offset, sdnv_length, pri_hdr_procflags);
+ tvb, offset, sdnv_length, *pri_hdr_procflags);
/* Primary Header COS Flags */
cosflags = (guint8) ((bundle_processing_control_flags >> 7) & 0x7f);
@@ -1316,17 +1008,10 @@ dissect_version_5_and_6_primary_header(packet_info *pinfo,
offset += sdnv_length;
- /* -- timestamp -- */
- timestamp = evaluate_sdnv(tvb, offset, &sdnv_length);
- if(timestamp < 0) {
- proto_tree_add_text(primary_tree, tvb, offset, sdnv_length,
- "Timestamp: Error");
+ sdnv_length = add_sdnv_time_to_tree(primary_tree, tvb, offset, hf_bundle_primary_timestamp);
+ if (sdnv_length == 0)
return 0;
- }
- time_since_2000 = (time_t) (timestamp + 946684800);
- time_string = abs_time_secs_to_str(time_since_2000, ABSOLUTE_TIME_LOCAL, TRUE);
- proto_tree_add_text(primary_tree, tvb, offset, sdnv_length,
- "Timestamp: 0x%x [%s]", timestamp, time_string);
+
offset += sdnv_length;
/* -- timestamp_sequence -- */
@@ -1540,7 +1225,7 @@ dissect_version_5_and_6_primary_header(packet_info *pinfo,
* Do this only if Fragment Flag is set
*/
- if(pri_hdr_procflags & BUNDLE_PROCFLAGS_FRAG_MASK) {
+ if(*pri_hdr_procflags & BUNDLE_PROCFLAGS_FRAG_MASK) {
fragment_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
if(fragment_offset < 0) {
return 0;
@@ -1566,9 +1251,10 @@ dissect_version_5_and_6_primary_header(packet_info *pinfo,
*/
static int
-dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *lastheader)
+dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, guint8 version,
+ guint8 pri_hdr_procflags, gboolean *lastheader)
{
- proto_item *payload_item;
+ proto_item *payload_item, *ti;
proto_tree *payload_tree;
int sdnv_length;
int header_start;
@@ -1584,7 +1270,7 @@ dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
/* Add tree for processing flags */
/* This is really a SDNV but there are only 7 bits defined so leave it this way*/
- if(hf_bundle_pdu_version == 4) {
+ if(version == 4) {
proto_item *proc_flag_item;
proto_tree *proc_flag_tree;
guint8 procflags;
@@ -1599,14 +1285,14 @@ dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
proc_flag_item = proto_tree_add_item(payload_tree, hf_bundle_payload_flags, tvb,
offset, 1, ENC_BIG_ENDIAN);
proc_flag_tree = proto_item_add_subtree(proc_flag_item, ett_payload_flags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_payload_flags_replicate_hdr,
- tvb, offset, 1, procflags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_payload_flags_xmit_report,
- tvb, offset, 1, procflags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_payload_flags_discard_on_fail,
- tvb, offset, 1, procflags);
- proto_tree_add_boolean(proc_flag_tree, hf_bundle_payload_flags_last_header,
- tvb, offset, 1, procflags);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_payload_flags_replicate_hdr,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_payload_flags_xmit_report,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_payload_flags_discard_on_fail,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(proc_flag_tree, hf_bundle_payload_flags_last_header,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
}
else { /*Bundle Protocol Version 5*/
@@ -1625,46 +1311,51 @@ dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
offset, sdnv_length, ENC_BIG_ENDIAN);
block_flag_tree = proto_item_add_subtree(block_flag_item, ett_block_flags);
- proto_tree_add_boolean(block_flag_tree, hf_block_control_replicate,
- tvb, offset, sdnv_length, control_flags);
- proto_tree_add_boolean(block_flag_tree, hf_block_control_transmit_status,
- tvb, offset, sdnv_length, control_flags);
- proto_tree_add_boolean(block_flag_tree, hf_block_control_delete_bundle,
- tvb, offset, sdnv_length, control_flags);
- proto_tree_add_boolean(block_flag_tree, hf_block_control_last_block,
- tvb, offset, sdnv_length, control_flags);
- proto_tree_add_boolean(block_flag_tree, hf_block_control_discard_block,
- tvb, offset, sdnv_length, control_flags);
- proto_tree_add_boolean(block_flag_tree, hf_block_control_not_processed,
- tvb, offset, sdnv_length, control_flags);
- proto_tree_add_boolean(block_flag_tree, hf_block_control_eid_reference,
- tvb, offset, sdnv_length, control_flags);
+ proto_tree_add_item(block_flag_tree, hf_block_control_replicate,
+ tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_flag_tree, hf_block_control_transmit_status,
+ tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_flag_tree, hf_block_control_delete_bundle,
+ tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_flag_tree, hf_block_control_last_block,
+ tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_flag_tree, hf_block_control_discard_block,
+ tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_flag_tree, hf_block_control_not_processed,
+ tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_flag_tree, hf_block_control_eid_reference,
+ tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
offset += sdnv_length;
}
payload_length = evaluate_sdnv(tvb, offset, &sdnv_length);
- proto_item_set_len(payload_item, 2 + sdnv_length);
-
+ ti = proto_tree_add_int(payload_tree, hf_bundle_payload_length, tvb, offset, sdnv_length, payload_length);
if(payload_length < 0) {
- proto_tree_add_text(payload_tree, tvb, offset, sdnv_length, "Payload Length: Error");
- return 0;
+ expert_add_info(pinfo, ti, &ei_bundle_payload_length);
+ /* Force quiting */
+ *lastheader = TRUE;
+ return offset;
}
- proto_tree_add_text(payload_tree, tvb, offset, sdnv_length, "Payload Length: %d", payload_length);
+
+ proto_item_set_len(payload_item, 2 + sdnv_length);
offset += sdnv_length;
if(pri_hdr_procflags & BUNDLE_PROCFLAGS_ADMIN_MASK) {
- int admin_size;
+ gboolean success = FALSE;
/*
* XXXX - Have not allowed for admin record spanning multiple segments!
*/
- admin_size = dissect_admin_record(payload_tree, tvb, offset, payload_length);
- if(admin_size == 0) {
- return 0;
+ offset = dissect_admin_record(payload_tree, tvb, pinfo, offset, payload_length, &success);
+ if (!success) {
+ /* Force quiting */
+ *lastheader = TRUE;
+ return offset;
}
}
- return (payload_length + (offset - header_start));
+
+ return payload_length + offset;
}
/*
@@ -1672,7 +1363,8 @@ dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
*/
static int
-dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int payload_length)
+dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, packet_info *pinfo,
+ int offset, int payload_length, gboolean* success)
{
proto_item *admin_record_item;
proto_tree *admin_record_tree;
@@ -1685,11 +1377,13 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
int endpoint_length;
guint8 *string_ptr;
+ *success = FALSE;
admin_record_item = proto_tree_add_text(primary_tree, tvb, offset, -1,
"Administrative Record");
admin_record_tree = proto_item_add_subtree(admin_record_item, ett_admin_record);
record_type = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_type, tvb, offset, 1, ENC_NA);
switch((record_type >> 4) & 0xf)
{
@@ -1698,15 +1392,7 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
proto_item *status_flag_item;
proto_tree *status_flag_tree;
- proto_tree_add_text(admin_record_tree, tvb, offset, 1,
- "Administrative Record Type: Bundle Status Report");
- if(record_type & ADMIN_REC_FLAGS_FRAGMENT) {
- proto_tree_add_text(admin_record_tree, tvb, offset, 1, "Record is for a Fragment");
- }
- else {
- proto_tree_add_text(admin_record_tree,
- tvb, offset, 1, "Record is not for a Fragment");
- }
+ proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_fragment, tvb, offset, 1, ENC_NA);
++offset;
/* Decode Bundle Status Report Flags */
@@ -1715,117 +1401,105 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
hf_bundle_admin_statflags, tvb, offset, 1, ENC_BIG_ENDIAN);
status_flag_tree = proto_item_add_subtree(status_flag_item,
ett_admin_rec_status);
- proto_tree_add_boolean(status_flag_tree, hf_bundle_admin_rcvd,
- tvb, offset, 1, status);
- proto_tree_add_boolean(status_flag_tree, hf_bundle_admin_accepted,
- tvb, offset, 1, status);
- proto_tree_add_boolean(status_flag_tree, hf_bundle_admin_forwarded,
- tvb, offset, 1, status);
- proto_tree_add_boolean(status_flag_tree, hf_bundle_admin_delivered,
- tvb, offset, 1, status);
- proto_tree_add_boolean(status_flag_tree, hf_bundle_admin_deleted,
- tvb, offset, 1, status);
- proto_tree_add_boolean(status_flag_tree, hf_bundle_admin_acked,
- tvb, offset, 1, status);
+ proto_tree_add_item(status_flag_tree, hf_bundle_admin_rcvd,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(status_flag_tree, hf_bundle_admin_accepted,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(status_flag_tree, hf_bundle_admin_forwarded,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(status_flag_tree, hf_bundle_admin_delivered,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(status_flag_tree, hf_bundle_admin_deleted,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(status_flag_tree, hf_bundle_admin_acked,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
proto_tree_add_item(admin_record_tree, hf_bundle_status_report_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
if(record_type & ADMIN_REC_FLAGS_FRAGMENT) {
- sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, offset,
- "Fragment Offset");
+ sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_offset);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
- sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, offset,
- "Fragment Length");
+ sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_length);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
if(status & ADMIN_STATUS_FLAGS_RECEIVED) {
- sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Received Time");
+ sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_receipt_time);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
if(status & ADMIN_STATUS_FLAGS_ACCEPTED) {
- sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Accepted Time");
+ sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_accept_time);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
if(status & ADMIN_STATUS_FLAGS_FORWARDED) {
- sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Forwarded Time");
+ sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_forward_time);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
if(status & ADMIN_STATUS_FLAGS_DELIVERED) {
- sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Delivered Time");
+ sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_delivery_time);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
if(status & ADMIN_STATUS_FLAGS_DELETED) {
- sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Deleted Time");
+ sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_delete_time);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
if(status & ADMIN_STATUS_FLAGS_ACKNOWLEDGED) {
- sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Acknowledged Time");
+ sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_ack_time);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
/* Get 2 SDNVs for Creation Timestamp */
- sdnv_length = add_sdnv_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Creation Timestamp");
+ sdnv_length = add_sdnv_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_timestamp_copy);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
timestamp_sequence = evaluate_sdnv(tvb, offset, &sdnv_length);
- timestamp_sequence_item = proto_tree_add_text(admin_record_tree, tvb, offset, sdnv_length, " ");
-
if(timestamp_sequence < 0) {
- gint64 ts_seq;
+ gint64 ts_seq = evaluate_sdnv_64(tvb, offset, &sdnv_length);
- if((ts_seq = evaluate_sdnv_64(tvb, offset, &sdnv_length)) < 0) {
- proto_item_set_text(timestamp_sequence_item, "Timestamp Sequence Number: Error");
- return 0;
+ timestamp_sequence_item = proto_tree_add_int64(admin_record_tree, hf_bundle_admin_timestamp_seq_num64,
+ tvb, offset, sdnv_length, ts_seq);
+ if(ts_seq < 0) {
+ expert_add_info(pinfo, timestamp_sequence_item, &ei_bundle_timestamp_seq_num);
+ return offset;
}
-
- proto_item_set_text(timestamp_sequence_item,
- "Timestamp Sequence Number: 0x%" G_GINT64_MODIFIER "x", ts_seq);
}
else {
- proto_item_set_text(timestamp_sequence_item,
- "Timestamp Sequence Number: %d", timestamp_sequence);
+ proto_tree_add_int(admin_record_tree, hf_bundle_admin_timestamp_seq_num32,
+ tvb, offset, sdnv_length, timestamp_sequence);
}
offset += sdnv_length;
endpoint_length = evaluate_sdnv(tvb, offset, &sdnv_length);
if(endpoint_length < 0) {
- return 0;
+ return offset;
}
proto_tree_add_text(admin_record_tree, tvb, offset, sdnv_length,
"Endpoint Length: %d", endpoint_length);
@@ -1840,19 +1514,11 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
"Bundle Endpoint ID: %s", string_ptr);
offset += endpoint_length;
- return offset - start_offset;
+ break;
} /* case ADMIN_REC_TYPE_STATUS_REPORT */
case ADMIN_REC_TYPE_CUSTODY_SIGNAL:
{
- proto_tree_add_text(admin_record_tree, tvb, offset, 1,
- "Administrative Record Type: Custody Signal");
- if(record_type & ADMIN_REC_FLAGS_FRAGMENT) {
- proto_tree_add_text(admin_record_tree, tvb, offset, 1, "Record is for a Fragment");
- }
- else {
- proto_tree_add_text(admin_record_tree,
- tvb, offset, 1, "Record is not for a Fragment");
- }
+ proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_fragment, tvb, offset, 1, ENC_NA);
++offset;
proto_tree_add_item(admin_record_tree, hf_bundle_custody_trf_succ_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
@@ -1860,55 +1526,47 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
++offset;
if(record_type & ADMIN_REC_FLAGS_FRAGMENT) {
- sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, offset,
- "Fragment Offset");
+ sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_offset);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
- sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, offset,
- "Fragment Length");
+ sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_length);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
}
/* Signal Time */
- sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Signal Time");
+ sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_signal_time);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
/* Timestamp copy */
- sdnv_length = add_sdnv_time_to_tree(admin_record_tree, tvb, offset,
- "Bundle Creation Timestamp");
+ sdnv_length = add_sdnv_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_timestamp_copy);
if(sdnv_length <= 0) {
- return 0;
+ return offset;
}
offset += sdnv_length;
timestamp_sequence = evaluate_sdnv(tvb, offset, &sdnv_length);
- timestamp_sequence_item = proto_tree_add_text(admin_record_tree, tvb, offset, sdnv_length, " ");
-
if(timestamp_sequence < 0) {
- gint64 ts_seq;
+ gint64 ts_seq = evaluate_sdnv_64(tvb, offset, &sdnv_length);
- if((ts_seq = evaluate_sdnv_64(tvb, offset, &sdnv_length)) < 0) {
- proto_item_set_text(timestamp_sequence_item, "Timestamp Sequence Number: Error");
- return 0;
+ timestamp_sequence_item = proto_tree_add_int64(admin_record_tree, hf_bundle_admin_timestamp_seq_num64,
+ tvb, offset, sdnv_length, ts_seq);
+ if(ts_seq < 0) {
+ expert_add_info(pinfo, timestamp_sequence_item, &ei_bundle_timestamp_seq_num);
+ return offset;
}
-
- proto_item_set_text(timestamp_sequence_item,
- "Timestamp Sequence Number: 0x%" G_GINT64_MODIFIER "x", ts_seq);
}
else {
- proto_item_set_text(timestamp_sequence_item,
- "Timestamp Sequence Number: %d", timestamp_sequence);
+ proto_tree_add_int(admin_record_tree, hf_bundle_admin_timestamp_seq_num32,
+ tvb, offset, sdnv_length, timestamp_sequence);
}
-
offset += sdnv_length;
endpoint_length = evaluate_sdnv(tvb, offset, &sdnv_length);
@@ -1922,7 +1580,7 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
proto_tree_add_text(admin_record_tree, tvb, offset, endpoint_length,
"Bundle Endpoint ID: %s", string_ptr);
offset += endpoint_length;
- return offset - start_offset;
+ break;
} /* case ADMIN_REC_TYPE_CUSTODY_SIGNAL */
case ADMIN_REC_TYPE_AGGREGATE_CUSTODY_SIGNAL:
{
@@ -1935,15 +1593,7 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
int sdnv_length_gap = -1;
int sdnv_length_length = -1;
- proto_tree_add_text(admin_record_tree, tvb, offset, 1,
- "Administrative Record Type: Aggregate Custody Signal");
- if(record_type & ADMIN_REC_FLAGS_FRAGMENT) {
- proto_tree_add_text(admin_record_tree, tvb, offset, 1, "Record is for a Fragment");
- }
- else {
- proto_tree_add_text(admin_record_tree,
- tvb, offset, 1, "Record is not for a Fragment");
- }
+ proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_fragment, tvb, offset, 1, ENC_NA);
++offset;
++payload_bytes_processed;
@@ -1957,13 +1607,13 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
if (fill_start < 0 || sdnv_length_start < 0) {
proto_tree_add_text(admin_record_tree, tvb, offset, 0,
"ACS: Unable to process CTEB Custody ID Range start SDNV");
- return 0;
+ return offset;
}
fill_length = evaluate_sdnv(tvb, offset + sdnv_length_start, &sdnv_length_length);
if (fill_length < 0 || sdnv_length_length < 0) {
proto_tree_add_text(admin_record_tree, tvb, offset, 0,
"ACS: Unable to process CTEB Custody ID Range length SDNV");
- return 0;
+ return offset;
}
if (fill_length == 1) {
proto_tree_add_text(admin_record_tree, tvb, offset, sdnv_length_start + sdnv_length_length,
@@ -1984,13 +1634,13 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
if (fill_gap < 0 || sdnv_length_gap < 0) {
proto_tree_add_text(admin_record_tree, tvb, offset, 0,
"ACS: Unable to process CTEB Custody ID Range gap SDNV");
- return 0;
+ return offset;
}
fill_length = evaluate_sdnv(tvb, offset + sdnv_length_gap, &sdnv_length_length);
if (fill_length < 0 || sdnv_length_length < 0) {
proto_tree_add_text(admin_record_tree, tvb, offset, 0,
"ACS: Unable to process CTEB Custody ID Range length SDNV");
- return 0;
+ return offset;
}
if (fill_length == 1) {
proto_tree_add_text(admin_record_tree, tvb, offset, sdnv_length_gap + sdnv_length_length,
@@ -2008,82 +1658,19 @@ dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, int offset, int pa
if (payload_bytes_processed > payload_length) {
proto_tree_add_text(admin_record_tree, tvb, offset, 0,
"ACS: CTEB Custody ID Range data extends past payload length");
- return 0;
+ return offset;
}
- return offset - start_offset;
+ break;
} /* case ADMIN_REC_TYPE_AGGREGATE_CUSTODY_SIGNAL */
case ADMIN_REC_TYPE_ANNOUNCE_BUNDLE:
- {
- proto_tree_add_text(admin_record_tree, tvb, offset, 1, "Announce Record (Contact)");
- return 1; /*Special case for poxy TCP Convergence Layer Announce Bundle*/
- }
default:
- {
- /* do nothing, fall through and fail */
- }
+ offset++;
+ break;
} /* End Switch */
- proto_tree_add_text(admin_record_tree, tvb, offset, 1,
- "Administrative Record Type: Unknown");
- return 0;
-}
-
-/*
- * Return length of contact header or 0 on failure
- */
-
-static int
-dissect_contact_header(tvbuff_t *tvb, packet_info *pinfo,
- proto_tree *conv_tree, proto_item *conv_item)
-{
- guint8 contact_hdr_flags;
- proto_item *contact_hdr_flag_item;
- proto_tree *contact_hdr_flag_tree;
- int eid_length;
- int sdnv_length;
- char *sptr;
-
- /*
- * I'm going to assume that if this is a contact header, the buffer
- * contains the complete header and that there are no other packets
- * in the buffer.
- */
-
- proto_tree_add_text(conv_tree, tvb, 0, 4, "Pkt Type: Contact Header");
- proto_tree_add_item(conv_tree, hf_contact_hdr_version, tvb, 4, 1, ENC_BIG_ENDIAN);
-
- /* Subtree to expand the bits in the Contact Header Flags */
- contact_hdr_flags = tvb_get_guint8(tvb, 5);
- contact_hdr_flag_item =
- proto_tree_add_item(conv_tree, hf_contact_hdr_flags, tvb, 5, 1, ENC_BIG_ENDIAN);
- contact_hdr_flag_tree =
- proto_item_add_subtree(contact_hdr_flag_item, ett_contact_hdr_flags);
- proto_tree_add_boolean(contact_hdr_flag_tree, hf_contact_hdr_flags_ack_req,
- tvb, 5, 1, contact_hdr_flags);
- proto_tree_add_boolean(contact_hdr_flag_tree, hf_contact_hdr_flags_frag_enable,
- tvb, 5, 1, contact_hdr_flags);
- proto_tree_add_boolean(contact_hdr_flag_tree, hf_contact_hdr_flags_nak,
- tvb, 5, 1, contact_hdr_flags);
- proto_tree_add_item(conv_tree, hf_contact_hdr_keep_alive, tvb, 6, 2, ENC_BIG_ENDIAN);
-
- /*
- * New format Contact header has length field followed by Bundle Header.
- */
-
- eid_length = evaluate_sdnv(tvb, 8, &sdnv_length);
- if(eid_length < 0) {
- col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error (Local EID Length)");
- return 0;
- }
- proto_tree_add_text(conv_tree, tvb, 8, sdnv_length,
- "Local EID Length: %d", eid_length);
- proto_item_set_len(conv_item, sdnv_length + eid_length + 8);
-
- sptr = (char *) tvb_get_ephemeral_string(tvb, sdnv_length + 8, eid_length);
- proto_tree_add_text(conv_tree, tvb, sdnv_length + 8, eid_length, "Local EID: %s", sptr);
-
- return(sdnv_length + eid_length + 8);
+ *success = TRUE;
+ return offset;
}
static int
@@ -2092,7 +1679,6 @@ display_metadata_block(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
proto_item *block_item;
proto_tree *block_tree;
int sdnv_length;
- int header_start;
int block_length;
guint8 type;
int control_flags;
@@ -2104,62 +1690,62 @@ display_metadata_block(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
int i = 0;
type = tvb_get_guint8(tvb, offset);
- header_start = offset; /*Used to compute total payload length*/
- offset = 0;
- block_item = proto_tree_add_text(tree, tvb, header_start + offset, -1, "Metadata Block");
+ block_item = proto_tree_add_text(tree, tvb, offset, -1, "Metadata Block");
block_tree = proto_item_add_subtree(block_item, ett_metadata_hdr);
- proto_tree_add_item(block_tree, hf_bundle_block_type_code, tvb, header_start + offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_tree, hf_bundle_block_type_code, tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
- control_flags = evaluate_sdnv(tvb, header_start + offset, &sdnv_length);
+ control_flags = evaluate_sdnv(tvb, offset, &sdnv_length);
if(control_flags & BLOCK_CONTROL_LAST_BLOCK) {
*lastheader = TRUE;
} else {
*lastheader = FALSE;
}
block_flag_item = proto_tree_add_item(block_tree, hf_block_control_flags, tvb,
- header_start + offset, sdnv_length, ENC_BIG_ENDIAN);
+ offset, sdnv_length, ENC_BIG_ENDIAN);
block_flag_tree = proto_item_add_subtree(block_flag_item, ett_block_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_replicate,
- tvb, header_start + offset, sdnv_length, control_flags);
+ tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_transmit_status,
- tvb, header_start + offset, sdnv_length, control_flags);
+ tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_delete_bundle,
- tvb, header_start + offset, sdnv_length, control_flags);
+ tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_last_block,
- tvb, header_start + offset, sdnv_length, control_flags);
+ tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_discard_block,
- tvb, header_start + offset, sdnv_length, control_flags);
+ tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_not_processed,
- tvb, header_start + offset, sdnv_length, control_flags);
+ tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_eid_reference,
- tvb, header_start + offset, sdnv_length, control_flags);
- control_flags_offset = header_start + offset;
+ tvb, offset, sdnv_length, control_flags);
+ control_flags_offset = offset;
control_flags_length = sdnv_length;
offset += sdnv_length;
/* TODO: if this block has EID references, add them to display tree */
if (control_flags & BLOCK_CONTROL_EID_REFERENCE) {
- num_eid_ref = evaluate_sdnv(tvb, header_start + offset, &sdnv_length);
+ num_eid_ref = evaluate_sdnv(tvb, offset, &sdnv_length);
offset += sdnv_length;
for (i = 0; i < num_eid_ref; i++)
{
- evaluate_sdnv(tvb, header_start + offset, &sdnv_length);
+ evaluate_sdnv(tvb, offset, &sdnv_length);
offset += sdnv_length;
- evaluate_sdnv(tvb, header_start + offset, &sdnv_length);
+ evaluate_sdnv(tvb, offset, &sdnv_length);
offset += sdnv_length;
}
}
- block_length = evaluate_sdnv(tvb, header_start + offset, &sdnv_length);
+ block_length = evaluate_sdnv(tvb, offset, &sdnv_length);
if(block_length < 0) {
- proto_tree_add_text(block_tree, tvb, header_start + offset, sdnv_length, "Metadata Block Length: Error");
- return 0;
+ proto_tree_add_text(block_tree, tvb, offset, sdnv_length, "Metadata Block Length: Error");
+ /* Force quitting */
+ *lastheader = TRUE;
+ return offset;
}
- proto_tree_add_text(block_tree, tvb, header_start + offset, sdnv_length, "Block Length: %d", block_length);
+ proto_tree_add_text(block_tree, tvb, offset, sdnv_length, "Block Length: %d", block_length);
offset += sdnv_length;
/* now we have enough info to know total length of metadata block */
proto_item_set_len(block_item, offset + block_length);
@@ -2192,40 +1778,40 @@ display_metadata_block(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
}
/* there are two elements in a CTEB, first is the custody ID */
- custody_id = evaluate_sdnv(tvb, header_start + offset, &sdnv_length);
- proto_tree_add_text(block_tree, tvb, header_start + offset, sdnv_length, "CTEB Custody ID: %d", custody_id);
+ custody_id = evaluate_sdnv(tvb, offset, &sdnv_length);
+ proto_tree_add_text(block_tree, tvb, offset, sdnv_length, "CTEB Custody ID: %d", custody_id);
offset += sdnv_length;
/* and second is the creator custodian EID */
cteb_creator_custodian_eid_length = block_length - sdnv_length;
- cteb_creator_custodian_eid = (char *) tvb_get_ephemeral_string(tvb, header_start + offset, cteb_creator_custodian_eid_length);
- proto_tree_add_text(block_tree, tvb, header_start + offset, cteb_creator_custodian_eid_length,
+ cteb_creator_custodian_eid = (char *) tvb_get_ephemeral_string(tvb, offset, cteb_creator_custodian_eid_length);
+ proto_tree_add_text(block_tree, tvb, offset, cteb_creator_custodian_eid_length,
"CTEB Creator Custodian EID: %s", cteb_creator_custodian_eid);
/* also check if CTEB is valid, i.e. custodians match */
if (cteb_creator_custodian_eid == NULL) {
- proto_tree_add_text(block_tree, tvb, header_start + offset,
+ proto_tree_add_text(block_tree, tvb, offset,
cteb_creator_custodian_eid_length,
"CTEB Is NOT Valid (CTEB Custodian NULL)");
}
else if (bundle_custodian == NULL) {
- proto_tree_add_text(block_tree, tvb, header_start + offset,
+ proto_tree_add_text(block_tree, tvb, offset,
cteb_creator_custodian_eid_length,
"CTEB Is NOT Valid (Bundle Custodian NULL)");
}
else if (strlen(cteb_creator_custodian_eid) != strlen(bundle_custodian)) {
- proto_tree_add_text(block_tree, tvb, header_start + offset,
+ proto_tree_add_text(block_tree, tvb, offset,
cteb_creator_custodian_eid_length,
"CTEB Is NOT Valid (Bundle Custodian [%s] != CTEB Custodian [%s])",
bundle_custodian, cteb_creator_custodian_eid);
}
else if (memcmp(cteb_creator_custodian_eid, bundle_custodian, strlen(bundle_custodian)) != 0) {
- proto_tree_add_text(block_tree, tvb, header_start + offset,
+ proto_tree_add_text(block_tree, tvb, offset,
cteb_creator_custodian_eid_length,
"CTEB Is NOT Valid (Bundle Custodian [%s] != CTEB Custodian [%s])",
bundle_custodian, cteb_creator_custodian_eid);
}
else {
- proto_tree_add_text(block_tree, tvb, header_start + offset,
+ proto_tree_add_text(block_tree, tvb, offset,
cteb_creator_custodian_eid_length,
"CTEB Is Valid");
}
@@ -2249,26 +1835,28 @@ display_metadata_block(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
}
/* flags byte */
- flags = (int)tvb_get_guint8(tvb, header_start + offset);
- ecos_flag_item = proto_tree_add_item(block_tree, hf_ecos_flags, tvb, header_start + offset, 1, ENC_BIG_ENDIAN);
+ flags = (int)tvb_get_guint8(tvb, offset);
+ ecos_flag_item = proto_tree_add_item(block_tree, hf_ecos_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
ecos_flag_tree = proto_item_add_subtree(ecos_flag_item, ett_block_flags);
- proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_critical, tvb, header_start + offset, 1, flags);
- proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_streaming, tvb, header_start + offset, 1, flags);
- proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_ordinal, tvb, header_start + offset, 1, flags);
+ proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_critical, tvb, offset, 1, flags);
+ proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_streaming, tvb, offset, 1, flags);
+ proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_ordinal, tvb, offset, 1, flags);
offset += 1;
/* ordinal byte */
- proto_tree_add_item(block_tree, hf_ecos_ordinal, tvb, header_start + offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(block_tree, hf_ecos_ordinal, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* optional flow label sdnv */
if ((flags & ECOS_FLAGS_ORDINAL) != 0) {
- flow_label = evaluate_sdnv(tvb, header_start + offset, &sdnv_length);
+ flow_label = evaluate_sdnv(tvb, offset, &sdnv_length);
if(flow_label < 0) {
- proto_tree_add_text(block_tree, tvb, header_start + offset, sdnv_length, "ECOS Flow Label: Error");
- return 0;
+ proto_tree_add_text(block_tree, tvb, offset, sdnv_length, "ECOS Flow Label: Error");
+ /* Force quitting */
+ *lastheader = TRUE;
+ return offset;
}
- proto_tree_add_text(block_tree, tvb, header_start + offset, sdnv_length, "ECOS Flow Label: %d", flow_label);
+ proto_tree_add_text(block_tree, tvb, offset, sdnv_length, "ECOS Flow Label: %d", flow_label);
offset += sdnv_length;
}
@@ -2285,16 +1873,6 @@ display_metadata_block(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean *la
return offset;
}
-/*
- * SDNV has a zero in high-order bit position of last byte. The high-order
- * bit of all preceding bytes is set to one. This returns the numeric value
- * in an integer and sets the value of the second argument to the number of
- * bytes used to code the SDNV. A -1 is returned if the evaluation fails
- * (value exceeds maximum for signed integer). 0 is an acceptable value.
- */
-
-#define SDNV_MASK 0x7f
-
/*3rd arg is number of bytes in field (returned)*/
int
evaluate_sdnv(tvbuff_t *tvb, int offset, int *bytecount)
@@ -2363,72 +1941,378 @@ evaluate_sdnv_64(tvbuff_t *tvb, int offset, int *bytecount)
return value;
}
-static int
-add_sdnv_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, const char *field_id)
+static guint
+get_dtn_contact_header_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
{
- int sdnv_length;
- int sdnv_value;
+ int len, bytecount;
- sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
- if(sdnv_value < 0) {
+ /* get length from sdnv */
+ len = evaluate_sdnv(tvb, offset+8, &bytecount);
+ if (len < 0)
return 0;
+
+ return len+bytecount+8;
+}
+
+static void
+dissect_dtn_contact_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_item *ti;
+ proto_tree *conv_proto_tree, *conv_tree, *conv_flag_tree;
+ int eid_length, sdnv_length;
+ int offset = 0;
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCPCL");
+ col_clear(pinfo->cinfo,COL_INFO); /* Clear out stuff in the info column */
+
+ ti = proto_tree_add_item(tree, proto_tcp_conv, tvb, offset, -1, ENC_NA);
+ conv_proto_tree = proto_item_add_subtree(ti, ett_tcp_conv);
+
+ ti = proto_tree_add_text(conv_proto_tree, tvb, offset, -1, "Contact Header");
+ conv_tree = proto_item_add_subtree(ti, ett_tcp_conv);
+
+ proto_tree_add_item(conv_tree, hf_contact_hdr_magic, tvb, offset, 4, ENC_NA|ENC_ASCII);
+ offset += 4;
+ proto_tree_add_item(conv_tree, hf_contact_hdr_version, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset++;
+
+ /* Subtree to expand the bits in the Contact Header Flags */
+ ti = proto_tree_add_item(conv_tree, hf_contact_hdr_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
+ conv_flag_tree = proto_item_add_subtree(ti, ett_contact_hdr_flags);
+ proto_tree_add_item(conv_flag_tree, hf_contact_hdr_flags_ack_req, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(conv_flag_tree, hf_contact_hdr_flags_frag_enable, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(conv_flag_tree, hf_contact_hdr_flags_nak, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset++;
+
+ proto_tree_add_item(conv_tree, hf_contact_hdr_keep_alive, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+
+ /*
+ * New format Contact header has length field followed by Bundle Header.
+ */
+ eid_length = evaluate_sdnv(tvb, offset, &sdnv_length);
+ ti = proto_tree_add_int(tree, hf_contact_hdr_local_eid_length, tvb, offset, sdnv_length, eid_length);
+ if(eid_length < 0) {
+ expert_add_info(pinfo, ti, &ei_bundle_sdnv_length);
+ return;
}
- proto_tree_add_text(tree, tvb, offset, sdnv_length, "%s: %d", field_id, sdnv_value);
- return sdnv_length;
+
+ proto_tree_add_item(conv_tree, hf_contact_hdr_local_eid, tvb, sdnv_length + offset, eid_length, ENC_NA|ENC_ASCII);
+}
+
+static guint
+get_tcpcl_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
+{
+ int len, bytecount;
+ guint8 conv_hdr = tvb_get_guint8(tvb, offset);
+
+ switch(conv_hdr & TCP_CONVERGENCE_TYPE_MASK)
+ {
+ case TCP_CONVERGENCE_DATA_SEGMENT:
+ case TCP_CONVERGENCE_ACK_SEGMENT:
+ /* get length from sdnv */
+ len = evaluate_sdnv(tvb, offset+1, &bytecount);
+ if (len < 0)
+ return 0;
+
+ return len+bytecount+1;
+
+ case TCP_CONVERGENCE_KEEP_ALIVE:
+ case TCP_CONVERGENCE_REFUSE_BUNDLE:
+ /* always 1 byte */
+ return 1;
+ case TCP_CONVERGENCE_SHUTDOWN:
+ len = 1;
+
+ if(conv_hdr & TCP_CONVERGENCE_SHUTDOWN_REASON) {
+ len += 1;
+ }
+ if(conv_hdr & TCP_CONVERGENCE_SHUTDOWN_DELAY) {
+ len += 2;
+ }
+
+ return len;
+ }
+
+ return 0;
+}
+
+static void
+dissect_tcpcl_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ guint8 conv_hdr;
+ int offset = 0;
+ int sdnv_length, segment_length, convergence_hdr_size;
+ proto_item *ci, *conv_item, *sub_item;
+ proto_tree *conv_proto_tree, *conv_tree, *sub_tree;
+ fragment_head *frag_msg;
+ tvbuff_t *new_tvb;
+ gboolean more_frags;
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCPCL");
+ col_clear(pinfo->cinfo,COL_INFO); /* Clear out stuff in the info column */
+
+ ci = proto_tree_add_item(tree, proto_tcp_conv, tvb, offset, -1, ENC_NA);
+ conv_proto_tree = proto_item_add_subtree(ci, ett_tcp_conv);
+
+ conv_item = proto_tree_add_text(conv_proto_tree, tvb, 0, -1, "TCP Convergence Header");
+ conv_tree = proto_item_add_subtree(conv_item, ett_tcp_conv_hdr);
+
+ conv_hdr = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(conv_tree, hf_tcp_convergence_pkt_type, tvb, offset, 1, ENC_NA);
+ col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const((conv_hdr>>4)&0xF, packet_type_vals, "Unknown"));
+
+ switch (conv_hdr & TCP_CONVERGENCE_TYPE_MASK)
+ {
+ case TCP_CONVERGENCE_DATA_SEGMENT:
+ sub_item = proto_tree_add_item(conv_tree, hf_tcp_convergence_data_procflags, tvb,
+ offset, 1, ENC_BIG_ENDIAN);
+ sub_tree = proto_item_add_subtree(sub_item, ett_conv_flags);
+ proto_tree_add_item(sub_tree, hf_tcp_convergence_data_procflags_start,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(sub_tree, hf_tcp_convergence_data_procflags_end,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+
+ /* Only Start and End flags (bits 0 & 1) are valid in Data Segment */
+ if((conv_hdr & ~(TCP_CONVERGENCE_TYPE_MASK | TCP_CONVERGENCE_DATA_FLAGS)) != 0) {
+ expert_add_info(pinfo, sub_item, &ei_tcp_convergence_data_flags);
+ }
+
+ segment_length = evaluate_sdnv(tvb, 1, &sdnv_length);
+ sub_item = proto_tree_add_int(conv_tree, hf_tcp_convergence_data_segment_length, tvb, 1, sdnv_length, segment_length);
+ if(segment_length < 0) {
+ expert_add_info(pinfo, sub_item, &ei_tcp_convergence_segment_length);
+ return;
+ }
+
+ convergence_hdr_size = sdnv_length + 1;
+
+ /*
+ * 1/11/2006 - If I got here, I should have a complete convergence layer
+ * "segment" beginning at frame_offset. However that might not be a
+ * complete bundle. Or there might be a complete bundle plus one or more
+ * additional convergence layer headers.
+ */
+
+ new_tvb = NULL;
+ sub_tree = NULL;
+ if((conv_hdr & TCP_CONVERGENCE_DATA_END_FLAG) == TCP_CONVERGENCE_DATA_END_FLAG) {
+ more_frags = FALSE;
+ }
+ else {
+ more_frags = TRUE;
+ }
+
+ /*
+ * Note: The reassembled bundle will only include the first
+ * Convergence layer header.
+ */
+ frag_msg = fragment_add_seq_next(&msg_reassembly_table,
+ tvb, offset + convergence_hdr_size,
+ pinfo, 0, NULL,
+ segment_length, more_frags);
+ if(frag_msg && !more_frags) {
+
+ sub_item = proto_tree_add_item(tree, proto_bundle, tvb, offset, -1, ENC_NA);
+ sub_tree = proto_item_add_subtree(sub_item, ett_bundle);
+
+ new_tvb = process_reassembled_data(tvb, offset + convergence_hdr_size,
+ pinfo, "Reassembled DTN", frag_msg,
+ &msg_frag_items, NULL, sub_tree);
+ }
+
+ if(new_tvb) {
+ int bundle_size = call_dissector(bundle_handle, new_tvb, pinfo, sub_tree);
+
+ if(bundle_size == 0) {
+ /*Couldn't parse bundle, treat as raw data */
+ call_dissector(data_handle, new_tvb, pinfo, sub_tree);
+ return;
+ }
+ }
+ else {
+
+ /*
+ * If there are 2 segments, the second of which is very short, this
+ * gets displayed instead of the usual Source EID/Destination EID in
+ * the Bundle Dissection frame. If these statements are left out entirely,
+ * nothing is displayed, i.e., there seems to be no way to get the
+ * Source/Destination in the 2-segment case. I'll leave it in because I
+ * think it is informative in the multi-segment case although confusing in the
+ * 2-segment case.
+ */
+ col_set_str(pinfo->cinfo, COL_INFO, "[Reassembled Segment of a Bundle]");
+ }
+ break;
+ case TCP_CONVERGENCE_ACK_SEGMENT:
+ segment_length = evaluate_sdnv(tvb, offset+1, &sdnv_length);
+ sub_item = proto_tree_add_int(conv_tree, hf_tcp_convergence_ack_length, tvb, offset+1, sdnv_length, segment_length);
+ if(segment_length < 0) {
+ expert_add_info(pinfo, sub_item, &ei_tcp_convergence_ack_length);
+ }
+ break;
+ case TCP_CONVERGENCE_KEEP_ALIVE:
+ /*No valid flags in Keep Alive*/
+ break;
+
+ case TCP_CONVERGENCE_SHUTDOWN:
+ /* Add tree for Shutdown Flags */
+ sub_item = proto_tree_add_item(conv_tree, hf_tcp_convergence_shutdown_flags, tvb,
+ offset, 1, ENC_BIG_ENDIAN);
+ sub_tree = proto_item_add_subtree(sub_item, ett_shutdown_flags);
+
+ proto_tree_add_item(sub_tree, hf_tcp_convergence_shutdown_flags_reason,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(sub_tree, hf_tcp_convergence_shutdown_flags_delay,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+
+ offset += 1;
+ if(conv_hdr & TCP_CONVERGENCE_SHUTDOWN_REASON) {
+ proto_tree_add_item(conv_tree,
+ hf_tcp_convergence_shutdown_reason, tvb,
+ offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ }
+ if(conv_hdr & TCP_CONVERGENCE_SHUTDOWN_DELAY) {
+ proto_tree_add_item(conv_tree,
+ hf_tcp_convergence_shutdown_delay, tvb,
+ offset, 2, ENC_BIG_ENDIAN);
+ }
+ break;
+ case TCP_CONVERGENCE_REFUSE_BUNDLE:
+ /*No valid flags*/
+ break;
+ }
+
}
-/*
- * Adds the result of 2 SDNVs to tree: First SDNV is seconds, next is nanoseconds.
- * Returns bytes in both SDNVs or 0 if something goes wrong.
- */
static int
-add_dtn_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, const char *field_id)
+dissect_tcpcl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
- int sdnv_length, sdnv2_length;
- int sdnv_value;
- time_t time_since_2000;
- char *time_string;
+ guint8 conv_hdr;
+ int offset, bytecount;
- sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
- if(sdnv_value < 0) {
+ /* Make sure we have a convergence header byte */
+ if (!tvb_bytes_exist(tvb, 0, 1))
return 0;
- }
- time_since_2000 = (time_t) (sdnv_value + 946684800);
- time_string = abs_time_secs_to_str(time_since_2000, ABSOLUTE_TIME_LOCAL, TRUE);
- proto_tree_add_text(tree, tvb, offset, sdnv_length,
- "%s (sec): %d [%s]", field_id, sdnv_value, time_string);
- offset += sdnv_length;
- sdnv_value = evaluate_sdnv(tvb, offset, &sdnv2_length);
- if(sdnv_value < 0) {
+ conv_hdr = tvb_get_guint8(tvb, 0);
+ switch(conv_hdr & TCP_CONVERGENCE_TYPE_MASK)
+ {
+ case TCP_CONVERGENCE_DATA_SEGMENT:
+ case TCP_CONVERGENCE_ACK_SEGMENT:
+ /* ensure sdnv */
+ offset = 1;
+ bytecount = 1;
+
+ if (!tvb_bytes_exist(tvb, offset, 1))
+ return 0;
+
+ while(tvb_get_guint8(tvb, offset) & ~SDNV_MASK) {
+ if (bytecount > (int)sizeof(int)) {
+ /* invalid length field */
+ return 0;
+ }
+
+ if (!tvb_bytes_exist(tvb, offset, 1))
+ return 0;
+
+ bytecount++;
+ offset++;
+ }
+ break;
+ case TCP_CONVERGENCE_KEEP_ALIVE:
+ case TCP_CONVERGENCE_REFUSE_BUNDLE:
+ /* always 1 byte */
+ break;
+ case TCP_CONVERGENCE_SHUTDOWN:
+ if((conv_hdr &
+ ~(TCP_CONVERGENCE_TYPE_MASK | TCP_CONVERGENCE_SHUTDOWN_FLAGS)) != 0) {
+ /* Not for us */
+ return 0;
+ }
+ break;
+ default:
+ if (conv_hdr == (guint8)magic[0]) {
+ if (!tvb_bytes_exist(tvb, 0, 4) || tvb_memeql(tvb, 0, magic, 4)) {
+ /* Not for us */
+ return 0;
+ }
+
+ tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 8, get_dtn_contact_header_len, dissect_dtn_contact_header);
+ return tvb_length(tvb);
+ }
+
+ /* Not for us */
return 0;
- }
- proto_tree_add_text(tree, tvb, offset, sdnv2_length,
- "%s (ns): %d", field_id, sdnv_value);
- return (sdnv_length + sdnv2_length);
+ };
+
+ tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 1, get_tcpcl_pdu_len, dissect_tcpcl_pdu);
+ return tvb_length(tvb);
}
-/*
- * Adds the result of SDNV which is a time since 2000 to tree.
- * Returns bytes in SDNV or 0 if something goes wrong.
- */
static int
-add_sdnv_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, const char *field_id)
+dissect_bundle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
- int sdnv_length;
- int sdnv_value;
- time_t time_since_2000;
- char *time_string;
+ proto_item *ti;
+ proto_tree *bundle_tree, *primary_tree;
+ int primary_header_size;
+ gboolean lastheader = FALSE;
+ int offset = 0;
+ guint8 version, pri_hdr_procflags;
- sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
- if(sdnv_value < 0) {
+ version = tvb_get_guint8(tvb, offset); /* Primary Header Version */
+ if((version != 4) && (version != 5) && (version != 6)) {
return 0;
}
- time_since_2000 = (time_t) (sdnv_value + 946684800);
- time_string = abs_time_secs_to_str(time_since_2000, ABSOLUTE_TIME_LOCAL, TRUE);
- proto_tree_add_text(tree, tvb, offset, sdnv_length,
- "%s: %d [%s]", field_id, sdnv_value, time_string);
- return sdnv_length;
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bundle");
+ /* Clear out stuff in the info column */
+ col_clear(pinfo->cinfo,COL_INFO);
+
+ ti = proto_tree_add_item(tree, proto_bundle, tvb, offset, -1, ENC_NA);
+ bundle_tree = proto_item_add_subtree(ti, ett_bundle);
+
+ ti = proto_tree_add_text(tree, tvb, offset, -1, "Primary Bundle Header");
+ primary_tree = proto_item_add_subtree(ti, ett_primary_hdr);
+
+ proto_tree_add_item(primary_tree, hf_bundle_pdu_version, tvb, offset, 1, ENC_BIG_ENDIAN);
+ if (version == 4) {
+ primary_header_size = dissect_version_4_primary_header(pinfo, primary_tree, tvb, &pri_hdr_procflags);
+ }
+ else {
+ primary_header_size = dissect_version_5_and_6_primary_header(pinfo, primary_tree, tvb, &pri_hdr_procflags);
+ }
+
+ if(primary_header_size == 0) { /*Couldn't parse primary header*/
+ col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
+ return(0); /*Give up*/
+ }
+
+ proto_item_set_len(ti, primary_header_size);
+ offset = primary_header_size;
+
+ /*
+ * Done with primary header; decode the remaining headers
+ */
+
+ while(lastheader == FALSE) {
+ guint8 next_header_type;
+
+ next_header_type = tvb_get_guint8(tvb, offset);
+ if(next_header_type == BUNDLE_BLOCK_TYPE_PAYLOAD) {
+
+ /*
+ * Returns payload size or 0 if can't parse payload
+ */
+ offset = dissect_payload_header(tree, tvb, pinfo, offset, version, pri_hdr_procflags, &lastheader);
+ }
+ else { /*Assume anything else is a Metadata Block*/
+ offset = display_metadata_block(tree, tvb, offset, &lastheader);
+ }
+ }
+
+ return(offset);
}
static void
@@ -2437,6 +2321,35 @@ bundle_defragment_init(void) {
&addresses_reassembly_table_functions);
}
+
+void
+proto_reg_handoff_bundle(void)
+{
+ static dissector_handle_t tcpcl_handle;
+ static guint tcp_port;
+ static guint udp_port;
+
+ static int Initialized = FALSE;
+
+ if (!Initialized) {
+#if 0
+ tcpcl_handle = create_dissector_handle(dissect_tcp_bundle, proto_bundle);
+#else
+ tcpcl_handle = new_create_dissector_handle(dissect_tcpcl, proto_bundle);
+#endif
+ data_handle = find_dissector("data");
+ Initialized = TRUE;
+ }
+ else {
+ dissector_delete_uint("tcp.port", tcp_port, tcpcl_handle);
+ dissector_delete_uint("udp.port", udp_port, bundle_handle);
+ }
+ tcp_port = bundle_tcp_port;
+ udp_port = bundle_udp_port;
+ dissector_add_uint("tcp.port", tcp_port, tcpcl_handle);
+ dissector_add_uint("udp.port", udp_port, bundle_handle);
+}
+
void
proto_register_bundle(void)
{
@@ -2446,63 +2359,6 @@ proto_register_bundle(void)
{"Bundle Version", "bundle.version",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
- {&hf_contact_hdr_version,
- {"Version", "bundle.tcp_conv.contact_hdr.version",
- FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
- },
- {&hf_contact_hdr_flags,
- {"Flags", "bundle.tcp_conv.contact_hdr.flags",
- FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
- },
- {&hf_contact_hdr_flags_ack_req,
- {"Bundle Acks Requested", "bundle.tcp_conv.contact_hdr.flags.ackreq",
- FT_BOOLEAN, 8, NULL, TCP_CONV_BUNDLE_ACK_FLAG, NULL, HFILL}
- },
- {&hf_contact_hdr_flags_frag_enable,
- {"Reactive Fragmentation Enabled", "bundle.tcp_conv.contact_hdr.flags.fragen",
- FT_BOOLEAN, 8, NULL, TCP_CONV_REACTIVE_FRAG_FLAG, NULL, HFILL}
- },
- {&hf_contact_hdr_flags_nak,
- {"Support Negative Acknowledgements", "bundle.tcp_conv.contact_hdr.flags.nak",
- FT_BOOLEAN, 8, NULL, TCP_CONV_CONNECTOR_RCVR_FLAG, NULL, HFILL}
- },
- {&hf_contact_hdr_keep_alive,
- {"Keep Alive", "bundle.tcp_conv.contact_hdr.keep_alive",
- FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
- },
- {&hf_tcp_convergence_data_procflags,
- {"TCP Convergence Data Flags", "bundle.tcp_conv.data.proc.flag",
- FT_UINT8, BASE_HEX, NULL, TCP_CONVERGENCE_DATA_FLAGS, NULL, HFILL}
- },
- {&hf_tcp_convergence_data_procflags_start,
- {"Segment contains start of bundle", "bundle.tcp_conv.data.proc.start",
- FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_DATA_START_FLAG, NULL, HFILL}
- },
- {&hf_tcp_convergence_data_procflags_end,
- {"Segment contains end of Bundle", "bundle.tcp_conv.data.proc.end",
- FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_DATA_END_FLAG, NULL, HFILL}
- },
- {&hf_tcp_convergence_shutdown_flags,
- {"TCP Convergence Shutdown Flags", "bundle.tcp_conv.shutdown.flags",
- FT_UINT8, BASE_HEX, NULL, TCP_CONVERGENCE_SHUTDOWN_FLAGS, NULL, HFILL}
- },
- {&hf_tcp_convergence_shutdown_flags_reason,
- {"Shutdown includes Reason Code", "bundle.tcp_conv.shutdown.reason.flag",
- FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_SHUTDOWN_REASON, NULL, HFILL}
- },
- {&hf_tcp_convergence_shutdown_flags_delay,
- {"Shutdown includes Reconnection Delay", "bundle.tcp_conv.shutdown.delay.flag",
- FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_SHUTDOWN_DELAY, NULL, HFILL}
- },
- {&hf_tcp_convergence_shutdown_reason,
- {"Shutdown Reason Code", "bundle.tcp_conv.shutdown.reason",
- FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
- },
- {&hf_tcp_convergence_shutdown_delay,
- {"Shutdown Reconnection Delay", "bundle.tcp_conv.shutdown.delay",
- FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
- },
-
{&hf_msg_fragments,
{"Message Fragments", "bundle.msg.fragments",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}
@@ -2581,14 +2437,10 @@ proto_register_bundle(void)
{"General Flags", "bundle.primary.proc.gen",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
-#endif
-#if 0
{&hf_bundle_procflags_cos,
{"Cloass of Service Flags", "bundle.primary.proc.cos",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
-#endif
-#if 0
{&hf_bundle_procflags_status,
{"Status Report Flags", "bundle.primary.proc.status",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
@@ -2636,6 +2488,10 @@ proto_register_bundle(void)
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
#endif
+ {&hf_bundle_primary_timestamp,
+ {"Timestamp", "bundle.primary.timestamp",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
+ },
{&hf_bundle_dest_scheme_offset,
{"Destination Scheme Offset", "bundle.primary.destschemeoff",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
@@ -2708,6 +2564,10 @@ proto_register_bundle(void)
{"Lifetime", "bundle.primary.lifetime",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
+ {&hf_bundle_payload_length,
+ {"Payload Length", "bundle.payload.length",
+ FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
{&hf_bundle_payload_flags,
{"Payload Header Processing Flags", "bundle.payload.proc.flag",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
@@ -2728,6 +2588,14 @@ proto_register_bundle(void)
{"Last Header", "bundle.payload.proc.lastheader",
FT_BOOLEAN, 8, NULL, PAYLOAD_PROCFLAGS_LAST_HEADER, NULL, HFILL}
},
+ {&hf_bundle_admin_record_type,
+ {"Administrative Record Type", "bundle.admin.record_type",
+ FT_UINT8, BASE_DEC, VALS(admin_record_type_vals), 0xF0, NULL, HFILL}
+ },
+ {&hf_bundle_admin_record_fragment,
+ {"Administrative Record Type", "bundle.admin.record_type",
+ FT_BOOLEAN, 8, TFS(&tfs_yes_no), ADMIN_REC_FLAGS_FRAGMENT, NULL, HFILL}
+ },
{&hf_bundle_admin_statflags,
{"Administrative Record Status Flags", "bundle.admin.status.flag",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
@@ -2756,40 +2624,54 @@ proto_register_bundle(void)
{"Acknowledged by Application", "bundle.admin.status.ack",
FT_BOOLEAN, 8, NULL, ADMIN_STATUS_FLAGS_ACKNOWLEDGED, NULL, HFILL}
},
-#if 0
+ {&hf_bundle_admin_fragment_offset,
+ {"Fragment Offset", "bundle.admin.fragment_offset",
+ FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_bundle_admin_fragment_length,
+ {"Fragment Length", "bundle.admin.fragment_length",
+ FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_bundle_admin_timestamp_seq_num64,
+ {"Timestamp Sequence Number", "bundle.admin.timestamp_seq_num",
+ FT_INT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_bundle_admin_timestamp_seq_num32,
+ {"Timestamp Sequence Number", "bundle.admin.timestamp_seq_num",
+ FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
{&hf_bundle_admin_receipt_time,
- {"Time of Receipt", "bundle.admin.status.receipttime",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Received Time", "bundle.admin.status.receipttime",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_accept_time,
- {"Time of Custody Acceptance", "bundle.admin.status.accepttime",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Accepted Time", "bundle.admin.status.accepttime",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_forward_time,
- {"Time of Forwarding", "bundle.admin.status.forwardtime",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Forwarded Time", "bundle.admin.status.forwardtime",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_delivery_time,
- {"Time of Delivery", "bundle.admin.status.deliverytime",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Delivered Time", "bundle.admin.status.deliverytime",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_delete_time,
- {"Time of Deletion", "bundle.admin.status.deletetime",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Deleted Time", "bundle.admin.status.deletetime",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_ack_time,
- {"Time of Acknowledgement", "bundle.admin.status.acktime",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Acknowledged Time", "bundle.admin.status.acktime",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_timestamp_copy,
- {"Copy of Creation Timestamp", "bundle.admin.status.timecopy",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Creation Timestamp", "bundle.admin.status.timecopy",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_signal_time,
- {"Time of Signal", "bundle.admin.signal.time",
- FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ {"Bundle Signal Time", "bundle.admin.signal.time",
+ FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
-#endif
{&hf_block_control_flags,
{"Block Processing Control Flags", "bundle.block.control.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
@@ -2860,12 +2742,91 @@ proto_register_bundle(void)
},
};
+ static hf_register_info hf_tcpcl[] = {
+ {&hf_tcp_convergence_pkt_type,
+ {"Pkt Type", "tcpcl.pkt_type",
+ FT_UINT8, BASE_DEC, VALS(packet_type_vals), 0xF0, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_data_procflags,
+ {"TCP Convergence Data Flags", "tcpcl.data.proc.flag",
+ FT_UINT8, BASE_HEX, NULL, TCP_CONVERGENCE_DATA_FLAGS, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_data_procflags_start,
+ {"Segment contains start of bundle", "tcpcl.data.proc.start",
+ FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_DATA_START_FLAG, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_data_procflags_end,
+ {"Segment contains end of Bundle", "tcpcl.data.proc.end",
+ FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_DATA_END_FLAG, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_data_segment_length,
+ {"Segment Length", "tcpcl.data.length",
+ FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_shutdown_flags,
+ {"TCP Convergence Shutdown Flags", "tcpcl.shutdown.flags",
+ FT_UINT8, BASE_HEX, NULL, TCP_CONVERGENCE_SHUTDOWN_FLAGS, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_shutdown_flags_reason,
+ {"Shutdown includes Reason Code", "tcpcl.shutdown.reason.flag",
+ FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_SHUTDOWN_REASON, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_shutdown_flags_delay,
+ {"Shutdown includes Reconnection Delay", "tcpcl.shutdown.delay.flag",
+ FT_BOOLEAN, 8, NULL, TCP_CONVERGENCE_SHUTDOWN_DELAY, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_shutdown_reason,
+ {"Shutdown Reason Code", "tcpcl.shutdown.reason",
+ FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_shutdown_delay,
+ {"Shutdown Reconnection Delay", "tcpcl.shutdown.delay",
+ FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_tcp_convergence_ack_length,
+ {"Ack Length", "tcpcl.ack.length",
+ FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_contact_hdr_version,
+ {"Version", "tcpcl.contact_hdr.version",
+ FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_contact_hdr_flags,
+ {"Flags", "tcpcl.contact_hdr.flags",
+ FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_contact_hdr_flags_ack_req,
+ {"Bundle Acks Requested", "tcpcl.contact_hdr.flags.ackreq",
+ FT_BOOLEAN, 8, NULL, TCP_CONV_BUNDLE_ACK_FLAG, NULL, HFILL}
+ },
+ {&hf_contact_hdr_flags_frag_enable,
+ {"Reactive Fragmentation Enabled", "tcpcl.contact_hdr.flags.fragen",
+ FT_BOOLEAN, 8, NULL, TCP_CONV_REACTIVE_FRAG_FLAG, NULL, HFILL}
+ },
+ {&hf_contact_hdr_flags_nak,
+ {"Support Negative Acknowledgements", "tcpcl.contact_hdr.flags.nak",
+ FT_BOOLEAN, 8, NULL, TCP_CONV_CONNECTOR_RCVR_FLAG, NULL, HFILL}
+ },
+ {&hf_contact_hdr_keep_alive,
+ {"Keep Alive", "tcpcl.contact_hdr.keep_alive",
+ FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_contact_hdr_magic,
+ {"Magic", "tcpcl.contact_hdr.magic",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_contact_hdr_local_eid,
+ {"Local EID", "tcpcl.contact_hdr.local_eid",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
+ },
+ {&hf_contact_hdr_local_eid_length,
+ {"Local EID Length", "tcpcl.contact_hdr.local_eid_length",
+ FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
+ },
+ };
+
static gint *ett[] = {
&ett_bundle,
- &ett_tcp_conv,
- &ett_tcp_conv_hdr,
- &ett_msg_fragment,
- &ett_msg_fragments,
&ett_bundle_hdr,
&ett_primary_hdr,
&ett_proc_flags,
@@ -2884,25 +2845,34 @@ proto_register_bundle(void)
&ett_metadata_hdr
};
+ static gint *ett_tcpcl[] = {
+ &ett_tcp_conv,
+ &ett_tcp_conv_hdr,
+ &ett_msg_fragment,
+ &ett_msg_fragments,
+ };
+
static ei_register_info ei[] = {
{ &ei_bundle_control_flags_length, { "bundle.block.control.flags.length", PI_UNDECODED, PI_WARN, "Wrong bundle control flag length", EXPFILL }},
+ { &ei_bundle_payload_length, { "bundle.payload.length.invalid", PI_PROTOCOL, PI_ERROR, "Payload length error", EXPFILL }},
+ { &ei_bundle_sdnv_length, { "bundle.sdnv_length.invalid", PI_PROTOCOL, PI_ERROR, "SDNV length error", EXPFILL }},
+ { &ei_bundle_timestamp_seq_num, { "bundle.admin.timestamp_seq_num.invalid", PI_PROTOCOL, PI_ERROR, "Timestamp Sequence Number error", EXPFILL }},
+ };
+
+ static ei_register_info ei_tcpcl[] = {
+ { &ei_tcp_convergence_data_flags, { "tcpcl.data.flags.invalid", PI_PROTOCOL, PI_WARN, "Invalid TCP CL Data Segment Flags", EXPFILL }},
+ { &ei_tcp_convergence_segment_length, { "tcpcl.data.length.invalid", PI_PROTOCOL, PI_ERROR, "Invalid Data Length", EXPFILL }},
+ { &ei_tcp_convergence_ack_length, { "tcpcl.ack.length.error", PI_PROTOCOL, PI_WARN, "Ack Length: Error", EXPFILL }},
};
module_t *bundle_module;
- expert_module_t* expert_bundle;
+ expert_module_t *expert_bundle, *expert_tcpcl;
- proto_bundle = proto_register_protocol (
- "Bundle Protocol",
- "Bundle",
- "bundle"
- );
+ proto_bundle = proto_register_protocol("Bundle Protocol", "Bundle", "bundle");
+ bundle_handle = new_register_dissector("bundle", dissect_bundle, proto_bundle);
bundle_module = prefs_register_protocol(proto_bundle, proto_reg_handoff_bundle);
- proto_tcp_conv = proto_register_protocol (
- "DTN TCP Convergence Layer Protocol",
- "TCPCL",
- "tcpcl"
- );
+ proto_tcp_conv = proto_register_protocol ("DTN TCP Convergence Layer Protocol", "TCPCL", "tcpcl");
prefs_register_uint_preference(bundle_module, "tcp.port",
"Bundle Protocol TCP Port",
@@ -2920,30 +2890,11 @@ proto_register_bundle(void)
proto_register_subtree_array(ett, array_length(ett));
expert_bundle = expert_register_protocol(proto_bundle);
expert_register_field_array(expert_bundle, ei, array_length(ei));
- register_init_routine(bundle_defragment_init);
-}
-void
-proto_reg_handoff_bundle(void)
-{
- static dissector_handle_t tcp_bundle_handle;
- static dissector_handle_t udp_bundle_handle;
- static guint tcp_port;
- static guint udp_port;
+ proto_register_field_array(proto_tcp_conv, hf_tcpcl, array_length(hf_tcpcl));
+ proto_register_subtree_array(ett_tcpcl, array_length(ett_tcpcl));
+ expert_tcpcl = expert_register_protocol(proto_tcp_conv);
+ expert_register_field_array(expert_tcpcl, ei_tcpcl, array_length(ei_tcpcl));
- static int Initialized = FALSE;
-
- if (!Initialized) {
- tcp_bundle_handle = create_dissector_handle(dissect_tcp_bundle, proto_bundle);
- udp_bundle_handle = create_dissector_handle(dissect_udp_bundle, proto_bundle);
- Initialized = TRUE;
- }
- else {
- dissector_delete_uint("tcp.port", tcp_port, tcp_bundle_handle);
- dissector_delete_uint("udp.port", udp_port, udp_bundle_handle);
- }
- tcp_port = bundle_tcp_port;
- udp_port = bundle_udp_port;
- dissector_add_uint("tcp.port", tcp_port, tcp_bundle_handle);
- dissector_add_uint("udp.port", udp_port, udp_bundle_handle);
+ register_init_routine(bundle_defragment_init);
}