ip.h

Go to the documentation of this file.
00001 /*
00002 ** ipv4.h for  in /home/anoman/work/lse/atomix/lseos-net/inet
00003 ** 
00004 ** Copyright (c)2004 Arthur Kopatsy
00005 ** Login   <kopats_a@epita.fr>
00006 ** 
00007 ** Started on  Thu Aug 26 10:51:14 2004 Arthur Kopatsy
00008 ** Last update Fri Dec 17 09:49:51 2004 Arthur Kopatsy
00009 */
00010 
00011 #ifndef IP_H_
00012 #define IP_H_
00013 
00014 #define IP_HEADER_LEN           20
00015 
00016 #define IP_V4           4
00017 #define IP_V6           6
00018 
00019 #define IP_TTL          63
00020 
00021 #define IP_FL_MOREFRAG  0x2000
00022 #define IP_FL_DONTFRAG  0x4000
00023 
00024 #define IP_OFFMASK      0x1fff
00025 #define IP_FLGMASK      0xe000
00026 #define IP_OFF          0x1fff
00027 
00028 struct s_ip_hdr
00029 {
00030 #if 1                   /* Little indian */
00031   u_int32_t             ip_hl : 4;
00032   u_int32_t             ip_v : 4;
00033 #else
00034   u_int32_t             ip_v : 4;
00035   u_int32_t             ip_hl : 4;
00036 #endif
00037   u_int8_t              ip_tos;
00038   u_int16_t             ip_len;
00039   u_int16_t             ip_id;
00040   u_int16_t             ip_off;
00041   u_int8_t              ip_ttl;
00042   u_int8_t              ip_p;
00043   u_int16_t             ip_sum;
00044   struct in_addr        ip_src;
00045   struct in_addr        ip_dst;
00046 } __attribute__ ((__packed__));
00047 
00048 /* UDP pseudo header for ckecksum computing */
00049 struct s_phdr
00050 {
00051   struct in_addr        ph_src;
00052   struct in_addr        ph_dst;
00053 #if 1                   /* Little indian */
00054   u_int8_t              ph_zero;
00055   u_int8_t              ph_p;
00056 #else
00057   u_int8_t              ph_p;
00058   u_int8_t              ph_zero;
00059 #endif
00060   u_int16_t             ph_len;  
00061 };
00062 
00063 #ifdef __INET__
00064 
00065 #define IP_FRAG_TTL             (60 * 1000000)
00066 
00067 struct s_frag_pk
00068 {
00069   LIST_ENTRY(s_frag_pk)         frp_next;
00070   struct in_addr                frp_src;
00071   u_int16_t                     frp_id;
00072   int                           frp_last;
00073   size_t                        frp_size;
00074   int64_t                       frp_timer;
00075   struct s_pkbuf                *frp_pk;
00076 };
00077 
00078 struct s_ip_proto_info
00079 {
00080   LIST_HEAD(s_frag_pks, s_frag_pk)      in_frag_pks;            /* List of waiting fragmented pk */
00081   int                                   in_id;                  /* Incremental id */
00082 };
00083 
00084 #endif
00085 
00086 /* PROTO ip.c */
00087 #ifdef __INET__
00088 /* ip.c */
00089 int ip_proto_init(void);
00090 void ip_dump(struct s_pkbuf *pk);
00091 int ip_output(struct s_pkbuf *pk);
00092 int ip_fragment_input(struct s_pkbuf *pk);
00093 int aa_ip_input(struct s_pkbuf *pk);
00094 #endif /* __INET__ */
00095 #endif

Generated on Wed May 24 23:05:52 2006 for LSE/OS by  doxygen 1.4.6