added minimalist MAPI dissector - only determines request/reply
[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.42 1999/11/11 23:13:43 nneul 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 "packet.h"
41 #include "resolv.h"
42 #include "follow.h"
43 #include "util.h"
44
45 #ifdef NEED_SNPRINTF_H
46 # ifdef HAVE_STDARG_H
47 #  include <stdarg.h>
48 # else
49 #  include <varargs.h>
50 # endif
51 # include "snprintf.h"
52 #endif
53
54 #ifndef __PACKET_IP_H__
55 #include "packet-ip.h"
56 #endif
57
58 extern FILE* data_out_file;
59
60 static gchar info_str[COL_MAX_LEN];
61 static int   info_len;
62
63 static int proto_tcp = -1;
64 static int hf_tcp_srcport = -1;
65 static int hf_tcp_dstport = -1;
66 static int hf_tcp_port = -1;
67 static int hf_tcp_seq = -1;
68 static int hf_tcp_ack = -1;
69 static int hf_tcp_hdr_len = -1;
70 static int hf_tcp_flags = -1;
71 static int hf_tcp_flags_urg = -1;
72 static int hf_tcp_flags_ack = -1;
73 static int hf_tcp_flags_push = -1;
74 static int hf_tcp_flags_reset = -1;
75 static int hf_tcp_flags_syn = -1;
76 static int hf_tcp_flags_fin = -1;
77 static int hf_tcp_window_size = -1;
78 static int hf_tcp_checksum = -1;
79 static int hf_tcp_urgent_pointer = -1;
80
81 /* TCP Ports */
82
83 #define TCP_PORT_FTPDATA  20
84 #define TCP_PORT_FTP      21
85 #define TCP_PORT_TELNET   23
86 #define TCP_PORT_SMTP     25
87 #define TCP_PORT_HTTP     80
88 #define TCP_PORT_POP      110
89 #define TCP_PORT_NNTP     119
90 #define TCP_PORT_NTP      123
91 #define TCP_PORT_NBSS     139
92 #define TCP_PORT_IMAP     143
93 #define TCP_PORT_BGP      179
94 #define TCP_PORT_PRINTER  515
95 #define TCP_ALT_PORT_HTTP 8080
96 #define TCP_PORT_PPTP     1723
97 #define TCP_PORT_RTSP     554
98 #define TCP_PORT_YHOO     5050
99 #define TCP_PORT_MAPI     1065
100
101 /* TCP structs and definitions */
102
103 typedef struct _e_tcphdr {
104   guint16 th_sport;
105   guint16 th_dport;
106   guint32 th_seq;
107   guint32 th_ack;
108   guint8  th_off_x2; /* combines th_off and th_x2 */
109   guint8  th_flags;
110 #define TH_FIN  0x01
111 #define TH_SYN  0x02
112 #define TH_RST  0x04
113 #define TH_PUSH 0x08
114 #define TH_ACK  0x10
115 #define TH_URG  0x20
116   guint16 th_win;
117   guint16 th_sum;
118   guint16 th_urp;
119 } e_tcphdr;
120
121 /*
122  *      TCP option
123  */
124  
125 #define TCPOPT_NOP              1       /* Padding */
126 #define TCPOPT_EOL              0       /* End of options */
127 #define TCPOPT_MSS              2       /* Segment size negotiating */
128 #define TCPOPT_WINDOW           3       /* Window scaling */
129 #define TCPOPT_SACK_PERM        4       /* SACK Permitted */
130 #define TCPOPT_SACK             5       /* SACK Block */
131 #define TCPOPT_ECHO             6
132 #define TCPOPT_ECHOREPLY        7
133 #define TCPOPT_TIMESTAMP        8       /* Better RTT estimations/PAWS */
134 #define TCPOPT_CC               11
135 #define TCPOPT_CCNEW            12
136 #define TCPOPT_CCECHO           13
137
138 /*
139  *     TCP option lengths
140  */
141
142 #define TCPOLEN_MSS            4
143 #define TCPOLEN_WINDOW         3
144 #define TCPOLEN_SACK_PERM      2
145 #define TCPOLEN_SACK_MIN       2
146 #define TCPOLEN_ECHO           6
147 #define TCPOLEN_ECHOREPLY      6
148 #define TCPOLEN_TIMESTAMP      10
149 #define TCPOLEN_CC             6
150 #define TCPOLEN_CCNEW          6
151 #define TCPOLEN_CCECHO         6
152
153 static void
154 tcp_info_append_uint(const char *abbrev, guint32 val) {
155   int add_len = 0;
156   
157   if (info_len > 0)
158   if(info_len > 0)
159     add_len = snprintf(&info_str[info_len], COL_MAX_LEN - info_len, " %s=%u",
160       abbrev, val);
161   if (add_len > 0)
162     info_len += add_len;
163 }
164
165 static void
166 dissect_tcpopt_maxseg(const ip_tcp_opt *optp, const u_char *opd,
167     int offset, guint optlen, proto_tree *opt_tree)
168 {
169   proto_tree_add_text(opt_tree, offset,      optlen,
170                         "%s: %u bytes", optp->name, pntohs(opd));
171   tcp_info_append_uint("MSS", pntohs(opd));
172 }
173
174 static void
175 dissect_tcpopt_wscale(const ip_tcp_opt *optp, const u_char *opd,
176     int offset, guint optlen, proto_tree *opt_tree)
177 {
178   proto_tree_add_text(opt_tree, offset,      optlen,
179                         "%s: %u bytes", optp->name, *opd);
180   tcp_info_append_uint("WS", *opd);
181 }
182
183 static void
184 dissect_tcpopt_sack(const ip_tcp_opt *optp, const u_char *opd,
185     int offset, guint optlen, proto_tree *opt_tree)
186 {
187   proto_tree *field_tree = NULL;
188   proto_item *tf;
189   guint leftedge, rightedge;
190
191   tf = proto_tree_add_text(opt_tree, offset,      optlen, "%s:", optp->name);
192   offset += 2;  /* skip past type and length */
193   optlen -= 2;  /* subtract size of type and length */
194   while (optlen > 0) {
195     if (field_tree == NULL) {
196       /* Haven't yet made a subtree out of this option.  Do so. */
197       field_tree = proto_item_add_subtree(tf, optp->subtree_index);
198     }
199     if (optlen < 4) {
200       proto_tree_add_text(field_tree, offset,      optlen,
201         "(suboption would go past end of option)");
202       break;
203     }
204     /* XXX - check whether it goes past end of packet */
205     leftedge = pntohl(opd);
206     opd += 4;
207     optlen -= 4;
208     if (optlen < 4) {
209       proto_tree_add_text(field_tree, offset,      optlen,
210         "(suboption would go past end of option)");
211       break;
212     }
213     /* XXX - check whether it goes past end of packet */
214     rightedge = pntohl(opd);
215     opd += 4;
216     optlen -= 4;
217     proto_tree_add_text(field_tree, offset,      8,
218         "left edge = %u, right edge = %u", leftedge, rightedge);
219     tcp_info_append_uint("SLE", leftedge);
220     tcp_info_append_uint("SRE", rightedge);
221     offset += 8;
222   }
223 }
224
225 static void
226 dissect_tcpopt_echo(const ip_tcp_opt *optp, const u_char *opd,
227     int offset, guint optlen, proto_tree *opt_tree)
228 {
229   proto_tree_add_text(opt_tree, offset,      optlen,
230                         "%s: %u", optp->name, pntohl(opd));
231   tcp_info_append_uint("ECHO", pntohl(opd));
232 }
233
234 static void
235 dissect_tcpopt_timestamp(const ip_tcp_opt *optp, const u_char *opd,
236     int offset, guint optlen, proto_tree *opt_tree)
237 {
238   proto_tree_add_text(opt_tree, offset,      optlen,
239     "%s: tsval %u, tsecr %u", optp->name, pntohl(opd), pntohl(opd + 4));
240   tcp_info_append_uint("TSV", pntohl(opd));
241   tcp_info_append_uint("TSER", pntohl(opd + 4));
242 }
243
244 static void
245 dissect_tcpopt_cc(const ip_tcp_opt *optp, const u_char *opd,
246     int offset, guint optlen, proto_tree *opt_tree)
247 {
248   proto_tree_add_text(opt_tree, offset,      optlen,
249                         "%s: %u", optp->name, pntohl(opd));
250   tcp_info_append_uint("CC", pntohl(opd));
251 }
252
253 static const ip_tcp_opt tcpopts[] = {
254   {
255     TCPOPT_EOL,
256     "EOL",
257     -1,
258     NO_LENGTH,
259     0,
260     NULL,
261   },
262   {
263     TCPOPT_NOP,
264     "NOP",
265     -1,
266     NO_LENGTH,
267     0,
268     NULL,
269   },
270   {
271     TCPOPT_MSS,
272     "Maximum segment size",
273     -1,
274     FIXED_LENGTH,
275     TCPOLEN_MSS,
276     dissect_tcpopt_maxseg
277   },
278   {
279     TCPOPT_WINDOW,
280     "Window scale",
281     -1,
282     FIXED_LENGTH,
283     TCPOLEN_WINDOW,
284     dissect_tcpopt_wscale
285   },
286   {
287     TCPOPT_SACK_PERM,
288     "SACK permitted",
289     -1,
290     FIXED_LENGTH,
291     TCPOLEN_SACK_PERM,
292     NULL,
293   },
294   {
295     TCPOPT_SACK,
296     "SACK",
297     ETT_TCP_OPTION_SACK,
298     VARIABLE_LENGTH,
299     TCPOLEN_SACK_MIN,
300     dissect_tcpopt_sack
301   },
302   {
303     TCPOPT_ECHO,
304     "Echo",
305     -1,
306     FIXED_LENGTH,
307     TCPOLEN_ECHO,
308     dissect_tcpopt_echo
309   },
310   {
311     TCPOPT_ECHOREPLY,
312     "Echo reply",
313     -1,
314     FIXED_LENGTH,
315     TCPOLEN_ECHOREPLY,
316     dissect_tcpopt_echo
317   },
318   {
319     TCPOPT_TIMESTAMP,
320     "Time stamp",
321     -1,
322     FIXED_LENGTH,
323     TCPOLEN_TIMESTAMP,
324     dissect_tcpopt_timestamp
325   },
326   {
327     TCPOPT_CC,
328     "CC",
329     -1,
330     FIXED_LENGTH,
331     TCPOLEN_CC,
332     dissect_tcpopt_cc
333   },
334   {
335     TCPOPT_CCNEW,
336     "CC.NEW",
337     -1,
338     FIXED_LENGTH,
339     TCPOPT_CCNEW,
340     dissect_tcpopt_cc
341   },
342   {
343     TCPOPT_CCECHO,
344     "CC.ECHO",
345     -1,
346     FIXED_LENGTH,
347     TCPOLEN_CCECHO,
348     dissect_tcpopt_cc
349   }
350 };
351
352 #define N_TCP_OPTS      (sizeof tcpopts / sizeof tcpopts[0])
353
354 /* TCP flags flag */
355 static const true_false_string flags_set_truth = {
356   "Set",
357   "Not set"
358 };
359
360 void
361 dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
362   e_tcphdr   th;
363   proto_tree *tcp_tree = NULL, *field_tree = NULL;
364   proto_item *ti, *tf;
365   gchar      flags[64] = "<None>";
366   gchar     *fstr[] = {"FIN", "SYN", "RST", "PSH", "ACK", "URG"};
367   gint       fpos = 0, i;
368   guint      bpos;
369   guint      hlen;
370   guint      optlen;
371   guint      packet_max = pi.len;
372
373   /* To do: Check for {cap len,pkt len} < struct len */
374   /* Avoids alignment problems on many architectures. */
375   memcpy(&th, &pd[offset], sizeof(e_tcphdr));
376   th.th_sport = ntohs(th.th_sport);
377   th.th_dport = ntohs(th.th_dport);
378   th.th_win   = ntohs(th.th_win);
379   th.th_sum   = ntohs(th.th_sum);
380   th.th_urp   = ntohs(th.th_urp);
381   th.th_seq   = ntohl(th.th_seq);
382   th.th_ack   = ntohl(th.th_ack);
383   
384   info_len = 0;
385
386   if (check_col(fd, COL_PROTOCOL) || tree) {  
387     for (i = 0; i < 6; i++) {
388       bpos = 1 << i;
389       if (th.th_flags & bpos) {
390         if (fpos) {
391           strcpy(&flags[fpos], ", ");
392           fpos += 2;
393         }
394         strcpy(&flags[fpos], fstr[i]);
395         fpos += 3;
396       }
397     }
398     flags[fpos] = '\0';
399   }
400   
401   hlen = hi_nibble(th.th_off_x2) * 4;  /* TCP header length, in bytes */
402
403   if (check_col(fd, COL_PROTOCOL))
404     col_add_str(fd, COL_PROTOCOL, "TCP");
405   if (check_col(fd, COL_INFO)) {
406     /* Copy the data into info_str in case one of the option handling
407        routines needs to append to it. */
408     if (th.th_flags & TH_URG)
409       info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Urg=%u",
410         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
411         th.th_seq, th.th_ack, th.th_win, th.th_urp);
412     else
413       info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u",
414         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
415         th.th_seq, th.th_ack, th.th_win);
416     /* The info column is actually written after the options are decoded */
417   }
418   
419   if (tree) {
420     ti = proto_tree_add_item(tree, proto_tcp, offset, hlen, NULL);
421     tcp_tree = proto_item_add_subtree(ti, ETT_TCP);
422     proto_tree_add_item_format(tcp_tree, hf_tcp_srcport, offset, 2, th.th_sport,
423         "Source port: %s (%u)", get_tcp_port(th.th_sport), th.th_sport);
424     proto_tree_add_item_format(tcp_tree, hf_tcp_dstport, offset + 2, 2, th.th_dport,
425         "Destination port: %s (%u)", get_tcp_port(th.th_dport), th.th_dport);
426     proto_tree_add_item_hidden(tcp_tree, hf_tcp_port, offset, 2, th.th_sport);
427     proto_tree_add_item_hidden(tcp_tree, hf_tcp_port, offset + 2, 2, th.th_dport);
428     proto_tree_add_item(tcp_tree, hf_tcp_seq, offset + 4, 4, th.th_seq);
429     if (th.th_flags & TH_ACK)
430       proto_tree_add_item(tcp_tree, hf_tcp_ack, offset + 8, 4, th.th_ack);
431     proto_tree_add_item_format(tcp_tree, hf_tcp_hdr_len, offset + 12, 1, hlen,
432         "Header length: %u bytes", hlen);
433     tf = proto_tree_add_item_format(tcp_tree, hf_tcp_flags, offset + 13, 1,
434         th.th_flags, "Flags: 0x%04x (%s)", th.th_flags, flags);
435     field_tree = proto_item_add_subtree(tf, ETT_TCP_FLAGS);
436     proto_tree_add_item(field_tree, hf_tcp_flags_urg, offset + 13, 1, th.th_flags);
437     proto_tree_add_item(field_tree, hf_tcp_flags_ack, offset + 13, 1, th.th_flags);
438     proto_tree_add_item(field_tree, hf_tcp_flags_push, offset + 13, 1, th.th_flags);
439     proto_tree_add_item(field_tree, hf_tcp_flags_reset, offset + 13, 1, th.th_flags);
440     proto_tree_add_item(field_tree, hf_tcp_flags_syn, offset + 13, 1, th.th_flags);
441     proto_tree_add_item(field_tree, hf_tcp_flags_fin, offset + 13, 1, th.th_flags);
442     proto_tree_add_item(tcp_tree, hf_tcp_window_size, offset + 14, 2, th.th_win);
443     proto_tree_add_item(tcp_tree, hf_tcp_checksum, offset + 16, 2, th.th_sum);
444     if (th.th_flags & TH_URG)
445       proto_tree_add_item(tcp_tree, hf_tcp_urgent_pointer, offset + 18, 2, th.th_urp);
446   }
447
448   /* Decode TCP options, if any. */
449   if (tree  && hlen > sizeof (e_tcphdr)) {
450     /* There's more than just the fixed-length header.  Decode the
451        options. */
452     optlen = hlen - sizeof (e_tcphdr); /* length of options, in bytes */
453     tf = proto_tree_add_text(tcp_tree, offset +  20, optlen,
454       "Options: (%d bytes)", optlen);
455     field_tree = proto_item_add_subtree(tf, ETT_TCP_OPTIONS);
456     dissect_ip_tcp_options(&pd[offset + 20], offset + 20, optlen,
457       tcpopts, N_TCP_OPTS, TCPOPT_EOL, field_tree);
458   }
459
460   if (check_col(fd, COL_INFO))
461     col_add_str(fd, COL_INFO, info_str);
462
463   /* Skip over header + options */
464   offset += hlen;
465
466   pi.ptype = PT_TCP;
467   pi.srcport = th.th_sport;
468   pi.destport = th.th_dport;
469   
470   /* Check the packet length to see if there's more data
471      (it could be an ACK-only packet) */
472   if (packet_max > offset) {
473     /* XXX - this should be handled the way UDP handles this, with a table
474        of port numbers to which stuff can be added */
475 #define PORT_IS(port)   (th.th_sport == port || th.th_dport == port)
476     if (PORT_IS(TCP_PORT_PRINTER))
477       dissect_lpd(pd, offset, fd, tree);
478     else if (PORT_IS(TCP_PORT_TELNET)) {
479       pi.match_port = TCP_PORT_TELNET;
480       dissect_telnet(pd, offset, fd, tree);
481     } else if (PORT_IS(TCP_PORT_FTPDATA)) {
482       pi.match_port = TCP_PORT_FTPDATA;
483       dissect_ftpdata(pd, offset, fd, tree);
484     } else if (PORT_IS(TCP_PORT_FTP)) {
485       pi.match_port = TCP_PORT_FTP;
486       dissect_ftp(pd, offset, fd, tree);
487     } else if (PORT_IS(TCP_PORT_POP)) {
488       pi.match_port = TCP_PORT_POP;
489       dissect_pop(pd, offset, fd, tree);
490     } else if (PORT_IS(TCP_PORT_IMAP)) {
491       pi.match_port = TCP_PORT_IMAP;
492       dissect_imap(pd, offset, fd, tree);
493     } else if (PORT_IS(TCP_PORT_NNTP)) {
494       pi.match_port = TCP_PORT_NNTP;
495       dissect_nntp(pd, offset, fd, tree);
496     } else if (PORT_IS(TCP_PORT_NTP)) {
497       pi.match_port = TCP_PORT_NTP;
498       dissect_ntp(pd, offset, fd, tree);
499     } else if (PORT_IS(TCP_PORT_PPTP)) {
500       pi.match_port = TCP_PORT_PPTP;
501       dissect_pptp(pd, offset, fd, tree);
502     } else if (PORT_IS(TCP_PORT_HTTP) || PORT_IS(TCP_ALT_PORT_HTTP)
503             || PORT_IS(631))
504       dissect_http(pd, offset, fd, tree);
505     else if (PORT_IS(TCP_PORT_NBSS)) {
506       pi.match_port = TCP_PORT_NBSS;
507       dissect_nbss(pd, offset, fd, tree);
508     } else if (PORT_IS(TCP_PORT_RTSP))
509       dissect_rtsp(pd, offset, fd, tree);
510     else if (PORT_IS(TCP_PORT_BGP)) {
511       pi.match_port = TCP_PORT_BGP;
512       dissect_bgp(pd, offset, fd, tree);
513     } else if (PORT_IS(TCP_PORT_MAPI)) {
514       pi.match_port = TCP_PORT_MAPI;
515       dissect_mapi(pd, offset, fd, tree);
516     } else {
517         /* check existence of high level protocols */
518
519         if (memcmp(&pd[offset], "GIOP",  4) == 0) {
520           dissect_giop(pd, offset, fd, tree);
521         }
522         else if ( PORT_IS(TCP_PORT_YHOO) && 
523                 (memcmp(&pd[offset], "YPNS",  4) == 0 ||
524                         memcmp(&pd[offset], "YHOO",  4) == 0 )) {
525           dissect_yhoo(pd, offset, fd, tree);
526         }
527         else {
528           dissect_data(pd, offset, fd, tree);
529         }
530     }
531   }
532  
533   if( data_out_file ) {
534     reassemble_tcp( th.th_seq,          /* sequence number */
535         ( pi.len - offset ),            /* data length */
536         ( pd+offset ),                  /* data */
537         ( pi.captured_len - offset ),   /* captured data length */
538         ( th.th_flags & TH_SYN ),       /* is syn set? */
539         &pi.net_src,
540         &pi.net_dst,
541         pi.srcport,
542         pi.destport); 
543   }
544 }
545
546 void
547 proto_register_tcp(void)
548 {
549         static hf_register_info hf[] = {
550
551                 { &hf_tcp_srcport,
552                 { "Source Port",                "tcp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
553                         "" }},
554
555                 { &hf_tcp_dstport,
556                 { "Destination Port",           "tcp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
557                         "" }},
558
559                 { &hf_tcp_port,
560                 { "Source or Destination Port", "tcp.port", FT_UINT16, BASE_DEC, NULL, 0x0,
561                         "" }},
562
563                 { &hf_tcp_seq,
564                 { "Sequence number",            "tcp.seq", FT_UINT32, BASE_DEC, NULL, 0x0,
565                         "" }},
566
567                 { &hf_tcp_ack,
568                 { "Acknowledgement number",     "tcp.ack", FT_UINT32, BASE_DEC, NULL, 0x0,
569                         "" }},
570
571                 { &hf_tcp_hdr_len,
572                 { "Header Length",              "tcp.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0,
573                         "" }},
574
575                 { &hf_tcp_flags,
576                 { "Flags",                      "tcp.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
577                         "" }},
578
579                 { &hf_tcp_flags_urg,
580                 { "Urgent",                     "tcp.flags.urg", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_URG,
581                         "" }},
582
583                 { &hf_tcp_flags_ack,
584                 { "Acknowledgment",             "tcp.flags.ack", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_ACK,
585                         "" }},
586
587                 { &hf_tcp_flags_push,
588                 { "Push",                       "tcp.flags.push", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_PUSH,
589                         "" }},
590
591                 { &hf_tcp_flags_reset,
592                 { "Reset",                      "tcp.flags.reset", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_RST,
593                         "" }},
594
595                 { &hf_tcp_flags_syn,
596                 { "Syn",                        "tcp.flags.syn", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_SYN,
597                         "" }},
598
599                 { &hf_tcp_flags_fin,
600                 { "Fin",                        "tcp.flags.fin", FT_BOOLEAN, 8, TFS(&flags_set_truth), TH_FIN,
601                         "" }},
602
603                 { &hf_tcp_window_size,
604                 { "Window size",                "tcp.window_size", FT_UINT16, BASE_DEC, NULL, 0x0,
605                         "" }},
606
607                 { &hf_tcp_checksum,
608                 { "Checksum",                   "tcp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
609                         "" }},
610
611                 { &hf_tcp_urgent_pointer,
612                 { "Urgent pointer",             "tcp.urgent_pointer", FT_UINT16, BASE_DEC, NULL, 0x0,
613                         "" }},
614         };
615
616         proto_tcp = proto_register_protocol ("Transmission Control Protocol", "tcp");
617         proto_register_field_array(proto_tcp, hf, array_length(hf));
618 }