Don't guard col_set_str (COL_INFO/COL_PROTOCOL) with col_check
[obnox/wireshark/wip.git] / epan / dissectors / packet-tcp.c
index 37528b3bd2d66ac56c77cf5b806a3db140ec0f4f..d76fceba2782105ac91a293b04fc689042c54ac0 100644 (file)
 #include <epan/prefs.h>
 #include <epan/emem.h>
 #include "packet-tcp.h"
-#include "packet-ip.h"
 #include "packet-frame.h"
 #include <epan/conversation.h>
-#include <epan/strutil.h>
 #include <epan/reassemble.h>
 #include <epan/tap.h>
 #include <epan/slab.h>
@@ -72,6 +70,7 @@ static int proto_tcp = -1;
 static int hf_tcp_srcport = -1;
 static int hf_tcp_dstport = -1;
 static int hf_tcp_port = -1;
+static int hf_tcp_stream = -1;
 static int hf_tcp_seq = -1;
 static int hf_tcp_nxtseq = -1;
 static int hf_tcp_ack = -1;
@@ -92,6 +91,7 @@ static int hf_tcp_checksum_good = -1;
 static int hf_tcp_len = -1;
 static int hf_tcp_urgent_pointer = -1;
 static int hf_tcp_analysis_flags = -1;
+static int hf_tcp_analysis_bytes_in_flight = -1;
 static int hf_tcp_analysis_acks_frame = -1;
 static int hf_tcp_analysis_ack_rtt = -1;
 static int hf_tcp_analysis_rto = -1;
@@ -143,17 +143,44 @@ static int hf_tcp_option_md5 = -1;
 static int hf_tcp_option_qs = -1;
 static int hf_tcp_ts_relative = -1;
 static int hf_tcp_ts_delta = -1;
+static int hf_tcp_option_scps = -1;
+static int hf_tcp_option_scps_vector = -1;
+static int hf_tcp_option_scps_binding = -1;
+static int hf_tcp_scpsoption_flags_bets = -1;
+static int hf_tcp_scpsoption_flags_snack1 = -1;
+static int hf_tcp_scpsoption_flags_snack2 = -1;
+static int hf_tcp_scpsoption_flags_compress = -1;
+static int hf_tcp_scpsoption_flags_nlts = -1;
+static int hf_tcp_scpsoption_flags_resv1 = -1;
+static int hf_tcp_scpsoption_flags_resv2 = -1;
+static int hf_tcp_scpsoption_flags_resv3 = -1;
+static int hf_tcp_option_snack = -1;
+static int hf_tcp_option_snack_offset = -1;
+static int hf_tcp_option_snack_size = -1;
+static int hf_tcp_option_snack_le = -1;
+static int hf_tcp_option_snack_re = -1;
+static int hf_tcp_proc_src_uid = -1;
+static int hf_tcp_proc_src_pid = -1;
+static int hf_tcp_proc_src_uname = -1;
+static int hf_tcp_proc_src_cmd = -1;
+static int hf_tcp_proc_dst_uid = -1;
+static int hf_tcp_proc_dst_pid = -1;
+static int hf_tcp_proc_dst_uname = -1;
+static int hf_tcp_proc_dst_cmd = -1;
 
 static gint ett_tcp = -1;
 static gint ett_tcp_flags = -1;
 static gint ett_tcp_options = -1;
 static gint ett_tcp_option_sack = -1;
+static gint ett_tcp_option_scps = -1;
+static gint ett_tcp_option_scps_extended = -1;
 static gint ett_tcp_analysis = -1;
 static gint ett_tcp_analysis_faults = -1;
 static gint ett_tcp_timestamps = -1;
 static gint ett_tcp_segments = -1;
 static gint ett_tcp_segment  = -1;
 static gint ett_tcp_checksum = -1;
+static gint ett_tcp_process_info = -1;
 
 
 /* not all of the hf_fields below make sense for TCP but we have to provide
@@ -185,6 +212,7 @@ static dissector_handle_t data_handle;
  * **************************************************************************/
 static gboolean tcp_analyze_seq = TRUE;
 static gboolean tcp_relative_seq = TRUE;
+static gboolean tcp_track_bytes_in_flight = TRUE;
 static gboolean tcp_calculate_ts = FALSE;
 
 /* SLAB allocator for tcp_unacked structures
@@ -221,66 +249,76 @@ process_tcp_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo,
 
 
 struct tcp_analysis *
-init_tcp_conversation(packet_info *pinfo)
+init_tcp_conversation_data(packet_info *pinfo)
 {
        struct tcp_analysis *tcpd=NULL;
 
        /* Initialize the tcp protocol datat structure to add to the tcp conversation */
-       tcpd=se_alloc(sizeof(struct tcp_analysis));
-       tcpd->flow1.segments=NULL;
-       tcpd->flow1.base_seq=0;
-       tcpd->flow1.lastack=0;
-       tcpd->flow1.lastacktime.secs=0;
-       tcpd->flow1.lastacktime.nsecs=0;
-       tcpd->flow1.lastnondupack=0;
-       tcpd->flow1.nextseq=0;
-       tcpd->flow1.nextseqtime.secs=0;
-       tcpd->flow1.nextseqtime.nsecs=0;
-       tcpd->flow1.nextseqframe=0;
-       tcpd->flow1.window=0;
+       tcpd=se_alloc0(sizeof(struct tcp_analysis));
+       memset(&tcpd->flow1, 0, sizeof(tcp_flow_t));
+       memset(&tcpd->flow2, 0, sizeof(tcp_flow_t));
        tcpd->flow1.win_scale=-1;
-       tcpd->flow1.flags=0;
        tcpd->flow1.multisegment_pdus=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "tcp_multisegment_pdus");
-       tcpd->flow2.segments=NULL;
-       tcpd->flow2.base_seq=0;
-       tcpd->flow2.lastack=0;
-       tcpd->flow2.lastacktime.secs=0;
-       tcpd->flow2.lastacktime.nsecs=0;
-       tcpd->flow2.lastnondupack=0;
-       tcpd->flow2.nextseq=0;
-       tcpd->flow2.nextseqtime.secs=0;
-       tcpd->flow2.nextseqtime.nsecs=0;
-       tcpd->flow2.nextseqframe=0;
-       tcpd->flow2.window=0;
+       tcpd->flow1.username = NULL;
+       tcpd->flow1.command = NULL;
        tcpd->flow2.win_scale=-1;
-       tcpd->flow2.flags=0;
        tcpd->flow2.multisegment_pdus=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "tcp_multisegment_pdus");
+       tcpd->flow2.username = NULL;
+       tcpd->flow2.command = NULL;
        tcpd->acked_table=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "tcp_analyze_acked_table");
        tcpd->ts_first.secs=pinfo->fd->abs_ts.secs;
        tcpd->ts_first.nsecs=pinfo->fd->abs_ts.nsecs;
        tcpd->ts_prev.secs=pinfo->fd->abs_ts.secs;
        tcpd->ts_prev.nsecs=pinfo->fd->abs_ts.nsecs;
 
-        return tcpd;
+       return tcpd;
+}
+
+conversation_t *
+get_tcp_conversation(packet_info *pinfo)
+{
+       conversation_t *conv=NULL;
+
+       /* Have we seen this conversation before? */
+       if( (conv=find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0)) == NULL){
+               /* No this is a new conversation. */
+               conv=conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+       }
+       return conv;
 }
 
 struct tcp_analysis *
