+ /* Read in all the subnets specified in the host configuration file */
+
+ for(config_t *cfg = lookup_config(config_tree, "Subnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) {
+ subnet_t *subnet;
+
+ if(!get_config_subnet(cfg, &subnet)) {
+ return false;
+ }
+
+ subnet_add(myself, subnet);
+ }
+
+ /* Check some options */
+
+ if(!setup_myself_reloadable()) {
+ return false;
+ }
+
+ get_config_bool(lookup_config(config_tree, "StrictSubnets"), &strictsubnets);
+ get_config_bool(lookup_config(config_tree, "TunnelServer"), &tunnelserver);
+ strictsubnets |= tunnelserver;
+
+ if(get_config_int(lookup_config(config_tree, "MaxConnectionBurst"), &max_connection_burst)) {
+ if(max_connection_burst <= 0) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "MaxConnectionBurst cannot be negative!");
+ return false;
+ }
+ }
+
+ if(get_config_int(lookup_config(config_tree, "UDPRcvBuf"), &udp_rcvbuf)) {
+ if(udp_rcvbuf < 0) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "UDPRcvBuf cannot be negative!");
+ return false;
+ }
+
+ udp_rcvbuf_warnings = true;
+ }
+
+ if(get_config_int(lookup_config(config_tree, "UDPSndBuf"), &udp_sndbuf)) {
+ if(udp_sndbuf < 0) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "UDPSndBuf cannot be negative!");
+ return false;
+ }
+
+ udp_sndbuf_warnings = true;
+ }
+
+ get_config_int(lookup_config(config_tree, "FWMark"), &fwmark);
+#ifndef SO_MARK
+
+ if(fwmark) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "FWMark not supported on this platform!");
+ return false;
+ }
+
+#endif
+
+ int replaywin_int;
+
+ if(get_config_int(lookup_config(config_tree, "ReplayWindow"), &replaywin_int)) {
+ if(replaywin_int < 0) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "ReplayWindow cannot be negative!");
+ return false;
+ }
+
+ replaywin = (unsigned)replaywin_int;
+ sptps_replaywin = replaywin;
+ }
+
+#ifndef DISABLE_LEGACY
+ /* Generate packet encryption key */
+
+ char *cipher;
+
+ if(!get_config_string(lookup_config(config_tree, "Cipher"), &cipher)) {
+ cipher = xstrdup("aes-256-cbc");
+ }
+
+ if(!strcasecmp(cipher, "none")) {
+ myself->incipher = NULL;
+ } else if(!(myself->incipher = cipher_open_by_name(cipher))) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized cipher type!");
+ free(cipher);
+ return false;
+ }
+
+ free(cipher);
+
+ timeout_add(&keyexpire_timeout, keyexpire_handler, &keyexpire_timeout, &(struct timeval) {
+ keylifetime, rand() % 100000
+ });
+
+ /* Check if we want to use message authentication codes... */
+
+ int maclength = 4;
+ get_config_int(lookup_config(config_tree, "MACLength"), &maclength);
+
+ if(maclength < 0) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Bogus MAC length!");
+ return false;
+ }
+
+ char *digest;
+
+ if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) {
+ digest = xstrdup("sha256");
+ }
+
+ if(!strcasecmp(digest, "none")) {
+ myself->indigest = NULL;
+ } else if(!(myself->indigest = digest_open_by_name(digest, maclength))) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized digest type!");
+ free(digest);
+ return false;
+ }
+
+ free(digest);
+#endif