summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2004-08-11 11:49:48 +0000
committerandre <andre@FreeBSD.org>2004-08-11 11:49:48 +0000
commita93503bce5774a1d50bc8d2659fa612fd093c64a (patch)
tree9c84cf3125bea1ca049825894eb718166b254d27 /sys/netinet/in.c
parent957506e985495914d7245b3e8a1b3b77ef63e200 (diff)
downloadFreeBSD-src-a93503bce5774a1d50bc8d2659fa612fd093c64a.zip
FreeBSD-src-a93503bce5774a1d50bc8d2659fa612fd093c64a.tar.gz
Add the function in_localip() which returns 1 if an internet address is for
the local host and configured on one of its interfaces.
Diffstat (limited to 'sys/netinet/in.c')
-rw-r--r--sys/netinet/in.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 0c43004..ec57015 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -94,6 +94,23 @@ in_localaddr(in)
}
/*
+ * 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
* may be forwarded.
OpenPOWER on IntegriCloud