2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * @(#)ip_fil.h 1.35 6/5/96
7 * $Id: ip_sync.h,v 2.11.2.4 2006/07/14 06:12:20 darrenr Exp $
13 typedef struct synchdr {
14 u_32_t sm_magic; /* magic */
15 u_char sm_v; /* version: 4,6 */
16 u_char sm_p; /* protocol */
17 u_char sm_cmd; /* command */
18 u_char sm_table; /* NAT, STATE, etc */
19 u_int sm_num; /* table entry number */
20 int sm_rev; /* forward/reverse */
21 int sm_len; /* length of the data section */
22 struct synclist *sm_sl; /* back pointer to parent */
26 #define SYNHDRMAGIC 0x0FF51DE5
30 * No delete required as expirey will take care of that!
32 #define SMC_CREATE 0 /* pass ipstate_t after synchdr_t */
45 * Only TCP requires "more" information than just a reference to the entry
46 * for which an update is being made.
48 typedef struct synctcp_update {
50 tcpdata_t stu_data[2];
55 typedef struct synclist {
56 struct synclist *sl_next;
57 struct synclist **sl_pnext;
58 int sl_idx; /* update index */
59 struct synchdr sl_hdr;
61 struct ipstate *slu_ips;
67 #define sl_ptr sl_un.slu_ptr
68 #define sl_ips sl_un.slu_ips
69 #define sl_ipn sl_un.slu_ipn
70 #define sl_magic sl_hdr.sm_magic
71 #define sl_v sl_hdr.sm_v
72 #define sl_p sl_hdr.sm_p
73 #define sl_cmd sl_hdr.sm_cmd
74 #define sl_rev sl_hdr.sm_rev
75 #define sl_table sl_hdr.sm_table
76 #define sl_num sl_hdr.sm_num
77 #define sl_len sl_hdr.sm_len
80 * NOTE: SYNCLOG_SZ is defined *low*. It should be the next power of two
81 * up for whatever number of packets per second you expect to see. Be
82 * warned: this index's a table of large elements (upto 272 bytes in size
83 * each), and thus a size of 8192, for example, results in a 2MB table.
84 * The lesson here is not to use small machines for running fast firewalls
85 * (100BaseT) in sync, where you might have upwards of 10k pps.
87 #define SYNCLOG_SZ 256
89 typedef struct synclogent {
90 struct synchdr sle_hdr;
92 struct ipstate sleu_ips;
97 typedef struct syncupdent { /* 28 or 32 bytes */
98 struct synchdr sup_hdr;
99 struct synctcp_update sup_tcp;
102 extern synclogent_t synclog[SYNCLOG_SZ];
105 extern int fr_sync_ioctl __P((caddr_t, ioctlcmd_t, int, int, void *));
106 extern synclist_t *ipfsync_new __P((int, fr_info_t *, void *));
107 extern void ipfsync_del __P((synclist_t *));
108 extern void ipfsync_update __P((int, fr_info_t *, synclist_t *));
109 extern int ipfsync_init __P((void));
110 extern int ipfsync_nat __P((synchdr_t *sp, void *data));
111 extern int ipfsync_state __P((synchdr_t *sp, void *data));
112 extern int ipfsync_read __P((struct uio *uio));
113 extern int ipfsync_write __P((struct uio *uio));
114 extern int ipfsync_canread __P((void));
115 extern int ipfsync_canwrite __P((void));