Page MenuHomeFreeBSD

D55344.diff
No OneTemporary

D55344.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_ifprimaryaddr(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
@@ -206,6 +206,28 @@
return (false);
}
+/*
+ * 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_ifprimaryaddr(struct ifnet *ifp)
+{
+ struct ifaddr *ifa;
+
+ NET_EPOCH_ASSERT();
+
+ CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
+ if (ifa->ifa_addr->sa_family == AF_INET)
+ break;
+
+ return ((struct in_ifaddr *)ifa);
+}
+
/*
* Return a reference to the interface address which is different to
* the supplied one but with same IP address value.
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
Fri, Feb 27, 5:30 PM (10 h, 2 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29037328
Default Alt Text
D55344.diff (1 KB)

Event Timeline