aboutsummaryrefslogtreecommitdiff
path: root/emulators/qemu-devel/files/patch-slirp-nat
blob: 9c1accaeaf839d624e1b1d2de77907cfce328218 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# http://lists.gnu.org/archive/html/qemu-devel/2005-12/msg00277.html

diff -wurb qemu/slirp/misc.c qemu-patched/slirp/misc.c
--- qemu/slirp/misc.c	Sun Dec 12 12:45:10 2004
+++ qemu-patched/slirp/misc.c	Mon Mar 21 13:22:05 2005
@@ -90,13 +90,12 @@
 	char buff[256];
 	struct hostent *he;
 	
-	if (gethostname(buff,256) < 0)
-	   return;
-	
-	if ((he = gethostbyname(buff)) == NULL)
-	   return;
-	
+	if (gethostname(buff,256) == 0)
+		if ((he = gethostbyname(buff)) != NULL)
 	our_addr = *(struct in_addr *)he->h_addr;
+
+	if (our_addr.s_addr == 0 || our_addr.s_addr == loopback_addr.s_addr)
+		our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
 }
 
 #if SIZEOF_CHAR_P == 8
diff -wurb qemu/slirp/slirp.c qemu-patched/slirp/slirp.c
--- qemu/slirp/slirp.c	Fri Oct  8 01:27:35 2004
+++ qemu-patched/slirp/slirp.c	Mon Mar 21 13:22:05 2005
@@ -144,7 +144,6 @@
     m_init();
 
     /* set default addresses */
-    getouraddr();
     inet_aton("127.0.0.1", &loopback_addr);
 
     if (get_dns_addr(&dns_addr) < 0) {
@@ -153,6 +152,7 @@
     }
 
     inet_aton(CTL_SPECIAL, &special_addr);
+    getouraddr();
 }
 
 #define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
diff -wurb qemu/slirp/udp.c qemu-patched/slirp/udp.c
--- qemu/slirp/udp.c	Fri Oct  8 01:27:35 2004
+++ qemu-patched/slirp/udp.c	Mon Mar 21 13:22:05 2005
@@ -314,6 +314,8 @@
     saddr = *addr;
     if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr)
         saddr.sin_addr.s_addr = so->so_faddr.s_addr;
+    if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff))
+        saddr.sin_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
     daddr.sin_addr = so->so_laddr;
     daddr.sin_port = so->so_lport;