/[gxemul]/trunk/src/net.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/net.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 10 by dpavlin, Mon Oct 8 16:18:27 2007 UTC revision 12 by dpavlin, Mon Oct 8 16:18:38 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $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 $
29   *   *
30   *  Emulated (ethernet / internet) network support.   *  Emulated (ethernet / internet) network support.
31   *   *
# Line 2254  void net_dumpinfo(struct net *net) Line 2254  void net_dumpinfo(struct net *net)
2254          int iadd = 4;          int iadd = 4;
2255          struct remote_net *rnp;          struct remote_net *rnp;
2256    
2257          debug("net: ");          debug("net: simulating ");
2258    
2259          net_debugaddr(&net->netmask_ipv4, ADDR_IPV4);          net_debugaddr(&net->netmask_ipv4, ADDR_IPV4);
2260          debug("/%i", net->netmask_ipv4_len);          debug("/%i", net->netmask_ipv4_len);
# Line 2264  void net_dumpinfo(struct net *net) Line 2264  void net_dumpinfo(struct net *net)
2264    
2265          debug_indentation(iadd);          debug_indentation(iadd);
2266    
2267          debug("gateway: ");          debug("simulated gateway: ");
2268          net_debugaddr(&net->gateway_ipv4_addr, ADDR_IPV4);          net_debugaddr(&net->gateway_ipv4_addr, ADDR_IPV4);
2269          debug(" (");          debug(" (");
2270          net_debugaddr(&net->gateway_ethernet_addr, ADDR_ETHERNET);          net_debugaddr(&net->gateway_ethernet_addr, ADDR_ETHERNET);
2271          debug(")\n");          debug(")\n");
2272    
2273          debug_indentation(iadd);          debug_indentation(iadd);
         if (net->domain_name != NULL && net->domain_name[0])  
                 debug("domain \"%s\", ", net->domain_name);  
2274          if (!net->nameserver_known) {          if (!net->nameserver_known) {
2275                  debug("(could not determine nameserver)");                  debug("(could not determine nameserver)");
2276          } else {          } else {
2277                  debug("nameserver ");                  debug("using nameserver ");
2278                  net_debugaddr(&net->nameserver_ipv4, ADDR_IPV4);                  net_debugaddr(&net->nameserver_ipv4, ADDR_IPV4);
2279          }          }
2280            if (net->domain_name != NULL && net->domain_name[0])
2281                    debug(", domain \"%s\"", net->domain_name);
2282          debug("\n");          debug("\n");
2283          debug_indentation(-iadd);          debug_indentation(-iadd);
2284    
2285          rnp = net->remote_nets;          rnp = net->remote_nets;
2286          if (rnp != NULL)          if (net->local_port != 0)
2287                  debug("distributed network: other hosts:\n");                  debug("distributed network: local port = %i\n",
2288                        net->local_port);
2289          debug_indentation(iadd);          debug_indentation(iadd);
2290          while (rnp != NULL) {          while (rnp != NULL) {
2291                  debug("\"%s\": ", rnp->name);                  debug("remote \"%s\": ", rnp->name);
2292                  net_debugaddr(&rnp->ipv4_addr, ADDR_IPV4);                  net_debugaddr(&rnp->ipv4_addr, ADDR_IPV4);
2293                  debug(" port %i\n", rnp->portnr);                  debug(" port %i\n", rnp->portnr);
2294                  rnp = rnp->next;                  rnp = rnp->next;
2295          }          }
2296          debug_indentation(-iadd);          debug_indentation(-iadd);
2297    
         if (net->local_port != 0)  
                 debug("distributed network: local port = %i\n",  
                     net->local_port);  
   
2298          debug_indentation(-iadd);          debug_indentation(-iadd);
2299  }  }
2300    
# Line 2385  struct net *net_init(struct emul *emul, Line 2381  struct net *net_init(struct emul *emul,
2381          if (n_remote != 0) {          if (n_remote != 0) {
2382                  struct remote_net *rnp;                  struct remote_net *rnp;
2383                  while ((n_remote--) != 0) {                  while ((n_remote--) != 0) {
2384                            struct hostent *hp;
2385    
2386                          /*  debug("adding '%s'\n", remote[n_remote]);  */                          /*  debug("adding '%s'\n", remote[n_remote]);  */
2387                          rnp = malloc(sizeof(struct remote_net));                          rnp = malloc(sizeof(struct remote_net));
2388                          memset(rnp, 0, sizeof(struct remote_net));                          memset(rnp, 0, sizeof(struct remote_net));
# Line 2395  struct net *net_init(struct emul *emul, Line 2393  struct net *net_init(struct emul *emul,
2393                          rnp->name = strdup(remote[n_remote]);                          rnp->name = strdup(remote[n_remote]);
2394                          if (strchr(rnp->name, ':') != NULL)                          if (strchr(rnp->name, ':') != NULL)
2395                                  strchr(rnp->name, ':')[0] = '\0';                                  strchr(rnp->name, ':')[0] = '\0';
2396                          /*  TODO: Name resolution?  */  
2397  #ifdef HAVE_INET_PTON                          hp = gethostbyname(rnp->name);
2398                          res = inet_pton(AF_INET, rnp->name, &rnp->ipv4_addr);                          if (hp == NULL) {
2399  #else                                  fprintf(stderr, "could not resolve '%s'\n",
2400                          res = inet_aton(rnp->name, &rnp->ipv4_addr);                                      rnp->name);
2401  #endif                                  exit(1);
2402                            }
2403                            memcpy(&rnp->ipv4_addr, hp->h_addr, hp->h_length);
2404                          free(rnp->name);                          free(rnp->name);
2405    
2406                          /*  And again:  */                          /*  And again:  */
2407                          rnp->name = strdup(remote[n_remote]);                          rnp->name = strdup(remote[n_remote]);
2408                          if (strchr(rnp->name, ':') == NULL) {                          if (strchr(rnp->name, ':') == NULL) {

Legend:
Removed from v.10  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.26