-new_tcp_conversation(packet_info *pinfo)
+get_tcp_conversation_data(conversation_t *conv, packet_info *pinfo)
 {
        int direction;
-       conversation_t *conv=NULL;
        struct tcp_analysis *tcpd=NULL;
 
-       /* Create a new conversation. */
-       conv=conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
-        tcpd = init_tcp_conversation(pinfo);
-       conversation_add_proto_data(conv, proto_tcp, tcpd);
+       /* Did the caller supply the conversation pointer? */
+       if( conv==NULL )
+               conv = get_tcp_conversation(pinfo);
+
+       /* Get the data for this conversation */
+       tcpd=conversation_get_proto_data(conv, proto_tcp);
+
+       /* If the conversation was just created or it matched a
+        * conversation with template options, tcpd will not
+        * have been initialized. So, initialize
+        * a new tcpd structure for the conversation.
+        */
+       if (!tcpd) {
+               tcpd = init_tcp_conversation_data(pinfo);
+               conversation_add_proto_data(conv, proto_tcp, tcpd);
+       }
+
+       if (!tcpd) {
+         return NULL;
+       }
 
        /* check direction and get ua lists */
        direction=CMP_ADDRESS(&pinfo->src, &pinfo->dst);
        /* if the addresses are equal, match the ports instead */
        if(direction==0) {
-               direction= (pinfo->srcport > pinfo->destport)*2-1;
+               direction= (pinfo->srcport > pinfo->destport) ? 1 : -1;
        }
        if(direction>=0){
                tcpd->fwd=&(tcpd->flow1);
@@ -294,61 +332,45 @@ new_tcp_conversation(packet_info *pinfo)
        return tcpd;
 }
 
-struct tcp_analysis *
-get_tcp_conversation_data(packet_info *pinfo)
-{
-       int direction;
-       conversation_t *conv=NULL;
-       struct tcp_analysis *tcpd=NULL;
+/* Attach process info to a flow */
+/* XXX - We depend on the TCP dissector finding the conversation first */
+void
+add_tcp_process_info(guint32 frame_num, address *local_addr, address *remote_addr, guint16 local_port, guint16 remote_port, guint32 uid, guint32 pid, gchar *username, gchar *command) {
+       conversation_t *conv;
+       struct tcp_analysis *tcpd;
+       tcp_flow_t *flow = NULL;
 
-       /* Have we seen this conversation before? */
-       if( (conv=find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0)) == NULL){
-               /* No this is a new conversation. */
-               tcpd=new_tcp_conversation(pinfo);
-       } else {
-               /* Get the data for this conversation */
-               tcpd=conversation_get_proto_data(conv, proto_tcp);
-
-                /* If the conversation matched a conversation with template
-                 * options, tcpd will not have been initialized. So, initialize
-                 * a new tcpd structure for the conversation.
-                 */
-                if (!tcpd) {
-                        tcpd = init_tcp_conversation(pinfo);
-                        conversation_add_proto_data(conv, proto_tcp, tcpd);
-                }
+       conv = find_conversation(frame_num, local_addr, remote_addr, PT_TCP, local_port, remote_port, 0);
+       if (!conv) {
+               return;
        }
 
+       tcpd = conversation_get_proto_data(conv, proto_tcp);
        if (!tcpd) {
-               return NULL;
+               return;
        }
 
-       /* check direction and get ua lists */
-       direction=CMP_ADDRESS(&pinfo->src, &pinfo->dst);
-       /* if the addresses are equal, match the ports instead */
-       if(direction==0) {
-               direction= (pinfo->srcport > pinfo->destport)*2-1;
+       if (CMP_ADDRESS(local_addr, &conv->key_ptr->addr1) == 0 && local_port == conv->key_ptr->port1) {
+               flow = &tcpd->flow1;
+       } else if (CMP_ADDRESS(remote_addr, &conv->key_ptr->addr1) == 0 && remote_port == conv->key_ptr->port1) {
+               flow = &tcpd->flow2;
        }
-       if(direction>=0){
-               tcpd->fwd=&(tcpd->flow1);
-               tcpd->rev=&(tcpd->flow2);
-       } else {
-               tcpd->fwd=&(tcpd->flow2);
-               tcpd->rev=&(tcpd->flow1);
+       if (!flow || flow->command) {
+               return;
        }
 
-       tcpd->ta=NULL;
-       return tcpd;
+       flow->process_uid = uid;
+       flow->process_pid = pid;
+       flow->username = se_strdup(username);
+       flow->command = se_strdup(command);
 }
 
+
 /* Calculate the timestamps relative to this conversation */
 static void
 tcp_calculate_timestamps(packet_info *pinfo, struct tcp_analysis *tcpd,
                        struct tcp_per_packet_data_t *tcppd)
 {
-       if( !tcppd )
-               tcppd = p_get_proto_data(pinfo->fd, proto_tcp);
-
        if( !tcppd ) {
                tcppd = se_alloc(sizeof(struct tcp_per_packet_data_t));
                p_add_proto_data(pinfo->fd, proto_tcp, tcppd);
@@ -557,13 +579,7 @@ tcp_analyze_get_acked_struct(guint32 frame, gboolean createflag, struct tcp_anal
 
        tcpd->ta=se_tree_lookup32(tcpd->acked_table, frame);
        if((!tcpd->ta) && createflag){
-               tcpd->ta=se_alloc(sizeof(struct tcp_acked));
-               tcpd->ta->frame_acked=0;
-               tcpd->ta->ts.secs=0;
-               tcpd->ta->ts.nsecs=0;
-               tcpd->ta->flags=0;
-               tcpd->ta->dupack_num=0;
-               tcpd->ta->dupack_frame=0;
+               tcpd->ta=se_alloc0(sizeof(struct tcp_acked));
                se_tree_insert32(tcpd->acked_table, frame, (void *)tcpd->ta);
        }
 }
@@ -778,6 +794,7 @@ printf("REV list lastflags:0x%04x base_seq:0x%08x:\n",tcpd->rev->lastsegmentflag
        }
 
 
+
 finished_fwd:
        /* If this was NOT a dupack we must reset the dupack counters */
        if( (!tcpd->ta) || !(tcpd->ta->flags&TCP_A_DUPLICATE_ACK) ){
@@ -935,6 +952,14 @@ finished_checking_retransmission_type:
                }
                ackcount++;
                tmpual=tcpd->rev->segments->next;
+
+               if (tcpd->rev->scps_capable) {
+                 /* Track largest segment successfully sent for SNACK analysis */
+                 if ((ual->nextseq - ual->seq) > tcpd->fwd->maxsizeacked) {
+                   tcpd->fwd->maxsizeacked = (ual->nextseq - ual->seq);
+                 }
+               }
+
                TCP_UNACKED_FREE(ual);
                tcpd->rev->segments=tmpual;
        }
@@ -951,11 +976,47 @@ finished_checking_retransmission_type:
                }
                ackcount++;
                tmpual=ual->next->next;
+
+               if (tcpd->rev->scps_capable) {
+                 /* Track largest segment successfully sent for SNACK analysis*/
+                 if ((ual->next->nextseq - ual->next->seq) > tcpd->fwd->maxsizeacked){
+                   tcpd->fwd->maxsizeacked = (ual->next->nextseq - ual->next->seq);
+                 }
+               }
+
                TCP_UNACKED_FREE(ual->next);
                ual->next=tmpual;
                ual=ual->next;
        }
 
+       /* how many bytes of data are there in flight after this frame
+        * was sent
+        */
+       ual=tcpd->fwd->segments;
+       if (tcp_track_bytes_in_flight && seglen!=0 && ual) {
+               guint32 first_seq, last_seq, in_flight;
+
+               first_seq = ual->seq - tcpd->fwd->base_seq;
+               last_seq = ual->nextseq - tcpd->fwd->base_seq;
+               while (ual) {
+                       if ((ual->nextseq-tcpd->fwd->base_seq)>last_seq) {
+                               last_seq = ual->nextseq-tcpd->fwd->base_seq;
+                       }
+                       if ((ual->seq-tcpd->fwd->base_seq)<first_seq) {
+                               first_seq = ual->seq-tcpd->fwd->base_seq;
+                       }
+                       ual = ual->next;
+               }
+               in_flight = last_seq-first_seq;
+
+               if (in_flight>0 && in_flight<2000000000) {
+                       if(!tcpd->ta){
+                               tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE, tcpd);
+                       }
+                       tcpd->ta->bytes_in_flight = in_flight;
+               }
+       }
+
 }
 
 /*
@@ -1240,7 +1301,7 @@ tcp_sequence_number_analysis_print_zero_window(packet_info * pinfo,
 {
   proto_item * flags_item;
 
-  /* TCP Zeor Window Probe */
+  /* TCP Zero Window Probe */
   if (ta->flags & TCP_A_ZERO_WINDOW_PROBE) {
     flags_item=proto_tree_add_none_format(flags_tree,
                                          hf_tcp_analysis_zero_window_probe,
@@ -1286,6 +1347,25 @@ tcp_sequence_number_analysis_print_zero_window(packet_info * pinfo,
 }
 
 
+/* Prints results of the sequence number analysis concerning how many bytes of data are in flight */
+static void
+tcp_sequence_number_analysis_print_bytes_in_flight(packet_info * pinfo _U_,
+                                             tvbuff_t * tvb _U_,
+                                             proto_tree * flags_tree _U_,
+                                             struct tcp_acked *ta
+                                           )
+{
+  proto_item * flags_item;
+
+  if (tcp_track_bytes_in_flight) {
+    flags_item=proto_tree_add_uint(flags_tree,
+                               hf_tcp_analysis_bytes_in_flight,
+                               tvb, 0, 0, ta->bytes_in_flight);
+
+    PROTO_ITEM_SET_GENERATED(flags_item);
+  }
+}
+
 static void
 tcp_print_sequence_number_analysis(packet_info *pinfo, tvbuff_t *tvb, proto_tree *parent_tree, struct tcp_analysis *tcpd)
 {
@@ -1324,8 +1404,13 @@ tcp_print_sequence_number_analysis(packet_info *pinfo, tvbuff_t *tvb, proto_tree
                }
        }
 
+       if(ta->bytes_in_flight) {
+               /* print results for amount of data in flight */
+               tcp_sequence_number_analysis_print_bytes_in_flight(pinfo, tvb, tree, ta);
+       }
+
        if(ta->flags){
-               item = proto_tree_add_item(tree, hf_tcp_analysis_flags, tvb, 0, -1, FALSE);
+               item = proto_tree_add_item(tree, hf_tcp_analysis_flags, tvb, 0, 0, FALSE);
                PROTO_ITEM_SET_GENERATED(item);
                flags_tree=proto_item_add_subtree(item, ett_tcp_analysis);
 
@@ -1349,10 +1434,34 @@ tcp_print_sequence_number_analysis(packet_info *pinfo, tvbuff_t *tvb, proto_tree
 
                /* print results for tcp zero window  */
                tcp_sequence_number_analysis_print_zero_window(pinfo, tvb, flags_tree, ta);
+
        }
 
 }
 
+static void
+print_tcp_fragment_tree(fragment_data *ipfd_head, proto_tree *tree, proto_tree *tcp_tree, packet_info *pinfo, tvbuff_t *next_tvb)
+{
+       proto_item *tcp_tree_item, *frag_tree_item;
+
+       /*
+        * The subdissector thought it was completely
+        * desegmented (although the stuff at the
+        * end may, in turn, require desegmentation),
+        * so we show a tree with all segments.
+        */
+       show_fragment_tree(ipfd_head, &tcp_segment_items,
+               tree, pinfo, next_tvb, &frag_tree_item);
+       /*
+        * The toplevel fragment subtree is now
+        * behind all desegmented data; move it
+        * right behind the TCP tree.
+        */
+       tcp_tree_item = proto_tree_get_parent(tcp_tree);
+       if(frag_tree_item && tcp_tree_item) {
+               proto_tree_move_item(tree, tcp_tree_item, frag_tree_item);
+       }
+}
 
 /* **************************************************************************
  * End of tcp sequence number analysis
@@ -1360,25 +1469,29 @@ tcp_print_sequence_number_analysis(packet_info *pinfo, tvbuff_t *tvb, proto_tree
 
 
 /* Minimum TCP header length. */
-#define        TCPH_MIN_LEN    20
+#define TCPH_MIN_LEN            20
 
 /*
  *     TCP option
  */
 
-#define TCPOPT_NOP             1       /* Padding */
-#define TCPOPT_EOL             0       /* End of options */
-#define TCPOPT_MSS             2       /* Segment size negotiating */
-#define TCPOPT_WINDOW          3       /* Window scaling */
+#define TCPOPT_NOP              1       /* Padding */
+#define TCPOPT_EOL              0       /* End of options */
+#define TCPOPT_MSS              2       /* Segment size negotiating */
+#define TCPOPT_WINDOW           3       /* Window scaling */
 #define TCPOPT_SACK_PERM        4       /* SACK Permitted */
 #define TCPOPT_SACK             5       /* SACK Block */
 #define TCPOPT_ECHO             6
 #define TCPOPT_ECHOREPLY        7
-#define TCPOPT_TIMESTAMP       8       /* Better RTT estimations/PAWS */
+#define TCPOPT_TIMESTAMP        8       /* Better RTT estimations/PAWS */
 #define TCPOPT_CC               11
 #define TCPOPT_CCNEW            12
 #define TCPOPT_CCECHO           13
 #define TCPOPT_MD5              19      /* RFC2385 */
+#define TCPOPT_SCPS             20      /* SCPS Capabilities */
+#define TCPOPT_SNACK            21      /* SCPS SNACK */
+#define TCPOPT_RECBOUND         22      /* SCPS Record Boundary */
+#define TCPOPT_CORREXP          23      /* SCPS Corruption Experienced */
 #define TCPOPT_QS               27      /* RFC4782 */
 
 /*
@@ -1396,6 +1509,10 @@ tcp_print_sequence_number_analysis(packet_info *pinfo, tvbuff_t *tvb, proto_tree
 #define TCPOLEN_CCNEW          6
 #define TCPOLEN_CCECHO         6
 #define TCPOLEN_MD5            18
+#define TCPOLEN_SCPS           4
+#define TCPOLEN_SNACK          6
+#define TCPOLEN_RECBOUND       2
+#define TCPOLEN_CORREXP        2
 #define TCPOLEN_QS             8
 
 
@@ -1422,6 +1539,7 @@ desegment_tcp(tvbuff_t *tvb, packet_info *pinfo, int offset,
 {
        struct tcpinfo *tcpinfo = pinfo->private_data;
        fragment_data *ipfd_head;
+       int last_fragment_len;
        gboolean must_desegment;
        gboolean called_dissector;
        int another_pdu_follows;
@@ -1429,12 +1547,11 @@ desegment_tcp(tvbuff_t *tvb, packet_info *pinfo, int offset,
        guint32 deseg_seq;
        gint nbytes;
        proto_item *item;
-       proto_item *frag_tree_item;
-       proto_item *tcp_tree_item;
-        struct tcp_multisegment_pdu *msp;
+       struct tcp_multisegment_pdu *msp;
 
 again:
        ipfd_head=NULL;
+       last_fragment_len=0;
        must_desegment = FALSE;
        called_dissector = FALSE;
        another_pdu_follows = 0;
@@ -1477,6 +1594,7 @@ again:
                } else {
                        len=MIN(nxtseq, msp->nxtpdu) - seq;
                }
+               last_fragment_len = len;
 
                ipfd_head = fragment_add(tvb, offset, pinfo, msp->first_frame,
                        tcp_fragment_table,
@@ -1557,11 +1675,9 @@ again:
                        int old_len;
 
                        /* create a new TVB structure for desegmented data */
-                       next_tvb = tvb_new_real_data(ipfd_head->data,
+                       next_tvb = tvb_new_child_real_data(tvb, ipfd_head->data,
                                        ipfd_head->datalen, ipfd_head->datalen);
 
-                       /* add this tvb as a child to the original one */
-                       tvb_set_child_real_data_tvbuff(tvb, next_tvb);
 
                        /* add desegmented data to the data source list */
                        add_new_data_source(pinfo, next_tvb, "Reassembled TCP");
@@ -1585,7 +1701,7 @@ again:
                         * desegmented, or does it think we need even more
                         * data?
                         */
-                       old_len=(int)(tvb_reported_length(next_tvb)-tvb_reported_length_remaining(tvb, offset));
+                       old_len=(int)(tvb_reported_length(next_tvb)-last_fragment_len);
                        if(pinfo->desegment_len &&
                            pinfo->desegment_offset<=old_len){
                                /*
@@ -1615,13 +1731,17 @@ again:
                                        msp->nxtpdu=seq+tvb_reported_length_remaining(tvb, offset) + 1;
                                        msp->flags|=MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT;
                                } else {
-                                       msp->nxtpdu=seq+tvb_reported_length_remaining(tvb, offset) + pinfo->desegment_len;
+                                       msp->nxtpdu=seq + last_fragment_len + pinfo->desegment_len;
                                }
                                /* Since we need at least some more data
                                 * there can be no pdu following in the
                                 * tail of this segment.
                                 */
                                another_pdu_follows=0;
+                               offset += last_fragment_len;
+                               seq += last_fragment_len;
+                               if (tvb_length_remaining(tvb, offset) > 0)
+                                       goto again;
                        } else {
                                /*
                                 * Show the stuff in this TCP segment as
@@ -1634,23 +1754,7 @@ again:
                                    "TCP segment data (%u byte%s)", nbytes,
                                    plurality(nbytes, "", "s"));
 
-                               /*
-                                * The subdissector thought it was completely
-                                * desegmented (although the stuff at the
-                                * end may, in turn, require desegmentation),
-                                * so we show a tree with all segments.
-                                */
-                               show_fragment_tree(ipfd_head, &tcp_segment_items,
-                                       tree, pinfo, next_tvb, &frag_tree_item);
-                               /*
-                                * The toplevel fragment subtree is now
-                                * behind all desegmented data; move it
-                                * right behind the TCP tree.
-                                */
-                               tcp_tree_item = proto_tree_get_parent(tcp_tree);
-                               if(frag_tree_item && tcp_tree_item) {
-                                       proto_tree_move_item(tree, tcp_tree_item, frag_tree_item);
-                               }
+                               print_tcp_fragment_tree(ipfd_head, tree, tcp_tree, pinfo, next_tvb);
 
                                /* Did the subdissector ask us to desegment
                                   some more data?  This means that the data
@@ -1786,12 +1890,8 @@ again:
                         * of the payload, and that's 0).
                         * Just mark this as TCP.
                         */
-                       if (check_col(pinfo->cinfo, COL_PROTOCOL)){
-                               col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCP");
-                       }
-                       if (check_col(pinfo->cinfo, COL_INFO)){
-                               col_set_str(pinfo->cinfo, COL_INFO, "[TCP segment of a reassembled PDU]");
-                       }
+                       col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCP");
+                       col_set_str(pinfo->cinfo, COL_INFO, "[TCP segment of a reassembled PDU]");
                }
 
                /*
@@ -1887,7 +1987,7 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
         * need, and return.
         */
        pinfo->desegment_offset = offset;
-       pinfo->desegment_len = fixed_len - length_remaining;
+       pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
        return;
       }
     }
@@ -1918,7 +2018,7 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
     /*
      * Display the PDU length as a field
      */
-    item=proto_tree_add_uint(pinfo->tcp_tree, hf_tcp_pdu_size, tvb, 0, 0, plen);
+    item=proto_tree_add_uint(pinfo->tcp_tree, hf_tcp_pdu_size, tvb, offset, plen, plen);
     PROTO_ITEM_SET_GENERATED(item);
 
 
@@ -1970,7 +2070,7 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
      */
     length = length_remaining;
     if (length > plen)
-       length = plen;
+        length = plen;
     next_tvb = tvb_new_subset(tvb, offset, length, plen);
 
     /*
@@ -2013,6 +2113,14 @@ tcp_info_append_uint(packet_info *pinfo, const char *abbrev, guint32 val)
     col_append_fstr(pinfo->cinfo, COL_INFO, " %s=%u", abbrev, val);
 }
 
+/* Supports the reporting the contents of a parsed SCPS capabilities vector */
+static void
+tcp_info_append_str(packet_info *pinfo, const char *abbrev, const char *val)
+{
+  if (check_col(pinfo->cinfo, COL_INFO))
+    col_append_fstr(pinfo->cinfo, COL_INFO, " %s[%s]", abbrev, val);
+}
+
 static void
 dissect_tcpopt_maxseg(const ip_tcp_opt *optp, tvbuff_t *tvb,
     int offset, guint optlen, packet_info *pinfo, proto_tree *opt_tree)
@@ -2037,7 +2145,7 @@ dissect_tcpopt_wscale(const ip_tcp_opt *optp, tvbuff_t *tvb,
   guint8 ws;
   struct tcp_analysis *tcpd=NULL;
 
-  tcpd=get_tcp_conversation_data(pinfo);
+  tcpd=get_tcp_conversation_data(NULL,pinfo);
 
   ws = tvb_get_guint8(tvb, offset + 2);
   hidden_item = proto_tree_add_boolean(opt_tree, hf_tcp_option_wscale, tvb,
@@ -2065,7 +2173,7 @@ dissect_tcpopt_sack(const ip_tcp_opt *optp, tvbuff_t *tvb,
 
   if(tcp_analyze_seq && tcp_relative_seq){
     /* find(or create if needed) the conversation for this tcp session */
-    tcpd=get_tcp_conversation_data(pinfo);
+    tcpd=get_tcp_conversation_data(NULL,pinfo);
 
     if (tcpd) {
       base_ack=tcpd->rev->base_seq;
@@ -2203,6 +2311,286 @@ dissect_tcpopt_qs(const ip_tcp_opt *optp, tvbuff_t *tvb,
     col_append_fstr(pinfo->cinfo, COL_INFO, " QSresp=%s", val_to_str(rate, qs_rates, "Unknown"));
 }
 
+
+static void
+dissect_tcpopt_scps(const ip_tcp_opt *optp, tvbuff_t *tvb,
+                   int offset, guint optlen, packet_info *pinfo,
+                   proto_tree *opt_tree)
+{
+  struct tcp_analysis *tcpd=NULL;
+  proto_tree *field_tree = NULL;
+  tcp_flow_t *flow;
+  int         direction;
+  proto_item *tf = NULL, *hidden_item;
+  gchar       flags[64] = "<None>";
+  gchar      *fstr[] = {"BETS", "SNACK1", "SNACK2", "COMP", "NLTS", "RESV1", "RESV2", "RESV3"};
+  gint        i, bpos;
+  guint8      capvector;
+  guint8      connid;
+
+  tcpd = get_tcp_conversation_data(NULL,pinfo);
+
+  /* check direction and get ua lists */
+  direction=CMP_ADDRESS(&pinfo->src, &pinfo->dst);
+
+  /* if the addresses are equal, match the ports instead */
+  if(direction==0) {
+    direction= (pinfo->srcport > pinfo->destport) ? 1 : -1;
+  }
+
+  if(direction>=0)
+    flow =&(tcpd->flow1);
+  else
+    flow =&(tcpd->flow2);
+
+  /* If the option length == 4, this is a real SCPS capability option
+   * See "CCSDS 714.0-B-2 (CCSDS Recommended Standard for SCPS Transport Protocol
+   * (SCPS-TP)" Section 3.2.3 for definition.
+   */
+  if (optlen == 4) {
+    capvector = tvb_get_guint8(tvb, offset + 2);
+    flags[0] = '\0';
+
+    /* Decode the capabilities vector for display */
+    for (i = 0; i < 5; i++) {
+      bpos = 128 >> i;
+      if (capvector & bpos) {
+               if (flags[0]) {
+                 g_strlcat(flags, ", ", 64);
+               }
+               g_strlcat(flags, fstr[i], 64);
+      }
+    }
+
+    /* If lossless header compression is offered, there will be a
+     * single octet connectionId following the capabilities vector
+     */
+    if (capvector & 0x10)
+      connid    = tvb_get_guint8(tvb, offset + 3);
+    else
+      connid    = 0;
+
+    tf = proto_tree_add_uint_format(opt_tree, hf_tcp_option_scps_vector, tvb,
+                                   offset, optlen, capvector,
+                                   "%s: 0x%02x (%s)",
+                                   optp->name, capvector, flags);
+    hidden_item = proto_tree_add_boolean(opt_tree, hf_tcp_option_scps,
+                                       tvb, offset, optlen, TRUE);
+    PROTO_ITEM_SET_HIDDEN(hidden_item);
+
+    field_tree = proto_item_add_subtree(tf, ett_tcp_option_scps);
+
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_bets, tvb,
+                          offset + 13, 1, capvector);
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_snack1, tvb,
+                          offset + 13, 1, capvector);
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_snack2, tvb,
+                          offset + 13, 1, capvector);
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_compress, tvb,
+                          offset + 13, 1, capvector);
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_nlts, tvb,
+                          offset + 13, 1, capvector);
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_resv1, tvb,
+                          offset + 13, 1, capvector);
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_resv2, tvb,
+                          offset + 13, 1, capvector);
+    proto_tree_add_boolean(field_tree, hf_tcp_scpsoption_flags_resv3, tvb,
+                          offset + 13, 1, capvector);
+
+    tcp_info_append_str(pinfo, "SCPS", flags);
+
+    flow->scps_capable = 1;
+
+    if (connid)
+      tcp_info_append_uint(pinfo, "Connection ID", connid);
+  }
+  else {
+    /* The option length != 4, so this is an infamous "extended capabilities
+     * option. See "CCSDS 714.0-B-2 (CCSDS Recommended Standard for SCPS
+     * Transport Protocol (SCPS-TP)" Section 3.2.5 for definition.
+     *
+     *  As the format of this option is only partially defined (it is
+     * a community (or more likely vendor) defined format beyond that, so
+     * at least for now, we only parse the standardized portion of the option.
+     */
+    guint8 local_offset = 2;
+    guint8 binding_space;
+    guint8 extended_cap_length;
+
+    if (flow->scps_capable != 1) {
+      /* There was no SCPS capabilities option preceeding this */
+      tf = proto_tree_add_uint_format(opt_tree, hf_tcp_option_scps_vector,
+                                     tvb, offset, optlen, 0, "%s: (%d %s)",
+                                     "Illegal SCPS Extended Capabilities",
+                                     (optlen),
+                                     "bytes");
+    }
+    else {
+      tf = proto_tree_add_uint_format(opt_tree, hf_tcp_option_scps_vector,
+                                     tvb, offset, optlen, 0, "%s: (%d %s)",
+                                     "SCPS Extended Capabilities",
+                                     (optlen),
+                                     "bytes");
+      field_tree=proto_item_add_subtree(tf, ett_tcp_option_scps_extended);
+      /* There may be multiple binding spaces included in a single option,
+       * so we will semi-parse each of the stacked binding spaces - skipping
+       * over the octets following the binding space identifier and length.
+       */
+
+      while (optlen > local_offset) {
+                 proto_item *hidden_item;
+
+       /* 1st octet is Extended Capability Binding Space */
+       binding_space = tvb_get_guint8(tvb, (offset + local_offset));
+
+       /* 2nd octet (upper 4-bits) has binding space length in 16-bit words.
+        * As defined by the specification, this length is exclusive of the
+        * octets containing the extended capability type and length
+        */
+
+       extended_cap_length =
+         (tvb_get_guint8(tvb, (offset + local_offset + 1)) >> 4);
+
+       /* Convert the extended capabilities length into bytes for display */
+       extended_cap_length = (extended_cap_length << 1);
+
+       proto_tree_add_text(field_tree, tvb, offset + local_offset, 2,
+                           "\tBinding Space %u",
+                           binding_space);
+       hidden_item = proto_tree_add_uint(field_tree, hf_tcp_option_scps_binding,
+                                  tvb, (offset + local_offset), 1,
+                                  binding_space);
+
+       PROTO_ITEM_SET_HIDDEN(hidden_item);
+
+       /* Step past the binding space and length octets */
+       local_offset += 2;
+
+       proto_tree_add_text(field_tree, tvb, offset + local_offset,
+                           extended_cap_length,
+                           "\tBinding Space Data (%u bytes)",
+                           extended_cap_length);
+
+       tcp_info_append_uint(pinfo, "EXCAP", binding_space);
+
+       /* Step past the Extended capability data
+        * Treat the extended capability data area as opaque;
+        * If one desires to parse the extended capability data
+        * (say, in a vendor aware build of wireshark), it would
+        * be trigged here.
+        */
+       local_offset += extended_cap_length;
+      }
+    }
+  }
+}
+
+/* This is called for SYN+ACK packets and the purpose is to verify that
+ * the SCPS capabilities option has been successfully negotiated for the flow.
+ * If the SCPS capabilities option was offered by only one party, the
+ * proactively set scps_capable attribute of the flow (set upon seeing
+ * the first instance of the SCPS option) is revoked.
+ */
+static void
+verify_scps(packet_info *pinfo,  proto_item *tf_syn, struct tcp_analysis *tcpd)
+{
+  tf_syn = 0x0;
+
+  if(tcpd) {
+    if ((!(tcpd->flow1.scps_capable)) || (!(tcpd->flow2.scps_capable))) {
+      tcpd->flow1.scps_capable = 0;
+      tcpd->flow2.scps_capable = 0;
+    }
+    else {
+      expert_add_info_format(pinfo, tf_syn, PI_SEQUENCE, PI_NOTE,
+                            "Connection establish request (SYN-ACK): SCPS Capabilities Negotiated");
+    }
+  }
+}
+
+/* See "CCSDS 714.0-B-2 (CCSDS Recommended Standard for SCPS
+ * Transport Protocol (SCPS-TP)" Section 3.5 for definition of the SNACK option
+ */
+static void
+dissect_tcpopt_snack(const ip_tcp_opt *optp, tvbuff_t *tvb,
+                   int offset, guint optlen, packet_info *pinfo,
+                   proto_tree *opt_tree)
+{
+  struct tcp_analysis *tcpd=NULL;
+  guint16 relative_hole_offset;
+  guint16 relative_hole_size;
+  guint16 base_mss = 0;
+  guint32 ack;
+  guint32 hole_start;
+  guint32 hole_end;
+  char    null_modifier[] = "\0";
+  char    relative_modifier[] = "(relative)";
+  char   *modifier = null_modifier;
+  proto_item *hidden_item;
+
+  tcpd = get_tcp_conversation_data(NULL,pinfo);
+
+  /* The SNACK option reports missing data with a granualarity of segments. */
+  relative_hole_offset = tvb_get_ntohs(tvb, offset + 2);
+  relative_hole_size = tvb_get_ntohs(tvb, offset + 4);
+
+  hidden_item = proto_tree_add_boolean(opt_tree, hf_tcp_option_snack, tvb,
+                               offset, optlen, TRUE);
+  PROTO_ITEM_SET_HIDDEN(hidden_item);
+
+  hidden_item = proto_tree_add_uint(opt_tree, hf_tcp_option_snack_offset,
+                              tvb, offset, optlen, relative_hole_offset);
+  PROTO_ITEM_SET_HIDDEN(hidden_item);
+
+  hidden_item = proto_tree_add_uint(opt_tree, hf_tcp_option_snack_size,
+                              tvb, offset, optlen, relative_hole_size);
+  PROTO_ITEM_SET_HIDDEN(hidden_item);
+  proto_tree_add_text(opt_tree, tvb, offset, optlen,
+                     "%s: Offset %u, Size %u", optp->name,
+                     relative_hole_offset, relative_hole_size);
+
+  ack   = tvb_get_ntohl(tvb, 8);
+
+  if (tcp_relative_seq) {
+    ack -= tcpd->rev->base_seq;
+    modifier = relative_modifier;
+  }
+
+  /* To aid analysis, we can use a simple but generally effective heuristic
+   * to report the most likely boundaries of the missing data.  If the
+   * flow is scps_capable, we track the maximum sized segment that was
+   * acknowledged by the receiver and use that as the reporting granularity.
+   * This may be different from the negotiated MTU due to PMTUD or flows
+   * that do not send max-sized segments.
+   */
+  base_mss = tcpd->fwd->maxsizeacked;
+
+  if (base_mss) {
+    proto_item *hidden_item;
+    /* Scale the reported offset and hole size by the largest segment acked */
+    hole_start = ack + (base_mss * relative_hole_offset);
+    hole_end   = hole_start + (base_mss * relative_hole_size);
+
+    hidden_item = proto_tree_add_uint(opt_tree, hf_tcp_option_snack_le,
+                              tvb, offset, optlen, hole_start);
+       PROTO_ITEM_SET_HIDDEN(hidden_item);
+
+    hidden_item = proto_tree_add_uint(opt_tree, hf_tcp_option_snack_re,
+                              tvb, offset, optlen, hole_end);
+       PROTO_ITEM_SET_HIDDEN(hidden_item);
+    proto_tree_add_text(opt_tree, tvb, offset, optlen,
+                       "\tMissing Sequence %u - %u %s",
+                       hole_start, hole_end, modifier);
+
+    tcp_info_append_uint(pinfo, "SNLE", hole_start);
+    tcp_info_append_uint(pinfo, "SNRE", hole_end);
+
+    expert_add_info_format(pinfo, NULL, PI_SEQUENCE, PI_NOTE,
+                          "SNACK Sequence %u - %u %s",
+                          hole_start, hole_end, modifier);
+  }
+}
+
 static const ip_tcp_opt tcpopts[] = {
   {
     TCPOPT_EOL,
@@ -2308,6 +2696,38 @@ static const ip_tcp_opt tcpopts[] = {
     TCPOLEN_MD5,
     NULL
   },
+  {
+    TCPOPT_SCPS,
+    "SCPS capabilities",
+    &ett_tcp_option_scps,
+    VARIABLE_LENGTH,
+    TCPOLEN_SCPS,
+    dissect_tcpopt_scps
+  },
+  {
+    TCPOPT_SNACK,
+    "Selective Negative Acknowledgement",
+    NULL,
+    FIXED_LENGTH,
+    TCPOLEN_SNACK,
+    dissect_tcpopt_snack
+  },
+  {
+    TCPOPT_RECBOUND,
+    "SCPS record boundary",
+    NULL,
+    FIXED_LENGTH,
+    TCPOLEN_RECBOUND,
+    NULL
+  },
+  {
+    TCPOPT_CORREXP,
+    "SCPS corruption experienced",
+    NULL,
+    FIXED_LENGTH,
+    TCPOLEN_CORREXP,
+    NULL
+  },
   {
     TCPOPT_QS,
     "Quick-Start",
@@ -2479,7 +2899,7 @@ process_tcp_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo,
                                        if(seq || nxtseq){
                                                pdu_store_sequencenumber_of_next_pdu(
                                                    pinfo,
-                                                   seq,
+                                                   seq,
                                                    nxtseq+pinfo->bytes_until_next_pdu,
                                                    tcpd->fwd->multisegment_pdus);
                                        }
@@ -2508,7 +2928,7 @@ process_tcp_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo,
                        if(tcpd && (!pinfo->fd->flags.visited) && tcp_analyze_seq && pinfo->want_pdu_tracking){
                                if(seq || nxtseq){
                                        pdu_store_sequencenumber_of_next_pdu(pinfo,
-                                           seq,
+                                           seq,
                                            nxtseq+pinfo->bytes_until_next_pdu,
                                            tcpd->fwd->multisegment_pdus);
                                }
@@ -2553,9 +2973,8 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   proto_tree *tcp_tree = NULL, *field_tree = NULL;
   proto_item *ti = NULL, *tf, *hidden_item;
   int        offset = 0;
-  gchar      *flags = "<None>";
-  const gchar *fstr[] = {"FIN", "SYN", "RST", "PSH", "ACK", "URG", "ECN", "CWR" };
-  size_t     fpos = 0, returned_length;
+  emem_strbuf_t *flags_strbuf = ep_strbuf_new_label("<None>");
+  const gchar *fstr[] = {"FIN", "SYN", "RST", "PSH", "ACK", "URG", "ECN", "CWR"};
   gint       i;
   guint      bpos;
   guint      optlen;
@@ -2570,6 +2989,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   struct tcpinfo tcpinfo;
   struct tcpheader *tcph;
   proto_item *tf_syn = NULL, *tf_fin = NULL, *tf_rst = NULL;
+  conversation_t *conv=NULL;
   struct tcp_analysis *tcpd=NULL;
   struct tcp_per_packet_data_t *tcppd=NULL;
   proto_item *item;
@@ -2581,12 +3001,10 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   SET_ADDRESS(&tcph->ip_src, pinfo->src.type, pinfo->src.len, pinfo->src.data);
   SET_ADDRESS(&tcph->ip_dst, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
 
-  if (check_col(pinfo->cinfo, COL_PROTOCOL))
-    col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCP");
+  col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCP");
 
   /* Clear out the Info column. */
-  if (check_col(pinfo->cinfo, COL_INFO))
-    col_clear(pinfo->cinfo, COL_INFO);
+  col_clear(pinfo->cinfo, COL_INFO);
 
   tcph->th_sport = tvb_get_ntohs(tvb, offset);
   tcph->th_dport = tvb_get_ntohs(tvb, offset + 2);
@@ -2629,7 +3047,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        *  g_str_has_suffix in glib2.2
        */
       if (strstr(pinfo->layer_names->str, "icmp:ip") != NULL)
-       proto_tree_add_item(tcp_tree, hf_tcp_seq, tvb, offset + 4, 4, FALSE);
+               proto_tree_add_item(tcp_tree, hf_tcp_seq, tvb, offset + 4, 4, FALSE);
     }
   }
 
@@ -2649,7 +3067,11 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   tcph->th_hlen = hi_nibble(th_off_x2) * 4;  /* TCP header length, in bytes */
 
   /* find(or create if needed) the conversation for this tcp session */
-  tcpd=get_tcp_conversation_data(pinfo);
+  conv=get_tcp_conversation(pinfo);
+  tcpd=get_tcp_conversation_data(conv,pinfo);
+
+  item = proto_tree_add_uint(tcp_tree, hf_tcp_stream, tvb, offset, 0, conv->index);
+  PROTO_ITEM_SET_GENERATED(item);
 
   /* If this is a SYN packet, then check if it's seq-nr is different
    * from the base_seq of the retrieved conversation. If this is the
@@ -2661,8 +3083,10 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   if(tcpd && ((tcph->th_flags&(TH_SYN|TH_ACK))==TH_SYN) &&
       (tcpd->fwd->base_seq!=0) &&
       (tcph->th_seq!=tcpd->fwd->base_seq) ) {
-    if (!(pinfo->fd->flags.visited))
-      tcpd=new_tcp_conversation(pinfo);
+    if (!(pinfo->fd->flags.visited)) {
+      conv=conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+      tcpd=get_tcp_conversation_data(conv,pinfo);
+    }
     if(!tcpd->ta)
       tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE, tcpd);
     tcpd->ta->flags|=TCP_A_REUSED_PORTS;
@@ -2671,6 +3095,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   /* Do we need to calculate timestamps relative to the tcp-stream? */
   if (tcp_calculate_ts) {
+    tcppd = p_get_proto_data(pinfo->fd, proto_tcp);
 
     /*
      * Calculate the timestamps relative to this conversation (but only on the
@@ -2679,7 +3104,6 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     if (!(pinfo->fd->flags.visited))
       tcp_calculate_timestamps(pinfo, tcpd, tcppd);
 
-
     /* Fill the conversation timestamp columns */
     if (tcpd && check_col(pinfo->cinfo, COL_REL_CONV_TIME)) {
       nstime_delta(&ts, &pinfo->fd->abs_ts, &tcpd->ts_first);
@@ -2687,9 +3111,6 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     }
 
     if (check_col(pinfo->cinfo, COL_DELTA_CONV_TIME)) {
-      if( !tcppd )
-       tcppd = p_get_proto_data(pinfo->fd, proto_tcp);
-
       if( tcppd )
         col_set_time(pinfo->cinfo, COL_DELTA_CONV_TIME, &tcppd->ts_del, "tcp.time_delta");
     }
@@ -2729,7 +3150,8 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
       if (tree) { /* Add the seglen as an invisible field */
 
-        proto_tree_add_uint_hidden(ti, hf_tcp_len, tvb, offset, 4, tcph->th_seglen);
+        hidden_item = proto_tree_add_uint(ti, hf_tcp_len, tvb, offset+12, 1, tcph->th_seglen);
+               PROTO_ITEM_SET_HIDDEN(hidden_item);
 
       }
 
@@ -2751,22 +3173,21 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     tcph->th_have_seglen = FALSE;
 
   if (check_col(pinfo->cinfo, COL_INFO) || tree) {
-#define MAX_FLAGS_LEN 64
-    flags=ep_alloc(MAX_FLAGS_LEN);
-    flags[0]=0;
+    gboolean first_flag = TRUE;
     for (i = 0; i < 8; i++) {
       bpos = 1 << i;
       if (tcph->th_flags & bpos) {
-        returned_length = g_snprintf(&flags[fpos], MAX_FLAGS_LEN-fpos, "%s%s",
-               fpos?", ":"",
-               fstr[i]);
-       fpos += MIN(returned_length, MAX_FLAGS_LEN-fpos);
+        if (first_flag) {
+          ep_strbuf_truncate(flags_strbuf, 0);
+        }
+        ep_strbuf_append_printf(flags_strbuf, "%s%s", first_flag ? "" : ", ", fstr[i]);
+        first_flag = FALSE;
       }
     }
   }
 
   if (check_col(pinfo->cinfo, COL_INFO)) {
-    col_append_fstr(pinfo->cinfo, COL_INFO, " [%s] Seq=%u", flags, tcph->th_seq);
+    col_append_fstr(pinfo->cinfo, COL_INFO, " [%s] Seq=%u", flags_strbuf->str, tcph->th_seq);
     if (tcph->th_flags&TH_ACK) {
       col_append_fstr(pinfo->cinfo, COL_INFO, " Ack=%u", tcph->th_ack);
     }
@@ -2832,13 +3253,13 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     } else {
       /* Verify that the ACK field is zero */
       if(tvb_get_ntohl(tvb, offset+8) != 0){
-       proto_tree_add_text(tcp_tree, tvb, offset+8, 4,"Acknowledgment number: Broken TCP. The acknowledge field is nonzero while the ACK flag is not set");
+       proto_tree_add_text(tcp_tree, tvb, offset+8, 4,"Acknowledgement number: Broken TCP. The acknowledge field is nonzero while the ACK flag is not set");
       }
     }
     proto_tree_add_uint_format(tcp_tree, hf_tcp_hdr_len, tvb, offset + 12, 1, tcph->th_hlen,
        "Header length: %u bytes", tcph->th_hlen);
     tf = proto_tree_add_uint_format(tcp_tree, hf_tcp_flags, tvb, offset + 13, 1,
-       tcph->th_flags, "Flags: 0x%02x (%s)", tcph->th_flags, flags);
+       tcph->th_flags, "Flags: 0x%02x (%s)", tcph->th_flags, flags_strbuf->str);
     field_tree = proto_item_add_subtree(tf, ett_tcp_flags);
     proto_tree_add_boolean(field_tree, hf_tcp_flags_cwr, tvb, offset + 13, 1, tcph->th_flags);
     proto_tree_add_boolean(field_tree, hf_tcp_flags_ecn, tvb, offset + 13, 1, tcph->th_flags);
@@ -2903,7 +3324,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
       cksum_vec[0].len = pinfo->src.len;
       cksum_vec[1].ptr = pinfo->dst.data;
       cksum_vec[1].len = pinfo->dst.len;
-      cksum_vec[2].ptr = (const guint8 *)&phdr;
+      cksum_vec[2].ptr = (const guint8 *)phdr;
       switch (pinfo->src.type) {
 
       case AT_IPv4:
@@ -2924,7 +3345,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
       }
       cksum_vec[3].ptr = tvb_get_ptr(tvb, offset, reported_len);
       cksum_vec[3].len = reported_len;
-      computed_cksum = in_cksum(&cksum_vec[0], 4);
+      computed_cksum = in_cksum(cksum_vec, 4);
       if (computed_cksum == 0 && th_sum == 0xffff) {
         item = proto_tree_add_uint_format(tcp_tree, hf_tcp_checksum, tvb,
            offset + 16, 2, th_sum,
@@ -3033,10 +3454,10 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     if (tcp_desegment) {
       /* Yes - is this segment being returned in an error packet? */
       if (!pinfo->in_error_pkt) {
-       /* No - indicate that we will desegment.
-          We do NOT want to desegment segments returned in error
-          packets, as they're not part of a TCP connection. */
-       pinfo->can_desegment = 2;
+               /* No - indicate that we will desegment.
+                  We do NOT want to desegment segments returned in error
+                  packets, as they're not part of a TCP connection. */
+               pinfo->can_desegment = 2;
       }
     }
   }
@@ -3076,13 +3497,21 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
       tcpopts, N_TCP_OPTS, TCPOPT_EOL, pinfo, field_tree);
   }
 
-  /* If there was window scaling in the SYN packet but none in the SYN+ACK
-   * then we should just forget about the windowscaling completely.
-   */
   if(!pinfo->fd->flags.visited){
-    if(tcp_analyze_seq && tcp_relative_seq){
-      if((tcph->th_flags & (TH_SYN|TH_ACK))==(TH_SYN|TH_ACK)) {
-        verify_tcp_window_scaling(tcpd);
+    if((tcph->th_flags & (TH_SYN|TH_ACK))==(TH_SYN|TH_ACK)) {
+      /* If there was window scaling in the SYN packet but none in the SYN+ACK
+       * then we should just forget about the windowscaling completely.
+       */
+      if(tcp_analyze_seq && tcp_relative_seq){
+               verify_tcp_window_scaling(tcpd);
+      }
+      /* If the SYN or the SYN+ACK offered SCPS capabilities,
+       * validate the flow's bidirectional scps capabilities.
+       * The or protects against broken implementations offering
+       * SCPS capabilities on SYN+ACK even if it wasn't offered with the SYN
+       */
+      if(tcpd && ((tcpd->rev->scps_capable) || (tcpd->fwd->scps_capable))) {
+               verify_scps(pinfo, tf_syn, tcpd);
       }
     }
   }
@@ -3142,11 +3571,10 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
       if(ipfd_head){
         tvbuff_t *next_tvb;
 
-        /* create a new TVB structure for desegmented data */
-        next_tvb = tvb_new_real_data(ipfd_head->data, ipfd_head->datalen, ipfd_head->datalen);
-
-        /* add this tvb as a child to the original one */
-        tvb_set_child_real_data_tvbuff(tvb, next_tvb);
+        /* create a new TVB structure for desegmented data
+         * datalen-1 to strip the dummy FIN byte off
+         */
+        next_tvb = tvb_new_child_real_data(tvb, ipfd_head->data, ipfd_head->datalen, ipfd_head->datalen);
 
         /* add desegmented data to the data source list */
         add_new_data_source(pinfo, next_tvb, "Reassembled TCP");
@@ -3154,15 +3582,43 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         /* call the payload dissector
          * but make sure we don't offer desegmentation any more
          */
-       pinfo->can_desegment = 0;
+        pinfo->can_desegment = 0;
 
         process_tcp_payload(next_tvb, 0, pinfo, tree, tcp_tree, tcph->th_sport, tcph->th_dport, tcph->th_seq, nxtseq, FALSE, tcpd);
 
+        print_tcp_fragment_tree(ipfd_head, tree, tcp_tree, pinfo, next_tvb);
+
         return;
       }
     }
   }
 
+  if (tcpd && (tcpd->fwd || tcpd->rev) && (tcpd->fwd->command || tcpd->rev->command)) {
+    ti = proto_tree_add_text(tcp_tree, tvb, offset, 0, "Process Information");
+       PROTO_ITEM_SET_GENERATED(ti);
+    field_tree = proto_item_add_subtree(ti, ett_tcp_process_info);
+       if (tcpd->fwd->command) {
+      proto_tree_add_uint_format_value(field_tree, hf_tcp_proc_dst_uid, tvb, 0, 0,
+              tcpd->fwd->process_uid, "%u", tcpd->fwd->process_uid);
+      proto_tree_add_uint_format_value(field_tree, hf_tcp_proc_dst_pid, tvb, 0, 0,
+              tcpd->fwd->process_pid, "%u", tcpd->fwd->process_pid);
+      proto_tree_add_string_format_value(field_tree, hf_tcp_proc_dst_uname, tvb, 0, 0,
+              tcpd->fwd->username, "%s", tcpd->fwd->username);
+      proto_tree_add_string_format_value(field_tree, hf_tcp_proc_dst_cmd, tvb, 0, 0,
+              tcpd->fwd->command, "%s", tcpd->fwd->command);
+       }
+       if (tcpd->rev->command) {
+      proto_tree_add_uint_format_value(field_tree, hf_tcp_proc_src_uid, tvb, 0, 0,
+              tcpd->rev->process_uid, "%u", tcpd->rev->process_uid);
+      proto_tree_add_uint_format_value(field_tree, hf_tcp_proc_src_pid, tvb, 0, 0,
+              tcpd->rev->process_pid, "%u", tcpd->rev->process_pid);
+      proto_tree_add_string_format_value(field_tree, hf_tcp_proc_src_uname, tvb, 0, 0,
+              tcpd->rev->username, "%s", tcpd->rev->username);
+      proto_tree_add_string_format_value(field_tree, hf_tcp_proc_src_cmd, tvb, 0, 0,
+              tcpd->rev->command, "%s", tcpd->rev->command);
+       }
+  }
+
   /*
    * XXX - what, if any, of this should we do if this is included in an
    * error packet?  It might be nice to see the details of the packet
@@ -3204,72 +3660,76 @@ proto_register_tcp(void)
 
                { &hf_tcp_srcport,
                { "Source Port",                "tcp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_dstport,
                { "Destination Port",           "tcp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_port,
                { "Source or Destination Port", "tcp.port", FT_UINT16, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
+
+               { &hf_tcp_stream,
+               { "Stream index",               "tcp.stream", FT_UINT32, BASE_DEC, NULL, 0x0,
+                       NULL, HFILL }},
 
                { &hf_tcp_seq,
                { "Sequence number",            "tcp.seq", FT_UINT32, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_nxtseq,
                { "Next sequence number",       "tcp.nxtseq", FT_UINT32, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_ack,
                { "Acknowledgement number",     "tcp.ack", FT_UINT32, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_hdr_len,
                { "Header Length",              "tcp.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_flags,
                { "Flags",                      "tcp.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_cwr,
-               { "Congestion Window Reduced (CWR)",                    "tcp.flags.cwr", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_CWR,
-                       "", HFILL }},
+               { "Congestion Window Reduced (CWR)",                    "tcp.flags.cwr", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_CWR,
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_ecn,
-               { "ECN-Echo",                   "tcp.flags.ecn", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_ECN,
-                       "", HFILL }},
+               { "ECN-Echo",                   "tcp.flags.ecn", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_ECN,
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_urg,
-               { "Urgent",                     "tcp.flags.urg", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_URG,
-                       "", HFILL }},
+               { "Urgent",                     "tcp.flags.urg", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_URG,
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_ack,
-               { "Acknowledgment",             "tcp.flags.ack", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_ACK,
-                       "", HFILL }},
+               { "Acknowledgement",            "tcp.flags.ack", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_ACK,
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_push,
-               { "Push",                       "tcp.flags.push", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_PUSH,
-                       "", HFILL }},
+               { "Push",                       "tcp.flags.push", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_PUSH,
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_reset,
-               { "Reset",                      "tcp.flags.reset", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_RST,
-                       "", HFILL }},
+               { "Reset",                      "tcp.flags.reset", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_RST,
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_syn,
-               { "Syn",                        "tcp.flags.syn", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_SYN,
-                       "", HFILL }},
+               { "Syn",                        "tcp.flags.syn", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_SYN,
+                       NULL, HFILL }},
 
                { &hf_tcp_flags_fin,
-               { "Fin",                        "tcp.flags.fin", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_FIN,
-                       "", HFILL }},
+               { "Fin",                        "tcp.flags.fin", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_FIN,
+                       NULL, HFILL }},
 
                /* 32 bits so we can present some values adjusted to window scaling */
                { &hf_tcp_window_size,
                { "Window size",                "tcp.window_size", FT_UINT32, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_checksum,
                { "Checksum",                   "tcp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
@@ -3357,12 +3817,16 @@ proto_register_tcp(void)
 
                { &hf_tcp_len,
                  { "TCP Segment Len",            "tcp.len", FT_UINT32, BASE_DEC, NULL, 0x0,
-                   "", HFILL}},
+                   NULL, HFILL}},
 
                { &hf_tcp_analysis_acks_frame,
                  { "This is an ACK to the segment in frame",            "tcp.analysis.acks_frame", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
                    "Which previous segment is this an ACK for", HFILL}},
 
+               { &hf_tcp_analysis_bytes_in_flight,
+                 { "Number of bytes in flight",            "tcp.analysis.bytes_in_flight", FT_UINT32, BASE_DEC, NULL, 0x0,
+                   "How many bytes are now in flight for this connection", HFILL}},
+
                { &hf_tcp_analysis_ack_rtt,
                  { "The RTT to ACK the segment was",            "tcp.analysis.ack_rtt", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
                    "How long time it took to ACK the segment (RTT)", HFILL}},
@@ -3377,7 +3841,7 @@ proto_register_tcp(void)
 
                { &hf_tcp_urgent_pointer,
                { "Urgent pointer",             "tcp.urgent_pointer", FT_UINT16, BASE_DEC, NULL, 0x0,
-                       "", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_segment_overlap,
                { "Segment overlap",    "tcp.segment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
@@ -3401,7 +3865,7 @@ proto_register_tcp(void)
 
                { &hf_tcp_segment,
                { "TCP Segment", "tcp.segment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
-                       "TCP Segment", HFILL }},
+                       NULL, HFILL }},
 
                { &hf_tcp_segments,
                { "Reassembled TCP Segments", "tcp.segments", FT_NONE, BASE_NONE, NULL, 0x0,
@@ -3413,15 +3877,15 @@ proto_register_tcp(void)
 
                { &hf_tcp_options,
                  { "TCP Options", "tcp.options", FT_BYTES,
-                   BASE_HEX, NULL, 0x0, "TCP Options", HFILL }},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL }},
 
                { &hf_tcp_option_mss,
                  { "TCP MSS Option", "tcp.options.mss", FT_BOOLEAN,
-                   BASE_NONE, NULL, 0x0, "TCP MSS Option", HFILL }},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL }},
 
                { &hf_tcp_option_mss_val,
                  { "TCP MSS Option Value", "tcp.options.mss_val", FT_UINT16,
-                   BASE_DEC, NULL, 0x0, "TCP MSS Option Value", HFILL}},
+                   BASE_DEC, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_wscale,
                  { "TCP Window Scale Option", "tcp.options.wscale",
@@ -3436,19 +3900,19 @@ proto_register_tcp(void)
                { &hf_tcp_option_sack_perm,
                  { "TCP Sack Perm Option", "tcp.options.sack_perm",
                    FT_BOOLEAN,
-                   BASE_NONE, NULL, 0x0, "TCP Sack Perm Option", HFILL}},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_sack,
                  { "TCP Sack Option", "tcp.options.sack", FT_BOOLEAN,
-                   BASE_NONE, NULL, 0x0, "TCP Sack Option", HFILL}},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_sack_sle,
                  {"TCP Sack Left Edge", "tcp.options.sack_le", FT_UINT32,
-                  BASE_DEC, NULL, 0x0, "TCP Sack Left Edge", HFILL}},
+                  BASE_DEC, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_sack_sre,
                  {"TCP Sack Right Edge", "tcp.options.sack_re", FT_UINT32,
-                  BASE_DEC, NULL, 0x0, "TCP Sack Right Edge", HFILL}},
+                  BASE_DEC, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_echo,
                  { "TCP Echo Option", "tcp.options.echo", FT_BOOLEAN,
@@ -3457,32 +3921,114 @@ proto_register_tcp(void)
                { &hf_tcp_option_echo_reply,
                  { "TCP Echo Reply Option", "tcp.options.echo_reply",
                    FT_BOOLEAN,
-                   BASE_NONE, NULL, 0x0, "TCP Echo Reply Option", HFILL}},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_time_stamp,
                  { "TCP Time Stamp Option", "tcp.options.time_stamp",
                    FT_BOOLEAN,
-                   BASE_NONE, NULL, 0x0, "TCP Time Stamp Option", HFILL}},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_cc,
                  { "TCP CC Option", "tcp.options.cc", FT_BOOLEAN, BASE_NONE,
-                   NULL, 0x0, "TCP CC Option", HFILL}},
+                   NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_ccnew,
                  { "TCP CC New Option", "tcp.options.ccnew", FT_BOOLEAN,
-                   BASE_NONE, NULL, 0x0, "TCP CC New Option", HFILL}},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_ccecho,
                  { "TCP CC Echo Option", "tcp.options.ccecho", FT_BOOLEAN,
-                   BASE_NONE, NULL, 0x0, "TCP CC Echo Option", HFILL}},
+                   BASE_NONE, NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_md5,
                  { "TCP MD5 Option", "tcp.options.md5", FT_BOOLEAN, BASE_NONE,
-                   NULL, 0x0, "TCP MD5 Option", HFILL}},
+                   NULL, 0x0, NULL, HFILL}},
 
                { &hf_tcp_option_qs,
                  { "TCP QS Option", "tcp.options.qs", FT_BOOLEAN, BASE_NONE,
-                   NULL, 0x0, "TCP QS Option", HFILL}},
+                   NULL, 0x0, NULL, HFILL}},
+
+               { &hf_tcp_option_scps,
+                 { "TCP SCPS Capabilities Option", "tcp.options.scps",
+                   FT_BOOLEAN, BASE_NONE, NULL,  0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_option_scps_vector,
+                 { "TCP SCPS Capabilities Vector", "tcp.options.scps.vector",
+                   FT_UINT8, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_option_scps_binding,
+                 { "TCP SCPS Extended Binding Spacce",
+                   "tcp.options.scps.binding",
+                   FT_UINT8, BASE_DEC, NULL, 0x0,
+                   "TCP SCPS Extended Binding Space", HFILL}},
+
+               { &hf_tcp_option_snack,
+                 { "TCP Selective Negative Acknowledgement Option",
+                   "tcp.options.snack",
+                   FT_BOOLEAN, BASE_NONE, NULL,  0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_option_snack_offset,
+                 { "TCP SNACK Offset", "tcp.options.snack.offset",
+                   FT_UINT16, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_option_snack_size,
+                 { "TCP SNACK Size", "tcp.options.snack.size",
+                   FT_UINT16, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_option_snack_le,
+                 { "TCP SNACK Left Edge", "tcp.options.snack.le",
+                   FT_UINT16, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_option_snack_re,
+                 { "TCP SNACK Right Edge", "tcp.options.snack.re",
+                   FT_UINT16, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_scpsoption_flags_bets,
+                 { "Partial Reliability Capable (BETS)",
+                   "tcp.options.scpsflags.bets", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x80, NULL, HFILL }},
+
+               { &hf_tcp_scpsoption_flags_snack1,
+                 { "Short Form SNACK Capable (SNACK1)",
+                   "tcp.options.scpsflags.snack1", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x40, NULL, HFILL }},
+
+               { &hf_tcp_scpsoption_flags_snack2,
+                 { "Long Form SNACK Capable (SNACK2)",
+                   "tcp.options.scpsflags.snack2", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x20, NULL, HFILL }},
+
+               { &hf_tcp_scpsoption_flags_compress,
+                 { "Lossless Header Compression (COMP)",
+                   "tcp.options.scpsflags.compress", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x10, NULL, HFILL }},
+
+               { &hf_tcp_scpsoption_flags_nlts,
+                 { "Network Layer Timestamp (NLTS)",
+                   "tcp.options.scpsflags.nlts", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x8, NULL, HFILL }},
+
+               { &hf_tcp_scpsoption_flags_resv1,
+                 { "Reserved Bit 1",
+                   "tcp.options.scpsflags.reserved1", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x4, NULL, HFILL }},
+
+               { &hf_tcp_scpsoption_flags_resv2,
+                 { "Reserved Bit 2",
+                   "tcp.options.scpsflags.reserved2", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x2, NULL, HFILL }},
+
+               { &hf_tcp_scpsoption_flags_resv3,
+                 { "Reserved Bit 3",
+                   "tcp.options.scpsflags.reserved3", FT_BOOLEAN, 8,
+                   TFS(&tfs_set_notset), 0x1, NULL, HFILL }},
 
                { &hf_tcp_pdu_time,
                  { "Time until the last segment of this PDU", "tcp.pdu.time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
@@ -3503,6 +4049,38 @@ proto_register_tcp(void)
                { &hf_tcp_ts_delta,
                  { "Time since previous frame in this TCP stream", "tcp.time_delta", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
                    "Time delta from previous frame in this TCP stream", HFILL}},
+
+               { &hf_tcp_proc_src_uid,
+                 { "Source process user ID", "tcp.proc.srcuid", FT_UINT32, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_proc_src_pid,
+                 { "Source process ID", "tcp.proc.srcpid", FT_UINT32, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_proc_src_uname,
+                 { "Source process user name", "tcp.proc.srcuname", FT_STRING, BASE_NONE, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_proc_src_cmd,
+                 { "Source process name", "tcp.proc.srccmd", FT_STRING, BASE_NONE, NULL, 0x0,
+                   "Source process command name", HFILL}},
+
+               { &hf_tcp_proc_dst_uid,
+                 { "Destination process user ID", "tcp.proc.dstuid", FT_UINT32, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_proc_dst_pid,
+                 { "Destination process ID", "tcp.proc.dstpid", FT_UINT32, BASE_DEC, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_proc_dst_uname,
+                 { "Destination process user name", "tcp.proc.dstuname", FT_STRING, BASE_NONE, NULL, 0x0,
+                   NULL, HFILL}},
+
+               { &hf_tcp_proc_dst_cmd,
+                 { "Destination process name", "tcp.proc.dstcmd", FT_STRING, BASE_NONE, NULL, 0x0,
+                   "Destination process command name", HFILL}}
        };
 
        static gint *ett[] = {
@@ -3510,12 +4088,15 @@ proto_register_tcp(void)
                &ett_tcp_flags,
                &ett_tcp_options,
                &ett_tcp_option_sack,
+               &ett_tcp_option_scps,
+               &ett_tcp_option_scps_extended,
                &ett_tcp_analysis_faults,
                &ett_tcp_analysis,
                &ett_tcp_timestamps,
                &ett_tcp_segments,
                &ett_tcp_segment,
-                &ett_tcp_checksum
+               &ett_tcp_checksum,
+               &ett_tcp_process_info
        };
        module_t *tcp_module;
 
@@ -3553,6 +4134,12 @@ proto_register_tcp(void)
            "To use this option you must also enable \"Analyze TCP sequence numbers\". "
            "This option will also try to track and adjust the window field according to any TCP window scaling options seen.",
            &tcp_relative_seq);
+       prefs_register_bool_preference(tcp_module, "track_bytes_in_flight",
+           "Track number of bytes in flight",
+           "Make the TCP dissector track the number on un-ACKed bytes of data are in flight per packet. "
+           "To use this option you must also enable \"Analyze TCP sequence numbers\". "
+           "This takes a lot of memory but allows you to track how much data are in flight at a time and graphing it in io-graphs",
+           &tcp_track_bytes_in_flight);
        prefs_register_bool_preference(tcp_module, "calculate_timestamps",
            "Calculate conversation timestamps",
            "Calculate timestamps relative to the first frame and the previous frame in the tcp conversation",
@@ -3575,3 +4162,16 @@ proto_reg_handoff_tcp(void)
        data_handle = find_dissector("data");
        tcp_tap = register_tap("tcp");
 }
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: t
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=4 noexpandtab
+ * :indentSize=4:tabSize=4:noTabs=false:
+ */