Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / ip_sync.h
blob46093016b1d446ba7ac81645803d5de3fb2aeec7
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 1993-2001 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * @(#)ip_fil.h 1.35 6/5/96
9 * Id: ip_sync.h,v 2.11.2.4 2006/07/14 06:12:20 darrenr Exp
12 #ifndef __IP_SYNC_H__
13 #define __IP_SYNC_H__
15 typedef struct synchdr {
16 u_32_t sm_magic; /* magic */
17 u_char sm_v; /* version: 4,6 */
18 u_char sm_p; /* protocol */
19 u_char sm_cmd; /* command */
20 u_char sm_table; /* NAT, STATE, etc */
21 u_int sm_num; /* table entry number */
22 int sm_rev; /* forward/reverse */
23 int sm_len; /* length of the data section */
24 struct synclist *sm_sl; /* back pointer to parent */
25 } synchdr_t;
28 #define SYNHDRMAGIC 0x0FF51DE5
31 * Commands
32 * No delete required as expirey will take care of that!
34 #define SMC_CREATE 0 /* pass ipstate_t after synchdr_t */
35 #define SMC_UPDATE 1
36 #define SMC_MAXCMD 1
39 * Tables
41 #define SMC_NAT 0
42 #define SMC_STATE 1
43 #define SMC_MAXTBL 1
47 * Only TCP requires "more" information than just a reference to the entry
48 * for which an update is being made.
50 typedef struct synctcp_update {
51 u_long stu_age;
52 tcpdata_t stu_data[2];
53 int stu_state[2];
54 } synctcp_update_t;
57 typedef struct synclist {
58 struct synclist *sl_next;
59 struct synclist **sl_pnext;
60 int sl_idx; /* update index */
61 struct synchdr sl_hdr;
62 union {
63 struct ipstate *slu_ips;
64 struct nat *slu_ipn;
65 void *slu_ptr;
66 } sl_un;
67 } synclist_t;
69 #define sl_ptr sl_un.slu_ptr
70 #define sl_ips sl_un.slu_ips
71 #define sl_ipn sl_un.slu_ipn
72 #define sl_magic sl_hdr.sm_magic
73 #define sl_v sl_hdr.sm_v
74 #define sl_p sl_hdr.sm_p
75 #define sl_cmd sl_hdr.sm_cmd
76 #define sl_rev sl_hdr.sm_rev
77 #define sl_table sl_hdr.sm_table
78 #define sl_num sl_hdr.sm_num
79 #define sl_len sl_hdr.sm_len
82 * NOTE: SYNCLOG_SZ is defined *low*. It should be the next power of two
83 * up for whatever number of packets per second you expect to see. Be
84 * warned: this index's a table of large elements (upto 272 bytes in size
85 * each), and thus a size of 8192, for example, results in a 2MB table.
86 * The lesson here is not to use small machines for running fast firewalls
87 * (100BaseT) in sync, where you might have upwards of 10k pps.
89 #define SYNCLOG_SZ 256
91 typedef struct synclogent {
92 struct synchdr sle_hdr;
93 union {
94 struct ipstate sleu_ips;
95 struct nat sleu_ipn;
96 } sle_un;
97 } synclogent_t;
99 typedef struct syncupdent { /* 28 or 32 bytes */
100 struct synchdr sup_hdr;
101 struct synctcp_update sup_tcp;
102 } syncupdent_t;
104 extern synclogent_t synclog[SYNCLOG_SZ];
107 extern int fr_sync_ioctl __P((caddr_t, ioctlcmd_t, int, int, void *));
108 extern synclist_t *ipfsync_new __P((int, fr_info_t *, void *));
109 extern void ipfsync_del __P((synclist_t *));
110 extern void ipfsync_update __P((int, fr_info_t *, synclist_t *));
111 extern int ipfsync_init __P((void));
112 extern int ipfsync_nat __P((synchdr_t *sp, void *data));
113 extern int ipfsync_state __P((synchdr_t *sp, void *data));
114 extern int ipfsync_read __P((struct uio *uio));
115 extern int ipfsync_write __P((struct uio *uio));
116 extern int ipfsync_canread __P((void));
117 extern int ipfsync_canwrite __P((void));
119 #endif /* IP_SYNC */