Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jun 1995 15:32:53 -0600
From:      Warner Losh <imp@village.org>
To:        hackers@freebsd.org
Subject:   Bug in header files on 2.0R
Message-ID:  <199506302132.PAA23787@rover.village.org>

next in thread | raw e-mail | index | archive | help
The file net/in.h is not compatible with C++. Specifically, it does
things like:

stuct ifnet {
	...
	sturct if_data {
	...
	} if_data;
	...
};

/* So far so good */

struct if_msghdr {
	...
	struct if_data ifm_data; /* [1] */
};

Note that at [1] there is no if_data in scope under C++.  There is a
ifnet::if_data, but no plain if_data.  Class and struct declrations
nest in C++, but don't in C.  Grrr.

This problem doesn't exist in BSDi 1.1.  A quick check of my BSD 4.4
Lite CD shows that it has the problem, however :-(.  Sounds like a
generic problem in BSD 4.4.

The fix is simple and obvious, so I've included a patch below.  I've
not checked this against 2.0.5R, as I don't have a system handy to
check it on.

I've posted here in the hopes that other places where this sort of
thing happens can be eliminated over time.  For the moment I'm just
using the patch.

Warner

*** if.h.dist	Fri Jun 30 15:21:57 1995
--- if.h	Fri Jun 30 15:24:09 1995
***************
*** 78,83 ****
--- 78,107 ----
  struct	socket;
  struct	ether_header;
  #endif
+ 
+ struct	if_data {
+ /* generic interface information */
+ 	u_char	ifi_type;	/* ethernet, tokenring, etc */
+ 	u_char	ifi_addrlen;	/* media address length */
+ 	u_char	ifi_hdrlen;	/* media header length */
+ 	u_long	ifi_mtu;	/* maximum transmission unit */
+ 	u_long	ifi_metric;	/* routing metric (external only) */
+ 	u_long	ifi_baudrate;	/* linespeed */
+ /* volatile statistics */
+ 	u_long	ifi_ipackets;	/* packets received on interface */
+ 	u_long	ifi_ierrors;	/* input errors on interface */
+ 	u_long	ifi_opackets;	/* packets sent on interface */
+ 	u_long	ifi_oerrors;	/* output errors on interface */
+ 	u_long	ifi_collisions;	/* collisions on csma interfaces */
+ 	u_long	ifi_ibytes;	/* total number of octets received */
+ 	u_long	ifi_obytes;	/* total number of octets sent */
+ 	u_long	ifi_imcasts;	/* packets received via multicast */
+ 	u_long	ifi_omcasts;	/* packets sent via multicast */
+ 	u_long	ifi_iqdrops;	/* dropped on input, this interface */
+ 	u_long	ifi_noproto;	/* destined for unsupported protocol */
+ 	struct	timeval ifi_lastchange;/* last updated */
+ };
+ 
  /*
   * Structure describing information about an interface
   * which may be of interest to management entities.
***************
*** 98,125 ****
  	short	if_unit;		/* sub-unit for lower level driver */
  	short	if_timer;		/* time 'til if_watchdog called */
  	short	if_flags;		/* up/down, broadcast, etc. */
! 	struct	if_data {
! /* generic interface information */
! 		u_char	ifi_type;	/* ethernet, tokenring, etc */
! 		u_char	ifi_addrlen;	/* media address length */
! 		u_char	ifi_hdrlen;	/* media header length */
! 		u_long	ifi_mtu;	/* maximum transmission unit */
! 		u_long	ifi_metric;	/* routing metric (external only) */
! 		u_long	ifi_baudrate;	/* linespeed */
! /* volatile statistics */
! 		u_long	ifi_ipackets;	/* packets received on interface */
! 		u_long	ifi_ierrors;	/* input errors on interface */
! 		u_long	ifi_opackets;	/* packets sent on interface */
! 		u_long	ifi_oerrors;	/* output errors on interface */
! 		u_long	ifi_collisions;	/* collisions on csma interfaces */
! 		u_long	ifi_ibytes;	/* total number of octets received */
! 		u_long	ifi_obytes;	/* total number of octets sent */
! 		u_long	ifi_imcasts;	/* packets received via multicast */
! 		u_long	ifi_omcasts;	/* packets sent via multicast */
! 		u_long	ifi_iqdrops;	/* dropped on input, this interface */
! 		u_long	ifi_noproto;	/* destined for unsupported protocol */
! 		struct	timeval ifi_lastchange;/* last updated */
! 	}	if_data;
  /* procedure handles */
  	void	(*if_init)		/* init routine */
  		__P((int));
--- 122,128 ----
  	short	if_unit;		/* sub-unit for lower level driver */
  	short	if_timer;		/* time 'til if_watchdog called */
  	short	if_flags;		/* up/down, broadcast, etc. */
! 	struct	if_data if_data;	/* Interface data */
  /* procedure handles */
  	void	(*if_init)		/* init routine */
  		__P((int));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199506302132.PAA23787>