Author: tjansen Date: Tue Nov 24 15:48:29 2009 New Revision: 1765 Log: Create a new conmgr entry for a service after a DNS lookup if none matching entry can be found. Modified: trunk/pisacd/cdservers.c Modified: trunk/pisacd/cdservers.c ============================================================================== --- trunk/pisacd/cdservers.c Tue Nov 24 15:18:45 2009 (r1764) +++ trunk/pisacd/cdservers.c Tue Nov 24 15:48:29 2009 (r1765) @@ -277,17 +277,24 @@ pisa_conmgr_entry *entry; struct in6_addr hit; struct in_addr remote; + pisa_contype type = cd_cfg.flag_native ? PISA_CONTYPE_SERVICE : PISA_CONTYPE_LEGACY_ROUTER; + /* Look up the service in DNS */ if (!pisa_servers_build_domain_name(&nat->local_private, dn, sizeof(dn))) goto failed; if (!pisa_servers_lookup_dns(dn, &hit, &remote)) goto failed; - /* TODO: If no conmgr entry exists we have to build one... */ - if (!(entry = pisa_conmgr_findby_hit(cd_ctx.conlist, &hit))) - goto failed; - pisa_nat_upgrade_preliminary(cd_ctx.natlist, nat, &remote, entry, NULL); + /* Find an existing conmgr entry for the service gateway or create a + * new one */ + entry = pisa_conmgr_findby_hit(cd_ctx.conlist, &hit); + if (!entry) { + entry = pisa_conmgr_add(cd_ctx.conlist, &hit, PISASD_DEFAULT_PORTNUM_CONTROL, type); + if (!entry) + goto failed; + } + pisa_nat_upgrade_preliminary(cd_ctx.natlist, nat, &remote, entry, NULL); return; failed: