a9ba552d48
sync w/update-patches
25 lines
991 B
Plaintext
25 lines
991 B
Plaintext
$OpenBSD: patch-src_network_c,v 1.2 2007/12/11 11:04:58 jakemsr Exp $
|
|
--- src/network.c.orig Sat Jan 5 00:47:40 2002
|
|
+++ src/network.c Tue Dec 11 00:04:51 2007
|
|
@@ -231,11 +231,17 @@ GString *get_default_host_ip(void)
|
|
char buf[512];
|
|
|
|
/* the following script does this: */
|
|
- /* 1) extract the interface used by the default route: netstat -rn | grep ^0.0.0.0 | awk '{print $8;} */
|
|
- /* 2) obtain the IP of this interface: netstat xxx | fgrep inet | cut -d : -f 2 | awk '{print $1;}' */
|
|
+ /* 1) extract the interface used by the default route from netstat */
|
|
+ /* 2) obtain the IP of this interface from ifconfig */
|
|
+
|
|
+#ifdef __OpenBSD__
|
|
const char *cmd=
|
|
+ "/sbin/ifconfig `netstat -rn | grep ^default | awk '{print $7;}'` | fgrep 'inet ' | awk '{print $2;}'";
|
|
+#else
|
|
+ const char *cmd=
|
|
"/sbin/ifconfig `netstat -rn | grep ^0.0.0.0 | awk '{print $8;}'` | fgrep inet | cut -d : -f 2 | awk '{print $1;}'";
|
|
-
|
|
+#endif
|
|
+
|
|
f=popen(cmd,"r");
|
|
if(f==NULL)
|
|
{
|