2 * Routines for LTP dissection
3 * Copyright 2009, Mithun Roy <mithunroy13@gmail.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * Licklider Transmission Protocol - RFC 5326.
35 #include <epan/packet.h>
36 #include <epan/prefs.h>
37 #include <epan/expert.h>
38 #include <epan/reassemble.h>
40 #include "packet-dtn.h"
42 #define LTP_MIN_DATA_BUFFER 5
43 #define LTP_MAX_HDR_EXTN 16
44 #define LTP_MAX_TRL_EXTN 16
46 void proto_reg_handoff_ltp(void);
48 /* For reassembling LTP segments */
49 static GHashTable *ltp_fragment_table = NULL;
50 static GHashTable *ltp_reassembled_table = NULL;
52 /* Initialize the protocol and registered fields */
53 static int proto_ltp = -1;
55 /* LTP Header variables */
56 static int hf_ltp_version = -1;
57 static int hf_ltp_type = -1;
58 static int hf_ltp_session_id = -1;
59 static int hf_ltp_session_orig = -1;
60 static int hf_ltp_session_no = -1;
61 static int hf_ltp_hdr_extn_cnt = -1;
62 static int hf_ltp_trl_extn_cnt = -1;
64 /* LTP Data Segment variable */
65 static int hf_ltp_data_clid = -1;
66 static int hf_ltp_data_offset = -1;
67 static int hf_ltp_data_length = -1;
68 static int hf_ltp_data_chkp = -1;
69 static int hf_ltp_data_rpt = -1;
70 static int hf_ltp_data_clidata = -1;
72 /* LTP Report Segment variable */
73 static int hf_ltp_rpt_sno = -1;
74 static int hf_ltp_rpt_chkp = -1;
75 static int hf_ltp_rpt_ub = -1;
76 static int hf_ltp_rpt_lb = -1;
77 static int hf_ltp_rpt_clm_cnt = -1;
78 static int hf_ltp_rpt_clm_off = -1;
79 static int hf_ltp_rpt_clm_len = -1;
81 /* LTP Report Ack Segment Variable */
82 static int hf_ltp_rpt_ack_sno = -1;
84 /* LTP Session Management Segment Variable */
85 static int hf_ltp_cancel_code = -1;
87 /* LTP Header Extension Segment */
88 static int hf_ltp_hdr_extn_tag = -1;
89 static int hf_ltp_hdr_extn_len = -1;
90 static int hf_ltp_hdr_extn_val = -1;
92 /* LTP Trailer Extension Segment */
93 static int hf_ltp_trl_extn_tag = -1;
94 static int hf_ltp_trl_extn_len = -1;
95 static int hf_ltp_trl_extn_val = -1;
98 static int hf_ltp_fragments = -1;
99 static int hf_ltp_fragment = -1;
100 static int hf_ltp_fragment_overlap = -1;
101 static int hf_ltp_fragment_overlap_conflicts = -1;
102 static int hf_ltp_fragment_multiple_tails = -1;
103 static int hf_ltp_fragment_too_long_fragment = -1;
104 static int hf_ltp_fragment_error = -1;
105 static int hf_ltp_fragment_count = -1;
106 static int hf_ltp_reassembled_in = -1;
107 static int hf_ltp_reassembled_length = -1;
109 static const value_string ltp_type_codes[] = {
110 {0x0, "Red data, NOT {Checkpoint, EORP or EOB}"},
111 {0x1, "Red data, Checkpoint, NOT {EORP or EOB}"},
112 {0x2, "Red data, Checkpoint, EORP, NOT EOB"},
113 {0x3, "Red data, Checkpoint, EORP, EOB"},
114 {0x4, "Green data, NOT EOB"},
115 {0x5, "Green data, undefined"},
116 {0x6, "Green data, undefined"},
117 {0x7, "Green data, EOB"},
118 {0x8, "Report segment"},
119 {0x9, "Report-acknowledgment segment"},
120 {0xa, "Control segment, undefined"},
121 {0xb, "Control segment, undefined"},
122 {0xc, "Cancel segment from block sender"},
123 {0xd, "Cancel-acknowledgment segment to block sender"},
124 {0xe, "Cancel segment from block receiver"},
125 {0xf, "Cancel-acknowledgment segment to block receiver"},
129 static const value_string ltp_type_col_info[] = {
138 {0x8, "Report segment"},
139 {0x9, "Report ack segment"},
140 {0xa, "Control segment"},
141 {0xb, "Control segment"},
142 {0xc, "Cancel segment"},
143 {0xd, "Cancel ack segment"},
144 {0xe, "Cancel segment"},
145 {0xf, "Cancel ack segment"},
149 static const value_string ltp_cancel_codes[] = {
150 {0x00, "Client service canceled session"},
151 {0x01, "Unreachable client service"},
152 {0x02, "Retransmission limit exceeded"},
153 {0x03, "Miscolored segment"},
154 {0x04, "A system error"},
155 {0x05, "Exceeded the Retransmission-Cycles limit"},
159 static const value_string extn_tag_codes[] = {
160 {0x00, "LTP authentication extension"},
161 {0x01, "LTP cookie extension"},
166 static guint ltp_port = 1113;
168 /* Initialize the subtree pointers */
169 static gint ett_ltp = -1;
170 static gint ett_ltp_hdr = -1;
171 static gint ett_hdr_session = -1;
172 static gint ett_hdr_extn = -1;
173 static gint ett_data_segm = -1;
174 static gint ett_data_data_segm = -1;
175 static gint ett_rpt_segm = -1;
176 static gint ett_rpt_clm = -1;
177 static gint ett_rpt_ack_segm = -1;
178 static gint ett_session_mgmt = -1;
179 static gint ett_trl_extn = -1;
180 static gint ett_ltp_fragment = -1;
181 static gint ett_ltp_fragments = -1;
183 static const fragment_items ltp_frag_items = {
184 /*Fragment subtrees*/
190 &hf_ltp_fragment_overlap,
191 &hf_ltp_fragment_overlap_conflicts,
192 &hf_ltp_fragment_multiple_tails,
193 &hf_ltp_fragment_too_long_fragment,
194 &hf_ltp_fragment_error,
195 &hf_ltp_fragment_count,
196 /*Reassembled in field*/
197 &hf_ltp_reassembled_in,
198 /*Reassembled length field*/
199 &hf_ltp_reassembled_length,
205 dissect_data_segment(proto_tree *ltp_tree, tvbuff_t *tvb,packet_info *pinfo,int frame_offset,int ltp_type, guint64 session_num){
209 guint64 chkp_sno = 0;
212 int segment_offset = 0;
223 int dissected_data_size = 0;
226 proto_item *ltp_data_item;
227 proto_item *ltp_data_data_item;
229 proto_tree *ltp_data_tree;
230 proto_tree *ltp_data_data_tree;
234 fragment_data *frag_msg = NULL;
235 gboolean more_frags = TRUE;
237 tvbuff_t *new_tvb = NULL;
239 /* Extract the info for the data segment */
240 client_id = evaluate_sdnv_64(tvb,frame_offset + segment_offset,&client_id_size);
241 segment_offset+= client_id_size;
243 if((unsigned)(frame_offset + segment_offset) >= tvb_length(tvb)){
244 /* This would mean the data segment is incomplete */
247 offset = evaluate_sdnv_64(tvb,frame_offset + segment_offset,&offset_size);
248 segment_offset+= offset_size;
250 if((unsigned)(frame_offset + segment_offset) >= tvb_length(tvb)){
251 /* This would mean the data segment is incomplete */
255 length = evaluate_sdnv_64(tvb,frame_offset + segment_offset,&length_size);
256 segment_offset+= length_size;
258 if((unsigned)(frame_offset + segment_offset) >= tvb_length(tvb)){
259 /* This would mean the data segment is incomplete */
265 chkp_sno = evaluate_sdnv_64(tvb,frame_offset + segment_offset,&chkp_sno_size);
266 segment_offset+= chkp_sno_size;
268 if((unsigned)(frame_offset + segment_offset) >= tvb_length(tvb)){
269 /* This would mean the data segment is incomplete */
273 rpt_sno = evaluate_sdnv_64(tvb,frame_offset + segment_offset,&rpt_sno_size);
274 segment_offset+= rpt_sno_size;
276 if((unsigned)(frame_offset + segment_offset) >= tvb_length(tvb)){
277 /* This would mean the data segment is incomplete */
281 /* Adding size of the data */
282 if ((segment_offset + (int)length < segment_offset) || (segment_offset + (int)length < (int)length)) {
283 /* Addition result has wrapped */
286 segment_offset+= (int)length;
288 if ((segment_offset + frame_offset < segment_offset) || (segment_offset + frame_offset < frame_offset)) {
289 /* Addition result has wrapped */
292 if((unsigned)(frame_offset + segment_offset) > tvb_length(tvb)){
293 /* This would mean the data segment is incomplete */
297 /* Create a subtree for data segment and add the other fields under it */
298 ltp_data_item = proto_tree_add_text(ltp_tree, tvb,frame_offset, segment_offset, "Data Segment");
299 ltp_data_tree = proto_item_add_subtree(ltp_data_item, ett_data_segm);
301 proto_tree_add_uint64(ltp_data_tree,hf_ltp_data_clid, tvb, frame_offset,client_id_size,client_id);
302 frame_offset += client_id_size;
304 proto_tree_add_uint64(ltp_data_tree, hf_ltp_data_offset, tvb, frame_offset,offset_size, offset);
305 frame_offset += offset_size;
307 proto_tree_add_uint64(ltp_data_tree,hf_ltp_data_length, tvb, frame_offset,length_size,length);
308 frame_offset += length_size;
312 proto_tree_add_uint64(ltp_data_tree, hf_ltp_data_chkp, tvb, frame_offset,chkp_sno_size, chkp_sno);
313 frame_offset += chkp_sno_size;
315 proto_tree_add_uint64(ltp_data_tree, hf_ltp_data_rpt, tvb, frame_offset,rpt_sno_size, rpt_sno);
316 frame_offset += rpt_sno_size;
319 frag_msg = fragment_add_check(tvb, frame_offset, pinfo, (guint32)session_num, ltp_fragment_table,
320 ltp_reassembled_table, (guint32)offset, (guint32)length, more_frags);
325 frag_msg = fragment_add_check(tvb, frame_offset, pinfo, (guint32)session_num, ltp_fragment_table,
326 ltp_reassembled_table, (guint32)offset, (guint32)length, more_frags);
333 /* Checking if the segment is completely reassembled */
334 if(!(frag_msg->flags & FD_PARTIAL_REASSEMBLY))
336 /* if the segment has not been fragmented, then no reassembly is needed */
337 if(!more_frags && offset == 0)
339 new_tvb = tvb_new_subset(tvb,frame_offset,tvb_length(tvb)-frame_offset,-1);
343 new_tvb = process_reassembled_data(tvb, frame_offset, pinfo, "Reassembled LTP Segment",
344 frag_msg, <p_frag_items,NULL, ltp_data_tree);
352 data_length = tvb_length(new_tvb);
353 while((unsigned)dissected_data_size < length)
355 ltp_data_data_item = proto_tree_add_text(ltp_data_tree, tvb,frame_offset, 0, "Data[%d]",data_count);
356 ltp_data_data_tree = proto_item_add_subtree(ltp_data_data_item, ett_data_data_segm);
358 datatvb = tvb_new_subset(new_tvb, data_offset, (int)data_length - dissected_data_size, tvb_length(new_tvb));
359 bundle_size = dissect_complete_bundle(datatvb, pinfo, ltp_data_data_tree);
360 if(bundle_size == 0) { /*Couldn't parse bundle*/
361 col_set_str(pinfo->cinfo, COL_INFO, "Dissection Failed");
362 return 0; /*Give up*/
364 data_offset += bundle_size;
365 dissected_data_size += bundle_size;
371 if(frag_msg && more_frags)
373 col_append_fstr(pinfo->cinfo, COL_INFO, "[Reassembled in %d] ",frag_msg->reassembled_in);
377 col_append_str(pinfo->cinfo, COL_INFO, "[Unfinished LTP Segment] ");
382 return segment_offset;
387 dissect_report_segment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ltp_tree, int frame_offset) {
398 int upper_bound_size;
399 int lower_bound_size;
400 int rcpt_clm_cnt_size;
404 int segment_offset = 0;
407 proto_item *ltp_rpt_item;
408 proto_item *ltp_rpt_clm_item;
410 proto_tree *ltp_rpt_tree;
411 proto_tree *ltp_rpt_clm_tree;
413 /* Create the subtree for report segment under the main LTP tree and all the report segment fields under it */
414 ltp_rpt_item = proto_tree_add_text(ltp_tree, tvb, frame_offset, -1, "Report Segment");
415 ltp_rpt_tree = proto_item_add_subtree(ltp_rpt_item, ett_rpt_segm);
417 /* Extract the report segment info */
418 rpt_sno = evaluate_sdnv_64(tvb, frame_offset, &rpt_sno_size);
419 proto_tree_add_uint64(ltp_rpt_tree, hf_ltp_rpt_sno, tvb, frame_offset + segment_offset, rpt_sno_size, rpt_sno);
420 segment_offset += rpt_sno_size;
422 chkp_sno = evaluate_sdnv_64(tvb, frame_offset + segment_offset, &chkp_sno_size);
423 proto_tree_add_uint64(ltp_rpt_tree, hf_ltp_rpt_chkp, tvb, frame_offset + segment_offset, chkp_sno_size, chkp_sno);
424 segment_offset += chkp_sno_size;
426 upper_bound = evaluate_sdnv(tvb, frame_offset + segment_offset, &upper_bound_size);
427 proto_tree_add_uint64(ltp_rpt_tree, hf_ltp_rpt_ub, tvb, frame_offset + segment_offset, upper_bound_size, upper_bound);
428 segment_offset += upper_bound_size;
430 lower_bound = evaluate_sdnv(tvb, frame_offset + segment_offset, &lower_bound_size);
431 proto_tree_add_uint64(ltp_rpt_tree, hf_ltp_rpt_lb, tvb, frame_offset + segment_offset, lower_bound_size, lower_bound);
432 segment_offset += lower_bound_size;
434 rcpt_clm_cnt = evaluate_sdnv(tvb, frame_offset + segment_offset, &rcpt_clm_cnt_size);
435 if (rcpt_clm_cnt < 0){
436 proto_item_set_end(ltp_rpt_item, tvb, frame_offset + segment_offset);
437 expert_add_info_format(pinfo, ltp_tree, PI_UNDECODED, PI_ERROR, "Negative reception claim count: %d", rcpt_clm_cnt);
440 proto_tree_add_uint(ltp_rpt_tree, hf_ltp_rpt_clm_cnt, tvb, frame_offset + segment_offset, rcpt_clm_cnt_size, rcpt_clm_cnt);
441 segment_offset += rcpt_clm_cnt_size;
443 ltp_rpt_clm_item = proto_tree_add_text(ltp_rpt_tree, tvb, frame_offset + segment_offset, -1, "Reception claims");
444 ltp_rpt_clm_tree = proto_item_add_subtree(ltp_rpt_clm_item, ett_rpt_clm);
446 /* There can be multiple reception claims in the same report segment */
447 for(i = 0; i<rcpt_clm_cnt; i++){
448 offset = evaluate_sdnv(tvb,frame_offset + segment_offset, &offset_size);
449 proto_tree_add_uint64_format(ltp_rpt_clm_tree, hf_ltp_rpt_clm_off, tvb, frame_offset + segment_offset, offset_size, offset,
450 "Offset[%d] : %"G_GINT64_MODIFIER"d", i, offset);
451 segment_offset += offset_size;
453 length = evaluate_sdnv(tvb,frame_offset + segment_offset, &length_size);
454 proto_tree_add_uint64_format(ltp_rpt_clm_tree, hf_ltp_rpt_clm_len, tvb, frame_offset + segment_offset, length_size, length,
455 "Length[%d] : %"G_GINT64_MODIFIER"d",i, length);
456 segment_offset += length_size;
458 proto_item_set_end(ltp_rpt_clm_item, tvb, frame_offset + segment_offset);
459 proto_item_set_end(ltp_rpt_item, tvb, frame_offset + segment_offset);
460 return segment_offset;
465 dissect_report_ack_segment(proto_tree *ltp_tree, tvbuff_t *tvb,int frame_offset){
469 int segment_offset = 0;
471 proto_item *ltp_rpt_ack_item;
472 proto_tree *ltp_rpt_ack_tree;
474 /* Extracing receipt serial number info */
475 rpt_sno = evaluate_sdnv_64(tvb,frame_offset, &rpt_sno_size);
476 segment_offset += rpt_sno_size;
478 if((unsigned)(frame_offset + segment_offset) > tvb_length(tvb)){
482 /* Creating tree for the report ack segment */
483 ltp_rpt_ack_item = proto_tree_add_text(ltp_tree, tvb,frame_offset, segment_offset, "Report Ack Segment");
484 ltp_rpt_ack_tree = proto_item_add_subtree(ltp_rpt_ack_item, ett_rpt_ack_segm);
486 proto_tree_add_uint64(ltp_rpt_ack_tree, hf_ltp_rpt_ack_sno, tvb, frame_offset,rpt_sno_size, rpt_sno);
487 return segment_offset;
492 dissect_cancel_segment(proto_tree * ltp_tree, tvbuff_t *tvb,int frame_offset){
495 proto_item *ltp_cancel_item;
496 proto_tree *ltp_cancel_tree;
498 /* The cancel segment has only one byte, which contains the reason code. */
499 reason_code = tvb_get_guint8(tvb,frame_offset);
501 /* Creating tree for the cancel segment */
502 ltp_cancel_item = proto_tree_add_text(ltp_tree, tvb,frame_offset, 1, "Cancel Segment");
503 ltp_cancel_tree = proto_item_add_subtree(ltp_cancel_item, ett_session_mgmt);
505 proto_tree_add_uint_format_value(ltp_cancel_tree, hf_ltp_cancel_code, tvb, frame_offset, 1, reason_code,
506 "%x (%s)", reason_code, val_to_str(reason_code,ltp_cancel_codes,"Reserved"));
511 dissect_header_extn(proto_tree *ltp_tree, tvbuff_t *tvb,int frame_offset,int hdr_extn_cnt){
512 guint8 extn_type[LTP_MAX_HDR_EXTN];
513 guint64 length[LTP_MAX_HDR_EXTN];
514 guint64 value[LTP_MAX_HDR_EXTN];
516 int length_size[LTP_MAX_HDR_EXTN];
517 int value_size[LTP_MAX_HDR_EXTN];
522 proto_item *ltp_hdr_extn_item;
523 proto_tree *ltp_hdr_extn_tree;
525 /* There can be more than one header extensions */
526 for(i = 0; i < hdr_extn_cnt; i++){
527 extn_type[i] = tvb_get_guint8(tvb,frame_offset);
530 if((unsigned)(frame_offset + extn_offset) >= tvb_length(tvb)){
533 length[i] = evaluate_sdnv_64(tvb,frame_offset,&length_size[i]);
534 extn_offset += length_size[i];
535 if((unsigned)(frame_offset + extn_offset) >= tvb_length(tvb)){
538 value[i] = evaluate_sdnv_64(tvb,frame_offset,&value_size[i]);
539 extn_offset += value_size[i];
540 if((unsigned)(frame_offset + extn_offset) >= tvb_length(tvb)){
544 ltp_hdr_extn_item = proto_tree_add_text(ltp_tree, tvb,frame_offset, extn_offset, "Header Extension");
545 ltp_hdr_extn_tree = proto_item_add_subtree(ltp_hdr_extn_item, ett_hdr_extn);
547 for(i = 0; i < hdr_extn_cnt; i++){
548 proto_tree_add_uint_format_value(ltp_hdr_extn_tree, hf_ltp_hdr_extn_tag, tvb, frame_offset, 1, extn_type[i], "%x (%s)", extn_type[i], val_to_str(extn_type[i],extn_tag_codes,"Unassigned/Reserved"));
550 proto_tree_add_uint64_format(ltp_hdr_extn_tree, hf_ltp_hdr_extn_len, tvb, frame_offset, length_size[i],length[i], "Length [%d]: %"G_GINT64_MODIFIER"d",i+1,length[i]);
551 frame_offset += length_size[i];
553 proto_tree_add_uint64_format(ltp_hdr_extn_tree, hf_ltp_hdr_extn_val, tvb, frame_offset, value_size[i],value[i], "Value [%d]: %"G_GINT64_MODIFIER"d",i+1,value[i]);
554 frame_offset += value_size[i];
560 dissect_trailer_extn(proto_tree *ltp_tree, tvbuff_t *tvb,int frame_offset,int trl_extn_cnt){
561 guint8 extn_type[LTP_MAX_TRL_EXTN];
562 guint64 length[LTP_MAX_TRL_EXTN];
563 guint64 value[LTP_MAX_TRL_EXTN];
565 int length_size[LTP_MAX_TRL_EXTN];
566 int value_size[LTP_MAX_TRL_EXTN];
571 proto_item *ltp_trl_extn_item;
572 proto_tree *ltp_trl_extn_tree;
574 DISSECTOR_ASSERT(trl_extn_cnt < LTP_MAX_TRL_EXTN);
576 for(i = 0; i < trl_extn_cnt; i++){
577 extn_type[i] = tvb_get_guint8(tvb,frame_offset);
580 if((unsigned)(frame_offset + extn_offset) >= tvb_length(tvb)){
584 length[i] = evaluate_sdnv_64(tvb,frame_offset,&length_size[i]);
585 extn_offset += length_size[i];
587 if((unsigned)(frame_offset + extn_offset) >= tvb_length(tvb)){
591 value[i] = evaluate_sdnv_64(tvb,frame_offset,&value_size[i]);
592 extn_offset += value_size[i];
594 if((unsigned)(frame_offset + extn_offset) >= tvb_length(tvb)){
598 ltp_trl_extn_item = proto_tree_add_text(ltp_tree, tvb,frame_offset, extn_offset, "Header Extension");
599 ltp_trl_extn_tree = proto_item_add_subtree(ltp_trl_extn_item, ett_trl_extn);
601 for(i = 0; i < trl_extn_cnt; i++){
602 proto_tree_add_uint_format_value(ltp_trl_extn_tree, hf_ltp_trl_extn_tag, tvb, frame_offset, 1, extn_type[i], "%x (%s)", extn_type[i], val_to_str(extn_type[i],extn_tag_codes,"Unassigned/Reserved"));
604 proto_tree_add_uint64_format(ltp_trl_extn_tree, hf_ltp_trl_extn_len, tvb, frame_offset, length_size[i], length[i], "Length [%d]: %"G_GINT64_MODIFIER"d",i+1,length[i]);
605 frame_offset += length_size[i];
607 proto_tree_add_uint64_format(ltp_trl_extn_tree, hf_ltp_trl_extn_val, tvb, frame_offset, value_size[i], value[i], "Value [%d]: %"G_GINT64_MODIFIER"d",i+0,value[i]);
608 frame_offset += value_size[i];
615 dissect_ltp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
617 proto_item *ti = NULL;
618 proto_tree *ltp_tree = NULL;
621 int segment_offset = 0;
622 int hdr_extn_offset = 0;
623 int trl_extn_offset = 0;
634 int session_num_size;
636 proto_item *ltp_header_item = NULL;
637 proto_item *ltp_session_item = NULL;
639 proto_tree *ltp_header_tree = NULL;
640 proto_tree *ltp_session_tree = NULL;
642 /* Check that there's enough data */
643 if(tvb_length(tvb) < LTP_MIN_DATA_BUFFER){
649 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LTP Segment");
651 /* Extract all the header info from the packet */
652 ltp_hdr = tvb_get_guint8(tvb, frame_offset);
655 engine_id = evaluate_sdnv_64(tvb,frame_offset + header_offset,&engine_id_size);
656 header_offset += engine_id_size;
657 if((unsigned)header_offset >= tvb_length(tvb)){
658 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
662 session_num = evaluate_sdnv_64(tvb,frame_offset + header_offset,&session_num_size);
663 header_offset += session_num_size;
664 if((unsigned)header_offset >= tvb_length(tvb)){
665 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
669 ti = proto_tree_add_item(tree, proto_ltp, tvb, 0, -1, ENC_NA);
670 ltp_tree = proto_item_add_subtree(ti, ett_ltp);
672 /* Adding Header Subtree */
673 ltp_header_item = proto_tree_add_text(ltp_tree, tvb, frame_offset, header_offset+1, "LTP Header");
674 ltp_header_tree = proto_item_add_subtree(ltp_header_item, ett_ltp_hdr);
676 proto_tree_add_uint(ltp_header_tree,hf_ltp_version,tvb,frame_offset,1,hi_nibble(ltp_hdr));
677 ltp_type = lo_nibble(ltp_hdr);
678 proto_tree_add_uint_format_value(ltp_header_tree,hf_ltp_type,tvb,frame_offset,1,ltp_type,"%x (%s)",
679 ltp_type,val_to_str(ltp_type,ltp_type_codes,"Invalid"));
682 /* Adding the session id subtree */
683 ltp_session_item = proto_tree_add_item(ltp_header_item,hf_ltp_session_id,tvb,frame_offset, engine_id_size + session_num_size,ENC_NA);
684 ltp_session_tree = proto_item_add_subtree(ltp_session_item,ett_hdr_session);
685 proto_tree_add_uint64(ltp_session_tree,hf_ltp_session_orig,tvb,frame_offset,engine_id_size,engine_id);
686 frame_offset+=engine_id_size;
687 proto_tree_add_uint64(ltp_session_tree,hf_ltp_session_no, tvb, frame_offset,session_num_size,session_num);
688 frame_offset+=session_num_size;
690 /* Adding Extension count to the header tree */
691 ltp_extn_cnt = tvb_get_guint8(tvb,frame_offset);
692 hdr_extn_cnt = hi_nibble(ltp_extn_cnt);
693 trl_extn_cnt = lo_nibble(ltp_extn_cnt);
695 proto_tree_add_uint(ltp_header_tree,hf_ltp_hdr_extn_cnt,tvb,frame_offset,1,hdr_extn_cnt);
696 proto_tree_add_uint(ltp_header_tree,hf_ltp_trl_extn_cnt,tvb,frame_offset,1,trl_extn_cnt);
699 col_add_str(pinfo->cinfo, COL_INFO, val_to_str_const(ltp_type,ltp_type_col_info,"Protocol Error"));
701 if((unsigned)frame_offset >= tvb_length(tvb)){
702 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
706 /* Check if there are any header extensions */
707 if(hdr_extn_cnt > 0){
708 hdr_extn_offset = dissect_header_extn(ltp_tree, tvb, frame_offset,hdr_extn_cnt);
709 if(hdr_extn_offset == 0){
710 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
713 frame_offset += hdr_extn_offset;
716 if((unsigned)frame_offset >= tvb_length(tvb)){
717 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
721 /* Call sub routines to handle the segment content*/
722 if((ltp_type >= 0) && (ltp_type < 8)){
723 segment_offset = dissect_data_segment(ltp_tree,tvb,pinfo,frame_offset,ltp_type,session_num);
724 if(segment_offset == 0){
725 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
729 else if(ltp_type == 8){
730 segment_offset = dissect_report_segment(tvb, pinfo, ltp_tree,frame_offset);
731 if(segment_offset == 0){
732 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
736 else if(ltp_type == 9){
737 segment_offset = dissect_report_ack_segment(ltp_tree,tvb,frame_offset);
738 if(segment_offset == 0){
739 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
743 else if(ltp_type == 12 || ltp_type == 14){
744 segment_offset = dissect_cancel_segment(ltp_tree,tvb,frame_offset);
745 if(segment_offset == 0){
746 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
750 frame_offset += segment_offset;
751 /* Check to see if there are any trailer extensions */
752 if(trl_extn_cnt > 0){
753 if((unsigned)frame_offset >= tvb_length(tvb)){
754 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
757 trl_extn_offset = dissect_trailer_extn(ltp_tree, tvb, frame_offset,trl_extn_cnt);
758 if(trl_extn_offset == 0){
759 col_set_str(pinfo->cinfo, COL_INFO, "Protocol Error");
763 /* Return the amount of data this dissector was able to dissect */
764 return tvb_length(tvb);
768 ltp_defragment_init(void) {
769 fragment_table_init(<p_fragment_table);
770 reassembled_table_init(<p_reassembled_table);
773 /* Register the protocol with Wireshark */
775 proto_register_ltp(void)
777 module_t *ltp_module;
779 static hf_register_info hf[] = {
781 {"LTP Version","ltp.version",
782 FT_UINT8,BASE_DEC,NULL, 0x0, NULL, HFILL}
785 {"LTP Type","ltp.type",
786 FT_UINT8,BASE_HEX,NULL, 0x0, NULL, HFILL}
789 {"Session ID","ltp.session",
790 FT_NONE,BASE_NONE,NULL, 0x0, NULL, HFILL}
792 {&hf_ltp_session_orig,
793 {"Session originator","ltp.session.orig",
794 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
797 {"Session number","ltp.session.number",
798 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
800 {&hf_ltp_hdr_extn_cnt,
801 {"Header Extension Count","ltp.hdr.extn.cnt",
802 FT_UINT8,BASE_DEC,NULL, 0x0, NULL, HFILL}
804 {&hf_ltp_trl_extn_cnt,
805 {"Trailer Extension Count","ltp.trl.extn.cnt",
806 FT_UINT8,BASE_DEC,NULL, 0x0, NULL, HFILL}
809 {"Client service ID","ltp.data.client.id",
810 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
812 {&hf_ltp_data_offset,
813 {"Offset","ltp.data.offset",
814 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
816 {&hf_ltp_data_length,
817 {"Length","ltp.data.length",
818 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
821 {"Checkpoint serial number","ltp.data.chkp",
822 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
825 {"Report serial number","ltp.data.rpt",
826 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
828 {&hf_ltp_data_clidata,
829 {"Client service data","ltp.data.data",
830 FT_BYTES,BASE_NONE,NULL, 0x0, NULL, HFILL}
833 {"Report serial number","ltp.rpt.sno",
834 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
837 {"Checkpoint serial number","ltp.rpt.chkp",
838 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
841 {"Upper bound","ltp.rpt.ub",
842 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
845 {"Lower bound","ltp.rpt.lb",
846 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
848 {&hf_ltp_rpt_clm_cnt,
849 {"Reception claim count","ltp.rpt.clm.cnt",
850 FT_UINT8,BASE_DEC,NULL, 0x0, NULL, HFILL}
852 {&hf_ltp_rpt_clm_off,
853 {"Offset","ltp.rpt.clm.off",
854 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
856 {&hf_ltp_rpt_clm_len,
857 {"Length","ltp.rpt.clm.len",
858 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
860 {&hf_ltp_rpt_ack_sno,
861 {"Report serial number","ltp.rpt.ack.sno",
862 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
864 {&hf_ltp_cancel_code,
865 {"Cancel code","ltp.cancel.code",
866 FT_UINT8,BASE_HEX,NULL, 0x0, NULL, HFILL}
868 {&hf_ltp_hdr_extn_tag,
869 {"Extension tag","ltp.hdr.extn.tag",
870 FT_UINT8,BASE_HEX,NULL, 0x0, NULL, HFILL}
872 {&hf_ltp_hdr_extn_len,
873 {"Length","ltp.hdr.extn.len",
874 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
876 {&hf_ltp_hdr_extn_val,
877 {"Value","ltp.hdr.extn.val",
878 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
880 {&hf_ltp_trl_extn_tag,
881 {"Extension tag","ltp.hdr.extn.tag",
882 FT_UINT8,BASE_HEX,NULL, 0x0, NULL, HFILL}
884 {&hf_ltp_trl_extn_len,
885 {"Length","ltp.hdr.extn.len",
886 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
888 {&hf_ltp_trl_extn_val,
889 {"Value","ltp.hdr.extn.val",
890 FT_UINT64,BASE_DEC,NULL, 0x0, NULL, HFILL}
893 {"LTP Fragments", "ltp.fragments",
894 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}
897 {"LTP Fragment", "ltp.fragment",
898 FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL}
900 {&hf_ltp_fragment_overlap,
901 {"LTP fragment overlap", "ltp.fragment.overlap",
902 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
904 {&hf_ltp_fragment_overlap_conflicts,
905 {"LTP fragment overlapping with conflicting data",
906 "ltp.fragment.overlap.conflicts",
907 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
909 {&hf_ltp_fragment_multiple_tails,
910 {"LTP has multiple tails", "ltp.fragment.multiple_tails",
911 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
913 {&hf_ltp_fragment_too_long_fragment,
914 {"LTP fragment too long", "ltp.fragment.too_long_fragment",
915 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
917 {&hf_ltp_fragment_error,
918 {"LTP defragmentation error", "ltp.fragment.error",
919 FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL}
921 {&hf_ltp_fragment_count,
922 {"LTP fragment count", "ltp.fragment.count",
923 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
925 {&hf_ltp_reassembled_in,
926 {"LTP reassembled in", "ltp.reassembled.in",
927 FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL}
929 {&hf_ltp_reassembled_length,
930 {"LTP reassembled length", "ltp.reassembled.length",
931 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
935 /* Setup protocol subtree array */
936 static gint *ett[] = {
952 /* Register the protocol name and description */
953 proto_ltp = proto_register_protocol("Licklider Transmission Protocol",
956 proto_register_field_array(proto_ltp, hf, array_length(hf));
957 proto_register_subtree_array(ett, array_length(ett));
958 ltp_module = prefs_register_protocol(proto_ltp, proto_reg_handoff_ltp);
960 prefs_register_uint_preference(ltp_module, "udp.port", "LTP UDP Port",
961 "UDP Port to accept LTP Connections",
963 register_init_routine(ltp_defragment_init);
967 proto_reg_handoff_ltp(void)
969 static gboolean initialized = FALSE;
970 static dissector_handle_t ltp_handle;
971 static int currentPort;
974 ltp_handle = new_create_dissector_handle(dissect_ltp, proto_ltp);
977 dissector_delete_uint("udp.port", currentPort, ltp_handle);
980 currentPort = ltp_port;
982 dissector_add_uint("udp.port", currentPort, ltp_handle);