SAMV71 Xplained Ultra Software Package 1.3

vjbsdhdr.h

00001 #ifndef VJBSDHDR_H
00002 #define VJBSDHDR_H
00003 
00004 #include "lwip/tcp.h"
00005 
00006 /*
00007  * Structure of an internet header, naked of options.
00008  *
00009  * We declare ip_len and ip_off to be short, rather than u_short
00010  * pragmatically since otherwise unsigned comparisons can result
00011  * against negative integers quite easily, and fail in subtle ways.
00012  */
00013 PACK_STRUCT_BEGIN
00014 struct ip
00015 {
00016 #if defined(NO_CHAR_BITFIELDS)
00017   u_char   ip_hl_v;  /* bug in GCC for mips means the bitfield stuff will sometimes break - so we use a char for both and get round it with macro's instead... */
00018 #else
00019 #if BYTE_ORDER == LITTLE_ENDIAN
00020   unsigned ip_hl:4,              /* header length */
00021            ip_v :4;              /* version */
00022 #elif BYTE_ORDER == BIG_ENDIAN 
00023   unsigned ip_v :4,              /* version */
00024            ip_hl:4;              /* header length */
00025 #else
00026   COMPLAIN - NO BYTE ORDER SELECTED!
00027 #endif
00028 #endif
00029   u_char  ip_tos;                /* type of service */
00030   u_short ip_len;                /* total length */
00031   u_short ip_id;                 /* identification */
00032   u_short ip_off;                /* fragment offset field */
00033 #define  IP_DF 0x4000            /* dont fragment flag */
00034 #define  IP_MF 0x2000            /* more fragments flag */
00035 #define  IP_OFFMASK 0x1fff       /* mask for fragmenting bits */
00036   u_char  ip_ttl;                /* time to live */
00037   u_char  ip_p;                  /* protocol */
00038   u_short ip_sum;                /* checksum */
00039   struct  in_addr ip_src,ip_dst; /* source and dest address */
00040 };
00041 PACK_STRUCT_END
00042 
00043 typedef u32_t tcp_seq;
00044 
00045 /*
00046  * TCP header.
00047  * Per RFC 793, September, 1981.
00048  */
00049 PACK_STRUCT_BEGIN
00050 struct tcphdr  
00051 {
00052   u_short  th_sport;    /* source port */
00053   u_short  th_dport;    /* destination port */
00054   tcp_seq  th_seq;      /* sequence number */
00055   tcp_seq  th_ack;      /* acknowledgement number */
00056 #if defined(NO_CHAR_BITFIELDS)
00057   u_char   th_x2_off;
00058 #else
00059 #if BYTE_ORDER == LITTLE_ENDIAN
00060   unsigned th_x2 :4,    /* (unused) */
00061            th_off:4;    /* data offset */
00062 #endif
00063 #if BYTE_ORDER == BIG_ENDIAN 
00064   unsigned th_off:4,    /* data offset */
00065            th_x2 :4;    /* (unused) */
00066 #endif
00067 #endif
00068   u_char   th_flags;
00069   u_short  th_win;      /* window */
00070   u_short  th_sum;      /* checksum */
00071   u_short  th_urp;      /* urgent pointer */
00072 };
00073 PACK_STRUCT_END
00074 
00075 #endif /* VJBSDHDR_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines