Jeff Foster's SOCKS dissector, support for associating dissectors
[obnox/wireshark/wip.git] / packet-tcp.c
1 /* packet-tcp.c
2  * Routines for TCP packet disassembly
3  *
4  * $Id: packet-tcp.c,v 1.67 2000/04/12 22:53:15 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  * 
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.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
32 #endif
33
34 #ifdef HAVE_NETINET_IN_H
35 # include <netinet/in.h>
36 #endif
37
38 #include <stdio.h>
39 #include <glib.h>
40 #include "globals.h"
41 #include "resolv.h"
42 #include "follow.h"
43
44 #ifdef NEED_SNPRINTF_H
45 # ifdef HAVE_STDARG_H
46 #  include <stdarg.h>
47 # else
48 #  include <varargs.h>
49 # endif
50 # include "snprintf.h"
51 #endif
52
53 #include "plugins.h"
54
55 #include "packet-ip.h"
56 #include "packet-giop.h"
57 #include "packet-rpc.h"
58 #include "packet-yhoo.h"
59
60 extern FILE* data_out_file;
61
62 guint16 tcp_urgent_pointer;
63
64 static gchar info_str[COL_MAX_LEN];
65 static int   info_len;
66
67 static int proto_tcp = -1;
68 static int hf_tcp_srcport = -1;
69 static int hf_tcp_dstport = -1;
70 static int hf_tcp_port = -1;
71 static int hf_tcp_seq = -1;
72 static int hf_tcp_ack = -1;
73 static int hf_tcp_hdr_len = -1;
74 static int hf_tcp_flags = -1;
75 static int hf_tcp_flags_urg = -1;
76 static int hf_tcp_flags_ack = -1;
77 static int hf_tcp_flags_push = -1;
78 static int hf_tcp_flags_reset = -1;
79 static int hf_tcp_flags_syn = -1;
80 static int hf_tcp_flags_fin = -1;
81 static int hf_tcp_window_size = -1;
82 static int hf_tcp_checksum = -1;
83 static int hf_tcp_urgent_pointer = -1;
84
85 static gint ett_tcp = -1;
86 static gint ett_tcp_flags = -1;
87 static gint ett_tcp_options = -1;
88 static gint ett_tcp_option_sack = -1;
89
90 static dissector_table_t subdissector_table;
91
92 /* TCP Ports */
93
94 #define TCP_PORT_SMTP                   25
95 #define TCP_PORT_YHOO                   5050
96
97 /* TCP structs and definitions */
98
99 typedef struct _e_tcphdr {
100   guint16 th_sport;
101   guint16 th_dport;
102   guint32 th_seq;
103   guint32 th_ack;
104   guint8  th_off_x2; /* combines th_off and th_x2 */
105   guint8  th_flags;
106 #define TH_FIN  0x01
107 #define TH_SYN  0x02
108 #define TH_RST  0x04
109 #define TH_PUSH 0x08
110 #define TH_ACK  0x10
111 #define TH_URG  0x20
112   guint16 th_win;
113   guint16 th_sum;
114   guint16 th_urp;
115 } e_tcphdr;
116
117 /*
118  *      TCP option
119  */
120  
121 #define TCPOPT_NOP              1       /* Padding */
122 #define TCPOPT_EOL              0       /* End of options */
123 #define TCPOPT_MSS              2       /* Segment size negotiating */
124 #define TCPOPT_WINDOW           3       /* Window scaling */
125 #define TCPOPT_SACK_PERM        4       /* SACK Permitted */
126 #define TCPOPT_SACK             5       /* SACK Block */
127 #define TCPOPT_ECHO             6
128 #define TCPOPT_ECHOREPLY        7
129 #define TCPOPT_TIMESTAMP        8       /* Better RTT estimations/PAWS */
130 #define TCPOPT_CC               11
131 #define TCPOPT_CCNEW            12
132 #define TCPOPT_CCECHO           13
133
134 /*
135  *     TCP option lengths
136  */
137
138 #define TCPOLEN_MSS            4
139 #define TCPOLEN_WINDOW         3
140 #define TCPOLEN_SACK_PERM      2
141 #define TCPOLEN_SACK_MIN       2
142 #define TCPOLEN_ECHO           6
143 #define TCPOLEN_ECHOREPLY      6
144 #define TCPOLEN_TIMESTAMP      10
145 #define TCPOLEN_CC             6
146 #define TCPOLEN_CCNEW          6
147 #define TCPOLEN_CCECHO         6
148
149 static void
150 tcp_info_append_uint(const char *abbrev, guint32 val) {
151   int add_len = 0;
152   
153   if (info_len > 0)
154   if(info_len > 0)
155     add_len = snprintf(&info_str[info_len], COL_MAX_LEN - info_len, " %s=%u",
156       abbrev, val);
157   if (add_len > 0)
158     info_len += add_len;
159 }
160
161 static void
162 dissect_tcpopt_maxseg(const ip_tcp_opt *optp, const u_char *opd,
163     int offset, guint optlen, proto_tree *opt_tree)
164 {
165   proto_tree_add_text(opt_tree, offset,      optlen,
166                         "%s: %u bytes", optp->name, pntohs(opd));
167   tcp_info_append_uint("MSS", pntohs(opd));
168 }
169
170 static void
171 dissect_tcpopt_wscale(const ip_tcp_opt *optp, const u_char *opd,
172     int offset, guint optlen, proto_tree *opt_tree)
173 {
174   proto_tree_add_text(opt_tree, offset,      optlen,
175                         "%s: %u bytes", optp->name, *opd);
176   tcp_info_append_uint("WS", *opd);
177 }
178
179 static void
180 dissect_tcpopt_sack(const ip_tcp_opt *optp, const u_char *opd,
181     int offset, guint optlen, proto_tree *opt_tree)
182 {
183   proto_tree *field_tree = NULL;
184   proto_item *tf;
185   guint leftedge, rightedge;
186
187   tf = proto_tree_add_text(opt_tree, offset,      optlen, "%s:", optp->name);
188   offset += 2;  /* skip past type and length */
189   optlen -= 2;  /* subtract size of type and length */
190   while (optlen > 0) {
191     if (field_tree == NULL) {
192       /* Haven't yet made a subtree out of this option.  Do so. */
193       field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
194     }
195     if (optlen < 4) {
196       proto_tree_add_text(field_tree, offset,      optlen,
197         "(suboption would go past end of option)");
198       break;
199     }
200     /* XXX - check whether it goes past end of packet */
201     leftedge = pntohl(opd);
202     opd += 4;
203     optlen -= 4;
204     if (optlen < 4) {
205       proto_tree_add_text(field_tree, offset,      optlen,
206         "(suboption would go past end of option)");
207       break;
208     }
209     /* XXX - check whether it goes past end of packet */
210     rightedge = pntohl(opd);
211     opd += 4;
212     optlen -= 4;
213     proto_tree_add_text(field_tree, offset,      8,
214         "left edge = %u, right edge = %u", leftedge, rightedge);
215     tcp_info_append_uint("SLE", leftedge);
216     tcp_info_append_uint("SRE", rightedge);
217     offset += 8;
218   }
219 }
220
221 static void
222 dissect_tcpopt_echo(const ip_tcp_opt *optp, const u_char *opd,
223     int offset, guint optlen, proto_tree *opt_tree)
224 {
225   proto_tree_add_text(opt_tree, offset,      optlen,
226                         "%s: %u", optp->name, pntohl(opd));
227   tcp_info_append_uint("ECHO", pntohl(opd));
228 }
229
230 static void
231 dissect_tcpopt_timestamp(const ip_tcp_opt *optp, const u_char *opd,
232     int offset, guint optlen, proto_tree *opt_tree)
233 {
234   proto_tree_add_text(opt_tree, offset,      optlen,
235     "%s: tsval %u, tsecr %u", optp->name, pntohl(opd), pntohl(opd + 4));
236   tcp_info_append_uint("TSV", pntohl(opd));
237   tcp_info_append_uint("TSER", pntohl(opd + 4));
238 }
239
240 static void
241 dissect_tcpopt_cc(const ip_tcp_opt *optp, const u_char *opd,
242     int offset, guint optlen, proto_tree *opt_tree)
243 {
244   proto_tree_add_text(opt_tree, offset,      optlen,
245                         "%s: %u", optp->name, pntohl(opd));
246   tcp_info_append_uint("CC", pntohl(opd));
247 }
248
249 static const ip_tcp_opt tcpopts[] = {
250   {
251     TCPOPT_EOL,
252     "EOL",
253     NULL,
254     NO_LENGTH,
255     0,
256     NULL,
257   },
258   {
259     TCPOPT_NOP,
260     "NOP",
261     NULL,
262     NO_LENGTH,
263     0,
264     NULL,
265   },
266   {
267     TCPOPT_MSS,
268     "Maximum segment size",
269     NULL,
270     FIXED_LENGTH,
271     TCPOLEN_MSS,
272     dissect_tcpopt_maxseg
273   },
274   {
275     TCPOPT_WINDOW,
276     "Window scale",
277     NULL,
278     FIXED_LENGTH,
279     TCPOLEN_WINDOW,
280     dissect_tcpopt_wscale
281   },
282   {
283     TCPOPT_SACK_PERM,
284     "SACK permitted",
285     NULL,
286     FIXED_LENGTH,
287     TCPOLEN_SACK_PERM,
288     NULL,
289   },
290   {
291     TCPOPT_SACK,
292     "SACK",
293     &ett_tcp_option_sack,
294     VARIABLE_LENGTH,
295     TCPOLEN_SACK_MIN,
296     dissect_tcpopt_sack
297   },
298   {
299     TCPOPT_ECHO,
300     "Echo",
301     NULL,
302     FIXED_LENGTH,
303     TCPOLEN_ECHO,
304     dissect_tcpopt_echo
305   },
306   {
307     TCPOPT_ECHOREPLY,
308     "Echo reply",
309     NULL,
310     FIXED_LENGTH,
311     TCPOLEN_ECHOREPLY,
312     dissect_tcpopt_echo
313   },
314   {
315     TCPOPT_TIMESTAMP,
316     "Time stamp",
317     NULL,
318     FIXED_LENGTH,
319     TCPOLEN_TIMESTAMP,
320     dissect_tcpopt_timestamp
321   },
322   {
323     TCPOPT_CC,
324     "CC",
325     NULL,
326     FIXED_LENGTH,
327     TCPOLEN_CC,
328     dissect_tcpopt_cc
329   },
330   {
331     TCPOPT_CCNEW,
332     "CC.NEW",
333     NULL,
334     FIXED_LENGTH,
335     TCPOPT_CCNEW,
336     dissect_tcpopt_cc
337   },
338   {
339     TCPOPT_CCECHO,
340     "CC.ECHO",
341     NULL,
342     FIXED_LENGTH,
343     TCPOLEN_CCECHO,
344     dissect_tcpopt_cc
345   }
346 };
347
348 #define N_TCP_OPTS      (sizeof tcpopts / sizeof tcpopts[0])
349
350 /* TCP flags flag */
351 static const true_false_string flags_set_truth = {
352   "Set",
353   "Not set"
354 };
355
356
357 void
358 decode_tcp_ports( const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
359         int src_port, int dst_port) {
360
361 /* Determine if there is a sub-dissector and call it.  This has been */
362 /* separated into a stand alone routine to other protocol dissectors */
363 /* can call to it, ie. socks    */
364
365
366   dissector_t sub_dissector;
367
368   sub_dissector = find_conversation_dissector( &pi.src, &pi.dst, PT_TCP,
369                 src_port, dst_port);
370   if (sub_dissector){
371         (sub_dissector)(pd, offset, fd, tree);
372         return;
373   }
374
375     /* ONC RPC.  We can't base this on anything in the TCP header; we have
376        to look at the payload.  If "dissect_rpc()" returns TRUE, it was
377        an RPC packet, otherwise it's some other type of packet. */
378     if (dissect_rpc(pd, offset, fd, tree))
379       return;
380
381     /* try to apply the plugins */
382 #ifdef HAVE_PLUGINS
383     {
384       plugin *pt_plug = plugin_list;
385
386       if (enabled_plugins_number > 0) {
387         while (pt_plug) {
388           if (pt_plug->enabled && !strcmp(pt_plug->protocol, "tcp") &&
389               tree && dfilter_apply(pt_plug->filter, tree, pd)) {
390             pt_plug->dissector(pd, offset, fd, tree);
391             return;
392           }
393           pt_plug = pt_plug->next;
394         }
395       }
396     }
397 #endif
398
399     /* do lookup with the subdissector table */
400     if (dissector_try_port(subdissector_table, src_port, pd, offset,
401                                 fd, tree) ||
402         dissector_try_port(subdissector_table, dst_port, pd, offset,
403                                 fd, tree))
404         return;
405
406     /* check existence of high level protocols */
407
408 #define PORT_IS(port)   ( src_port == port || dst_port == port)    
409
410     if (memcmp(&pd[offset], "GIOP",  4) == 0) {
411         dissect_giop(pd, offset, fd, tree);
412         return;
413     }
414
415     if ( PORT_IS(TCP_PORT_YHOO) && 
416                 (memcmp(&pd[offset], "YPNS",  4) == 0 ||
417                 memcmp(&pd[offset], "YHOO",  4) == 0 )) {
418         dissect_yhoo(pd, offset, fd, tree);
419         return;
420     }
421
422     dissect_data(pd, offset, fd, tree);
423 }
424
425
426 void
427 dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
428   e_tcphdr   th;
429   proto_tree *tcp_tree = NULL, *field_tree = NULL;
430   proto_item *ti, *tf;
431   gchar      flags[64] = "<None>";
432   gchar     *fstr[] = {"FIN", "SYN", "RST", "PSH", "ACK", "URG"};
433   gint       fpos = 0, i;
434   guint      bpos;
435   guint      hlen;
436   guint      optlen;
437   guint      packet_max = pi.len;
438
439   /* To do: Check for {cap len,pkt len} < struct len */
440   /* Avoids alignment problems on many architectures. */
441   memcpy(&th, &pd[offset], sizeof(e_tcphdr));
442   th.th_sport = ntohs(th.th_sport);
443   th.th_dport = ntohs(th.th_dport);
444   th.th_win   = ntohs(th.th_win);
445   th.th_sum   = ntohs(th.th_sum);
446   th.th_urp   = ntohs(th.th_urp);
447   th.th_seq   = ntohl(th.th_seq);
448   th.th_ack   = ntohl(th.th_ack);
449
450   /* Export the urgent pointer, for the benefit of protocols such as
451      rlogin. */
452   tcp_urgent_pointer = th.th_urp;
453  
454   info_len = 0;
455
456   if (check_col(fd, COL_PROTOCOL) || tree) {  
457     for (i = 0; i < 6; i++) {
458       bpos = 1 << i;
459       if (th.th_flags & bpos) {
460         if (fpos) {
461           strcpy(&flags[fpos], ", ");
462           fpos += 2;
463         }
464         strcpy(&flags[fpos], fstr[i]);
465         fpos += 3;
466       }
467     }
468     flags[fpos] = '\0';
469   }
470   
471   hlen = hi_nibble(th.th_off_x2) * 4;  /* TCP header length, in bytes */
472
473   if (check_col(fd, COL_PROTOCOL))
474     col_add_str(fd, COL_PROTOCOL, "TCP");
475   if (check_col(fd, COL_INFO)) {
476     /* Copy the data into info_str in case one of the option handling
477        routines needs to append to it. */
478     if (th.th_flags & TH_URG)
479       info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Urg=%u Len=%d",
480         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
481         th.th_seq, th.th_ack, th.th_win, th.th_urp, pi.len - offset - hlen);
482     else
483       info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Len=%d",
484         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
485         th.th_seq, th.th_ack, th.th_win, pi.len - offset - hlen);
486     /* The info column is actually written after the options are decoded */
487   }
488   
489   if (tree) {
490     ti = proto_tree_add_protocol_format(tree, proto_tcp, offset, hlen, "Transmission Control Protocol, Src Port: %s (%u), Dst Port: %s (%u), Seq: %u, Ack: %u", get_tcp_port(th.th_sport), th.th_sport, get_tcp_port(th.th_dport), th.th_dport, th.th_seq, th.th_ack);
491     tcp_tree = proto_item_add_subtree(ti, ett_tcp);
492     proto_tree_add_uint_format(tcp_tree, hf_tcp_srcport, offset, 2, th.th_sport,
493         "Source port: %s (%u)", get_tcp_port(th.th_sport), th.th_sport);
494     proto_tree_add_uint_format(tcp_tree, hf_tcp_dstport, offset + 2, 2, th.th_dport,
495         "Destination port: %s (%u)", get_tcp_port(th.th_dport), th.th_dport);
496     proto_tree_add_item_hidden(tcp_tree, hf_tcp_port, offset, 2, th.th_sport);
497     proto_tree_add_item_hidden(tcp_tree, hf_tcp_port, offset + 2, 2, th.th_dport);
498     proto_tree_add_item(tcp_tree, hf_tcp_seq, offset + 4, 4, th.th_seq);
499     if (th.th_flags & TH_ACK)
500       proto_tree_add_item(tcp_tree, hf_tcp_ack, offset + 8, 4, th.th_ack);
501     proto_tree_add_uint_format(tcp_tree, hf_tcp_hdr_len, offset + 12, 1, hlen,
502         "Header length: %u bytes", hlen);
503     tf = proto_tree_add_uint_format(tcp_tree, hf_tcp_flags, offset + 13, 1,
504         th.th_flags, "Flags: 0x%04x (%s)", th.th_flags, flags);
505     field_tree = proto_item_add_subtree(tf, ett_tcp_flags);
506     proto_tree_add_item(field_tree, hf_tcp_flags_urg, offset + 13, 1, th.th_flags);
507     proto_tree_add_item(field_tree, hf_tcp_flags_ack, offset + 13, 1, th.th_flags);
508     proto_tree_add_item(field_tree, hf_tcp_flags_push, offset + 13, 1, th.th_flags);
509     proto_tree_add_item(field_tree, hf_tcp_flags_reset, offset + 13, 1, th.th_flags);
510     proto_tree_add_item(field_tree, hf_tcp_flags_syn, offset + 13, 1, th.th_flags);
511     proto_tree_add_item(field_tree, hf_tcp_flags_fin, offset + 13, 1, th.th_flags);
512     proto_tree_add_item(tcp_tree, hf_tcp_window_size, offset + 14, 2, th.th_win);
513     proto_tree_add_item(tcp_tree, hf_tcp_checksum, offset + 16, 2, th.th_sum);
514     if (th.th_flags & TH_URG)
515       proto_tree_add_item(tcp_tree, hf_tcp_urgent_pointer, offset + 18, 2, th.th_urp);
516   }
517
518   /* Decode TCP options, if any. */
519   if (tree  && hlen > sizeof (e_tcphdr)) {
520     /* There's more than just the fixed-length header.  Decode the
521        options. */
522     optlen = hlen - sizeof (e_tcphdr); /* length of options, in bytes */
523     tf = proto_tree_add_text(tcp_tree, offset +  20, optlen,
524       "Options: (%d bytes)", optlen);
525     field_tree = proto_item_add_subtree(tf, ett_tcp_options);
526     dissect_ip_tcp_options(&pd[offset + 20], offset + 20, optlen,
527       tcpopts, N_TCP_OPTS, TCPOPT_EOL, field_tree);
528   }
529
530   if (check_col(fd, COL_INFO))
531     col_add_str(fd, COL_INFO, info_str);
532
533   /* Skip over header + options */
534   offset += hlen;
535
536   pi.ptype = PT_TCP;
537   pi.srcport = th.th_sport;
538   pi.destport = th.th_dport;
539   
540   /* Check the packet length to see if there's more data
541      (it could be an ACK-only packet) */
542   if (packet_max > offset) 
543     decode_tcp_ports( pd, offset, fd, tree, th.th_sport, th.th_dport);
544  
545   if( data_out_file ) {
546     reassemble_tcp( th.th_seq,          /* sequence number */
547         ( pi.len - offset ),            /* data length */
548         ( pd+offset ),                  /* data */
549         ( pi.captured_len - offset ),   /* captured data length */
550         ( th.th_flags & TH_SYN ),       /* is syn set? */
551         &pi.net_src,
552         &pi.net_dst,
553         pi.srcport,
554         pi.destport);
555   }
556 }
557
558 void
559 proto_register_tcp(void)
560 {
561         static hf_register_info hf[] = {
562
563                 { &hf_tcp_srcport,
564                 { "Source Port",                "tcp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
565                         "" }},
566
567                 { &hf_tcp_dstport,
568                 { "Destination Port",           "tcp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
569                         "" }},
570
571                 { &hf_tcp_port,
572                 { "Source or Destination Port", "tcp.port", FT_UINT16, BASE_DEC, NULL, 0x0,
573                         "" }},
574
575                 { &hf_tcp_seq,
576                 { "Sequence number",            "tcp.seq", FT_UINT32, BASE_DEC, NULL, 0x0,
577                         "" }},
578
579                 { &hf_tcp_ack,
580                 { "Acknowledgement number",     "tcp.ack", FT_UINT32, BASE_DEC, NULL, 0x0,
581                         "" }},
582
583                 { &hf_tcp_hdr_len,
584                 { "Header Length",              "tcp.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0,
585                         "" }},
586
587                 { &hf_tcp_flags,
588                 { "Flags",                      "tcp.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
589                         "" }},
590
591                 { &hf_tcp_flags_urg,
592                 { "Urgent",                     "tcp.flags.urg", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_URG,
593                         "" }},
594
595                 { &hf_tcp_flags_ack,
596                 { "Acknowledgment",             "tcp.flags.ack", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_ACK,
597                         "" }},
598
599                 { &hf_tcp_flags_push,
600                 { "Push",                       "tcp.flags.push", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_PUSH,
601                         "" }},
602
603                 { &hf_tcp_flags_reset,
604                 { "Reset",                      "tcp.flags.reset", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_RST,
605                         "" }},
606
607                 { &hf_tcp_flags_syn,
608                 { "Syn",                        "tcp.flags.syn", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_SYN,
609                         "" }},
610
611                 { &hf_tcp_flags_fin,
612                 { "Fin",                        "tcp.flags.fin", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_FIN,
613                         "" }},
614
615                 { &hf_tcp_window_size,
616                 { "Window size",                "tcp.window_size", FT_UINT16, BASE_DEC, NULL, 0x0,
617                         "" }},
618
619                 { &hf_tcp_checksum,
620                 { "Checksum",                   "tcp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
621                         "" }},
622
623                 { &hf_tcp_urgent_pointer,
624                 { "Urgent pointer",             "tcp.urgent_pointer", FT_UINT16, BASE_DEC, NULL, 0x0,
625                         "" }},
626         };
627         static gint *ett[] = {
628                 &ett_tcp,
629                 &ett_tcp_flags,
630                 &ett_tcp_options,
631                 &ett_tcp_option_sack,
632         };
633
634         proto_tcp = proto_register_protocol ("Transmission Control Protocol", "tcp");
635         proto_register_field_array(proto_tcp, hf, array_length(hf));
636         proto_register_subtree_array(ett, array_length(ett));
637
638 /* subdissector code */
639         subdissector_table = register_dissector_table(hf_tcp_port);
640 }