From ff9985cb3686b38cd83d86968a0e339dadac7b08 Mon Sep 17 00:00:00 2001 From: jjako Date: Fri, 16 Jan 2004 11:05:22 +0000 Subject: [PATCH] Improved Solaris support --- NEWS | 2 +- README | 10 +++++----- acinclude.m4 | 17 +++++++++++++++++ ggsn/ggsn.c | 16 +++++++--------- sgsnemu/sgsnemu.c | 3 ++- 5 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 acinclude.m4 diff --git a/NEWS b/NEWS index 0955abb..a7a7ca3 100644 --- a/NEWS +++ b/NEWS @@ -7,7 +7,7 @@ Copyright (C) 2002, 2003 Mondru AB. Version 0.8 =========== - * Solaris support. + * Support for compilation under Solaris. * Iptables firewall script. Version 0.7 diff --git a/README b/README index d85582e..3a254a5 100644 --- a/README +++ b/README @@ -9,11 +9,11 @@ QuickStart Requirements ------------ -*Linux* -OpenGGSN was developed and tested using Redhat 8.0 and 9.0 and Solaris -2.8. It should run also on other Linux distributions as well as -FreeBSD, but this is untested. Please tell me of any -testing results. +*Linux* +OpenGGSN was developed and tested using Redhat 8.0 and 9.0. It should +run also on other Linux distributions as well as FreeBSD, but this is +untested. Compilation on Solaris 2.8 has also been verified. Please +tell me of any testing results. *Tun* The tun driver is required for proper operation of openggsn. For linux diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..2aea10b --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,17 @@ +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/htmldoc/adl_func_getopt_long.html +dnl +AC_DEFUN([adl_FUNC_GETOPT_LONG], + [AC_PREREQ(2.49)dnl + # clean out junk possibly left behind by a previous configuration + rm -f lib/getopt.h + # Check for getopt_long support + AC_CHECK_HEADERS([getopt.h]) + AC_CHECK_FUNCS([getopt_long],, + [# FreeBSD has a gnugetopt library for this + AC_CHECK_LIB([gnugetopt],[getopt_long],[AC_DEFINE([HAVE_GETOPT_LONG])], + [# use the GNU replacement + AC_LIBOBJ(getopt) + AC_LIBOBJ(getopt1) + AC_CONFIG_LINKS([ggsn/getopt.h:ggsn/gnugetopt.h]) + AC_CONFIG_LINKS([sgsnemu/getopt.h:sgsnemu/gnugetopt.h])])])]) diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 0728261..b75b01d 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -47,6 +47,8 @@ #include +#include "config.h" + #include "tun.h" #include "ippool.h" #include "syserr.h" @@ -328,7 +330,7 @@ int main(int argc, char **argv) } /* DNS1 and DNS2 */ -#ifndef HAVE_INET_ATON +#ifdef HAVE_INET_ATON dns1.s_addr = 0; if (args_info.pcodns1_arg) { if (0 == inet_aton(args_info.pcodns1_arg, &dns1)) { @@ -346,11 +348,10 @@ int main(int argc, char **argv) } } #else -#ifndef HAVE_INET_ADDR dns1.s_addr = 0; if (args_info.pcodns1_arg) { - dns1 = inet_addr(args_info.pcodns1_arg); - if (dns1.s_addr == INADDR_NONE) { + dns1.s_addr = inet_addr(args_info.pcodns1_arg); + if (dns1.s_addr == -1) { sys_err(LOG_ERR, __FILE__, __LINE__, 0, "Failed to convert pcodns1!"); exit(1); @@ -358,16 +359,13 @@ int main(int argc, char **argv) } dns2.s_addr = 0; if (args_info.pcodns2_arg) { - dns2 = inet_addr(args_info.pcodns2_arg); - if (dns2.s_addr == INADDR_NONE) { + dns2.s_addr = inet_addr(args_info.pcodns2_arg); + if (dns2.s_addr == -1) { sys_err(LOG_ERR, __FILE__, __LINE__, 0, "Failed to convert pcodns2!"); exit(1); } } -#else -#error Function missing! -#endif #endif diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index c655ef1..fbed846 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -48,6 +48,7 @@ #include #include +#include "config.h" #include "tun.h" #include "ippool.h" #include "syserr.h" @@ -932,7 +933,7 @@ int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause) { if ((options.createif) && (!options.net.s_addr)) { struct in_addr m; -#ifndef HAVE_INET_ATON +#ifdef HAVE_INET_ATON inet_aton("255.255.255.255", &m); #else m.s_addr = INADDR_NONE;