Page MenuHomeFreeBSD

D55344.id172139.diff
No OneTemporary

D55344.id172139.diff

diff --git a/sys/netinet/in.h b/sys/netinet/in.h
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -680,6 +680,7 @@
bool in_localip_fib(struct in_addr, uint16_t);
bool in_ifhasaddr(struct ifnet *, struct in_addr);
struct in_ifaddr *in_findlocal(uint32_t, bool);
+struct in_ifaddr *in_primaryaddr(struct ifnet *);
int inet_aton(const char *, struct in_addr *); /* in libkern */
char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -266,6 +266,29 @@
return (ia);
}
+/*
+ * Return the first configured IPv4 address on the given ifnet.
+ * Replaces deprecated IFP_TO_IA() from 4.3BSD.
+ * Used only by IPv4 multicast, where source-address selection
+ * has not yet been introduced.
+ *
+ * Returns ifa or NULL.
+ */
+struct in_ifaddr *
+in_primaryaddr(struct ifnet *ifp)
+{
+ struct in_ifaddr *ia;
+
+ NET_EPOCH_ASSERT();
+
+ for ((ia) = CK_STAILQ_FIRST(&V_in_ifaddrhead);
+ (ia) != NULL && (ia)->ia_ifp != (ifp);
+ (ia) = CK_STAILQ_NEXT((ia), ia_link))
+ continue;
+
+ return (ia);
+}
+
/*
* Determine whether an IP address is in a reserved set of addresses
* that may not be forwarded, or whether datagrams to that destination
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -153,7 +153,7 @@
/*
* Macro for finding the internet address structure (in_ifaddr) corresponding
- * to a given interface (ifnet structure).
+ * to a given interface (ifnet structure). DEPRECATED.
*/
#define IFP_TO_IA(ifp, ia) \
/* struct ifnet *ifp; */ \

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 8, 10:11 PM (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31118099
Default Alt Text
D55344.id172139.diff (1 KB)

Event Timeline