Changeset View
Changeset View
Standalone View
Standalone View
sbin/ipfw/nat64stl.c
- This file was copied to sbin/ipfw/nat64clat.c.
/*- | /*- | ||||
* Copyright (c) 2015-2016 Yandex LLC | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | ||||
* Copyright (c) 2015-2016 Andrey V. Elsukov <ae@FreeBSD.org> | |||||
* All rights reserved. | |||||
* | * | ||||
* Copyright (c) 2015-2019 Yandex LLC | |||||
* Copyright (c) 2015-2019 Andrey V. Elsukov <ae@FreeBSD.org> | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* | * | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static struct _s_x nat64newcmds[] = { | static struct _s_x nat64newcmds[] = { | ||||
{ "table4", TOK_TABLE4 }, | { "table4", TOK_TABLE4 }, | ||||
{ "table6", TOK_TABLE6 }, | { "table6", TOK_TABLE6 }, | ||||
{ "prefix6", TOK_PREFIX6 }, | { "prefix6", TOK_PREFIX6 }, | ||||
{ "log", TOK_LOG }, | { "log", TOK_LOG }, | ||||
{ "-log", TOK_LOGOFF }, | { "-log", TOK_LOGOFF }, | ||||
{ "allow_private", TOK_PRIVATE }, | |||||
{ "-allow_private", TOK_PRIVATEOFF }, | |||||
{ NULL, 0 } | { NULL, 0 } | ||||
}; | }; | ||||
/* | /* | ||||
* Creates new nat64stl instance | * Creates new nat64stl instance | ||||
* ipfw nat64stl <NAME> create table4 <name> table6 <name> [ prefix6 <prefix>] | * ipfw nat64stl <NAME> create table4 <name> table6 <name> [ prefix6 <prefix>] | ||||
* Request: [ ipfw_obj_lheader ipfw_nat64stl_cfg ] | * Request: [ ipfw_obj_lheader ipfw_nat64stl_cfg ] | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | case TOK_PREFIX6: | ||||
ac--; av++; | ac--; av++; | ||||
break; | break; | ||||
case TOK_LOG: | case TOK_LOG: | ||||
cfg->flags |= NAT64_LOG; | cfg->flags |= NAT64_LOG; | ||||
break; | break; | ||||
case TOK_LOGOFF: | case TOK_LOGOFF: | ||||
cfg->flags &= ~NAT64_LOG; | cfg->flags &= ~NAT64_LOG; | ||||
break; | break; | ||||
case TOK_PRIVATE: | |||||
cfg->flags |= NAT64_ALLOW_PRIVATE; | |||||
break; | |||||
case TOK_PRIVATEOFF: | |||||
cfg->flags &= ~NAT64_ALLOW_PRIVATE; | |||||
break; | |||||
} | } | ||||
} | } | ||||
/* Check validness */ | /* Check validness */ | ||||
if ((flags & NAT64STL_HAS_TABLE4) != NAT64STL_HAS_TABLE4) | if ((flags & NAT64STL_HAS_TABLE4) != NAT64STL_HAS_TABLE4) | ||||
errx(EX_USAGE, "table4 required"); | errx(EX_USAGE, "table4 required"); | ||||
if ((flags & NAT64STL_HAS_TABLE6) != NAT64STL_HAS_TABLE6) | if ((flags & NAT64STL_HAS_TABLE6) != NAT64STL_HAS_TABLE6) | ||||
errx(EX_USAGE, "table6 required"); | errx(EX_USAGE, "table6 required"); | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | case TOK_TABLE6: | ||||
break; | break; | ||||
#endif | #endif | ||||
case TOK_LOG: | case TOK_LOG: | ||||
cfg->flags |= NAT64_LOG; | cfg->flags |= NAT64_LOG; | ||||
break; | break; | ||||
case TOK_LOGOFF: | case TOK_LOGOFF: | ||||
cfg->flags &= ~NAT64_LOG; | cfg->flags &= ~NAT64_LOG; | ||||
break; | break; | ||||
case TOK_PRIVATE: | |||||
cfg->flags |= NAT64_ALLOW_PRIVATE; | |||||
break; | |||||
case TOK_PRIVATEOFF: | |||||
cfg->flags &= ~NAT64_ALLOW_PRIVATE; | |||||
break; | |||||
default: | default: | ||||
errx(EX_USAGE, "Can't change %s option", opt); | errx(EX_USAGE, "Can't change %s option", opt); | ||||
} | } | ||||
} | } | ||||
if (do_set3(IP_FW_NAT64STL_CONFIG, &oh->opheader, sizeof(buf)) != 0) | if (do_set3(IP_FW_NAT64STL_CONFIG, &oh->opheader, sizeof(buf)) != 0) | ||||
err(EX_OSERR, "nat64stl instance configuration failed"); | err(EX_OSERR, "nat64stl instance configuration failed"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | if (co.use_set != 0 || cfg->set != 0) | ||||
printf("set %u ", cfg->set); | printf("set %u ", cfg->set); | ||||
printf("nat64stl %s table4 %s table6 %s", | printf("nat64stl %s table4 %s table6 %s", | ||||
cfg->name, cfg->ntlv4.name, cfg->ntlv6.name); | cfg->name, cfg->ntlv4.name, cfg->ntlv6.name); | ||||
inet_ntop(AF_INET6, &cfg->prefix6, abuf, sizeof(abuf)); | inet_ntop(AF_INET6, &cfg->prefix6, abuf, sizeof(abuf)); | ||||
printf(" prefix6 %s/%u", abuf, cfg->plen6); | printf(" prefix6 %s/%u", abuf, cfg->plen6); | ||||
if (cfg->flags & NAT64_LOG) | if (cfg->flags & NAT64_LOG) | ||||
printf(" log"); | printf(" log"); | ||||
if (cfg->flags & NAT64_ALLOW_PRIVATE) | |||||
printf(" allow_private"); | |||||
printf("\n"); | printf("\n"); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
nat64stl_destroy_cb(ipfw_nat64stl_cfg *cfg, const char *name, uint8_t set) | nat64stl_destroy_cb(ipfw_nat64stl_cfg *cfg, const char *name, uint8_t set) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |