00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef WIN32
00037 #include <endian.h>
00038 #else
00039 typedef char * caddr_t;
00040 #include <winsock2.h>
00041 #ifndef LITTLE_ENDIAN
00042 #define LITTLE_ENDIAN 1234
00043 #define BIG_ENDIAN 4321
00044 #define BYTE_ORDER LITTLE_ENDIAN
00045 #endif
00046 #endif
00047
00048
00049
00050
00051 struct ipovly {
00052 caddr_t ih_next, ih_prev;
00053 u_char ih_x1;
00054 u_char ih_pr;
00055 short ih_len;
00056 struct in_addr ih_src;
00057 struct in_addr ih_dst;
00058 };
00059
00060
00061
00062
00063
00064
00065
00066 struct ipq {
00067 struct ipq *next,*prev;
00068 u_char ipq_ttl;
00069 u_char ipq_p;
00070 u_short ipq_id;
00071 struct ipasfrag *ipq_next,*ipq_prev;
00072
00073 struct in_addr ipq_src,ipq_dst;
00074 };
00075
00076
00077
00078
00079
00080
00081 struct ipasfrag {
00082 #if BYTE_ORDER == LITTLE_ENDIAN
00083 u_char ip_hl:4,
00084 ip_v:4;
00085 #endif
00086 #if BYTE_ORDER == BIG_ENDIAN
00087 u_char ip_v:4,
00088 ip_hl:4;
00089 #endif
00090 u_char ipf_mff;
00091
00092
00093 short ip_len;
00094 u_short ip_id;
00095 short ip_off;
00096 u_char ip_ttl;
00097 u_char ip_p;
00098 u_short ip_sum;
00099 struct ipasfrag *ipf_next;
00100 struct ipasfrag *ipf_prev;
00101 };
00102
00103
00104
00105
00106
00107
00108
00109 #define MAX_IPOPTLEN 40
00110
00111 struct ipoption {
00112 struct in_addr ipopt_dst;
00113 char ipopt_list[MAX_IPOPTLEN];
00114 };
00115
00116 struct ipstat {
00117 n_long ips_total;
00118 n_long ips_badsum;
00119 n_long ips_tooshort;
00120 n_long ips_toosmall;
00121 n_long ips_badhlen;
00122 n_long ips_badlen;
00123 n_long ips_fragments;
00124 n_long ips_fragdropped;
00125 n_long ips_fragtimeout;
00126 n_long ips_forward;
00127 n_long ips_cantforward;
00128 n_long ips_redirectsent;
00129 n_long ips_noproto;
00130 n_long ips_delivered;
00131 n_long ips_localout;
00132 n_long ips_odropped;
00133 n_long ips_reassembled;
00134 n_long ips_fragmented;
00135 n_long ips_ofragments;
00136 n_long ips_cantfrag;
00137 n_long ips_badoptions;
00138 n_long ips_noroute;
00139 n_long ips_badvers;
00140 n_long ips_rawout;
00141 };
00142
00143 #ifdef KERNEL
00144
00145 #define IP_FORWARDING 0x1
00146 #define IP_RAWOUTPUT 0x2
00147 #define IP_ROUTETOIF SO_DONTROUTE
00148 #define IP_ALLOWBROADCAST SO_BROADCAST
00149
00150 struct ipstat ipstat;
00151 struct ipq ipq;
00152 u_short ip_id;
00153 int ip_defttl;
00154
00155 int in_control __P((struct socket *, n_long, caddr_t, struct ifnet *));
00156 int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
00157 void ip_deq __P((struct ipasfrag *));
00158 int ip_dooptions __P((struct mbuf *));
00159 void ip_drain __P((void));
00160 void ip_enq __P((struct ipasfrag *, struct ipasfrag *));
00161 void ip_forward __P((struct mbuf *, int));
00162 void ip_freef __P((struct ipq *));
00163 void ip_freemoptions __P((struct ip_moptions *));
00164 int ip_getmoptions __P((int, struct ip_moptions *, struct mbuf **));
00165 void ip_init __P((void));
00166 int ip_mforward __P((struct mbuf *, struct ifnet *));
00167 int ip_optcopy __P((struct ip *, struct ip *));
00168 int ip_output __P((struct mbuf *,
00169 struct mbuf *, struct route *, int, struct ip_moptions *));
00170 int ip_pcbopts __P((struct mbuf **, struct mbuf *));
00171 struct ip *
00172 ip_reass __P((struct ipasfrag *, struct ipq *));
00173 struct in_ifaddr *
00174 ip_rtaddr __P((struct in_addr));
00175 int ip_setmoptions __P((int, struct ip_moptions **, struct mbuf *));
00176 void ip_slowtimo __P((void));
00177 struct mbuf *
00178 ip_srcroute __P((void));
00179 void ip_stripoptions __P((struct mbuf *, struct mbuf *));
00180 int ip_sysctl __P((int *, n_long, void *, size_t *, void *, size_t));
00181 void ipintr __P((void));
00182 int rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
00183 void rip_init __P((void));
00184 void rip_input __P((struct mbuf *));
00185 int rip_output __P((struct mbuf *, struct socket *, n_long));
00186 int rip_usrreq __P((struct socket *,
00187 int, struct mbuf *, struct mbuf *, struct mbuf *));
00188 #endif