/[gxemul]/upstream/0.4.2/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 /upstream/0.4.2/src/net.c

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

revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2004-2006  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: net.c,v 1.84 2005/11/25 03:38:00 debug Exp $   *  $Id: net.c,v 1.89 2006/02/09 22:40:26 debug Exp $
29   *   *
30   *  Emulated (ethernet / internet) network support.   *  Emulated (ethernet / internet) network support.
31   *   *
# Line 157  void net_generate_unique_mac(struct mach Line 157  void net_generate_unique_mac(struct mach
157          x = machine->serial_nr;          x = machine->serial_nr;
158          y = machine->nr_of_nics;          y = machine->nr_of_nics;
159    
         /*  
          *  TODO: What is a good starting value? Something like this?  
          *  
          *  +-----------+-------------------+-------------+-------------+  
          *  |  16 bits  |  16 bits machine  |  12 bits    |  4 bits of  |  
          *  |  fixed    |  serial nr        |  NIC nr(*)  |  zeroes     |  
          *  +-----------+-------------------+-------------+-------------+  
          */  
160          macbuf[0] = 0x10;          macbuf[0] = 0x10;
161          macbuf[1] = 0x20;          macbuf[1] = 0x20;
162          macbuf[2] = 0x30;          macbuf[2] = 0x30;
163          macbuf[3] = 0;          macbuf[3] = 0;
164          macbuf[4] = 0;          macbuf[4] = 0;
165          macbuf[5] = machine->serial_nr << 4;          /*  NOTE/TODO: This only allows 8 nics per machine!  */
166            macbuf[5] = (machine->serial_nr << 4) + (machine->nr_of_nics << 1);
167    
168          if (macbuf[0] & 1 || macbuf[5] & 1) {          if (macbuf[0] & 1 || macbuf[5] & 1) {
169                  fatal("Internal error in net_generate_unique_mac().\n");                  fatal("Internal error in net_generate_unique_mac().\n");
# Line 1961  void send_udp(struct in_addr *addrp, int Line 1954  void send_udp(struct in_addr *addrp, int
1954          si.sin_port = htons(portnr);          si.sin_port = htons(portnr);
1955    
1956          if (sendto(s, packet, len, 0, (struct sockaddr *)&si,          if (sendto(s, packet, len, 0, (struct sockaddr *)&si,
1957              sizeof(si)) != len) {              sizeof(si)) != (ssize_t)len) {
1958                  perror("send_udp(): sendto");                  perror("send_udp(): sendto");
1959          }          }
1960    
# Line 2258  static void net_gateway_init(struct net Line 2251  static void net_gateway_init(struct net
2251   */   */
2252  void net_dumpinfo(struct net *net)  void net_dumpinfo(struct net *net)
2253  {  {
2254          int iadd = 4;          int iadd = DEBUG_INDENTATION;
2255          struct remote_net *rnp;          struct remote_net *rnp;
2256    
2257          debug("net: simulating ");          debug("net: simulating ");
# Line 2426  struct net *net_init(struct emul *emul, Line 2419  struct net *net_init(struct emul *emul,
2419    
2420          net_dumpinfo(net);          net_dumpinfo(net);
2421    
2422          /*  This is neccessary when using the real network:  */          /*  This is necessary when using the real network:  */
2423          signal(SIGPIPE, SIG_IGN);          signal(SIGPIPE, SIG_IGN);
2424    
2425          return net;          return net;

Legend:
Removed from v.20  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26