openbsd-ports/net/dctc/patches/patch-src_network_c
naddy f67f6898c6 Import dctc 0.68.0; submitted by Nils Nordman <nino@nforced.com>.
DCTC is a Direct Connect clone, allowing users to share their files
and talk (like IRC but more software sharing oriented) using a
proprietary protocol.
2002-01-31 12:21:53 +00:00

25 lines
993 B
Plaintext

$OpenBSD: patch-src_network_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
--- src/network.c.orig Sun Jan 13 17:10:07 2002
+++ src/network.c Sun Jan 13 17:12:42 2002
@@ -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)
{