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.)
This commit is contained in:
Garrett Wollman 1998-01-13 02:56:21 +00:00
parent 01b67e0e07
commit 906f09bca4

View File

@ -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;