tcp.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2005 Christian Dankbar
00003 // Copyright (C) 2009 Thomas Reschka
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef OPPSIM_NETINET_TCP_H
00020 #define OPPSIM_NETINET_TCP_H
00021 
00022 #include "headers/defs.h"   // for endian macros
00023 
00024 #  define TH_FIN    0x01
00025 #  define TH_SYN    0x02
00026 #  define TH_RST    0x04
00027 #  define TH_PUSH   0x08
00028 #  define TH_ACK    0x10
00029 #  define TH_URG    0x20
00030 #define TH_FLAGS    0x3F
00031 
00032 struct tcphdr
00033   {
00034     uint16_t th_sport;         /* source port */
00035     uint16_t th_dport;         /* destination port */
00036     uint32_t th_seq;           /* sequence number */
00037     uint32_t th_ack;           /* acknowledgement number */
00038 #  if BYTE_ORDER == LITTLE_ENDIAN
00039     uint8_t th_x2:4;           /* (unused) */
00040     uint8_t th_offs:4;         /* data offset */
00041 #  elif BYTE_ORDER == BIG_ENDIAN
00042     uint8_t th_offs:4;         /* data offset */
00043     uint8_t th_x2:4;           /* (unused) */
00044 #else
00045 # error "Please check BYTE_ORDER declaration"
00046 #  endif
00047     uint8_t th_flags;
00048     uint16_t th_win;           /* window */
00049     uint16_t th_sum;           /* checksum */
00050     uint16_t th_urp;           /* urgent pointer */
00051 
00052     uint32_t th_options[0];    /* options (optional) */
00053     //unsigned char data[0];        XXX MSVC only allows zero-size arrays at the end of a struct
00054 }; // TODO  __attribute__((packed));
00055 
00056 #endif /* netinet/tcp.h */
00057