int parse_proxy_etrs(cfg_t *cfg, lisp_xtr_t *xtr) { int n,i; void *fwd_map_inf; /* PROXY-ETR CONFIG */ n = cfg_size(cfg, "proxy-etr"); for(i = 0; i < n; i++) { cfg_t *petr = cfg_getnsec(cfg, "proxy-etr", i); if (add_proxy_etr_entry(xtr->petrs, cfg_getstr(petr, "address"), cfg_getint(petr, "priority"), cfg_getint(petr, "weight")) == GOOD) { OOR_LOG(LDBG_1, "Added %s to proxy-etr list", cfg_getstr(petr, "address")); } else{ OOR_LOG(LERR, "Can't add proxy-etr %s", cfg_getstr(petr, "address")); } } /* Calculate forwarding info for petrs */ fwd_map_inf = xtr->fwd_policy->new_map_cache_policy_inf(xtr->fwd_policy_dev_parm,mcache_entry_mapping(xtr->petrs)); if (fwd_map_inf == NULL){ OOR_LOG(LDBG_1, "xtr_ctrl_construct: Couldn't create routing info for PeTRs!."); mcache_entry_del(xtr->petrs); return(BAD); } mcache_entry_set_routing_info(xtr->petrs,fwd_map_inf,xtr->fwd_policy->del_map_cache_policy_inf); return (GOOD); }
int handle_lispd_config_file() { cfg_t *cfg = 0; unsigned int i = 0; unsigned n = 0; int ret = 0; static cfg_opt_t map_server_opts[] = { CFG_STR("address", 0, CFGF_NONE), CFG_INT("key-type", 0, CFGF_NONE), CFG_STR("key", 0, CFGF_NONE), CFG_BOOL("proxy-reply", cfg_false, CFGF_NONE), CFG_BOOL("verify", cfg_false, CFGF_NONE), CFG_END() }; static cfg_opt_t db_mapping_opts[] = { CFG_STR("eid-prefix", 0, CFGF_NONE), CFG_INT("iid", -1, CFGF_NONE), CFG_STR("interface", 0, CFGF_NONE), CFG_INT("priority_v4", 0, CFGF_NONE), CFG_INT("weight_v4", 0, CFGF_NONE), CFG_INT("priority_v6", 0, CFGF_NONE), CFG_INT("weight_v6", 0, CFGF_NONE), CFG_END() }; static cfg_opt_t mc_mapping_opts[] = { CFG_STR("eid-prefix", 0, CFGF_NONE), CFG_INT("iid", 0, CFGF_NONE), CFG_STR("rloc", 0, CFGF_NONE), CFG_INT("priority", 0, CFGF_NONE), CFG_INT("weight", 0, CFGF_NONE), CFG_END() }; static cfg_opt_t petr_mapping_opts[] = { CFG_STR("address", 0, CFGF_NONE), CFG_INT("priority", 255, CFGF_NONE), CFG_INT("weight", 0, CFGF_NONE), CFG_END() }; cfg_opt_t opts[] = { CFG_SEC("database-mapping", db_mapping_opts, CFGF_MULTI), CFG_SEC("static-map-cache", mc_mapping_opts, CFGF_MULTI), CFG_SEC("map-server", map_server_opts, CFGF_MULTI), CFG_SEC("proxy-etr", petr_mapping_opts, CFGF_MULTI), CFG_INT("map-request-retries", 0, CFGF_NONE), CFG_INT("control-port", 0, CFGF_NONE), CFG_BOOL("debug", cfg_false, CFGF_NONE), CFG_STR("map-resolver", 0, CFGF_NONE), CFG_STR_LIST("proxy-itrs", 0, CFGF_NONE), CFG_END() }; /* * parse config_file */ cfg = cfg_init(opts, CFGF_NOCASE); ret = cfg_parse(cfg, config_file); if (ret == CFG_FILE_ERROR) { syslog(LOG_DAEMON, "Couldn't find config file %s, exiting...", config_file); exit(EXIT_FAILURE); } else if(ret == CFG_PARSE_ERROR) { syslog(LOG_DAEMON, "NOTE: Version 0.2.4 changed the format of the 'proxy-etr' element."); syslog(LOG_DAEMON, " Check the 'lispd.conf.example' file for an example entry in"); syslog(LOG_DAEMON, " the new format."); syslog(LOG_DAEMON, "Parse error in file %s, exiting...", config_file); exit(EXIT_FAILURE); } /* * lispd config options */ ret = cfg_getint(cfg, "map-request-retries"); if (ret != 0) map_request_retries = ret; cfg_getbool(cfg, "debug") ? (debug = 1) : (debug = 0); /* * LISP config options */ /* * handle map-resolver config */ map_resolver = cfg_getstr(cfg, "map-resolver"); if (!add_server(map_resolver, &map_resolvers)) return(0); #ifdef DEBUG syslog(LOG_DAEMON, "Added %s to map-resolver list", map_resolver); #endif /* * handle proxy-etr config */ n = cfg_size(cfg, "proxy-etr"); for(i = 0; i < n; i++) { cfg_t *petr = cfg_getnsec(cfg, "proxy-etr", i); if (!add_proxy_etr_entry(petr, &proxy_etrs)) { syslog(LOG_DAEMON, "Can't add proxy-etr %d (%s)", i, cfg_getstr(petr, "address")); } } if (!proxy_etrs){ syslog(LOG_DAEMON, "WARNING: No Proxy-ETR defined. Packets to non-LISP destinations will be forwarded natively (no LISP encapsulation). This may prevent mobility in some scenarios."); sleep(3); } /* * handle proxy-itr config */ n = cfg_size(cfg, "proxy-itrs"); for(i = 0; i < n; i++) { if ((proxy_itr = cfg_getnstr(cfg, "proxy-itrs", i)) != NULL) { if (!add_server(proxy_itr, &proxy_itrs)) continue; #ifdef DEBUG syslog(LOG_DAEMON, "Added %s to proxy-itr list", proxy_itr); #endif } } /* * handle database-mapping config */ n = cfg_size(cfg, "database-mapping"); for(i = 0; i < n; i++) { cfg_t *dm = cfg_getnsec(cfg, "database-mapping", i); if (!add_database_mapping(dm)) { syslog(LOG_DAEMON, "Can't add database-mapping %d (%s->%s)", i, cfg_getstr(dm, "eid-prefix"), cfg_getstr(dm, "interface")); } } /* * handle map-server config */ n = cfg_size(cfg, "map-server"); for(i = 0; i < n; i++) { cfg_t *ms = cfg_getnsec(cfg, "map-server", i); if (!add_map_server(cfg_getstr(ms, "address"), cfg_getint(ms, "key-type"), cfg_getstr(ms, "key"), (cfg_getbool(ms, "proxy-reply") ? 1:0), (cfg_getbool(ms, "verify") ? 1:0))) return(0); #ifdef DEBUG syslog(LOG_DAEMON, "Added %s to map-server list", cfg_getstr(ms, "address")); #endif } /* * handle static-map-cache config */ n = cfg_size(cfg, "static-map-cache"); for(i = 0; i < n; i++) { cfg_t *smc = cfg_getnsec(cfg, "static-map-cache", i); if (!add_static_map_cache_entry(smc)) { syslog(LOG_DAEMON,"Can't add static-map-cache %d (EID:%s -> RLOC:%s)", i, cfg_getstr(smc, "eid-prefix"), cfg_getstr(smc, "rloc")); } } #if (DEBUG > 3) dump_tree(AF_INET,AF4_database); dump_tree(AF_INET6,AF6_database); dump_database(); dump_map_servers(); dump_servers(map_resolvers, "map-resolvers"); dump_servers(proxy_etrs, "proxy-etrs"); dump_servers(proxy_itrs, "proxy-itrs"); dump_map_cache(); #endif cfg_free(cfg); return(0); }