1c4c9b52bSGleb Smirnoff /*- 2c4c9b52bSGleb Smirnoff * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org> 3c4c9b52bSGleb Smirnoff * All rights reserved. 4c4c9b52bSGleb Smirnoff * 5c4c9b52bSGleb Smirnoff * Redistribution and use in source and binary forms, with or without 6c4c9b52bSGleb Smirnoff * modification, are permitted provided that the following conditions 7c4c9b52bSGleb Smirnoff * are met: 8c4c9b52bSGleb Smirnoff * 1. Redistributions of source code must retain the above copyright 9c4c9b52bSGleb Smirnoff * notice, this list of conditions and the following disclaimer. 10c4c9b52bSGleb Smirnoff * 2. Redistributions in binary form must reproduce the above copyright 11c4c9b52bSGleb Smirnoff * notice, this list of conditions and the following disclaimer in the 12c4c9b52bSGleb Smirnoff * documentation and/or other materials provided with the distribution. 13c4c9b52bSGleb Smirnoff * 14c4c9b52bSGleb Smirnoff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15c4c9b52bSGleb Smirnoff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16c4c9b52bSGleb Smirnoff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17c4c9b52bSGleb Smirnoff * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18c4c9b52bSGleb Smirnoff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19c4c9b52bSGleb Smirnoff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20c4c9b52bSGleb Smirnoff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21c4c9b52bSGleb Smirnoff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22c4c9b52bSGleb Smirnoff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23c4c9b52bSGleb Smirnoff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24c4c9b52bSGleb Smirnoff * SUCH DAMAGE. 25c4c9b52bSGleb Smirnoff * 26c4c9b52bSGleb Smirnoff * $FreeBSD$ 27c4c9b52bSGleb Smirnoff */ 28c4c9b52bSGleb Smirnoff 29c4c9b52bSGleb Smirnoff #define NG_NAT_NODE_TYPE "nat" 30c4c9b52bSGleb Smirnoff #define NGM_NAT_COOKIE 1107718711 31c4c9b52bSGleb Smirnoff 32c4c9b52bSGleb Smirnoff #define NG_NAT_HOOK_IN "in" 33c4c9b52bSGleb Smirnoff #define NG_NAT_HOOK_OUT "out" 34c4c9b52bSGleb Smirnoff 35e842c540SAlexander Motin /* Arguments for NGM_NAT_SET_MODE message */ 36e842c540SAlexander Motin struct ng_nat_mode { 37e842c540SAlexander Motin uint32_t flags; 38e842c540SAlexander Motin uint32_t mask; 39e842c540SAlexander Motin }; 40e842c540SAlexander Motin 41e842c540SAlexander Motin /* Keep this in sync with the above structure definition */ 42e842c540SAlexander Motin #define NG_NAT_MODE_INFO { \ 43e842c540SAlexander Motin { "flags", &ng_parse_uint32_type }, \ 44e842c540SAlexander Motin { "mask", &ng_parse_uint32_type }, \ 45e842c540SAlexander Motin { NULL } \ 46e842c540SAlexander Motin } 47e842c540SAlexander Motin 48e842c540SAlexander Motin #define NG_NAT_LOG 0x01 49e842c540SAlexander Motin #define NG_NAT_DENY_INCOMING 0x02 50e842c540SAlexander Motin #define NG_NAT_SAME_PORTS 0x04 51e842c540SAlexander Motin #define NG_NAT_UNREGISTERED_ONLY 0x10 52e842c540SAlexander Motin #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 53e842c540SAlexander Motin #define NG_NAT_PROXY_ONLY 0x40 54e842c540SAlexander Motin #define NG_NAT_REVERSE 0x80 55e842c540SAlexander Motin 56fffba935SAlexander Motin #define NG_NAT_DESC_LENGTH 64 57fffba935SAlexander Motin #define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */ 58fffba935SAlexander Motin 59fffba935SAlexander Motin /* Arguments for NGM_NAT_REDIRECT_PORT message */ 60fffba935SAlexander Motin struct ng_nat_redirect_port { 61fffba935SAlexander Motin struct in_addr local_addr; 62fffba935SAlexander Motin struct in_addr alias_addr; 63fffba935SAlexander Motin struct in_addr remote_addr; 64fffba935SAlexander Motin uint16_t local_port; 65fffba935SAlexander Motin uint16_t alias_port; 66fffba935SAlexander Motin uint16_t remote_port; 67fffba935SAlexander Motin uint8_t proto; 68fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 69fffba935SAlexander Motin }; 70fffba935SAlexander Motin 71fffba935SAlexander Motin /* Keep this in sync with the above structure definition */ 72fffba935SAlexander Motin #define NG_NAT_REDIRECT_PORT_TYPE_INFO(desctype) { \ 73fffba935SAlexander Motin { "local_addr", &ng_parse_ipaddr_type }, \ 74fffba935SAlexander Motin { "alias_addr", &ng_parse_ipaddr_type }, \ 75fffba935SAlexander Motin { "remote_addr", &ng_parse_ipaddr_type }, \ 76fffba935SAlexander Motin { "local_port", &ng_parse_uint16_type }, \ 77fffba935SAlexander Motin { "alias_port", &ng_parse_uint16_type }, \ 78fffba935SAlexander Motin { "remote_port", &ng_parse_uint16_type }, \ 79fffba935SAlexander Motin { "udp", &ng_parse_uint8_type }, \ 80fffba935SAlexander Motin { "description", (desctype) }, \ 81fffba935SAlexander Motin { NULL } \ 82fffba935SAlexander Motin } 83fffba935SAlexander Motin 84fffba935SAlexander Motin /* Arguments for NGM_NAT_REDIRECT_ADDR message */ 85fffba935SAlexander Motin struct ng_nat_redirect_addr { 86fffba935SAlexander Motin struct in_addr local_addr; 87fffba935SAlexander Motin struct in_addr alias_addr; 88fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 89fffba935SAlexander Motin }; 90fffba935SAlexander Motin 91fffba935SAlexander Motin /* Keep this in sync with the above structure definition */ 92fffba935SAlexander Motin #define NG_NAT_REDIRECT_ADDR_TYPE_INFO(desctype) { \ 93fffba935SAlexander Motin { "local_addr", &ng_parse_ipaddr_type }, \ 94fffba935SAlexander Motin { "alias_addr", &ng_parse_ipaddr_type }, \ 95fffba935SAlexander Motin { "description", (desctype) }, \ 96fffba935SAlexander Motin { NULL } \ 97fffba935SAlexander Motin } 98fffba935SAlexander Motin 99fffba935SAlexander Motin /* Arguments for NGM_NAT_REDIRECT_PROTO message */ 100fffba935SAlexander Motin struct ng_nat_redirect_proto { 101fffba935SAlexander Motin struct in_addr local_addr; 102fffba935SAlexander Motin struct in_addr alias_addr; 103fffba935SAlexander Motin struct in_addr remote_addr; 104fffba935SAlexander Motin uint8_t proto; 105fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 106fffba935SAlexander Motin }; 107fffba935SAlexander Motin 108fffba935SAlexander Motin /* Keep this in sync with the above structure definition */ 109fffba935SAlexander Motin #define NG_NAT_REDIRECT_PROTO_TYPE_INFO(desctype) { \ 110fffba935SAlexander Motin { "local_addr", &ng_parse_ipaddr_type }, \ 111fffba935SAlexander Motin { "alias_addr", &ng_parse_ipaddr_type }, \ 112fffba935SAlexander Motin { "remote_addr", &ng_parse_ipaddr_type }, \ 113fffba935SAlexander Motin { "proto", &ng_parse_uint8_type }, \ 114fffba935SAlexander Motin { "description", (desctype) }, \ 115fffba935SAlexander Motin { NULL } \ 116fffba935SAlexander Motin } 117fffba935SAlexander Motin 118fffba935SAlexander Motin /* Arguments for NGM_NAT_ADD_SERVER message */ 119fffba935SAlexander Motin struct ng_nat_add_server { 120fffba935SAlexander Motin uint32_t id; 121fffba935SAlexander Motin struct in_addr addr; 122fffba935SAlexander Motin uint16_t port; 123fffba935SAlexander Motin }; 124fffba935SAlexander Motin 125fffba935SAlexander Motin /* Keep this in sync with the above structure definition */ 126fffba935SAlexander Motin #define NG_NAT_ADD_SERVER_TYPE_INFO { \ 127fffba935SAlexander Motin { "id", &ng_parse_uint32_type }, \ 128fffba935SAlexander Motin { "addr", &ng_parse_ipaddr_type }, \ 129fffba935SAlexander Motin { "port", &ng_parse_uint16_type }, \ 130fffba935SAlexander Motin { NULL } \ 131fffba935SAlexander Motin } 132fffba935SAlexander Motin 133fffba935SAlexander Motin /* List entry of array returned in NGM_NAT_LIST_REDIRECTS message */ 134fffba935SAlexander Motin struct ng_nat_listrdrs_entry { 135fffba935SAlexander Motin uint32_t id; /* Anything except zero */ 136fffba935SAlexander Motin struct in_addr local_addr; 137fffba935SAlexander Motin struct in_addr alias_addr; 138fffba935SAlexander Motin struct in_addr remote_addr; 139fffba935SAlexander Motin uint16_t local_port; 140fffba935SAlexander Motin uint16_t alias_port; 141fffba935SAlexander Motin uint16_t remote_port; 142fffba935SAlexander Motin uint16_t proto; /* Valid proto or NG_NAT_REDIRPROTO_ADDR */ 143fffba935SAlexander Motin uint16_t lsnat; /* LSNAT servers count */ 144fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 145fffba935SAlexander Motin }; 146fffba935SAlexander Motin 147fffba935SAlexander Motin /* Keep this in sync with the above structure definition */ 148fffba935SAlexander Motin #define NG_NAT_LISTRDRS_ENTRY_TYPE_INFO(desctype) { \ 149fffba935SAlexander Motin { "id", &ng_parse_uint32_type }, \ 150fffba935SAlexander Motin { "local_addr", &ng_parse_ipaddr_type }, \ 151fffba935SAlexander Motin { "alias_addr", &ng_parse_ipaddr_type }, \ 152fffba935SAlexander Motin { "remote_addr", &ng_parse_ipaddr_type }, \ 153fffba935SAlexander Motin { "local_port", &ng_parse_uint16_type }, \ 154fffba935SAlexander Motin { "alias_port", &ng_parse_uint16_type }, \ 155fffba935SAlexander Motin { "remote_port", &ng_parse_uint16_type }, \ 156fffba935SAlexander Motin { "proto", &ng_parse_uint16_type }, \ 157fffba935SAlexander Motin { "lsnat", &ng_parse_uint16_type }, \ 158fffba935SAlexander Motin { "description", (desctype) }, \ 159fffba935SAlexander Motin { NULL } \ 160fffba935SAlexander Motin } 161fffba935SAlexander Motin 162fffba935SAlexander Motin /* Structure returned by NGM_NAT_LIST_REDIRECTS */ 163fffba935SAlexander Motin struct ng_nat_list_redirects { 164fffba935SAlexander Motin uint32_t total_count; 165fffba935SAlexander Motin struct ng_nat_listrdrs_entry redirects[]; 166fffba935SAlexander Motin }; 167fffba935SAlexander Motin 168fffba935SAlexander Motin /* Keep this in sync with the above structure definition */ 169fffba935SAlexander Motin #define NG_NAT_LIST_REDIRECTS_TYPE_INFO(redirtype) { \ 170fffba935SAlexander Motin { "total_count", &ng_parse_uint32_type }, \ 171fffba935SAlexander Motin { "redirects", (redirtype) }, \ 172fffba935SAlexander Motin { NULL } \ 173fffba935SAlexander Motin } 174fffba935SAlexander Motin 175c4c9b52bSGleb Smirnoff enum { 176c4c9b52bSGleb Smirnoff NGM_NAT_SET_IPADDR = 1, 177e842c540SAlexander Motin NGM_NAT_SET_MODE, 178e842c540SAlexander Motin NGM_NAT_SET_TARGET, 179fffba935SAlexander Motin NGM_NAT_REDIRECT_PORT, 180fffba935SAlexander Motin NGM_NAT_REDIRECT_ADDR, 181fffba935SAlexander Motin NGM_NAT_REDIRECT_PROTO, 182fffba935SAlexander Motin NGM_NAT_REDIRECT_DYNAMIC, 183fffba935SAlexander Motin NGM_NAT_REDIRECT_DELETE, 184fffba935SAlexander Motin NGM_NAT_ADD_SERVER, 185fffba935SAlexander Motin NGM_NAT_LIST_REDIRECTS, 186fffba935SAlexander Motin NGM_NAT_PROXY_RULE, 187c4c9b52bSGleb Smirnoff }; 188