Use this patch.

I discovered this when compiling in Solaris. I think it's just some versions of gcc that are picky about the || operands

--- chillispot-1.1.0/src/tun.c      Mon Sep 25 03:48:25 2006
+++ chillispot-1.1.0/src/tun.c   Tue Feb 24 09:00:03 2009
@@ -366,7 +366,7 @@
   this->addrs++;
   return 0;

-#elif defined (__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)

   int fd;
   struct ifaliasreq      areq;
@@ -445,7 +445,7 @@
 #if defined(__linux__)
   ifr.ifr_netmask.sa_family = AF_INET;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
   ((struct sockaddr_in *) &ifr.ifr_addr)->sin_len =
     sizeof (struct sockaddr_in);
   ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_len =
@@ -497,7 +497,7 @@
     ((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr =
       netmask->s_addr;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
     ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr =
       netmask->s_addr;

@@ -585,7 +585,7 @@
   close(fd);
   return 0;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)

 struct {
   struct rt_msghdr rt;
@@ -674,7 +674,7 @@
 #if defined(__linux__)
   struct ifreq ifr;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
   char devname[IFNAMSIZ+5]; /* "/dev/" + ifname */
   int devnum;
   struct ifaliasreq areq;
@@ -722,7 +722,7 @@
   ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */
   return 0;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)

   /* Find suitable device */
   for (devnum = 0; devnum < 255; devnum++) { /* TODO 255 */

2

(6 replies, posted in from Source)

So people are reading my posts but not replying to them tongue

I thought I'd update you all on the progress. I've managed to get dhcp_getmac working by dumping a solaris version of getifaddrs() into the compilation.
Also a version of clearenv() was required to get chilli.c to stop showing compile errors.

I'm now having some compile errors with dhcp_open_eth, dhcp_new and dhcp_receive. I think because some structures aren't implemented in Solaris?

Here's the errors I get:

dhcp.c: In function `dhcp_open_eth':
dhcp.c:611: error: `u_int32_t' undeclared (first use in this function)
dhcp.c:611: error: (Each undeclared identifier is reported only once
dhcp.c:611: error: for each function it appears in.)
dhcp.c:611: error: syntax error before "ipaddr"
dhcp.c:630: error: `BIOCSETIF' undeclared (first use in this function)
dhcp.c:636: error: `BIOCVERSION' undeclared (first use in this function)
dhcp.c:668: error: `BIOCPROMISC' undeclared (first use in this function)
dhcp.c:673: error: `BIOCSHDRCMPLT' undeclared (first use in this function)
dhcp.c:688: error: `BIOCIMMEDIATE' undeclared (first use in this function)
dhcp.c: In function `dhcp_new':
dhcp.c:1153: error: `BIOCGBLEN' undeclared (first use in this function)
dhcp.c:1156: error: structure has no member named `rbuf_max'
dhcp.c:1157: error: structure has no member named `rbuf'
dhcp.c:1157: error: structure has no member named `rbuf_max'
dhcp.c:1161: error: structure has no member named `rbuf_offset'
dhcp.c:1162: error: structure has no member named `rbuf_len'
dhcp.c: In function `dhcp_receive':
dhcp.c:2645: error: structure has no member named `rbuf_offset'
dhcp.c:2645: error: structure has no member named `rbuf_len'
dhcp.c:2646: error: structure has no member named `rbuf'
dhcp.c:2646: error: structure has no member named `rbuf_max'
dhcp.c:2649: error: structure has no member named `rbuf_offset'
dhcp.c:2650: error: structure has no member named `rbuf_len'
dhcp.c:2653: error: structure has no member named `rbuf_offset'
dhcp.c:2653: error: structure has no member named `rbuf_len'
dhcp.c:2655: error: structure has no member named `rbuf_len'
dhcp.c:2655: error: structure has no member named `rbuf_offset'
dhcp.c:2655: error: invalid application of `sizeof' to incomplete type `bpf_hdr'
dhcp.c:2656: error: structure has no member named `rbuf_offset'
dhcp.c:2656: error: structure has no member named `rbuf_len'
dhcp.c:2660: error: structure has no member named `rbuf'
dhcp.c:2660: error: structure has no member named `rbuf_offset'
dhcp.c:2662: error: structure has no member named `rbuf_offset'
dhcp.c:2662: error: dereferencing pointer to incomplete type
dhcp.c:2662: error: dereferencing pointer to incomplete type
dhcp.c:2663: error: structure has no member named `rbuf_len'
dhcp.c:2664: error: structure has no member named `rbuf_offset'
dhcp.c:2664: error: structure has no member named `rbuf_len'
dhcp.c:2668: error: dereferencing pointer to incomplete type
dhcp.c:2668: error: dereferencing pointer to incomplete type
dhcp.c:2669: error: structure has no member named `rbuf_offset'
dhcp.c:2669: error: dereferencing pointer to incomplete type
dhcp.c:2669: error: dereferencing pointer to incomplete type
dhcp.c:2674: error: structure has no member named `rbuf'
dhcp.c:2674: error: structure has no member named `rbuf_offset'
dhcp.c:2674: error: dereferencing pointer to incomplete type
dhcp.c:2678: error: dereferencing pointer to incomplete type
dhcp.c:2682: error: dereferencing pointer to incomplete type
dhcp.c:2688: error: structure has no member named `rbuf_offset'
dhcp.c:2688: error: dereferencing pointer to incomplete type
dhcp.c:2688: error: dereferencing pointer to incomplete type

3

(6 replies, posted in from Source)

for anyone interested here's the diffs for what I've done so far

--- chillispot-1.1.0/src/tun.c      Mon Sep 25 03:48:25 2006
+++ src/tun.c   Tue Feb 24 09:00:03 2009
@@ -366,7 +366,7 @@
   this->addrs++;
   return 0;

-#elif defined (__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)

   int fd;
   struct ifaliasreq      areq;
@@ -445,7 +445,7 @@
 #if defined(__linux__)
   ifr.ifr_netmask.sa_family = AF_INET;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
   ((struct sockaddr_in *) &ifr.ifr_addr)->sin_len =
     sizeof (struct sockaddr_in);
   ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_len =
@@ -497,7 +497,7 @@
     ((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr =
       netmask->s_addr;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
     ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr =
       netmask->s_addr;

@@ -585,7 +585,7 @@
   close(fd);
   return 0;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)

 struct {
   struct rt_msghdr rt;
@@ -674,7 +674,7 @@
 #if defined(__linux__)
   struct ifreq ifr;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
   char devname[IFNAMSIZ+5]; /* "/dev/" + ifname */
   int devnum;
   struct ifaliasreq areq;
@@ -722,7 +722,7 @@
   ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */
   return 0;

-#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__)

   /* Find suitable device */
   for (devnum = 0; devnum < 255; devnum++) { /* TODO 255 */

--- chillispot-1.1.0/src/chilli.c   Mon Sep 25 03:48:25 2006
+++ src/chilli.c        Tue Feb 24 08:35:04 2009
@@ -3888,8 +3888,12 @@
   struct itimerval itval;

   /* open a connection to the syslog daemon */
-  /*openlog(PACKAGE, LOG_PID, LOG_DAEMON);*/
+
+  #if defined(__sun__)
+  openlog(PACKAGE, LOG_PID, LOG_DAEMON);
+  #else /* this is not POSIX */
   openlog(PACKAGE, (LOG_PID | LOG_PERROR), LOG_DAEMON);
+  #endif

   /* Process options given in configuration file and command line */
   if (process_options(argc, argv, 1))

--- chillispot-1.1.0/src/dhcp.c     Mon Sep 25 03:48:25 2006
+++ src/dhcp.c  Tue Feb 24 09:12:57 2009
@@ -84,6 +84,12 @@
 #include <net/if_dl.h>
 #include <net/if_types.h>
 #include <ifaddrs.h>
+
+#elif defined (__sun__)
+#include <stropts.h>
+#include <sys/sockio.h>
+#include <net/if.h>
+#include <net/if_tun.h>
 #endif

 #ifdef HAVE_NET_ETHERNET_H

Plus a couple of things


./configure LIBS="-lsocket -lresolv -lnsl"

Configure doesn't appear to include these on solaris system


Download http://vtun.sourceforge.net/tun/tun-1.1.tar.gz

gzip -d tun-1.1.tar.gz

tar -xf tun-1.1.tar

cp tun-1.1/solaris/if_tun.h /usr/include/net

Solaris development doesn't include this file by default.

4

(6 replies, posted in from Source)

I'm trying to get Chillispot running on Solaris 10.
I've fixed the headers etc. and having come down to the last couple of functions that deal with low level network drives.
dhcp_getmac() and dhcp_open_eth()

can someone explain what these functions do in as much detail as possible? I haven't had much dealings with network interfaces in C, so all help would be appreciated.