/*-1* Copyright (c) 2016 Yandex LLC2* Copyright (c) 2016 Andrey V. Elsukov <[email protected]>3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR16* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,19* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT20* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,21* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF24* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25*/2627#ifndef _IP_FW_NPTV6_H_28#define _IP_FW_NPTV6_H_2930#include <netinet6/ip_fw_nptv6.h>3132#ifdef _KERNEL33#define NPTV6STATS (sizeof(struct ipfw_nptv6_stats) / sizeof(uint64_t))34#define NPTV6STAT_ADD(c, f, v) \35counter_u64_add((c)->stats[ \36offsetof(struct ipfw_nptv6_stats, f) / sizeof(uint64_t)], (v))37#define NPTV6STAT_INC(c, f) NPTV6STAT_ADD(c, f, 1)38#define NPTV6STAT_FETCH(c, f) \39counter_u64_fetch((c)->stats[ \40offsetof(struct ipfw_nptv6_stats, f) / sizeof(uint64_t)])4142struct nptv6_cfg {43struct named_object no;4445struct in6_addr internal; /* Internal IPv6 prefix */46struct in6_addr external; /* External IPv6 prefix */47struct in6_addr mask; /* IPv6 prefix mask */48uint16_t adjustment; /* Checksum adjustment value */49uint8_t plen; /* Prefix length */50uint8_t flags; /* Flags for internal use */51#define NPTV6_READY 0x8052#define NPTV6_48PLEN 0x405354char if_name[IF_NAMESIZE];55char name[64]; /* Instance name */56counter_u64_t stats[NPTV6STATS]; /* Statistics counters */57};58#define NPTV6_FLAGSMASK (NPTV6_DYNAMIC_PREFIX)5960int nptv6_init(struct ip_fw_chain *ch, int first);61void nptv6_uninit(struct ip_fw_chain *ch, int last);62#endif /* _KERNEL */6364#endif /* _IP_FW_NPTV6_H_ */656667