tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pppoectl(8) with COMPAT_NETBSD32



Hi List

Attached is a patch which should make pppoectl work with COMPAT_NETBSD32 to make my erlite happy, but it's failing with the PPPOESETPARMS ioctl. Infact, it doesn't even make it into the kernel as the call bails out with a Inappropriate ioctl for device error, but I don't easily see what's wrong!

Anyone have a better clue than me?

Thanks

Roy
? sys/compat/netbsd32/.netbsd32_ioctl.c.swo
? sys/compat/netbsd32/.netbsd32_ioctl.c.swp
Index: sys/compat/netbsd32/netbsd32_ioctl.c
===================================================================
RCS file: /cvsroot/src/sys/compat/netbsd32/netbsd32_ioctl.c,v
retrieving revision 1.75
diff -u -r1.75 netbsd32_ioctl.c
--- sys/compat/netbsd32/netbsd32_ioctl.c	31 May 2015 15:08:14 -0000	1.75
+++ sys/compat/netbsd32/netbsd32_ioctl.c	31 May 2015 15:14:26 -0000
@@ -65,6 +65,9 @@
 #include <net/if.h>
 #include <net/route.h>
 
+#include <net/if_pppoe.h>
+#include <net/if_sppp.h>
+
 #include <net/bpf.h>
 #include <netinet/in.h>
 #include <netinet/in_var.h>
@@ -160,6 +163,44 @@
 }
 
 static inline void
+netbsd32_to_pppoediscparms(struct netbsd32_pppoediscparms *s32p,
+    struct pppoediscparms *p, u_long cmd)
+{
+
+	memset(p, 0, sizeof *p);
+	memcpy(p->ifname, s32p->ifname, sizeof p->ifname);
+	memcpy(p->eth_ifname, s32p->eth_ifname, sizeof p->eth_ifname);
+	if (s32p->ac_name_len != 0) {
+		p->ac_name = (char *)NETBSD32PTR64(s32p->ac_name);
+		p->ac_name_len = s32p->ac_name_len;
+	}
+	if (s32p->service_name_len != 0) {
+		p->service_name = (char *)NETBSD32PTR64(s32p->service_name);
+		p->service_name_len = s32p->service_name_len;
+	}
+}
+
+static inline void
+netbsd32_to_spppauthcfg(struct netbsd32_spppauthcfg *s32p,
+    struct spppauthcfg *p, u_long cmd)
+{
+
+	memcpy(p->ifname, s32p->ifname, sizeof p->ifname);
+	p->hisauth = s32p->hisauth;
+	p->myauth = s32p->myauth;
+	p->myname_length = s32p->myname_length;
+	p->mysecret_length = s32p->mysecret_length;
+	p->hisname_length = s32p->hisname_length;
+	p->hissecret_length = s32p->hissecret_length;
+	p->myauthflags = s32p->myauthflags;
+	p->hisauthflags = s32p->hisauthflags;
+	p->myname = (char *)NETBSD32PTR64(s32p->myname);
+	p->mysecret = (char *)NETBSD32PTR64(s32p->mysecret);
+	p->hisname = (char *)NETBSD32PTR64(s32p->hisname);
+	p->hissecret = (char *)NETBSD32PTR64(s32p->hissecret);
+}
+
+static inline void
 netbsd32_to_ifdrv(struct netbsd32_ifdrv *s32p, struct ifdrv *p, u_long cmd)
 {
 
@@ -502,6 +543,44 @@
 }
 
 static inline void
