]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/net/tcpip/v2_0/include/netinet/ip_state.h
Initial revision
[karo-tx-redboot.git] / packages / net / tcpip / v2_0 / include / netinet / ip_state.h
1 //==========================================================================
2 //
3 //      include/netinet/ip_state.h
4 //
5 //      
6 //
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 //
12 // Portions of this software may have been derived from OpenBSD or other sources,
13 // and are covered by the appropriate copyright disclaimers included herein.
14 //
15 // -------------------------------------------
16 //
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
20 //
21 // Author(s):    gthomas
22 // Contributors: gthomas
23 // Date:         2000-01-10
24 // Purpose:      
25 // Description:  
26 //              
27 //
28 //####DESCRIPTIONEND####
29 //
30 //==========================================================================
31
32
33 /* $OpenBSD: ip_state.h,v 1.10 1999/12/15 05:20:23 kjell Exp $ */
34 /*
35  * Copyright (C) 1995-1998 by Darren Reed.
36  *
37  * Redistribution and use in source and binary forms are permitted
38  * provided that this notice is preserved and due credit is given
39  * to the original author and the contributors.
40  *
41  * @(#)ip_state.h       1.3 1/12/96 (C) 1995 Darren Reed
42  */
43
44 #ifndef _NETINET_IP_STATE_H__
45 #define _NETINET_IP_STATE_H__
46
47 #define IPSTATE_SIZE    257
48 #define IPSTATE_MAX     2048    /* Maximum number of states held */
49
50 #define PAIRS(s1,d1,s2,d2)      ((((s1) == (s2)) && ((d1) == (d2))) ||\
51                                  (((s1) == (d2)) && ((d1) == (s2))))
52 #define IPPAIR(s1,d1,s2,d2)     PAIRS((s1).s_addr, (d1).s_addr, \
53                                       (s2).s_addr, (d2).s_addr)
54
55
56 typedef struct udpstate {
57         u_short us_sport;
58         u_short us_dport;
59 } udpstate_t;
60
61 typedef struct icmpstate {
62         u_short ics_id;
63         u_short ics_seq;
64         u_char  ics_type;
65 } icmpstate_t;
66
67 typedef struct  tcpdata {
68         u_32_t  td_end;
69         u_32_t  td_maxend;
70         u_short td_maxwin;
71 } tcpdata_t;
72
73 typedef struct tcpstate {
74         u_short ts_sport;
75         u_short ts_dport;
76         tcpdata_t ts_data[2];
77         u_char  ts_state[2];
78 } tcpstate_t;
79
80 typedef struct ipstate {
81         struct  ipstate *is_next;
82         u_long  is_age;
83         u_int   is_pass;
84         U_QUAD_T        is_pkts;
85         U_QUAD_T        is_bytes;
86         void    *is_ifpin;
87         void    *is_ifpout;
88         frentry_t       *is_rule;
89         struct  in_addr is_src;
90         struct  in_addr is_dst;
91         u_char  is_p;                   /* Protocol */
92         u_char  is_rout;                /* Is rule in/out ? */
93         u_32_t  is_flags;
94         u_32_t  is_opt;                 /* packet options set */
95         u_32_t  is_optmsk;              /*    "      "    mask */
96         u_short is_sec;                 /* security options set */
97         u_short is_secmsk;              /*    "        "    mask */
98         u_short is_auth;                /* authentication options set */
99         u_short is_authmsk;             /*    "              "    mask */
100         union {
101                 icmpstate_t     is_ics;
102                 tcpstate_t      is_ts;
103                 udpstate_t      is_us;
104         } is_ps;
105 } ipstate_t;
106
107 #define is_icmp is_ps.is_ics
108 #define is_type is_icmp.ics_type
109 #define is_code is_icmp.ics_code
110 #define is_tcp  is_ps.is_ts
111 #define is_udp  is_ps.is_us
112 #define is_send is_tcp.ts_data[0].td_end
113 #define is_dend is_tcp.ts_data[1].td_end
114 #define is_maxswin      is_tcp.ts_data[0].td_maxwin
115 #define is_maxdwin      is_tcp.ts_data[1].td_maxwin
116 #define is_maxsend      is_tcp.ts_data[0].td_maxend
117 #define is_maxdend      is_tcp.ts_data[1].td_maxend
118 #define is_sport        is_tcp.ts_sport
119 #define is_dport        is_tcp.ts_dport
120 #define is_state        is_tcp.ts_state
121
122 #define TH_OPENING      (TH_SYN|TH_ACK)
123 /*
124  * is_flags:
125  * Bits 0 - 3 are use as a mask with the current packet's bits to check for
126  * whether it is short, tcp/udp, a fragment or the presence of IP options.
127  * Bits 4 - 7 are set from the initial packet and contain what the packet
128  * anded with bits 0-3 must match.
129  * Bits 8,9 are used to indicate wildcard source/destination port matching.
130  */
131
132
133 typedef struct  ipslog  {
134         U_QUAD_T        isl_pkts;
135         U_QUAD_T        isl_bytes;
136         struct  in_addr isl_src;
137         struct  in_addr isl_dst;
138         u_char  isl_p;
139         u_char  isl_flags;
140         u_char  isl_state[2];
141         u_short isl_type;
142         union {
143                 u_short isl_filler[2];
144                 u_short isl_ports[2];
145                 u_short isl_icmp;
146         } isl_ps;
147 } ipslog_t;
148
149 #define isl_sport       isl_ps.isl_ports[0]
150 #define isl_dport       isl_ps.isl_ports[1]
151 #define isl_itype       isl_ps.isl_icmp
152
153 #define ISL_NEW         0
154 #define ISL_EXPIRE      0xffff
155 #define ISL_FLUSH       0xfffe
156
157
158 typedef struct  ips_stat {
159         u_long  iss_hits;
160         u_long  iss_miss;
161         u_long  iss_max;
162         u_long  iss_tcp;
163         u_long  iss_udp;
164         u_long  iss_icmp;
165         u_long  iss_nomem;
166         u_long  iss_expire;
167         u_long  iss_fin;
168         u_long  iss_active;
169         u_long  iss_logged;
170         u_long  iss_logfail;
171         u_long  iss_inuse;
172         ipstate_t **iss_table;
173 } ips_stat_t;
174
175
176 extern  u_long  fr_tcpidletimeout;
177 extern  u_long  fr_tcpclosewait;
178 extern  u_long  fr_tcplastack;
179 extern  u_long  fr_tcptimeout;
180 extern  u_long  fr_tcpclosed;
181 extern  u_long  fr_udptimeout;
182 extern  u_long  fr_icmptimeout;
183 extern  int     fr_stateinit __P((void));
184 extern  int     fr_tcpstate __P((ipstate_t *, fr_info_t *, ip_t *, tcphdr_t *));
185 extern  ipstate_t       *fr_addstate __P((ip_t *, fr_info_t *, u_int));
186 extern  frentry_t       *fr_checkstate __P((ip_t *, fr_info_t *));
187 extern  void    fr_timeoutstate __P((void));
188 extern  void    fr_tcp_age __P((u_long *, u_char *, ip_t *, fr_info_t *, int));
189 extern  void    fr_stateunload __P((void));
190 extern  void    ipstate_log __P((struct ipstate *, u_int));
191 #if defined(__NetBSD__) || defined(__OpenBSD__)
192 extern  int     fr_state_ioctl __P((caddr_t, u_long, int));
193 #else
194 extern  int     fr_state_ioctl __P((caddr_t, int, int));
195 #endif
196
197 #endif /* _NETINET_IP_STATE_H__ */