Add the function in_localip() which returns 1 if an internet address is for

the local host and configured on one of its interfaces.
This commit is contained in:
Andre Oppermann 2004-08-11 11:49:48 +00:00
parent 6e234ede37
commit 2eccc90b61
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133486
2 changed files with 18 additions and 0 deletions

View File

@ -93,6 +93,23 @@ in_localaddr(in)
return (0);
}
/*
* Return 1 if an internet address is for the local host and configured
* on one of its interfaces.
*/
int
in_localip(in)
struct in_addr in;
{
struct in_ifaddr *ia;
LIST_FOREACH(ia, INADDR_HASH(in.s_addr), ia_hash) {
if (IA_SIN(ia)->sin_addr.s_addr == in.s_addr)
return 1;
}
return 0;
}
/*
* Determine whether an IP address is in a reserved set of addresses
* that may not be forwarded, or whether datagrams to that destination

View File

@ -560,6 +560,7 @@ struct ifnet; struct mbuf; /* forward declarations for Standard C */
int in_broadcast(struct in_addr, struct ifnet *);
int in_canforward(struct in_addr);
int in_localaddr(struct in_addr);
int in_localip(struct in_addr);
char *inet_ntoa(struct in_addr); /* in libkern */
char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */