aboutsummaryrefslogtreecommitdiff
path: root/src/libip/myipaddr.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-11-23 18:23:20 +0000
committerrsc <devnull@localhost>2003-11-23 18:23:20 +0000
commitd7094239263eac816ebb3af32641079b7924c666 (patch)
tree61b016942d567560042adf110f5fb558dc328a98 /src/libip/myipaddr.c
parent99947423b136903263513b9022aab6586c8c6cc5 (diff)
downloadplan9port-d7094239263eac816ebb3af32641079b7924c666.tar.gz
plan9port-d7094239263eac816ebb3af32641079b7924c666.tar.bz2
plan9port-d7094239263eac816ebb3af32641079b7924c666.zip
add libip
Diffstat (limited to 'src/libip/myipaddr.c')
-rw-r--r--src/libip/myipaddr.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libip/myipaddr.c b/src/libip/myipaddr.c
new file mode 100644
index 00000000..d9b69201
--- /dev/null
+++ b/src/libip/myipaddr.c
@@ -0,0 +1,21 @@
+#include <u.h>
+#include <libc.h>
+#include <ip.h>
+
+int
+myipaddr(uchar *ip, char *net)
+{
+ Ipifc *nifc;
+ Iplifc *lifc;
+ static Ipifc *ifc;
+
+ ifc = readipifc(net, ifc, -1);
+ for(nifc = ifc; nifc; nifc = nifc->next)
+ for(lifc = nifc->lifc; lifc; lifc = lifc->next)
+ if(ipcmp(lifc->ip, IPnoaddr) != 0){
+ ipmove(ip, lifc->ip);
+ return 0;
+ }
+ ipmove(ip, IPnoaddr);
+ return -1;
+}