From 689c5ad56338b4a9ed81ac9a58d13689a24ba955 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Thu, 7 May 2015 08:57:58 +0200 Subject: [PATCH] allow specifying a subnet id --- src/config.c | 4 ++++ src/ocserv-args.def | 5 +++++ src/vpn.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/src/config.c b/src/config.c index cdaea4cd..e1a0a74d 100644 --- a/src/config.c +++ b/src/config.c @@ -163,6 +163,7 @@ static struct cfg_options available_options[] = { { .name = "ipv6-network", .type = OPTION_STRING, .mandatory = 0 }, { .name = "ipv6-prefix", .type = OPTION_NUMERIC, .mandatory = 0 }, + { .name = "ipv6-subnet-id-length", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "route-add-cmd", .type = OPTION_STRING, .mandatory = 0 }, { .name = "route-del-cmd", .type = OPTION_STRING, .mandatory = 0 }, { .name = "config-per-user", .type = OPTION_STRING, .mandatory = 0 }, @@ -886,6 +887,9 @@ unsigned urlfw_size = 0; } READ_STRING("ipv6-network", config->network.ipv6); + READ_NUMERIC("ipv6-subnet-id-length", config->network.ipv6_subnet_id_length); + if (config->network.ipv6_subnet_id_length == 0) + config->network.ipv6_subnet_id_length = DEFAULT_SUBNET_ID_LENGTH; prefix = extract_prefix(config->network.ipv6); if (prefix == 0) { diff --git a/src/ocserv-args.def b/src/ocserv-args.def index 0cb99965..beb9cfb2 100644 --- a/src/ocserv-args.def +++ b/src/ocserv-args.def @@ -450,6 +450,11 @@ ipv4-netmask = 255.255.255.0 # The IPv6 subnet that leases will be given from. #ipv6-network = fda9:4efe:7e3b:03ea::/64 +# The length, in bits, of the subnet id to give addresses to clients. +# This also defines the maximum number of clients the server can handle, +# i.e., 2^(length). +#ipv6-subnet-id-length = 16 + # The advertized DNS server. Use multiple lines for # multiple servers. # dns = fc00::4be0 diff --git a/src/vpn.h b/src/vpn.h index 66876b42..78f19522 100644 --- a/src/vpn.h +++ b/src/vpn.h @@ -66,6 +66,7 @@ typedef enum { #define DEFAULT_KKDCP_POINTS 1 #define DEFAULT_MAX_BAN_SCORE (MAX_PASSWORD_TRIES*DEFAULT_PASSWORD_POINTS) #define DEFAULT_BAN_RESET_TIME 300 +#define DEFAULT_SUBNET_ID_LENGTH 16 #define MIN_NO_COMPRESS_LIMIT 64 #define DEFAULT_NO_COMPRESS_LIMIT 256 @@ -218,6 +219,7 @@ struct vpn_st { char *ipv6; char *ipv6_local; /* local IPv6 address */ + unsigned ipv6_subnet_id_length; unsigned int mtu; char **routes;