diff --git a/src/slirp/misc.c b/src/slirp/misc.c index 39dc1e6e5..90bc2483e 100644 --- a/src/slirp/misc.c +++ b/src/slirp/misc.c @@ -119,7 +119,7 @@ getouraddr() our_addr.s_addr = loopback_addr.s_addr; #endif #undef ANCIENT - pclog("My IP address: %s (%s)\n", inet_ntoa(our_addr), buff); + pclog(" Our IP address: %s (%s)\n", inet_ntoa(our_addr), buff); } //#if SIZEOF_CHAR_P == 8 diff --git a/src/slirp/slirp.c b/src/slirp/slirp.c index c8861b965..6a9670f12 100644 --- a/src/slirp/slirp.c +++ b/src/slirp/slirp.c @@ -1,23 +1,20 @@ #include "slirp.h" -/* host address */ -struct in_addr our_addr; -/* host dns address */ -struct in_addr dns_addr; -/* host loopback address */ -struct in_addr loopback_addr; -/* address for slirp virtual addresses */ -struct in_addr special_addr; -/* virtual address alias for host */ -struct in_addr alias_addr; +/* Our actual addresses. */ +char slirp_hostname[33]; +struct in_addr our_addr; /* host IP address */ +struct in_addr dns_addr; /* host DNS server */ +struct in_addr loopback_addr; /* host loopback address */ -/* FIXME: this is probably not working with new MAC address stuff.. --FvK */ +/* Our SLiRP virtual addresses. */ +struct in_addr special_addr; /* virtual IP address */ +struct in_addr alias_addr; /* virtual address alias for host */ const uint8_t special_ethaddr[6] = { - 0x52, 0x54, 0x00, 0x12, 0x35, 0x00 + 0x52, 0x54, 0x00, 0x12, 0x35, 0x00 /* virtual MAC address. */ }; -uint8_t client_ethaddr[6]; +uint8_t client_ethaddr[6]; /* guest's MAC address */ int do_slowtimo; int link_up; @@ -28,8 +25,6 @@ struct ex_list *exec_list; /* XXX: suppress those select globals */ fd_set *global_readfds, *global_writefds, *global_xfds; -char slirp_hostname[33]; - extern void pclog(const char *, ...); extern int config_get_int(char *, char *, int); @@ -67,16 +62,11 @@ static int get_dns_addr(struct in_addr *pdns_addr) pIPAddr = &(FixedInfo->DnsServerList); inet_aton(pIPAddr->IpAddress.String, &tmp_addr); *pdns_addr = tmp_addr; -#if 1 - printf( "DNS Servers:\n" ); - printf( "DNS Addr:%s\n", pIPAddr->IpAddress.String ); - - pIPAddr = FixedInfo -> DnsServerList.Next; + printf( " DNS Servers:\n" ); while ( pIPAddr ) { - printf( "DNS Addr:%s\n", pIPAddr ->IpAddress.String ); + printf( " Address: %s\n", pIPAddr ->IpAddress.String ); pIPAddr = pIPAddr ->Next; } -#endif if (FixedInfo) { GlobalFree(FixedInfo); FixedInfo = NULL; @@ -132,13 +122,17 @@ void slirp_cleanup(void) } #endif -int slirp_init(void) + +int +slirp_init(void) { - struct in_addr myaddr; - int rc; - char* category = "SLiRP Port Forwarding"; - char key[32]; - int i = 0, udp, from, to; + char* category = "SLiRP Port Forwarding"; + char key[32]; + struct in_addr myaddr; + int i = 0, udp, from, to; + int rc; + + pclog("%s initializing..\n", category); #ifdef SLIRP_DEBUG // debug_init("/tmp/slirp.log", DEBUG_DEFAULT); @@ -170,29 +164,28 @@ debug_init("slirplog.txt",DEBUG_DEFAULT); return -1; inet_aton(CTL_SPECIAL, &special_addr); - alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS); - getouraddr(); + alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS); + getouraddr(); + inet_aton(CTL_LOCAL, &myaddr); - inet_aton("10.0.2.15",&myaddr); + while (1) { + sprintf(key, "%d_udp", i); + udp = config_get_int(category, key, 0); + sprintf(key, "%d_from", i); + from = config_get_int(category, key, 0); + if (from < 1) + break; + sprintf(key, "%d_to", i); + to = config_get_int(category, key, from); - while (1) { - sprintf(key, "%d_udp", i); - udp = config_get_int(category, key, 0); - sprintf(key, "%d_from", i); - from = config_get_int(category, key, 0); - if (from < 1) - break; - sprintf(key, "%d_to", i); - to = config_get_int(category, key, from); + rc = slirp_redir(udp, from, myaddr, to); + if (rc == 0) + pclog("slirp redir %d -> %d successful\n", from, to); + else + pclog("slirp redir %d -> %d failed (%d)\n", from, to, rc); - rc = slirp_redir(udp, from, myaddr, to); - if (rc == 0) - pclog("slirp redir %d -> %d successful\n", from, to); - else - pclog("slirp redir %d -> %d failed (%d)\n", from, to, rc); - - i++; - } + i++; + } return 0; } @@ -648,7 +641,6 @@ void slirp_input(const uint8_t *pkt, int pkt_len) struct SLIRPmbuf *m; int proto; -pclog("SLIRP_input(%08lx, %d)\n", pkt, pkt_len); if (pkt_len < ETH_HLEN) return; diff --git a/src/slirp/slirp.h b/src/slirp/slirp.h index 7ca179335..3f4efd0bd 100644 --- a/src/slirp/slirp.h +++ b/src/slirp/slirp.h @@ -1,8 +1,6 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#define SLIRP_DEBUG 1 - #define SLIRP_VERSION "Cockatrice special" #define CONFIG_QEMU diff --git a/src/timer.h b/src/timer.h index b2e7fec93..bdc77493b 100644 --- a/src/timer.h +++ b/src/timer.h @@ -39,11 +39,11 @@ extern int timer_start; timer_update_outstanding(); \ } while (0) -void timer_process(); -void timer_update_outstanding(); -void timer_reset(); -int timer_add(void (*callback)(void *priv), int *count, int *enable, void *priv); -void timer_set_callback(int timer, void (*callback)(void *priv)); +extern void timer_process(void); +extern void timer_update_outstanding(void); +extern void timer_reset(void); +extern int timer_add(void (*callback)(void *priv), int *count, int *enable, void *priv); +extern void timer_set_callback(int timer, void (*callback)(void *priv)); #define TIMER_ALWAYS_ENABLED &timer_one