1145937Sglebius/*- 2145937Sglebius * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org> 3145937Sglebius * All rights reserved. 4145937Sglebius * 5145937Sglebius * Redistribution and use in source and binary forms, with or without 6145937Sglebius * modification, are permitted provided that the following conditions 7145937Sglebius * are met: 8145937Sglebius * 1. Redistributions of source code must retain the above copyright 9145937Sglebius * notice, this list of conditions and the following disclaimer. 10145937Sglebius * 2. Redistributions in binary form must reproduce the above copyright 11145937Sglebius * notice, this list of conditions and the following disclaimer in the 12145937Sglebius * documentation and/or other materials provided with the distribution. 13145937Sglebius * 14145937Sglebius * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15145937Sglebius * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16145937Sglebius * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17145937Sglebius * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18145937Sglebius * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19145937Sglebius * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20145937Sglebius * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21145937Sglebius * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22145937Sglebius * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23145937Sglebius * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24145937Sglebius * SUCH DAMAGE. 25145937Sglebius * 26145937Sglebius * $FreeBSD: releng/10.3/sys/netgraph/ng_nat.h 248570 2013-03-21 08:36:15Z glebius $ 27145937Sglebius */ 28145937Sglebius 29145937Sglebius#define NG_NAT_NODE_TYPE "nat" 30145937Sglebius#define NGM_NAT_COOKIE 1107718711 31145937Sglebius 32145937Sglebius#define NG_NAT_HOOK_IN "in" 33145937Sglebius#define NG_NAT_HOOK_OUT "out" 34145937Sglebius 35169867Smav/* Arguments for NGM_NAT_SET_MODE message */ 36169867Smavstruct ng_nat_mode { 37169867Smav uint32_t flags; 38169867Smav uint32_t mask; 39169867Smav}; 40169867Smav 41169867Smav/* Keep this in sync with the above structure definition */ 42169867Smav#define NG_NAT_MODE_INFO { \ 43169867Smav { "flags", &ng_parse_uint32_type }, \ 44169867Smav { "mask", &ng_parse_uint32_type }, \ 45169867Smav { NULL } \ 46169867Smav} 47169867Smav 48169867Smav#define NG_NAT_LOG 0x01 49169867Smav#define NG_NAT_DENY_INCOMING 0x02 50169867Smav#define NG_NAT_SAME_PORTS 0x04 51169867Smav#define NG_NAT_UNREGISTERED_ONLY 0x10 52169867Smav#define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 53169867Smav#define NG_NAT_PROXY_ONLY 0x40 54169867Smav#define NG_NAT_REVERSE 0x80 55169867Smav 56176706Smav#define NG_NAT_DESC_LENGTH 64 57176706Smav#define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */ 58176706Smav 59176706Smav/* Arguments for NGM_NAT_REDIRECT_PORT message */ 60176706Smavstruct ng_nat_redirect_port { 61176706Smav struct in_addr local_addr; 62176706Smav struct in_addr alias_addr; 63176706Smav struct in_addr remote_addr; 64176706Smav uint16_t local_port; 65176706Smav uint16_t alias_port; 66176706Smav uint16_t remote_port; 67176706Smav uint8_t proto; 68176706Smav char description[NG_NAT_DESC_LENGTH]; 69176706Smav}; 70176706Smav 71176706Smav/* Keep this in sync with the above structure definition */ 72176706Smav#define NG_NAT_REDIRECT_PORT_TYPE_INFO(desctype) { \ 73176706Smav { "local_addr", &ng_parse_ipaddr_type }, \ 74176706Smav { "alias_addr", &ng_parse_ipaddr_type }, \ 75176706Smav { "remote_addr", &ng_parse_ipaddr_type }, \ 76176706Smav { "local_port", &ng_parse_uint16_type }, \ 77176706Smav { "alias_port", &ng_parse_uint16_type }, \ 78176706Smav { "remote_port", &ng_parse_uint16_type }, \ 79176791Smav { "proto", &ng_parse_uint8_type }, \ 80176706Smav { "description", (desctype) }, \ 81176706Smav { NULL } \ 82176706Smav} 83176706Smav 84176706Smav/* Arguments for NGM_NAT_REDIRECT_ADDR message */ 85176706Smavstruct ng_nat_redirect_addr { 86176706Smav struct in_addr local_addr; 87176706Smav struct in_addr alias_addr; 88176706Smav char description[NG_NAT_DESC_LENGTH]; 89176706Smav}; 90176706Smav 91176706Smav/* Keep this in sync with the above structure definition */ 92176706Smav#define NG_NAT_REDIRECT_ADDR_TYPE_INFO(desctype) { \ 93176706Smav { "local_addr", &ng_parse_ipaddr_type }, \ 94176706Smav { "alias_addr", &ng_parse_ipaddr_type }, \ 95176706Smav { "description", (desctype) }, \ 96176706Smav { NULL } \ 97176706Smav} 98176706Smav 99176706Smav/* Arguments for NGM_NAT_REDIRECT_PROTO message */ 100176706Smavstruct ng_nat_redirect_proto { 101176706Smav struct in_addr local_addr; 102176706Smav struct in_addr alias_addr; 103176706Smav struct in_addr remote_addr; 104176706Smav uint8_t proto; 105176706Smav char description[NG_NAT_DESC_LENGTH]; 106176706Smav}; 107176706Smav 108176706Smav/* Keep this in sync with the above structure definition */ 109176706Smav#define NG_NAT_REDIRECT_PROTO_TYPE_INFO(desctype) { \ 110176706Smav { "local_addr", &ng_parse_ipaddr_type }, \ 111176706Smav { "alias_addr", &ng_parse_ipaddr_type }, \ 112176706Smav { "remote_addr", &ng_parse_ipaddr_type }, \ 113176706Smav { "proto", &ng_parse_uint8_type }, \ 114176706Smav { "description", (desctype) }, \ 115176706Smav { NULL } \ 116176706Smav} 117176706Smav 118176706Smav/* Arguments for NGM_NAT_ADD_SERVER message */ 119176706Smavstruct ng_nat_add_server { 120176706Smav uint32_t id; 121176706Smav struct in_addr addr; 122176706Smav uint16_t port; 123176706Smav}; 124176706Smav 125176706Smav/* Keep this in sync with the above structure definition */ 126176706Smav#define NG_NAT_ADD_SERVER_TYPE_INFO { \ 127176706Smav { "id", &ng_parse_uint32_type }, \ 128176706Smav { "addr", &ng_parse_ipaddr_type }, \ 129176706Smav { "port", &ng_parse_uint16_type }, \ 130176706Smav { NULL } \ 131176706Smav} 132176706Smav 133176706Smav/* List entry of array returned in NGM_NAT_LIST_REDIRECTS message */ 134176706Smavstruct ng_nat_listrdrs_entry { 135176706Smav uint32_t id; /* Anything except zero */ 136176706Smav struct in_addr local_addr; 137176706Smav struct in_addr alias_addr; 138176706Smav struct in_addr remote_addr; 139176706Smav uint16_t local_port; 140176706Smav uint16_t alias_port; 141176706Smav uint16_t remote_port; 142176706Smav uint16_t proto; /* Valid proto or NG_NAT_REDIRPROTO_ADDR */ 143176706Smav uint16_t lsnat; /* LSNAT servers count */ 144176706Smav char description[NG_NAT_DESC_LENGTH]; 145176706Smav}; 146176706Smav 147176706Smav/* Keep this in sync with the above structure definition */ 148176706Smav#define NG_NAT_LISTRDRS_ENTRY_TYPE_INFO(desctype) { \ 149176706Smav { "id", &ng_parse_uint32_type }, \ 150176706Smav { "local_addr", &ng_parse_ipaddr_type }, \ 151176706Smav { "alias_addr", &ng_parse_ipaddr_type }, \ 152176706Smav { "remote_addr", &ng_parse_ipaddr_type }, \ 153176706Smav { "local_port", &ng_parse_uint16_type }, \ 154176706Smav { "alias_port", &ng_parse_uint16_type }, \ 155176706Smav { "remote_port", &ng_parse_uint16_type }, \ 156176706Smav { "proto", &ng_parse_uint16_type }, \ 157176706Smav { "lsnat", &ng_parse_uint16_type }, \ 158176706Smav { "description", (desctype) }, \ 159176706Smav { NULL } \ 160176706Smav} 161176706Smav 162176706Smav/* Structure returned by NGM_NAT_LIST_REDIRECTS */ 163176706Smavstruct ng_nat_list_redirects { 164176706Smav uint32_t total_count; 165176706Smav struct ng_nat_listrdrs_entry redirects[]; 166176706Smav}; 167176706Smav 168176706Smav/* Keep this in sync with the above structure definition */ 169176706Smav#define NG_NAT_LIST_REDIRECTS_TYPE_INFO(redirtype) { \ 170176706Smav { "total_count", &ng_parse_uint32_type }, \ 171176706Smav { "redirects", (redirtype) }, \ 172176706Smav { NULL } \ 173176706Smav} 174176706Smav 175248570Sglebius/* Structure returned by NGM_NAT_LIBALIAS_INFO */ 176248570Sglebiusstruct ng_nat_libalias_info { 177248570Sglebius uint32_t icmpLinkCount; 178248570Sglebius uint32_t udpLinkCount; 179248570Sglebius uint32_t tcpLinkCount; 180248570Sglebius uint32_t sctpLinkCount; 181248570Sglebius uint32_t pptpLinkCount; 182248570Sglebius uint32_t protoLinkCount; 183248570Sglebius uint32_t fragmentIdLinkCount; 184248570Sglebius uint32_t fragmentPtrLinkCount; 185248570Sglebius uint32_t sockCount; 186248570Sglebius}; 187248570Sglebius 188248570Sglebius/* Keep this in sync with the above structure definition */ 189248570Sglebius#define NG_NAT_LIBALIAS_INFO { \ 190248570Sglebius { "icmpLinkCount", &ng_parse_uint32_type }, \ 191248570Sglebius { "udpLinkCount", &ng_parse_uint32_type }, \ 192248570Sglebius { "tcpLinkCount", &ng_parse_uint32_type }, \ 193248570Sglebius { "sctpLinkCount", &ng_parse_uint32_type }, \ 194248570Sglebius { "pptpLinkCount", &ng_parse_uint32_type }, \ 195248570Sglebius { "protoLinkCount", &ng_parse_uint32_type }, \ 196248570Sglebius { "fragmentIdLinkCount", &ng_parse_uint32_type }, \ 197248570Sglebius { "fragmentPtrLinkCount", &ng_parse_uint32_type }, \ 198248570Sglebius { "sockCount", &ng_parse_uint32_type }, \ 199248570Sglebius { NULL } \ 200248570Sglebius} 201248570Sglebius 202145937Sglebiusenum { 203145937Sglebius NGM_NAT_SET_IPADDR = 1, 204169867Smav NGM_NAT_SET_MODE, 205169867Smav NGM_NAT_SET_TARGET, 206176706Smav NGM_NAT_REDIRECT_PORT, 207176706Smav NGM_NAT_REDIRECT_ADDR, 208176706Smav NGM_NAT_REDIRECT_PROTO, 209176706Smav NGM_NAT_REDIRECT_DYNAMIC, 210176706Smav NGM_NAT_REDIRECT_DELETE, 211176706Smav NGM_NAT_ADD_SERVER, 212176706Smav NGM_NAT_LIST_REDIRECTS, 213176706Smav NGM_NAT_PROXY_RULE, 214248570Sglebius NGM_NAT_LIBALIAS_INFO, 215145937Sglebius}; 216