summaryrefslogtreecommitdiffstats
path: root/sys/net/if.h
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1998-01-13 02:56:21 +0000
committerwollman <wollman@FreeBSD.org>1998-01-13 02:56:21 +0000
commit6ce595a40c4ac6011201f812617639a05193a421 (patch)
treeea67aaadfadd55b4bf726b63ca1a95ae0b1a012e /sys/net/if.h
parent3d7686dc1c5e0216bbb43929905217dbdb11dc18 (diff)
downloadFreeBSD-src-6ce595a40c4ac6011201f812617639a05193a421.zip
FreeBSD-src-6ce595a40c4ac6011201f812617639a05193a421.tar.gz
Add a macro to accurately calculate the length of a struct ifreq when
it contains an address. This can replace all the myriad (wrong) ways in which this task is performed in the current system. As an added bonus, since it's a macro, then third-party software vendors have an easy way to tell whether it's there or not. (This will become necessary when sizeof(struct sockaddr) is increaased, and also when additional fields are added to struct ifreq.)
Diffstat (limited to 'sys/net/if.h')
-rw-r--r--sys/net/if.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/net/if.h b/sys/net/if.h
index 0fe9205..0a7a48e 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
- * $Id: if.h,v 1.46 1997/05/03 21:07:12 peter Exp $
+ * $Id: if.h,v 1.47 1997/10/12 20:25:11 phk Exp $
*/
#ifndef _NET_IF_H_
@@ -167,6 +167,11 @@ struct ifreq {
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
};
+#define _SIZEOF_ADDR_IFREQ(ifr) \
+ ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
+ (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
+ (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
+
struct ifaliasreq {
char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
struct sockaddr ifra_addr;
OpenPOWER on IntegriCloud