/home/tomh/openhip/hip-0.5/src/include/win32/ip.h

Go to the documentation of this file.
00001 /*
00002  * Host Identity Protocol
00003  * Copyright (C) 2005 the Boeing Company
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (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  *  ip.h
00016  *
00017  *  Authors: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
00018  * 
00019  * Definitions for TCP/IP headers that are missing from Windows.
00020  *
00021  */
00022 
00023 #ifndef _HIP_IP_H_
00024 #define _HIP_IP_H_
00025 
00026 #include <ws2tcpip.h> /* this is required for the struct in6_addr's in 
00027                          struct ip6_hdr */
00028 
00029 #define IPVERSION 4
00030 struct ip {
00031         __u8 ip_hl:4, ip_v:4;   /* MSVC requires these are char */
00032         /*__u32 ip_hl:4;           This will not work with MSVC.
00033           __u32 ip_v:4;*/
00034         __u8 ip_tos;
00035         __u16 ip_len;
00036         __u16 ip_id;
00037         __u16 ip_off;
00038         __u8 ip_ttl;
00039         __u8 ip_p;
00040         __u16 ip_sum;
00041         union {                 /* allows use of struct ip or iphdr*/
00042                 struct in_addr ip_src;
00043                 __u32 saddr;
00044         };
00045         union {
00046                 struct in_addr ip_dst;
00047                 __u32 daddr;
00048         };
00049 };
00050 /* allows use of struct ip or iphdr*/
00051 #define iphdr ip
00052 #define ihl ip_hl
00053 
00054 
00055 struct udphdr {
00056 /*      __u16 uh_sport;
00057         __u16 uh_dport; */
00058         __u16 source;
00059         __u16 dest;
00060         __u16 uh_ulen;
00061         __u16 check;
00062 };
00063 
00064 struct tcphdr {
00065 /*      __u16 th_sport;
00066         __u16 th_dport; */
00067         __u16 source;
00068         __u16 dest;
00069         __u32 th_seq;
00070         __u32 th_ack;
00071         __u8 th_x2:4, th_off:4;
00072         __u8 th_flags;
00073         __u16 th_win;
00074         __u16 check;
00075         __u16 th_urp;
00076 };
00077 
00078 /* from netinet/ip6.h */
00079 struct ip6_hdr
00080   {
00081     union
00082       {
00083         struct ip6_hdrctl
00084           {
00085             __u32 ip6_un1_flow;   /* 4 bits version, 8 bits TC,
00086                                         20 bits flow-ID */
00087             __u16 ip6_un1_plen;   /* payload length */
00088             __u8  ip6_un1_nxt;    /* next header */
00089             __u8  ip6_un1_hlim;   /* hop limit */
00090           } ip6_un1;
00091         __u8 ip6_un2_vfc;       /* 4 bits version, top 4 bits tclass */
00092       } ip6_ctlun;
00093     struct in6_addr ip6_src;      /* source address */
00094     struct in6_addr ip6_dst;      /* destination address */
00095   };
00096 
00097 #define ip6_vfc   ip6_ctlun.ip6_un2_vfc
00098 #define ip6_flow  ip6_ctlun.ip6_un1.ip6_un1_flow
00099 #define ip6_plen  ip6_ctlun.ip6_un1.ip6_un1_plen
00100 #define ip6_nxt   ip6_ctlun.ip6_un1.ip6_un1_nxt
00101 #define ip6_hlim  ip6_ctlun.ip6_un1.ip6_un1_hlim
00102 #define ip6_hops  ip6_ctlun.ip6_un1.ip6_un1_hlim
00103 
00104 /* from netinet/icmp6.h */
00105 struct icmp6_hdr
00106   {
00107     __u8     icmp6_type;   /* type field */
00108     __u8     icmp6_code;   /* code field */
00109     __u16    icmp6_cksum;  /* checksum field */
00110     union
00111       {
00112         __u32  icmp6_un_data32[1]; /* type-specific field */
00113         __u16  icmp6_un_data16[2]; /* type-specific field */
00114         __u8   icmp6_un_data8[4];  /* type-specific field */
00115       } icmp6_dataun;
00116   };
00117 
00118 #define icmp6_data32    icmp6_dataun.icmp6_un_data32
00119 #define icmp6_data16    icmp6_dataun.icmp6_un_data16
00120 #define icmp6_data8     icmp6_dataun.icmp6_un_data8
00121 #define icmp6_pptr      icmp6_data32[0]  /* parameter prob */
00122 #define icmp6_mtu       icmp6_data32[0]  /* packet too big */
00123 #define icmp6_id        icmp6_data16[0]  /* echo request/reply */
00124 #define icmp6_seq       icmp6_data16[1]  /* echo request/reply */
00125 #define icmp6_maxdelay  icmp6_data16[0]  /* mcast group membership */
00126 
00127 #define ICMP6_DST_UNREACH             1
00128 #define ICMP6_PACKET_TOO_BIG          2
00129 #define ICMP6_TIME_EXCEEDED           3
00130 #define ICMP6_PARAM_PROB              4
00131 
00132 #define ICMP6_INFOMSG_MASK  0x80    /* all informational messages */
00133 
00134 #define ICMP6_ECHO_REQUEST          128
00135 #define ICMP6_ECHO_REPLY            129
00136 #define ICMP6_MEMBERSHIP_QUERY      130
00137 #define ICMP6_MEMBERSHIP_REPORT     131
00138 #define ICMP6_MEMBERSHIP_REDUCTION  132
00139 #define ND_ROUTER_SOLICIT           133
00140 #define ND_ROUTER_ADVERT            134
00141 #define ND_NEIGHBOR_SOLICIT         135
00142 #define ND_NEIGHBOR_ADVERT          136
00143 #define ND_REDIRECT                 137
00144 
00145 #if     BYTE_ORDER == BIG_ENDIAN
00146 #define ND_NA_FLAG_ROUTER        0x80000000
00147 #define ND_NA_FLAG_SOLICITED     0x40000000
00148 #define ND_NA_FLAG_OVERRIDE      0x20000000
00149 #else   /* BYTE_ORDER == LITTLE_ENDIAN */
00150 #define ND_NA_FLAG_ROUTER        0x00000080
00151 #define ND_NA_FLAG_SOLICITED     0x00000040
00152 #define ND_NA_FLAG_OVERRIDE      0x00000020
00153 #endif
00154 
00155 struct nd_opt_hdr             /* Neighbor discovery option header */
00156   {
00157     uint8_t  nd_opt_type;
00158     uint8_t  nd_opt_len;        /* in units of 8 octets */
00159     /* followed by option specific data */
00160   };
00161 
00162 #define  ND_OPT_SOURCE_LINKADDR       1
00163 #define  ND_OPT_TARGET_LINKADDR       2
00164 #define  ND_OPT_PREFIX_INFORMATION    3
00165 #define  ND_OPT_REDIRECTED_HEADER     4
00166 #define  ND_OPT_MTU                   5
00167 #define  ND_OPT_RTR_ADV_INTERVAL      7
00168 #define  ND_OPT_HOME_AGENT_INFO       8
00169 
00170 #endif /* _HIP_IP_H_ */

Generated on Mon Oct 22 11:43:43 2007 for OpenHIP by  doxygen 1.5.1