--- trunk/src/net.c 2007/10/08 16:18:27 10 +++ trunk/src/net.c 2007/10/08 16:18:38 12 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: net.c,v 1.77 2005/06/26 11:36:28 debug Exp $ + * $Id: net.c,v 1.80 2005/08/12 05:49:46 debug Exp $ * * Emulated (ethernet / internet) network support. * @@ -2254,7 +2254,7 @@ int iadd = 4; struct remote_net *rnp; - debug("net: "); + debug("net: simulating "); net_debugaddr(&net->netmask_ipv4, ADDR_IPV4); debug("/%i", net->netmask_ipv4_len); @@ -2264,41 +2264,37 @@ debug_indentation(iadd); - debug("gateway: "); + debug("simulated gateway: "); net_debugaddr(&net->gateway_ipv4_addr, ADDR_IPV4); debug(" ("); net_debugaddr(&net->gateway_ethernet_addr, ADDR_ETHERNET); debug(")\n"); debug_indentation(iadd); - if (net->domain_name != NULL && net->domain_name[0]) - debug("domain \"%s\", ", net->domain_name); if (!net->nameserver_known) { debug("(could not determine nameserver)"); } else { - debug("nameserver "); + debug("using nameserver "); net_debugaddr(&net->nameserver_ipv4, ADDR_IPV4); } + if (net->domain_name != NULL && net->domain_name[0]) + debug(", domain \"%s\"", net->domain_name); debug("\n"); debug_indentation(-iadd); rnp = net->remote_nets; - if (rnp != NULL) - debug("distributed network: other hosts:\n"); - + if (net->local_port != 0) + debug("distributed network: local port = %i\n", + net->local_port); debug_indentation(iadd); while (rnp != NULL) { - debug("\"%s\": ", rnp->name); + debug("remote \"%s\": ", rnp->name); net_debugaddr(&rnp->ipv4_addr, ADDR_IPV4); debug(" port %i\n", rnp->portnr); rnp = rnp->next; } debug_indentation(-iadd); - if (net->local_port != 0) - debug("distributed network: local port = %i\n", - net->local_port); - debug_indentation(-iadd); } @@ -2385,6 +2381,8 @@ if (n_remote != 0) { struct remote_net *rnp; while ((n_remote--) != 0) { + struct hostent *hp; + /* debug("adding '%s'\n", remote[n_remote]); */ rnp = malloc(sizeof(struct remote_net)); memset(rnp, 0, sizeof(struct remote_net)); @@ -2395,13 +2393,16 @@ rnp->name = strdup(remote[n_remote]); if (strchr(rnp->name, ':') != NULL) strchr(rnp->name, ':')[0] = '\0'; - /* TODO: Name resolution? */ -#ifdef HAVE_INET_PTON - res = inet_pton(AF_INET, rnp->name, &rnp->ipv4_addr); -#else - res = inet_aton(rnp->name, &rnp->ipv4_addr); -#endif + + hp = gethostbyname(rnp->name); + if (hp == NULL) { + fprintf(stderr, "could not resolve '%s'\n", + rnp->name); + exit(1); + } + memcpy(&rnp->ipv4_addr, hp->h_addr, hp->h_length); free(rnp->name); + /* And again: */ rnp->name = strdup(remote[n_remote]); if (strchr(rnp->name, ':') == NULL) {