Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/mopd Quick+Dirty port to linux



details:   https://anonhg.NetBSD.org/src/rev/db4d9adabd5b
branches:  trunk
changeset: 345766:db4d9adabd5b
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jun 08 01:11:49 2016 +0000

description:
Quick+Dirty port to linux

diffstat:

 usr.sbin/mopd/common/Makefile.linux |   15 +
 usr.sbin/mopd/common/cmp.c          |    6 +-
 usr.sbin/mopd/common/device.c       |   46 ++--
 usr.sbin/mopd/common/dl.c           |    6 +-
 usr.sbin/mopd/common/file.c         |    6 +-
 usr.sbin/mopd/common/get.c          |    6 +-
 usr.sbin/mopd/common/log.c          |    6 +-
 usr.sbin/mopd/common/loop-bsd.c     |    6 +-
 usr.sbin/mopd/common/loop-linux2.c  |  158 ++++++++++++++++++
 usr.sbin/mopd/common/mopdef.c       |    6 +-
 usr.sbin/mopd/common/nma.c          |    6 +-
 usr.sbin/mopd/common/os.h           |    7 +-
 usr.sbin/mopd/common/pf-linux2.c    |  305 ++++++++++++++++++++++++++++++++++++
 usr.sbin/mopd/common/pf.c           |    6 +-
 usr.sbin/mopd/common/print.c        |    6 +-
 usr.sbin/mopd/common/put.c          |    6 +-
 usr.sbin/mopd/common/rc.c           |    6 +-
 usr.sbin/mopd/common/version.c      |    1 +
 usr.sbin/mopd/mopd/Makefile.linux   |   11 +
 usr.sbin/mopd/mopd/mopd.c           |    9 +-
 usr.sbin/mopd/mopd/process.c        |    6 +-
 21 files changed, 559 insertions(+), 71 deletions(-)

diffs (truncated from 956 to 300 lines):

diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/Makefile.linux
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/mopd/common/Makefile.linux       Wed Jun 08 01:11:49 2016 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile.linux,v 1.1 2016/06/08 01:11:49 christos Exp $
+SRCS+=cmp.c device.c dl.c file.c get.c log.c loop-linux2.c mopdef.c nma.c
+SRCS+=pf-linux2.c print.c put.c rc.c version.c
+OBJS+=${SRCS:.c=.o}
+
+CFLAGS+=-DNOAOUT
+
+libcommon.a: ${OBJS}
+       ar cr $@ ${OBJS}
+
+version.c: VERSION
+       @rm -f $@
+       sed -e 's/.*/char version[] = "&";/' VERSION > $@
+clean:
+       rm -f ${OBJS} libcommon.a version.c
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/cmp.c
--- a/usr.sbin/mopd/common/cmp.c        Tue Jun 07 23:33:45 2016 +0000
+++ b/usr.sbin/mopd/common/cmp.c        Wed Jun 08 01:11:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmp.c,v 1.5 2009/11/17 18:58:07 drochner Exp $ */
+/*     $NetBSD: cmp.c,v 1.6 2016/06/08 01:11:49 christos Exp $ */
 
 /*
  * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
@@ -24,9 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+#include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: cmp.c,v 1.5 2009/11/17 18:58:07 drochner Exp $");
+__RCSID("$NetBSD: cmp.c,v 1.6 2016/06/08 01:11:49 christos Exp $");
 #endif
 
 #include "os.h"
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/device.c
--- a/usr.sbin/mopd/common/device.c     Tue Jun 07 23:33:45 2016 +0000
+++ b/usr.sbin/mopd/common/device.c     Wed Jun 08 01:11:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: device.c,v 1.12 2011/08/30 19:49:10 joerg Exp $        */
+/*     $NetBSD: device.c,v 1.13 2016/06/08 01:11:49 christos Exp $     */
 
 /*
  * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
@@ -24,9 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+#include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: device.c,v 1.12 2011/08/30 19:49:10 joerg Exp $");
+__RCSID("$NetBSD: device.c,v 1.13 2016/06/08 01:11:49 christos Exp $");
 #endif
 
 #include "os.h"
@@ -40,7 +40,6 @@
 
 void   deviceOpen(const char *, u_short, int);
 
-#ifdef DEV_NEW_CONF
 /*
  * Return ethernet address for interface
  */
@@ -48,6 +47,20 @@
 void
 deviceEthAddr(const char *ifname, u_char *eaddr)
 {
+#ifndef AF_LINK
+       int fd;
+       struct ifreq ifr;
+
+       /* Use datagram socket to get Ethernet address. */
+       if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+               mopLogErr("deviceEthAddr: socket");
+
+       strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+       if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1)
+               mopLogErr("deviceEthAddr: SIOGIFHWADDR");
+       memcpy(eaddr, ifr.ifr_hwaddr.sa_data, 6);
+       close(fd);
+#else
        struct sockaddr_dl *sdl;
        struct ifaddrs *ifap, *ifa;
 
@@ -68,8 +81,8 @@
 
        freeifaddrs(ifap);
        mopLogErrX("deviceEthAddr: Never saw interface `%s'!", ifname);
+#endif
 }
-#endif /* DEV_NEW_CONF */
 
 void
 deviceOpen(const char *ifname, u_short proto, int trans)
