Author: tjansen Date: Tue Nov 24 16:11:51 2009 New Revision: 1766 Log: Removed code to parse the services section in the config file. We switch to DNS, so this is dead code. It also gets rid of a rather complex structure in the config file. This way we have the option to get rid of libconfig eventually. Modified: trunk/pisacd/cdservers.c trunk/pisacd/cdservers.h Modified: trunk/pisacd/cdservers.c ============================================================================== --- trunk/pisacd/cdservers.c Tue Nov 24 15:48:29 2009 (r1765) +++ trunk/pisacd/cdservers.c Tue Nov 24 16:11:51 2009 (r1766) @@ -56,7 +56,6 @@ const char *hit = NULL; long port = PISACD_DEFAULT_PORTNUM_CONTROL; struct in6_addr hitaddr; - pisa_conmgr_entry *entry; if (config_setting_lookup_string(server, "hit", &hit) == CONFIG_FALSE) { PISA_ERROR("No hit given in a server block\n"); @@ -72,8 +71,7 @@ PISA_DEBUG(PL_CONFIG, "Server HIT: %s port: %i\n", hit, port); - if ((entry = pisa_server_add(&hitaddr, port, contype)) != NULL) - pisa_servers_add_services(entry); + pisa_server_add(&hitaddr, port, contype); } /** @@ -109,90 +107,6 @@ } /** - * Find a server block for a given connection. - * @param entry connection - * @return server block in the config file - */ -static config_setting_t *pisa_servers_get_servers_subsection(pisa_conmgr_entry *entry) -{ - config_setting_t *servers, *s; - int i, max; - const char *hit = NULL; - struct in6_addr addr; - - if ((servers = pisa_cfg_get_setting("servers")) == NULL) - return NULL; - - max = config_setting_length(servers); - for (i = 0; i < max; i++) { - - s = config_setting_get_elem(servers, i); - if (config_setting_lookup_string(s, "hit", &hit) == CONFIG_TRUE) { - - inet_pton(AF_INET6, hit, &addr); - if (!memcmp(&addr, &entry->hit, sizeof(struct in6_addr))) - return s; - } - } - - return NULL; -} - -/** - * Parse a NAT mapping block and add it to the NAT mappings hash - * @param nat configuration block - * @param entry connection - */ -static void pisa_servers_add_mapping(config_setting_t *nat, pisa_conmgr_entry *entry) -{ - const char *local_str = NULL, *remote_str = NULL; - struct in_addr local, remote; - - config_setting_lookup_string(nat, "local", &local_str); - config_setting_lookup_string(nat, "remote", &remote_str); - - if (!(local_str && remote_str)) - return; - - if (inet_pton(AF_INET, local_str, &local) != 1) { - PISA_ERROR("\tcould not parse local %s\n", local_str); - return; - } - if (inet_pton(AF_INET, remote_str, &remote) != 1) { - PISA_ERROR("\tcould not parse remote %s\n", remote_str); - return; - } - - pisa_nat_add_mapping(cd_ctx.natlist, &local, &remote, entry, NULL); - - PISA_DEBUG(PL_CONFIG, "\tlocal: %s remote: %s\n", local_str, remote_str); -} - -/** - * Add all NAT mappings for a given connection. Parse the servers block to - * find a matching entry and add all its NAT mappings. - * @param entry connection - */ -void pisa_servers_add_services(pisa_conmgr_entry *entry) -{ - config_setting_t *servers, *mappings; - int i, max; - - if ((servers = pisa_servers_get_servers_subsection(entry)) == NULL) - return; - - if ((mappings = config_setting_get_member(servers, "services")) == NULL ) { - PISA_DEBUG(PL_CONFIG, "\tNo NAT mappings found\n"); - return; - } - - max = config_setting_length(mappings); - for (i = 0; i < max; i++) - pisa_servers_add_mapping(config_setting_get_elem(mappings, i), entry); - PISA_DEBUG(PL_CONFIG, "\n"); -} - -/** * Generate a domain name for looking up a virtual local IP. * * @param addr virtual local IP address Modified: trunk/pisacd/cdservers.h ============================================================================== --- trunk/pisacd/cdservers.h Tue Nov 24 15:48:29 2009 (r1765) +++ trunk/pisacd/cdservers.h Tue Nov 24 16:11:51 2009 (r1766) @@ -9,7 +9,6 @@ #include "libpisa/conmgr.h" void pisa_servers_add_all(void); -void pisa_servers_add_services(pisa_conmgr_entry *entry); pisa_conmgr_entry *pisa_server_add(struct in6_addr *hit, int port, pisa_contype type); pisa_nat_mapping *pisa_servers_add_via_dns(struct in_addr *local_ip);