2 * Copyright (c) 2016 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Bill Yuan <bycn82@dragonflybsd.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #ifndef _IP_FW3_SYNC_H_
37 #define _IP_FW3_SYNC_H_
41 #define SYNC_TYPE_SEND_TEST 0 /* testing sync status */
42 #define SYNC_TYPE_SEND_STATE 1 /* syncing state */
43 #define SYNC_TYPE_SEND_NAT 2 /* syncing nat */
46 struct ipfw_sync_edge
{
51 struct ipfw_ioc_sync_context
{
52 int edge_port
; /* edge listening port */
53 int hw_same
; /* duplicate to all CPU when hardware different */
54 int count
; /* count of edge */
55 struct ipfw_sync_edge edges
[0]; /* edge */
58 struct ipfw_ioc_sync_centre
{
59 int count
; /* count of edge */
60 struct ipfw_sync_edge edges
[0]; /* edge */
63 struct ipfw_ioc_sync_edge
{
68 struct ipfw_sync_context
{
69 int edge_port
; /* edge listening port */
70 int hw_same
; /* duplicate to all CPU when hardware different */
71 int count
; /* count of edge */
72 int running
; /* edge 01, centre 10 */
73 struct ipfw_sync_edge
*edges
; /* edge */
74 struct thread
*edge_td
; /* edge handler thread */
75 struct socket
*edge_sock
; /* edge sock */
76 struct socket
*centre_socks
[MAX_EDGES
]; /* centre socks */
82 void ipfw3_sync_modevent(int type
);
84 struct cmd_send_test
{
89 struct cmd_send_state
{
90 int type
; /* test, state or NAT */
91 struct ipfw_flow_id flow
;
100 int type
; /* test, state, or NAT */
104 struct netmsg_base base
;
105 struct ipfw_ioc_sync_centre
*centre
;
110 typedef void ipfw_sync_install_state_t(struct cmd_send_state
*cmd
);
112 void sync_centre_conf_dispath(netmsg_t nmsg
);
113 int ipfw_ctl_sync_centre_conf(struct sockopt
*sopt
);
114 int ipfw_ctl_sync_show_conf(struct sockopt
*sopt
);
115 int ipfw_ctl_sync_show_status(struct sockopt
*sopt
);
116 int ipfw_ctl_sync_edge_conf(struct sockopt
*sopt
);
117 void sync_edge_socket_handler(void *dummy
);
118 int ipfw_ctl_sync_edge_start(struct sockopt
*sopt
);
119 int ipfw_ctl_sync_edge_test(struct sockopt
*sopt
);
120 int ipfw_ctl_sync_centre_start(struct sockopt
*sopt
);
121 int ipfw_ctl_sync_centre_test(struct sockopt
*sopt
);
122 int ipfw_ctl_sync_edge_stop(struct sockopt
*sopt
);
123 int ipfw_ctl_sync_centre_stop(struct sockopt
*sopt
);
124 int ipfw_ctl_sync_edge_clear(struct sockopt
*sopt
);
125 int ipfw_ctl_sync_centre_clear(struct sockopt
*sopt
);
126 int ipfw_ctl_sync_sockopt(struct sockopt
*sopt
);
127 void ipfw_sync_send_state(struct ip_fw_state
*state
, int cpu
, int hash
);
130 #endif /* _IP_FW3_SYNC_H_ */