[rtems commit] network: Move RTEMS specifics

Sebastian Huber sebh at rtems.org
Wed Jun 7 13:28:13 UTC 2017


Module:    rtems
Branch:    master
Commit:    d4ab0aef967e8d9fc0891d4232284ccefbc05fc6
Changeset: http://git.rtems.org/rtems/commit/?id=d4ab0aef967e8d9fc0891d4232284ccefbc05fc6

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun  6 11:14:21 2017 +0200

network: Move RTEMS specifics

Move RTEMS specifics to <rtems/rtems_bsdnet.h>.

Introduce rtems_tap_ifreq.  The interface tap support is RTEMS-specific
and only available in the legacy network stack.

Update #2833.

---

 cpukit/libcsupport/include/sys/sockio.h   | 11 -----------
 cpukit/libnetworking/net/if.c             |  9 +++++++--
 cpukit/libnetworking/net/if.h             |  2 --
 cpukit/libnetworking/rtems/rtems_bsdnet.h | 28 +++++++++++++++++++++++++---
 4 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/cpukit/libcsupport/include/sys/sockio.h b/cpukit/libcsupport/include/sys/sockio.h
index 839be8d..695fc14 100644
--- a/cpukit/libcsupport/include/sys/sockio.h
+++ b/cpukit/libcsupport/include/sys/sockio.h
@@ -50,19 +50,14 @@
 #define	SIOCGETSGCNT	_IOWR('r', 16, struct sioc_sg_req) /* get s,g pkt cnt */
 
 #define	SIOCSIFADDR	 _IOW('i', 12, struct ifreq)	/* set ifnet address */
-#define	OSIOCGIFADDR	_IOWR('i', 13, struct ifreq)	/* get ifnet address */
 #define	SIOCGIFADDR	_IOWR('i', 33, struct ifreq)	/* get ifnet address */
 #define	SIOCSIFDSTADDR	 _IOW('i', 14, struct ifreq)	/* set p-p address */
-#define	OSIOCGIFDSTADDR	_IOWR('i', 15, struct ifreq)	/* get p-p address */
 #define	SIOCGIFDSTADDR	_IOWR('i', 34, struct ifreq)	/* get p-p address */
 #define	SIOCSIFFLAGS	 _IOW('i', 16, struct ifreq)	/* set ifnet flags */
 #define	SIOCGIFFLAGS	_IOWR('i', 17, struct ifreq)	/* get ifnet flags */
-#define	OSIOCGIFBRDADDR	_IOWR('i', 18, struct ifreq)	/* get broadcast addr */
 #define	SIOCGIFBRDADDR	_IOWR('i', 35, struct ifreq)	/* get broadcast addr */
 #define	SIOCSIFBRDADDR	 _IOW('i', 19, struct ifreq)	/* set broadcast addr */
-#define	OSIOCGIFCONF	_IOWR('i', 20, struct ifconf)	/* get ifnet list */
 #define	SIOCGIFCONF	_IOWR('i', 36, struct ifconf)	/* get ifnet list */
-#define	OSIOCGIFNETMASK	_IOWR('i', 21, struct ifreq)	/* get net addr mask */
 #define	SIOCGIFNETMASK	_IOWR('i', 37, struct ifreq)	/* get net addr mask */
 #define	SIOCSIFNETMASK	 _IOW('i', 22, struct ifreq)	/* set net addr mask */
 #define	SIOCGIFMETRIC	_IOWR('i', 23, struct ifreq)	/* get IF metric */
@@ -108,12 +103,6 @@
 #define	SIOCGPRIVATE_0	_IOWR('i', 80, struct ifreq)	/* device private 0 */
 #define	SIOCGPRIVATE_1	_IOWR('i', 81, struct ifreq)	/* device private 1 */
 
-/*
- * RTEMS additions for setting/getting `tap' function on incoming packets.
- */
-#define	SIOCSIFTAP	_IOW('i', 88, struct ifreq)	/* set tap function */
-#define	SIOCGIFTAP	_IOW('i', 89, struct ifreq)	/* get tap function */
-
 #define	SIOCSIFVNET	_IOWR('i', 90, struct ifreq)	/* move IF jail/vnet */
 #define	SIOCSIFRVNET	_IOWR('i', 91, struct ifreq)	/* reclaim vnet IF */
 