+netbsd32_from_pppoediscparms(struct pppoediscparms *p,
+    struct netbsd32_pppoediscparms *s32p, u_long cmd)
+{
+
+	memset(s32p, 0, sizeof *s32p);
+	memcpy(s32p->ifname, p->ifname, sizeof s32p->ifname);
+	memcpy(s32p->eth_ifname, p->eth_ifname, sizeof s32p->eth_ifname);
+	if (p->ac_name_len != 0) {
+		NETBSD32PTR32(s32p->ac_name, p->ac_name);
+		s32p->ac_name_len = p->ac_name_len;
+	}
+	if (p->service_name_len != 0) {
+		NETBSD32PTR32(s32p->service_name, p->service_name);
+		s32p->service_name_len = p->service_name_len;
+	}
+}
+
+static inline void
+netbsd32_from_spppauthcfg(struct spppauthcfg *p,
+    struct netbsd32_spppauthcfg *s32p, u_long cmd)
+{
+
+	memcpy(s32p->ifname, p->ifname, sizeof s32p->ifname);
+	s32p->hisauth = p->hisauth;
+	s32p->myauth = p->myauth;
+	s32p->myname_length = p->myname_length;
+	s32p->mysecret_length = p->mysecret_length;
+	s32p->hisname_length = p->hisname_length;
+	s32p->hissecret_length = p->hissecret_length;
+	s32p->myauthflags = p->myauthflags;
+	s32p->hisauthflags = p->hisauthflags;
+	NETBSD32PTR32(s32p->myname, p->myname);
+	NETBSD32PTR32(s32p->mysecret, p->mysecret);
+	NETBSD32PTR32(s32p->hisname, p->hisname);
+	NETBSD32PTR32(s32p->hissecret, p->hissecret);
+}
+
+static inline void
 netbsd32_from_ifdrv(struct ifdrv *p, struct netbsd32_ifdrv *s32p, u_long cmd)
 {
 
@@ -1040,6 +1119,15 @@
 	case SIOCGIFMEDIA32:
 		IOCTL_STRUCT_CONV_TO(SIOCGIFMEDIA, ifmediareq);
 
+	case PPPOESETPARMS32:
+		IOCTL_STRUCT_CONV_TO(PPPOESETPARMS, pppoediscparms);
+	case PPPOEGETPARMS32:
+		IOCTL_STRUCT_CONV_TO(PPPOEGETPARMS, pppoediscparms);
+	case SPPPGETAUTHCFG32:
+		IOCTL_STRUCT_CONV_TO(SPPPGETAUTHCFG, spppauthcfg);
+	case SPPPSETAUTHCFG32:
+		IOCTL_STRUCT_CONV_TO(SPPPSETAUTHCFG, spppauthcfg);
+
 	case SIOCSDRVSPEC32:
 		IOCTL_STRUCT_CONV_TO(SIOCSDRVSPEC, ifdrv);
 	case SIOCGDRVSPEC32:
Index: sys/compat/netbsd32/netbsd32_ioctl.h
===================================================================
RCS file: /cvsroot/src/sys/compat/netbsd32/netbsd32_ioctl.h,v
retrieving revision 1.49
diff -u -r1.49 netbsd32_ioctl.h
--- sys/compat/netbsd32/netbsd32_ioctl.h	27 May 2015 21:42:43 -0000	1.49
+++ sys/compat/netbsd32/netbsd32_ioctl.h	31 May 2015 15:14:26 -0000
@@ -426,6 +426,37 @@
 /* from <sys/sockio.h> */
 #define	SIOCGIFMEDIA32	_IOWR('i', 54, struct netbsd32_ifmediareq) /* get net media */
 
+/* from net/if_pppoe.h */
+struct netbsd32_pppoediscparms {
+	char	ifname[IFNAMSIZ];	/* pppoe interface name */
+	char	eth_ifname[IFNAMSIZ];	/* external ethernet interface name */
+	netbsd32_charp ac_name;		/* access concentrator name (or NULL) */
+	size_t	ac_name_len;		/* on write: length of buffer for ac_name */
+	netbsd32_charp service_name;	/* service name (or NULL) */
+	size_t	service_name_len;	/* on write: length of buffer for service name */
+};
+#define	PPPOESETPARMS32	_IOW('i', 110, struct netbsd32_pppoediscparms)
+#define	PPPOEGETPARMS32	_IOWR('i', 111, struct netbsd32_pppoediscparms)
+
+/* from net/if_sppp.h */
+struct netbsd32_spppauthcfg {
+	char	ifname[IFNAMSIZ];	/* pppoe interface name */
+	u_int	hisauth;		/* one of SPPP_AUTHPROTO_* above */
+	u_int	myauth;			/* one of SPPP_AUTHPROTO_* above */
+	u_int	myname_length;		/* includes terminating 0 */
+	u_int	mysecret_length;	/* includes terminating 0 */
+	u_int	hisname_length;		/* includes terminating 0 */
+	u_int	hissecret_length;	/* includes terminating 0 */
+	u_int	myauthflags;
+	u_int	hisauthflags;
+	netbsd32_charp	myname;
+	netbsd32_charp	mysecret;
+	netbsd32_charp	hisname;
+	netbsd32_charp	hissecret;
+};
+#define SPPPGETAUTHCFG32 _IOWR('i', 120, struct netbsd32_spppauthcfg)
+#define SPPPSETAUTHCFG32 _IOW('i', 121, struct netbsd32_spppauthcfg)
+
 /* from <net/if.h> */
 struct  netbsd32_ifdrv {
 	char		ifd_name[IFNAMSIZ];	/* if name, e.g. "en0" */


Home | Main Index | Thread Index | Old Index