#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "fileio.h"
#include "debug.h"
#include "auth.h"
#include "mn.h"
Include dependency graph for mn_config.c:
Go to the source code of this file.
Data Structures | |
struct | load_mn_data |
Defines | |
#define | DEBUG_FLAG 'M' |
Functions | |
int | load_mn (struct mn_config *cfg, char *program_name, char *config_file) |
#define DEBUG_FLAG 'M' |
Definition at line 27 of file mn_config.c.
int load_mn | ( | struct mn_config * | cfg, | |
char * | program_name, | |||
char * | config_file | |||
) |
Definition at line 543 of file mn_config.c.
References mn_config::alt_ha_ip_addrs, mn_config::auth_alg, load_mn_data::cfg, mn_config::fa_spi_list, FALSE, mn_config::ha_ip_addr_orig, mn_config::home_net_addr, mn_config::home_net_addr_plen, mn_config::home_net_subnet_bc, mn_config::ignore_iflist, mn, MN_DEFAULT_SYSLOG_FACILITY, MN_DEFAULT_TUNNEL_LIFETIME, mn_config::mn_default_tunnel_lifetime, mn_config::mn_home_ip_addr_orig, MNDECAPS_ROUTE_DEFAULT, mn_config::mndecaps_route_handling, mn_config::replay_meth, mn_config::shared_secret_len, mn_config::socket_priority, mn_config::solicitation_interval, mn_config::syslog_facility, TRUE, TUNMODE_AUTO_REVERSE, mn_config::tunneling_mode, mn_config::udp_port, mn_config::use_hadisc, and mn_config::wlan_ap_poll_interval.
Referenced by mn_init().
00543 { 00544 FILE *file; 00545 struct load_mn_data mn; 00546 int i; 00547 00548 mn.cfg = cfg; 00549 memset(cfg, '\0', sizeof(struct mn_config)); 00550 cfg->mn_default_tunnel_lifetime = MN_DEFAULT_TUNNEL_LIFETIME; 00551 cfg->syslog_facility = MN_DEFAULT_SYSLOG_FACILITY; 00552 00553 cfg->shared_secret_len = -1; 00554 cfg->auth_alg = 1; 00555 cfg->replay_meth = 1; 00556 cfg->udp_port = 434; 00557 cfg->socket_priority = -1; 00558 cfg->home_net_addr_plen = -1; 00559 cfg->mndecaps_route_handling = MNDECAPS_ROUTE_DEFAULT; 00560 cfg->tunneling_mode = TUNMODE_AUTO_REVERSE; 00561 cfg->wlan_ap_poll_interval = -1; 00562 cfg->solicitation_interval = -1; 00563 mn.process_fa_spi_list = FALSE; 00564 mn.process_ignore_iflist = FALSE; 00565 list_init(&cfg->fa_spi_list); 00566 list_init(&cfg->ignore_iflist); 00567 list_init(&cfg->alt_ha_ip_addrs); 00568 00569 #ifdef BIND_UDP_SOCKET 00570 cfg->bind_addr.s_addr = INADDR_ANY; 00571 cfg->bind_port = htons(cfg->udp_port); 00572 #endif 00573 00574 file = fopen(config_file, "r"); 00575 if (file == NULL) { 00576 fprintf(stderr, 00577 "%s: Could not open configuration file '%s'.\n", 00578 program_name, config_file); 00579 return FALSE; 00580 } 00581 if (load_data(&mn, file, process_load_mn) == FALSE) { 00582 fprintf(stderr, 00583 "load_mn: Error while interpreting file '%s'!\n", 00584 config_file); 00585 fclose(file); 00586 return FALSE; 00587 } 00588 fclose(file); 00589 00590 if (cfg->home_net_addr_plen > -1) { 00591 /* determine home net's subnet-direct broadcast address */ 00592 __u32 ones = 0; 00593 for (i = cfg->home_net_addr_plen; i < 32; i++) { 00594 ones |= 1 << (31 - i); 00595 } 00596 cfg->home_net_subnet_bc.s_addr = cfg->home_net_addr.s_addr | 00597 htonl(ones); 00598 } 00599 00600 if (cfg->ha_ip_addr.s_addr == 0) 00601 cfg->use_hadisc = TRUE; 00602 00603 cfg->ha_ip_addr_orig.s_addr = cfg->ha_ip_addr.s_addr; 00604 cfg->mn_home_ip_addr_orig.s_addr = cfg->mn_home_ip_addr.s_addr; 00605 00606 return check_config_data(cfg); 00607 }