@@ -93,7 +106,7 @@
        }
        
        if (tmp.fd != -1) {
-               p = (struct if_info *)malloc(sizeof(*p));
+               p = malloc(sizeof(*p));
                if (p == 0)
                        mopLogErr("deviceOpen: malloc");
        
@@ -220,18 +233,19 @@
 void
 deviceInitAll(void)
 {
-#ifdef DEV_NEW_CONF
-       struct sockaddr_dl *sdl;
        struct ifaddrs *ifap, *ifa;
 
        if (getifaddrs(&ifap) != 0)
                mopLogErr("deviceInitAll: socket");
 
        for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
+#ifdef AF_LINK
+               struct sockaddr_dl *sdl;
                sdl = (struct sockaddr_dl *)ifa->ifa_addr;
                if (sdl->sdl_family != AF_LINK || sdl->sdl_type != IFT_ETHER ||
                    sdl->sdl_alen != 6)
                        continue;
+#endif
                if ((ifa->ifa_flags &
                    (IFF_UP | IFF_LOOPBACK | IFF_POINTOPOINT)) != IFF_UP)
                        continue;
@@ -239,20 +253,4 @@
        }
 
        freeifaddrs(ifap);
-#else
-       struct ifaddrs *ifap, *ifa;
-
-       if (getifaddrs(&ifap) != 0)
-               mopLogErr("deviceInitAll: old socket");
-
-       for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
-               if (/*(ifa->ifa_flags & IFF_UP) == 0 ||*/
-                   ifa->ifa_flags & IFF_LOOPBACK ||
-                   ifa->ifa_flags & IFF_POINTOPOINT)
-                       continue;
-               deviceInitOne(ifa->ifa_name);
-       }
-       
-       freeifaddrs(ifap);
-#endif /* DEV_NEW_CONF */
 }
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/dl.c
--- a/usr.sbin/mopd/common/dl.c Tue Jun 07 23:33:45 2016 +0000
+++ b/usr.sbin/mopd/common/dl.c Wed Jun 08 01:11:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dl.c,v 1.8 2011/05/24 13:08:16 joerg Exp $     */
+/*     $NetBSD: dl.c,v 1.9 2016/06/08 01:11:49 christos Exp $  */
 
 /*
  * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
@@ -24,9 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+#include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: dl.c,v 1.8 2011/05/24 13:08:16 joerg Exp $");
+__RCSID("$NetBSD: dl.c,v 1.9 2016/06/08 01:11:49 christos Exp $");
 #endif
 
 #include "os.h"
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/file.c
--- a/usr.sbin/mopd/common/file.c       Tue Jun 07 23:33:45 2016 +0000
+++ b/usr.sbin/mopd/common/file.c       Wed Jun 08 01:11:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: file.c,v 1.15 2011/08/31 13:09:10 nakayama Exp $       */
+/*     $NetBSD: file.c,v 1.16 2016/06/08 01:11:49 christos Exp $       */
 
 /*
  * Copyright (c) 1995-96 Mats O Jansson.  All rights reserved.
@@ -24,9 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+#include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: file.c,v 1.15 2011/08/31 13:09:10 nakayama Exp $");
+__RCSID("$NetBSD: file.c,v 1.16 2016/06/08 01:11:49 christos Exp $");
 #endif
 
 #include "os.h"
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/get.c
--- a/usr.sbin/mopd/common/get.c        Tue Jun 07 23:33:45 2016 +0000
+++ b/usr.sbin/mopd/common/get.c        Wed Jun 08 01:11:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: get.c,v 1.6 2009/11/17 18:58:07 drochner Exp $ */
+/*     $NetBSD: get.c,v 1.7 2016/06/08 01:11:49 christos Exp $ */
 
 /*
  * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
@@ -24,9 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+#include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: get.c,v 1.6 2009/11/17 18:58:07 drochner Exp $");
+__RCSID("$NetBSD: get.c,v 1.7 2016/06/08 01:11:49 christos Exp $");
 #endif
 
 #include "os.h"
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/log.c
--- a/usr.sbin/mopd/common/log.c        Tue Jun 07 23:33:45 2016 +0000
+++ b/usr.sbin/mopd/common/log.c        Wed Jun 08 01:11:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: log.c,v 1.3 2014/07/27 04:38:03 dholland Exp $ */
+/*     $NetBSD: log.c,v 1.4 2016/06/08 01:11:49 christos Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -29,9 +29,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+#include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: log.c,v 1.3 2014/07/27 04:38:03 dholland Exp $");
+__RCSID("$NetBSD: log.c,v 1.4 2016/06/08 01:11:49 christos Exp $");
 #endif
 
 #include <err.h>
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/loop-bsd.c
--- a/usr.sbin/mopd/common/loop-bsd.c   Tue Jun 07 23:33:45 2016 +0000
+++ b/usr.sbin/mopd/common/loop-bsd.c   Wed Jun 08 01:11:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: loop-bsd.c,v 1.11 2011/08/30 19:49:10 joerg Exp $      */
+/*     $NetBSD: loop-bsd.c,v 1.12 2016/06/08 01:11:49 christos Exp $   */
 
 /*
  * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
@@ -24,9 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+#include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: loop-bsd.c,v 1.11 2011/08/30 19:49:10 joerg Exp $");
+__RCSID("$NetBSD: loop-bsd.c,v 1.12 2016/06/08 01:11:49 christos Exp $");
 #endif
 
 #include <errno.h>
diff -r 57260243e341 -r db4d9adabd5b usr.sbin/mopd/common/loop-linux2.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/mopd/common/loop-linux2.c        Wed Jun 08 01:11:49 2016 +0000
@@ -0,0 +1,158 @@
+/*     $NetBSD: loop-linux2.c,v 1.1 2016/06/08 01:11:49 christos Exp $ */
+
+/*
+ * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "port.h"
+#ifndef lint
+__RCSID("$NetBSD: loop-linux2.c,v 1.1 2016/06/08 01:11:49 christos Exp $");
+#endif
+
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>



Home | Main Index | Thread Index | Old Index