version 1.1.1.1, 2022/06/22 13:01:55
|
version 1.10.2.2, 2022/08/26 13:59:41
|
Line 1
|
Line 1
|
/************************************************************************* | /*- |
* (C) 2022 CloudSigma AG - Sofia/Bulgaria | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD |
* by Michael Pounov <misho@elwix.org> | * |
**************************************************************************/ | * Copyright (c) 2022 Michael Pounov <misho@elwix.org>, CloudSigma AG |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| * are met: |
| * 1. Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. |
| * |
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| * SUCH DAMAGE. |
| */ |
#ifndef __FWSYNC_H |
#ifndef __FWSYNC_H |
#define __FWSYNC_H |
#define __FWSYNC_H |
|
|
Line 21
|
Line 43
|
#include <sys/un.h> |
#include <sys/un.h> |
#include <sys/module.h> |
#include <sys/module.h> |
#include <sys/kthread.h> |
#include <sys/kthread.h> |
|
#include <sys/priority.h> |
#include <sys/taskqueue.h> |
#include <sys/taskqueue.h> |
|
#include <sys/queue.h> |
|
#include <sys/tree.h> |
|
#include <sys/mutex.h> |
#include <sys/uio.h> |
#include <sys/uio.h> |
#include <sys/poll.h> |
#include <sys/poll.h> |
|
|
|
#include <netinet/libalias/alias.h> |
|
#include <netinet/libalias/alias_local.h> |
|
#include <netinet/libalias/alias_db.h> |
|
|
#include <net/if.h> |
#include <net/if.h> |
#include <net/if_var.h> |
#include <net/if_var.h> |
#include <net/if_dl.h> |
#include <net/if_dl.h> |
Line 31
|
Line 62
|
#include <netinet/ip.h> |
#include <netinet/ip.h> |
#include <netinet/ip_var.h> |
#include <netinet/ip_var.h> |
#include <netinet/udp.h> |
#include <netinet/udp.h> |
|
|
#define IPFW_INTERNAL |
|
|
|
#include <netinet/ip_fw.h> |
#include <netinet/ip_fw.h> |
|
|
#include <netpfil/ipfw/ip_fw_private.h> |
#include <netpfil/ipfw/ip_fw_private.h> |
|
|
#include "fwsync_proto.h" |
#include "fwsync_proto.h" |
#include "fwsync_workers.h" |
#include "fwsync_workers.h" |
|
|
#if 0 |
|
#include <sys/uio.h> |
|
#include <sys/taskqueue.h> |
|
#include <sys/rwlock.h> |
|
#include <sys/queue.h> |
|
#include <sys/tree.h> |
|
#include <sys/ioccom.h> |
|
|
|
#include <sys/poll.h> |
|
#include <sys/event.h> |
|
#include <sys/selinfo.h> |
|
#include <sys/fcntl.h> |
|
#include <sys/syslog.h> |
|
#include <sys/rwlock.h> |
|
#endif |
|
|
|
|
|
#define IFT_FWSYNC 0xfc |
#define IFT_FWSYNC 0xfc |
|
#define IFT_FWSYNC_ACCT 0xfd |
|
|
#define DRV_NAME "fwsync" |
#define DRV_NAME "fwsync" |
#define DRV_VERSION 1 |
#define DRV_VERSION 1 |
Line 134 struct fwsync_context {
|
Line 148 struct fwsync_context {
|
#define CTX_COLLECTOR_1_ONLINE 0x80 |
#define CTX_COLLECTOR_1_ONLINE 0x80 |
#define CTX_COLLECTOR_2_ONLINE 0x100 |
#define CTX_COLLECTOR_2_ONLINE 0x100 |
|
|
#if 0 | struct fws_sndpkt { |
| struct fws_proto sp_proto; |
| TAILQ_ENTRY(fws_sndpkt) sp_next; |
| }; |
|
|
#define DRV_PKTSTART 0xDEADBEEF | typedef TAILQ_HEAD(, fws_sndpkt) fwsync_sndpkt_t; |
#define DRV_PKTEND 0xDEBADEBA | |
|
|
#define DRETFLUSH _IOW('D', 1, u_char) | struct fws_acct { |
#define DRETADDFILT _IOW('D', 2, struct dret_filter) | uint64_t states[2]; |
#define DRETDELFILT _IOW('D', 3, struct dret_filter) | uint64_t aliases[2]; |
#define DRETACCTFLUSH _IOW('D', 4, u_char) | |
#define DRETACCTDEL _IOW('D', 5, struct tagAccount) | |
#define DRETACCTGET _IOWR('D', 6, struct tagAccount) | |
| |
#define DRETDIROFF 0 | |
#define DRETDIRIN 1 | |
#define DRETDIROUT 2 | |
#define DRETDIRANY 3 | |
#define DRETACCT 4 | |
| |
struct dret_filter { | |
u_char filt_dir; | |
u_int filt_proto[8]; | |
char filt_iface[IFNAMSIZ]; | |
netaddr_t filt_net; | |
}; |
}; |
#define FP_MASK(n) ((u_int) 1 << ((n) % 32)) |
|
#define FP_ISSET(n, a) ((a)[(n) / 32] & FP_MASK(n)) |
|
#define FP_CLR(n, a) ((a)[(n) / 32] &= ~FP_MASK(n)) |
|
#define FP_SET(n, a) ((a)[(n) / 32] |= FP_MASK(n)) |
|
#define FP_ZERO(a) do { int _i = 8; \ |
|
while (_i > 0) \ |
|
(a)[--_i] = 0; \ |
|
} while (0) |
|
#endif |
|
|
|
extern int fwsync_debug; |
extern int fwsync_debug; |
extern struct fwsync_context fws_ctx; |
extern struct fwsync_context fws_ctx; |
extern struct cfg_sync fws_cfg; |
extern struct cfg_sync fws_cfg; |
extern struct task fws_sndpkt_task; |
extern struct task fws_sndpkt_task; |
|
extern struct taskqueue *fws_tq; |
|
extern struct callout fws_co; |
|
extern struct mtx fws_mtx_c, fws_mtx_e, fws_mtx_u, fws_mtx_n; |
|
extern struct mbuf *fws_sndpkt; |
|
extern fwsync_sndpkt_t fwsync_sndpkt, fwsync_updpkt, fwsync_natpkt; |
|
extern struct fws_acct fws_acct; |
|
|
int fwsync_cfg(struct ip_fw_chain *ch, ip_fw3_opheader *op3, struct sockopt_data *sd); |
int fwsync_cfg(struct ip_fw_chain *ch, ip_fw3_opheader *op3, struct sockopt_data *sd); |
int fwsync_destroy(struct ip_fw_chain *ch, ip_fw3_opheader *op3, struct sockopt_data *sd); |
int fwsync_destroy(struct ip_fw_chain *ch, ip_fw3_opheader *op3, struct sockopt_data *sd); |