add libip
This commit is contained in:
parent
99947423b1
commit
d709423926
13 changed files with 875 additions and 0 deletions
21
src/libip/myipaddr.c
Normal file
21
src/libip/myipaddr.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue