mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
simplify the input of IPv6 networks
The prefix is specified as part of the network.
This commit is contained in:
@@ -269,8 +269,7 @@ dns = 192.168.1.2
|
||||
#nbns = 192.168.1.3
|
||||
|
||||
# The IPv6 subnet that leases will be given from.
|
||||
#ipv6-network = fc00::
|
||||
#ipv6-prefix = 16
|
||||
ipv6-network = fda9:4efe:7e3b:03ea::/64
|
||||
|
||||
# The domains over which the provided DNS should be used. Use
|
||||
# multiple lines for multiple domains.
|
||||
|
||||
28
src/config.c
28
src/config.c
@@ -367,6 +367,28 @@ static char *get_brackets_string2(void *pool, const char *str)
|
||||
return talloc_strndup(pool, p, len);
|
||||
}
|
||||
|
||||
/* Parses the string ::1/prefix, to return prefix
|
||||
* and modify the string to contain the network only.
|
||||
*/
|
||||
unsigned extract_prefix(char *network)
|
||||
{
|
||||
char *p;
|
||||
unsigned prefix;
|
||||
|
||||
if (network == NULL)
|
||||
return 0;
|
||||
|
||||
p = strchr(network, '/');
|
||||
|
||||
if (p == NULL)
|
||||
return 0;
|
||||
|
||||
prefix = atoi(p+1);
|
||||
*p = 0;
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
const struct auth_mod_st *get_auth_mod(void)
|
||||
{
|
||||
return amod;
|
||||
@@ -646,7 +668,11 @@ unsigned force_cert_auth;
|
||||
|
||||
READ_STRING("ipv6-network", config->network.ipv6);
|
||||
|
||||
READ_NUMERIC("ipv6-prefix", prefix);
|
||||
prefix = extract_prefix(config->network.ipv6);
|
||||
if (prefix == 0) {
|
||||
READ_NUMERIC("ipv6-prefix", prefix);
|
||||
}
|
||||
|
||||
if (prefix > 0) {
|
||||
config->network.ipv6_prefix = prefix;
|
||||
|
||||
|
||||
@@ -362,8 +362,7 @@ dns = 192.168.1.2
|
||||
#nbns = 192.168.1.3
|
||||
|
||||
# The IPv6 subnet that leases will be given from.
|
||||
#ipv6-network = fc00::
|
||||
#ipv6-prefix = 16
|
||||
#ipv6-network = fda9:4efe:7e3b:03ea::/64
|
||||
|
||||
# The domains over which the provided DNS should be used. Use
|
||||
# multiple lines for multiple domains.
|
||||
@@ -421,7 +420,7 @@ route = 192.168.5.0/255.255.255.0
|
||||
# per group. Each file name on these directories must match the username
|
||||
# or the groupname.
|
||||
# The options allowed in the configuration files are dns, nbns,
|
||||
# ipv?-network, ipv4-netmask, ipv6-prefix, rx/tx-per-sec, iroute, route,
|
||||
# ipv?-network, ipv4-netmask, rx/tx-per-sec, iroute, route,
|
||||
# net-priority, deny-roaming, no-udp, user-profile, require-cert, and cgroup.
|
||||
#
|
||||
# Note that the 'iroute' option allows to add routes on the server
|
||||
|
||||
@@ -204,7 +204,13 @@ unsigned prefix = 0;
|
||||
READ_RAW_STRING("ipv6-network", msg->ipv6_net);
|
||||
READ_RAW_STRING("ipv4-netmask", msg->ipv4_netmask);
|
||||
|
||||
READ_RAW_NUMERIC("ipv6-prefix", msg->ipv6_prefix, msg->has_ipv6_prefix);
|
||||
msg->ipv6_prefix = extract_prefix(msg->ipv6_net);
|
||||
if (msg->ipv6_prefix == 0) {
|
||||
READ_RAW_NUMERIC("ipv6-prefix", msg->ipv6_prefix, msg->has_ipv6_prefix);
|
||||
} else {
|
||||
msg->has_ipv6_prefix = 1;
|
||||
}
|
||||
|
||||
if (msg->has_ipv6_prefix != 0) {
|
||||
if (valid_ipv6_prefix(msg->ipv6_prefix) == 0) {
|
||||
syslog(LOG_ERR, "unknown ipv6-prefix '%u' in %s", prefix, file);
|
||||
|
||||
Reference in New Issue
Block a user