[Olsr-dev] Some fixes for NetBSD [was: Re: [Berlin-wireless] IPv6, wer macht mit?]

Hannes Gredler (spam-protected)
Tue Apr 15 23:01:36 CEST 2008


hi pierre,

one minor nit. - how do you ensure that PREFIX is only set for netbsd ?

/hannes

In-Reply-To: <(spam-protected)>

On Wed, Apr 02, 2008 at 11:46:08PM +0200, Pierre Pronchery wrote:
| Pierre Pronchery wrote:
| > [please CC me as I'm not following this list]
| 
| [this is still valid]
| 
| > Hannes Gredler wrote:
| >> as far as i am concerned, yes there is interest.
| >> pls send your patch to the olsrd developer mailing list (cc:).
| > 
| > It's not finished but here it is, better now than forgetting it.
| 
| I just fixed the wireless interface detection.
| The full patch is attached.
| 
| HTH
| 
| >> Pierre Pronchery wrote:
| >>> BTW, if anyone is interested, I have a patch to make olsrd work on
| >>> NetBSD. I'll review and post it where adequate some time soon.
| > 
| > The patch includes:
| > - cosmetics with the base Makefile;
| > - always compile with libnet/SPOOF on NetBSD (probably not cool for
| > library dependency/path/etc, but I don't remember what was wrong
| > otherwise), btw __NetBSD__ is already defined by the compiler;
| > - src/bsd/net.c: size_t should always be available (otherwise #ifndef
| > size_t would be maybe more appropriate);
| > - src/bsd/net.c: a check for correct interface name is always failing
| > and blocks further processing, I disabled it but I can't tell if it has
| > undesired side-effects yet;
| > - src/bsd/net.c: added code to check if an interface is wireless on
| > NetBSD, however it doesn't work yet;
| > - two typos.
| > 
| > This is against 0.5.5 and still a bit rough, I hope it helps nonetheless.
| 
| -- 
| khorben

| diff -Naur olsrd-a5b9cf969979/Makefile.inc olsrd-a5b9cf969979.netbsd/Makefile.inc
| --- olsrd-a5b9cf969979/Makefile.inc	2008-02-06 19:32:49.000000000 +0100
| +++ olsrd-a5b9cf969979.netbsd/Makefile.inc	2008-02-08 19:50:38.000000000 +0100
| @@ -40,12 +40,13 @@
|  TAGCMD ?=	etags
|  
|  # target directories and names
| +PREFIX	?= /usr/local
|  DESTDIR ?=
| -SBINDIR ?= $(DESTDIR)/usr/sbin
| -ETCDIR  ?= $(DESTDIR)/etc
| -LIBDIR  ?= $(DESTDIR)/usr/lib
| -DOCDIR  ?= $(DESTDIR)/usr/share/doc
| -MANDIR  ?= $(DESTDIR)/usr/share/man
| +SBINDIR ?= $(DESTDIR)/$(PREFIX)/sbin
| +ETCDIR  ?= $(DESTDIR)/$(PREFIX)/etc
| +LIBDIR  ?= $(DESTDIR)/$(PREFIX)/lib
| +DOCDIR  ?= $(DESTDIR)/$(PREFIX)/share/doc
| +MANDIR  ?= $(DESTDIR)/$(PREFIX)/share/man
|  EXENAME ?= olsrd
|  CFGNAME ?= $(EXENAME).conf
|  CFGFILE ?= $(ETCDIR)/$(CFGNAME)
| diff -Naur olsrd-a5b9cf969979/make/Makefile.nbsd olsrd-a5b9cf969979.netbsd/make/Makefile.nbsd
| --- olsrd-a5b9cf969979/make/Makefile.nbsd	2008-02-06 19:32:49.000000000 +0100
| +++ olsrd-a5b9cf969979.netbsd/make/Makefile.nbsd	2008-02-10 02:51:20.000000000 +0100
| @@ -8,8 +8,8 @@
|  SRCS +=		$(wildcard src/bsd/*.c src/unix/*.c)
|  HDRS +=		$(wildcard src/bsd/*.h src/unix/*.h)
|  
| -CPPFLAGS +=	-D__NetBSD__
| -LIBS +=		
| +CPPFLAGS +=	-D SPOOF -I /usr/pkg/include/libnet11
| +LIBS +=		/usr/pkg/lib/libnet11/libnet.a
|  
|  PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
|  INSTALL_LIB =	install -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
| diff -Naur olsrd-a5b9cf969979/src/bsd/net.c olsrd-a5b9cf969979.netbsd/src/bsd/net.c
| --- olsrd-a5b9cf969979/src/bsd/net.c	2008-02-06 19:32:49.000000000 +0100
| +++ olsrd-a5b9cf969979.netbsd/src/bsd/net.c	2008-04-02 23:41:50.000000000 +0200
| @@ -59,6 +59,9 @@
|  
|  #ifdef __NetBSD__
|  #include <net/if_ether.h>
| +#include <netinet6/in6_var.h> /* For struct in6_ifreq */
| +#include <net80211/ieee80211_ioctl.h>
| +#include <ifaddrs.h>
|  #endif
|  
|  #ifdef __OpenBSD__
| @@ -110,11 +113,7 @@
|  static int set_sysctl_int(const char *name, int new)
|  {
|    int old;
| -#if __MacOSX__ || __OpenBSD__
|    size_t len = sizeof (old);
| -#else
| -  unsigned int len = sizeof (old);
| -#endif
|  
|  #ifdef __OpenBSD__
|    int mib[4];
| @@ -182,7 +181,7 @@
|  
|    // do not accept ICMP redirects
|  
| -#ifdef __OpenBSD__
| +#if defined __OpenBSD__ || defined __NetBSD__
|    if (version == AF_INET)
|      name = "net.inet.icmp.rediraccept";
|    else
| @@ -786,10 +785,12 @@
|  	       ifc->int_name,
|  	       iname);
|  
| +#if 0 /* This is causing trouble */
|    if (strcmp (ifc->int_name, iname) != 0)
|      {
|        return (0);
|      }
| +#endif
|  
|    return (count);
|  }
| @@ -827,6 +828,18 @@
|    ireq.i_type = IEEE80211_IOC_SSID;
|    ireq.i_val = -1;
|    return (ioctl(olsr_cnf->ioctl_s, SIOCG80211, &ireq) >= 0) ? 1 : 0;
| +#elif defined __NetBSD__
| +  struct ifreq ireq;
| +  struct ieee80211_nwid data;
| +  int ret;
| +
| +  memset(&ireq, 0, sizeof(ireq));
| +  strlcpy(ireq.ifr_name, ifname, sizeof(ireq.ifr_name));
| +  ireq.ifr_data = &data;
| +  ret = ioctl(olsr_cnf->ioctl_s, SIOCG80211NWID, &ireq);
| +  if(ret == 0)
| +	  return 1;
| +  return 0;
|  #elif defined __OpenBSD__
|    struct ieee80211_nodereq nr;
|    bzero(&nr, sizeof(nr));
| diff -Naur olsrd-a5b9cf969979/src/cfgparser/olsrd_conf.c olsrd-a5b9cf969979.netbsd/src/cfgparser/olsrd_conf.c
| --- olsrd-a5b9cf969979/src/cfgparser/olsrd_conf.c	2008-02-06 19:32:49.000000000 +0100
| +++ olsrd-a5b9cf969979.netbsd/src/cfgparser/olsrd_conf.c	2008-02-08 19:45:57.000000000 +0100
| @@ -625,7 +625,7 @@
|              printf("\tLinkQualityMult          : %s %0.2f\n", inet_ntop(cnf->ip_version, &mult->addr, ipv6_buf, sizeof (ipv6_buf)), mult->val);
|            }
|  
| -          printf("\tAutodetetc changes       : %s\n", in->cnf->autodetect_chg ? "yes" : "no");
| +          printf("\tAutodetect changes       : %s\n", in->cnf->autodetect_chg ? "yes" : "no");
|  
|  	  in = in->next;
|  	}
| diff -Naur olsrd-a5b9cf969979/src/lq_packet.c olsrd-a5b9cf969979.netbsd/src/lq_packet.c
| --- olsrd-a5b9cf969979/src/lq_packet.c	2008-02-06 19:32:49.000000000 +0100
| +++ olsrd-a5b9cf969979.netbsd/src/lq_packet.c	2008-02-10 03:27:00.000000000 +0100
| @@ -231,7 +231,7 @@
|              neigh->neigh_link_quality = lnk->neigh_link_quality;
|            }
|            else {
| -            OLSR_PRINTF(0, "Error: link_qualtiy undefined");
| +            OLSR_PRINTF(0, "Error: link_quality undefined");
|              neigh->link_quality = 0.0;
|              neigh->neigh_link_quality = 0.0;
|            }          

| -- 
| Olsr-dev mailing list
| (spam-protected)
| http://lists.olsr.org/mailman/listinfo/olsr-dev




More information about the Olsr-dev mailing list