ip_sync.h revision 1.2.2.2 1 1.2.2.2 joerg /* $NetBSD: ip_sync.h,v 1.2.2.2 2012/04/17 19:25:22 joerg Exp $ */
2 1.2.2.2 joerg
3 1.2.2.2 joerg /*
4 1.2.2.2 joerg * Copyright (C) 2008 by Darren Reed.
5 1.2.2.2 joerg *
6 1.2.2.2 joerg * See the IPFILTER.LICENCE file for details on licencing.
7 1.2.2.2 joerg *
8 1.2.2.2 joerg * @(#)ip_fil.h 1.35 6/5/96
9 1.2.2.2 joerg * Id: ip_sync.h,v 2.19.2.1 2012/01/26 05:29:13 darrenr Exp
10 1.2.2.2 joerg */
11 1.2.2.2 joerg
12 1.2.2.2 joerg #ifndef __IP_SYNC_H__
13 1.2.2.2 joerg #define __IP_SYNC_H__
14 1.2.2.2 joerg
15 1.2.2.2 joerg typedef struct synchdr {
16 1.2.2.2 joerg u_32_t sm_magic; /* magic */
17 1.2.2.2 joerg u_char sm_v; /* version: 4,6 */
18 1.2.2.2 joerg u_char sm_p; /* protocol */
19 1.2.2.2 joerg u_char sm_cmd; /* command */
20 1.2.2.2 joerg u_char sm_table; /* NAT, STATE, etc */
21 1.2.2.2 joerg u_int sm_num; /* table entry number */
22 1.2.2.2 joerg int sm_rev; /* forward/reverse */
23 1.2.2.2 joerg int sm_len; /* length of the data section */
24 1.2.2.2 joerg struct synclist *sm_sl; /* back pointer to parent */
25 1.2.2.2 joerg } synchdr_t;
26 1.2.2.2 joerg
27 1.2.2.2 joerg
28 1.2.2.2 joerg #define SYNHDRMAGIC 0x0FF51DE5
29 1.2.2.2 joerg
30 1.2.2.2 joerg /*
31 1.2.2.2 joerg * Commands
32 1.2.2.2 joerg * No delete required as expirey will take care of that!
33 1.2.2.2 joerg */
34 1.2.2.2 joerg #define SMC_CREATE 0 /* pass ipstate_t after synchdr_t */
35 1.2.2.2 joerg #define SMC_UPDATE 1
36 1.2.2.2 joerg #define SMC_MAXCMD 1
37 1.2.2.2 joerg
38 1.2.2.2 joerg /*
39 1.2.2.2 joerg * Tables
40 1.2.2.2 joerg */
41 1.2.2.2 joerg #define SMC_RLOG -2 /* Only used with SIOCIPFFL */
42 1.2.2.2 joerg #define SMC_NAT 0
43 1.2.2.2 joerg #define SMC_STATE 1
44 1.2.2.2 joerg #define SMC_MAXTBL 1
45 1.2.2.2 joerg
46 1.2.2.2 joerg
47 1.2.2.2 joerg /*
48 1.2.2.2 joerg * Only TCP requires "more" information than just a reference to the entry
49 1.2.2.2 joerg * for which an update is being made.
50 1.2.2.2 joerg */
51 1.2.2.2 joerg typedef struct synctcp_update {
52 1.2.2.2 joerg u_long stu_age;
53 1.2.2.2 joerg tcpdata_t stu_data[2];
54 1.2.2.2 joerg int stu_state[2];
55 1.2.2.2 joerg } synctcp_update_t;
56 1.2.2.2 joerg
57 1.2.2.2 joerg
58 1.2.2.2 joerg typedef struct synclist {
59 1.2.2.2 joerg struct synclist *sl_next;
60 1.2.2.2 joerg struct synclist **sl_pnext;
61 1.2.2.2 joerg int sl_idx; /* update index */
62 1.2.2.2 joerg struct synchdr sl_hdr;
63 1.2.2.2 joerg union {
64 1.2.2.2 joerg struct ipstate *slu_ips;
65 1.2.2.2 joerg struct nat *slu_ipn;
66 1.2.2.2 joerg void *slu_ptr;
67 1.2.2.2 joerg } sl_un;
68 1.2.2.2 joerg } synclist_t;
69 1.2.2.2 joerg
70 1.2.2.2 joerg #define sl_ptr sl_un.slu_ptr
71 1.2.2.2 joerg #define sl_ips sl_un.slu_ips
72 1.2.2.2 joerg #define sl_ipn sl_un.slu_ipn
73 1.2.2.2 joerg #define sl_magic sl_hdr.sm_magic
74 1.2.2.2 joerg #define sl_v sl_hdr.sm_v
75 1.2.2.2 joerg #define sl_p sl_hdr.sm_p
76 1.2.2.2 joerg #define sl_cmd sl_hdr.sm_cmd
77 1.2.2.2 joerg #define sl_rev sl_hdr.sm_rev
78 1.2.2.2 joerg #define sl_table sl_hdr.sm_table
79 1.2.2.2 joerg #define sl_num sl_hdr.sm_num
80 1.2.2.2 joerg #define sl_len sl_hdr.sm_len
81 1.2.2.2 joerg
82 1.2.2.2 joerg /*
83 1.2.2.2 joerg * NOTE: SYNCLOG_SZ is defined *low*. It should be the next power of two
84 1.2.2.2 joerg * up for whatever number of packets per second you expect to see. Be
85 1.2.2.2 joerg * warned: this index's a table of large elements (upto 272 bytes in size
86 1.2.2.2 joerg * each), and thus a size of 8192, for example, results in a 2MB table.
87 1.2.2.2 joerg * The lesson here is not to use small machines for running fast firewalls
88 1.2.2.2 joerg * (100BaseT) in sync, where you might have upwards of 10k pps.
89 1.2.2.2 joerg */
90 1.2.2.2 joerg #define SYNCLOG_SZ 256
91 1.2.2.2 joerg
92 1.2.2.2 joerg typedef struct synclogent {
93 1.2.2.2 joerg struct synchdr sle_hdr;
94 1.2.2.2 joerg union {
95 1.2.2.2 joerg struct ipstate sleu_ips;
96 1.2.2.2 joerg struct nat sleu_ipn;
97 1.2.2.2 joerg } sle_un;
98 1.2.2.2 joerg } synclogent_t;
99 1.2.2.2 joerg
100 1.2.2.2 joerg typedef struct syncupdent { /* 28 or 32 bytes */
101 1.2.2.2 joerg struct synchdr sup_hdr;
102 1.2.2.2 joerg struct synctcp_update sup_tcp;
103 1.2.2.2 joerg } syncupdent_t;
104 1.2.2.2 joerg
105 1.2.2.2 joerg extern void *ipf_sync_create(ipf_main_softc_t *);
106 1.2.2.2 joerg extern int ipf_sync_soft_init(ipf_main_softc_t *, void *);
107 1.2.2.2 joerg extern int ipf_sync_soft_fini(ipf_main_softc_t *, void *);
108 1.2.2.2 joerg extern int ipf_sync_canread(void *);
109 1.2.2.2 joerg extern int ipf_sync_canwrite(void *);
110 1.2.2.2 joerg extern void ipf_sync_del_nat(void *, synclist_t *);
111 1.2.2.2 joerg extern void ipf_sync_del_state(void *, synclist_t *);
112 1.2.2.2 joerg extern int ipf_sync_init(void);
113 1.2.2.2 joerg extern int ipf_sync_ioctl(ipf_main_softc_t *, void *, ioctlcmd_t, int, int, void *);
114 1.2.2.2 joerg extern synclist_t *ipf_sync_new(ipf_main_softc_t *, int, fr_info_t *, void *);
115 1.2.2.2 joerg extern int ipf_sync_read(ipf_main_softc_t *, struct uio *uio);
116 1.2.2.2 joerg extern int ipf_sync_write(ipf_main_softc_t *, struct uio *uio);
117 1.2.2.2 joerg extern int ipf_sync_main_unload(void);
118 1.2.2.2 joerg extern void ipf_sync_update(ipf_main_softc_t *, int, fr_info_t *, synclist_t *);
119 1.2.2.2 joerg extern void ipf_sync_expire(ipf_main_softc_t *);
120 1.2.2.2 joerg extern void ipf_sync_soft_destroy(ipf_main_softc_t *, void *);
121 1.2.2.2 joerg extern void *ipf_sync_soft_create(ipf_main_softc_t *);
122 1.2.2.2 joerg
123 1.2.2.2 joerg #endif /* IP_SYNC */
124