aboutsummaryrefslogtreecommitdiff
path: root/src/libip/myipaddr.c
blob: d9b692017ef9950cefd58f14c8959044e9625d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}