diff --git a/cpukit/libnetworking/net/if.c b/cpukit/libnetworking/net/if.c
index 740bb90..b6c73cd 100644
--- a/cpukit/libnetworking/net/if.c
+++ b/cpukit/libnetworking/net/if.c
@@ -54,6 +54,9 @@
 #include <net/if_types.h>
 #include <net/if_var.h>
 #include <net/radix.h>
+#ifdef __rtems__
+#include <rtems/rtems_bsdnet.h>
+#endif /* __rtems__ */
 
 /*
  * System initialization
@@ -478,6 +481,7 @@ ifunit(char *name)
 int
 ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
 {
+	struct rtems_tap_ifreq *tr;
 	struct ifnet *ifp;
 	struct ifreq *ifr;
 	int error;
@@ -488,6 +492,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
 	case OSIOCGIFCONF:
 		return (ifconf(cmd, data));
 	}
+	tr = (struct rtems_tap_ifreq *)data;
 	ifr = (struct ifreq *)data;
 	ifp = ifunit(ifr->ifr_name);
 	if (ifp == 0)
@@ -660,11 +665,11 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
 	 * RTEMS additions for setting/getting `tap' function
 	 */
 	case SIOCSIFTAP:
-		ifp->if_tap = ifr->ifr_tap;
+		ifp->if_tap = tr->ifr_tap;
 		return 0;
 
 	case SIOCGIFTAP:
-		ifr->ifr_tap = ifp->if_tap;
+		tr->ifr_tap = ifp->if_tap;
 		return 0;
 	}
 	return (0);
diff --git a/cpukit/libnetworking/net/if.h b/cpukit/libnetworking/net/if.h
index cfa140b..3bedab4 100644
--- a/cpukit/libnetworking/net/if.h
+++ b/cpukit/libnetworking/net/if.h
@@ -214,7 +214,6 @@ struct	ifreq {
 		int	ifru_phys;
 		int	ifru_media;
 		caddr_t	ifru_data;
-		int	(*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
 	} ifr_ifru;
 #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
 #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
@@ -226,7 +225,6 @@ struct	ifreq {
 #define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
 #define ifr_media	ifr_ifru.ifru_media	/* physical media */
 #define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
-#define ifr_tap		ifr_ifru.ifru_tap	/* tap function */
 };
 
 struct ifaliasreq {
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet.h b/cpukit/libnetworking/rtems/rtems_bsdnet.h
index 80886ec..a97c058 100644
--- a/cpukit/libnetworking/rtems/rtems_bsdnet.h
+++ b/cpukit/libnetworking/rtems/rtems_bsdnet.h
@@ -6,13 +6,16 @@
 #ifndef _RTEMS_BSDNET_H
 #define _RTEMS_BSDNET_H
 
+#include <rtems.h>
+#include <sys/cpuset.h>
+#include <sys/ioccom.h>
+#include <sys/socket.h>
+#include <net/if.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <rtems.h>
-#include <sys/cpuset.h>
-
 /*
  *  If this file is included from inside the Network Stack proper or
  *  a device driver, then __INSIDE_RTEMS_BSD_TCPIP_STACK__ should be
@@ -325,6 +328,25 @@ void* rtems_bsdnet_malloc_mbuf(size_t size, int type);
 #define SO_SNDWAKEUP	0x1020		/* wakeup when ready to send */
 #define SO_RCVWAKEUP	0x1021		/* wakeup when ready to receive */
 
+/*
+ * RTEMS additions for setting/getting `tap' function on incoming packets.
+ */
+struct ifnet;
+struct ether_header;
+struct mbuf;
+struct	rtems_tap_ifreq {
+	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
+	int	(*ifr_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
+};
+#define        SIOCSIFTAP      _IOW('i', 88, struct rtems_tap_ifreq)     /* set tap function */
+#define        SIOCGIFTAP      _IOW('i', 89, struct rtems_tap_ifreq)     /* get tap function */
+
+#define	OSIOCGIFADDR	_IOWR('i', 13, struct ifreq)	/* get ifnet address */
+#define	OSIOCGIFDSTADDR	_IOWR('i', 15, struct ifreq)	/* get p-p address */
+#define	OSIOCGIFBRDADDR	_IOWR('i', 18, struct ifreq)	/* get broadcast addr */
+#define	OSIOCGIFCONF	_IOWR('i', 20, struct ifconf)	/* get ifnet list */
+#define	OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq)	/* get net addr mask */
+
 struct socket;
 
 struct	sockwakeup {



More information about the vc mailing list