2001-03-26 10:11:46 +04:00
|
|
|
/* $NetBSD: ip_state.h,v 1.18 2001/03/26 06:13:14 mike Exp $ */
|
1997-01-06 00:32:18 +03:00
|
|
|
|
1997-01-05 16:47:59 +03:00
|
|
|
/*
|
2000-05-03 15:12:03 +04:00
|
|
|
* Copyright (C) 1995-2000 by Darren Reed.
|
1997-01-05 16:47:59 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that this notice is preserved and due credit is given
|
|
|
|
* to the original author and the contributors.
|
|
|
|
*
|
|
|
|
* @(#)ip_state.h 1.3 1/12/96 (C) 1995 Darren Reed
|
2001-03-26 10:11:46 +04:00
|
|
|
* Id: ip_state.h,v 2.13.2.2 2000/08/23 11:01:31 darrenr Exp
|
1997-01-05 16:47:59 +03:00
|
|
|
*/
|
1998-02-10 04:26:19 +03:00
|
|
|
|
|
|
|
#ifndef _NETINET_IP_STATE_H_
|
|
|
|
#define _NETINET_IP_STATE_H_
|
1997-01-05 16:47:59 +03:00
|
|
|
|
2000-05-03 15:12:03 +04:00
|
|
|
#if defined(__STDC__) || defined(__GNUC__)
|
|
|
|
# define SIOCDELST _IOW('r', 61, struct ipstate *)
|
|
|
|
#else
|
|
|
|
# define SIOCDELST _IOW(r, 61, struct ipstate *)
|
|
|
|
#endif
|
|
|
|
|
2000-08-10 01:00:39 +04:00
|
|
|
#define IPSTATE_SIZE 5737
|
|
|
|
#define IPSTATE_MAX 4013 /* Maximum number of states held */
|
1997-01-05 16:47:59 +03:00
|
|
|
|
1997-05-25 16:40:11 +04:00
|
|
|
#define PAIRS(s1,d1,s2,d2) ((((s1) == (s2)) && ((d1) == (d2))) ||\
|
|
|
|
(((s1) == (d2)) && ((d1) == (s2))))
|
|
|
|
#define IPPAIR(s1,d1,s2,d2) PAIRS((s1).s_addr, (d1).s_addr, \
|
|
|
|
(s2).s_addr, (d2).s_addr)
|
|
|
|
|
|
|
|
|
1997-01-05 16:47:59 +03:00
|
|
|
typedef struct udpstate {
|
|
|
|
u_short us_sport;
|
|
|
|
u_short us_dport;
|
|
|
|
} udpstate_t;
|
|
|
|
|
|
|
|
typedef struct icmpstate {
|
|
|
|
u_short ics_id;
|
|
|
|
u_short ics_seq;
|
|
|
|
u_char ics_type;
|
|
|
|
} icmpstate_t;
|
|
|
|
|
1999-12-12 14:11:15 +03:00
|
|
|
typedef struct tcpdata {
|
|
|
|
u_32_t td_end;
|
|
|
|
u_32_t td_maxend;
|
|
|
|
u_short td_maxwin;
|
|
|
|
} tcpdata_t;
|
|
|
|
|
1997-01-05 16:47:59 +03:00
|
|
|
typedef struct tcpstate {
|
|
|
|
u_short ts_sport;
|
|
|
|
u_short ts_dport;
|
1999-12-12 14:11:15 +03:00
|
|
|
tcpdata_t ts_data[2];
|
1997-01-05 16:47:59 +03:00
|
|
|
u_char ts_state[2];
|
|
|
|
} tcpstate_t;
|
|
|
|
|
|
|
|
typedef struct ipstate {
|
|
|
|
struct ipstate *is_next;
|
2000-05-03 15:12:03 +04:00
|
|
|
struct ipstate **is_pnext;
|
|
|
|
struct ipstate *is_hnext;
|
|
|
|
struct ipstate **is_phnext;
|
1997-03-29 03:54:55 +03:00
|
|
|
u_long is_age;
|
1997-01-05 16:47:59 +03:00
|
|
|
u_int is_pass;
|
1997-05-25 16:40:11 +04:00
|
|
|
U_QUAD_T is_pkts;
|
|
|
|
U_QUAD_T is_bytes;
|
2000-05-03 15:12:03 +04:00
|
|
|
void *is_ifp[2];
|
1999-12-12 14:11:15 +03:00
|
|
|
frentry_t *is_rule;
|
2000-05-03 15:12:03 +04:00
|
|
|
union i6addr is_src;
|
|
|
|
union i6addr is_dst;
|
1999-12-12 14:11:15 +03:00
|
|
|
u_char is_p; /* Protocol */
|
2000-05-03 15:12:03 +04:00
|
|
|
u_char is_v;
|
|
|
|
u_int is_hv;
|
1999-12-12 14:11:15 +03:00
|
|
|
u_32_t is_flags;
|
|
|
|
u_32_t is_opt; /* packet options set */
|
|
|
|
u_32_t is_optmsk; /* " " mask */
|
|
|
|
u_short is_sec; /* security options set */
|
|
|
|
u_short is_secmsk; /* " " mask */
|
|
|
|
u_short is_auth; /* authentication options set */
|
|
|
|
u_short is_authmsk; /* " " mask */
|
1997-01-05 16:47:59 +03:00
|
|
|
union {
|
|
|
|
icmpstate_t is_ics;
|
|
|
|
tcpstate_t is_ts;
|
|
|
|
udpstate_t is_us;
|
|
|
|
} is_ps;
|
2000-05-03 15:12:03 +04:00
|
|
|
char is_ifname[2][IFNAMSIZ];
|
|
|
|
#if SOLARIS || defined(__sgi)
|
|
|
|
kmutex_t is_lock;
|
|
|
|
#endif
|
1997-01-05 16:47:59 +03:00
|
|
|
} ipstate_t;
|
|
|
|
|
2000-05-03 15:12:03 +04:00
|
|
|
#define is_saddr is_src.in4.s_addr
|
|
|
|
#define is_daddr is_dst.in4.s_addr
|
|
|
|
#define is_icmp is_ps.is_ics
|
|
|
|
#define is_type is_icmp.ics_type
|
|
|
|
#define is_code is_icmp.ics_code
|
|
|
|
#define is_tcp is_ps.is_ts
|
|
|
|
#define is_udp is_ps.is_us
|
|
|
|
#define is_send is_tcp.ts_data[0].td_end
|
|
|
|
#define is_dend is_tcp.ts_data[1].td_end
|
1999-12-12 14:11:15 +03:00
|
|
|
#define is_maxswin is_tcp.ts_data[0].td_maxwin
|
|
|
|
#define is_maxdwin is_tcp.ts_data[1].td_maxwin
|
|
|
|
#define is_maxsend is_tcp.ts_data[0].td_maxend
|
|
|
|
#define is_maxdend is_tcp.ts_data[1].td_maxend
|
1997-01-05 16:47:59 +03:00
|
|
|
#define is_sport is_tcp.ts_sport
|
|
|
|
#define is_dport is_tcp.ts_dport
|
|
|
|
#define is_state is_tcp.ts_state
|
2000-05-03 15:12:03 +04:00
|
|
|
#define is_ifpin is_ifp[0]
|
|
|
|
#define is_ifpout is_ifp[1]
|
1997-01-05 16:47:59 +03:00
|
|
|
|
|
|
|
#define TH_OPENING (TH_SYN|TH_ACK)
|
1999-12-12 14:11:15 +03:00
|
|
|
/*
|
|
|
|
* is_flags:
|
|
|
|
* Bits 0 - 3 are use as a mask with the current packet's bits to check for
|
|
|
|
* whether it is short, tcp/udp, a fragment or the presence of IP options.
|
|
|
|
* Bits 4 - 7 are set from the initial packet and contain what the packet
|
|
|
|
* anded with bits 0-3 must match.
|
|
|
|
* Bits 8,9 are used to indicate wildcard source/destination port matching.
|
|
|
|
*/
|
1997-01-05 16:47:59 +03:00
|
|
|
|
2000-05-03 15:12:03 +04:00
|
|
|
typedef struct ipstate_save {
|
|
|
|
void *ips_next;
|
|
|
|
struct ipstate ips_is;
|
|
|
|
struct frentry ips_fr;
|
|
|
|
} ipstate_save_t;
|
|
|
|
|
|
|
|
#define ips_rule ips_is.is_rule
|
|
|
|
|
1997-05-25 16:40:11 +04:00
|
|
|
|
|
|
|
typedef struct ipslog {
|
|
|
|
U_QUAD_T isl_pkts;
|
|
|
|
U_QUAD_T isl_bytes;
|
2000-05-03 15:12:03 +04:00
|
|
|
union i6addr isl_src;
|
|
|
|
union i6addr isl_dst;
|
1997-05-25 16:40:11 +04:00
|
|
|
u_short isl_type;
|
|
|
|
union {
|
|
|
|
u_short isl_filler[2];
|
|
|
|
u_short isl_ports[2];
|
|
|
|
u_short isl_icmp;
|
|
|
|
} isl_ps;
|
2000-05-03 15:12:03 +04:00
|
|
|
u_char isl_v;
|
|
|
|
u_char isl_p;
|
|
|
|
u_char isl_flags;
|
|
|
|
u_char isl_state[2];
|
1997-05-25 16:40:11 +04:00
|
|
|
} ipslog_t;
|
|
|
|
|
|
|
|
#define isl_sport isl_ps.isl_ports[0]
|
|
|
|
#define isl_dport isl_ps.isl_ports[1]
|
|
|
|
#define isl_itype isl_ps.isl_icmp
|
|
|
|
|
|
|
|
#define ISL_NEW 0
|
|
|
|
#define ISL_EXPIRE 0xffff
|
1997-11-14 15:40:06 +03:00
|
|
|
#define ISL_FLUSH 0xfffe
|
2000-05-03 15:12:03 +04:00
|
|
|
#define ISL_REMOVE 0xfffd
|
1997-05-25 16:40:11 +04:00
|
|
|
|
|
|
|
|
1997-01-05 16:47:59 +03:00
|
|
|
typedef struct ips_stat {
|
|
|
|
u_long iss_hits;
|
|
|
|
u_long iss_miss;
|
|
|
|
u_long iss_max;
|
|
|
|
u_long iss_tcp;
|
|
|
|
u_long iss_udp;
|
|
|
|
u_long iss_icmp;
|
|
|
|
u_long iss_nomem;
|
|
|
|
u_long iss_expire;
|
|
|
|
u_long iss_fin;
|
|
|
|
u_long iss_active;
|
1997-05-25 16:40:11 +04:00
|
|
|
u_long iss_logged;
|
|
|
|
u_long iss_logfail;
|
1999-12-12 14:11:15 +03:00
|
|
|
u_long iss_inuse;
|
1997-01-05 16:47:59 +03:00
|
|
|
ipstate_t **iss_table;
|
2000-05-03 15:12:03 +04:00
|
|
|
ipstate_t *iss_list;
|
1997-01-05 16:47:59 +03:00
|
|
|
} ips_stat_t;
|
|
|
|
|
1997-05-25 16:40:11 +04:00
|
|
|
|
1997-07-05 09:38:14 +04:00
|
|
|
extern u_long fr_tcpidletimeout;
|
|
|
|
extern u_long fr_tcpclosewait;
|
|
|
|
extern u_long fr_tcplastack;
|
|
|
|
extern u_long fr_tcptimeout;
|
|
|
|
extern u_long fr_tcpclosed;
|
2001-03-26 10:11:46 +04:00
|
|
|
extern u_long fr_tcphalfclosed;
|
1997-07-05 09:38:14 +04:00
|
|
|
extern u_long fr_udptimeout;
|
|
|
|
extern u_long fr_icmptimeout;
|
2000-05-03 15:12:03 +04:00
|
|
|
extern int fr_state_lock;
|
1999-12-12 14:11:15 +03:00
|
|
|
extern int fr_stateinit __P((void));
|
1998-05-30 00:24:36 +04:00
|
|
|
extern int fr_tcpstate __P((ipstate_t *, fr_info_t *, ip_t *, tcphdr_t *));
|
1999-12-12 14:11:15 +03:00
|
|
|
extern ipstate_t *fr_addstate __P((ip_t *, fr_info_t *, u_int));
|
|
|
|
extern frentry_t *fr_checkstate __P((ip_t *, fr_info_t *));
|
2000-02-02 00:29:15 +03:00
|
|
|
extern void ip_statesync __P((void *));
|
1997-07-05 09:38:14 +04:00
|
|
|
extern void fr_timeoutstate __P((void));
|
2000-05-03 15:12:03 +04:00
|
|
|
extern void fr_tcp_age __P((u_long *, u_char *, fr_info_t *, int));
|
1997-07-05 09:38:14 +04:00
|
|
|
extern void fr_stateunload __P((void));
|
1999-12-12 14:11:15 +03:00
|
|
|
extern void ipstate_log __P((struct ipstate *, u_int));
|
1997-10-30 19:08:54 +03:00
|
|
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
1997-07-05 09:38:14 +04:00
|
|
|
extern int fr_state_ioctl __P((caddr_t, u_long, int));
|
|
|
|
#else
|
|
|
|
extern int fr_state_ioctl __P((caddr_t, int, int));
|
|
|
|
#endif
|
1998-02-10 04:26:19 +03:00
|
|
|
|
|
|
|
#endif /* _NETINET_IP_STATE_H_ */
|