Topic: Solaris

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.

2 (edited by nemski 2009-02-24 13:00:49)

Re: Solaris

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.

Re: Solaris

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

Re: Solaris

Hi nemski

Am under solaris 5.10 Generic_138889-02 i86pc i386 i86pc and wanted ton know if u were you able to compile chillispot under solaris?
If so is it possible to post the procedure, i couldn,t go beyond gmake

gmake  all-recursive
gmake[1]: Entering directory `/usr/share/src/chillispot'
Making all in src
gmake[2]: Entering directory `/usr/share/src/chillispot/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -g -O2 -MT chilli.o -MD -MP -MF ".deps/chilli.Tpo" -c -o chilli.o chilli.c; \
then mv -f ".deps/chilli.Tpo" ".deps/chilli.Po"; else rm -f ".deps/chilli.Tpo"; exit 1; fi
chilli.c: In function `main':
chilli.c:3892: error: `LOG_PERROR' undeclared (first use in this function)
chilli.c:3892: error: (Each undeclared identifier is reported only once
chilli.c:3892: error: for each function it appears in.)
gmake[2]: *** [chilli.o] Error 1
gmake[2]: Leaving directory `/usr/share/src/chillispot/src'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/share/src/chillispot'
gmake: *** [all] Error 2

Re: Solaris

Hello Again
I saved the above patch to /usr/src/chillispot/chillispot-1.1.0_main.patch
cd /usr/src/chillispot

removed the all chillispot-1.1.0/ in chillispot-1.1.0_main.patch

pached via gpatch
gpatch -p0 < chillispot/chillispot-1.1.0_main.patch

did a gmake
gmake clean
gmake

gmake  all-recursive
gmake[1]: Entering directory `/usr/share/src/chillispot'
Making all in src
gmake[2]: Entering directory `/usr/share/src/chillispot/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT chilli.o -MD -MP -MF ".deps/chilli.Tpo" -c -o chilli.o chilli.c; \
then mv -f ".deps/chilli.Tpo" ".deps/chilli.Po"; else rm -f ".deps/chilli.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT tun.o -MD -MP -MF ".deps/tun.Tpo" -c -o tun.o tun.c; \
then mv -f ".deps/tun.Tpo" ".deps/tun.Po"; else rm -f ".deps/tun.Tpo"; exit 1; fi
tun.c:369:29: missing binary operator before token "defined"
tun.c:448:28: missing binary operator before token "defined"
tun.c:500:28: missing binary operator before token "defined"
tun.c:588:28: missing binary operator before token "defined"
tun.c:677:28: missing binary operator before token "defined"
tun.c:725:28: missing binary operator before token "defined"
gmake[2]: *** [tun.o] Error 1
gmake[2]: Leaving directory `/usr/share/src/chillispot/src'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/share/src/chillispot'
gmake: *** [all] Error 2

seems the chilli.c issue was solved but not still tun.c

Anyone?

Re: Solaris

Ok had to manually add the required "||" binary operators in src/tun. c

Went past the above error.

Now a new error

gmake

gmake  all-recursive
gmake[1]: Entering directory `/usr/share/src/chillispot'
Making all in src
gmake[2]: Entering directory `/usr/share/src/chillispot/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT tun.o -MD -MP -MF ".deps/tun.Tpo" -c -o tun.o tun.c; \
then mv -f ".deps/tun.Tpo" ".deps/tun.Po"; else rm -f ".deps/tun.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT cmdline.o -MD -MP -MF ".deps/cmdline.Tpo" -c -o cmdline.o cmdline.c; \
then mv -f ".deps/cmdline.Tpo" ".deps/cmdline.Po"; else rm -f ".deps/cmdline.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT ippool.o -MD -MP -MF ".deps/ippool.Tpo" -c -o ippool.o ippool.c; \
then mv -f ".deps/ippool.Tpo" ".deps/ippool.Po"; else rm -f ".deps/ippool.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT radius.o -MD -MP -MF ".deps/radius.Tpo" -c -o radius.o radius.c; \
then mv -f ".deps/radius.Tpo" ".deps/radius.Po"; else rm -f ".deps/radius.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT md5.o -MD -MP -MF ".deps/md5.Tpo" -c -o md5.o md5.c; \
then mv -f ".deps/md5.Tpo" ".deps/md5.Po"; else rm -f ".deps/md5.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT redir.o -MD -MP -MF ".deps/redir.Tpo" -c -o redir.o redir.c; \
then mv -f ".deps/redir.Tpo" ".deps/redir.Po"; else rm -f ".deps/redir.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT dhcp.o -MD -MP -MF ".deps/dhcp.Tpo" -c -o dhcp.o dhcp.c; \
then mv -f ".deps/dhcp.Tpo" ".deps/dhcp.Po"; else rm -f ".deps/dhcp.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT syserr.o -MD -MP -MF ".deps/syserr.Tpo" -c -o syserr.o syserr.c; \
then mv -f ".deps/syserr.Tpo" ".deps/syserr.Po"; else rm -f ".deps/syserr.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT iphash.o -MD -MP -MF ".deps/iphash.Tpo" -c -o iphash.o iphash.c; \
then mv -f ".deps/iphash.Tpo" ".deps/iphash.Po"; else rm -f ".deps/iphash.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I..    -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -MT lookup.o -MD -MP -MF ".deps/lookup.Tpo" -c -o lookup.o lookup.c; \
then mv -f ".deps/lookup.Tpo" ".deps/lookup.Po"; else rm -f ".deps/lookup.Tpo"; exit 1; fi
/bin/bash ../libtool --tag=CC --mode=link gcc -D_GNU_SOURCE -fno-builtin -DSBINDIR='"/usr/local/sbin"'  -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl   -o chilli  chilli.o tun.o cmdline.o ippool.o radius.o md5.o redir.o dhcp.o syserr.o iphash.o lookup.o  -lsocket -lresolv -lnsl
mkdir .libs
gcc -D_GNU_SOURCE -fno-builtin -DSBINDIR=\"/usr/local/sbin\" -I/usr/include/ -I/usr/sfw/include -I/opt/csw/mysql5/include/mysql/ -I/opt/csw/include/ -I/opt/csw/include/openssl -o chilli chilli.o tun.o cmdline.o ippool.o radius.o md5.o redir.o dhcp.o syserr.o iphash.o lookup.o  -lsocket -lresolv -lnsl
Undefined                       first referenced
symbol                             in file
clearenv                            chilli.o
dhcp_getmac                         chilli.o
dhcp_open_eth                       dhcp.o
ld: fatal: Symbol referencing errors. No output written to chilli
collect2: ld returned 1 exit status
gmake[2]: *** [chilli] Error 1
gmake[2]: Leaving directory `/usr/share/src/chillispot/src'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/share/src/chillispot'
gmake: *** [all] Error 2

Anyone?

Re: Solaris

I managed to solve the clearenv() function just like nemski did by replacing the function with solaris version unsetenv() for every env entry in chilli.c and tun.c
Am now stuck with dhcp_getmac() dhcp_open_eth() functions.

Is there vesrions of dhcp_getmac() and dhcp_open_eth() im solaris to handle the same requirements?
Has anyone successfully build chillispot under solaris?

Please anyone.