9
0
Fork 0

qos length bugfix and apple support plus header cleanup

This commit is contained in:
jjako 2004-09-17 11:30:40 +00:00
parent 12f9e6e263
commit 0fe0df0079
23 changed files with 120 additions and 145 deletions

33
README.MacOSX Normal file
View File

@ -0,0 +1,33 @@
OpenGGSN/Mac OS X notes
Mac OS X support is experimental, please test and report bugs. The
Mac OS X port is tested on Mac OS X 10.3.5, but may also work on
other versions.
1. Compiling
Everything should be straight-forward. Create a separate
build directory, run ../openggsn/configure and then make.
If you have problems with configure, execute
$ aclocal && automake && autoheader && autoconf
and then again configure and make.
2. Kernel extensions
You need to add a tunnel kernel extension to your kernel.
The one I've used is available at
http://www-user.rhrk.uni-kl.de/~nissler/tuntap/
but there are others. If you want to compile that from
sources (instead of using the binary installer), you
will also need kernel sources from opensource.apple.com.
3. Known problems
None.
--
Pekka Nikander <pekka.nikander@nomadiclab.com>

View File

@ -1,16 +1,13 @@
# OpenGGSN - Gateway GPRS Support Node # OpenGGSN - Gateway GPRS Support Node
# Copyright (C) 2002, 2003 Mondru AB. # Copyright (C) 2002, 2003, 2004 Mondru AB.
# #
# The contents of this file may be used under the terms of the GNU # The contents of this file may be used under the terms of the GNU
# General Public License Version 2, provided that the above copyright # General Public License Version 2, provided that the above copyright
# notice and this permission notice is included in all copies or # notice and this permission notice is included in all copies or
# substantial portions of the software. # substantial portions of the software.
# #
# The initial developer of the original code is # Use "gengetopt --conf-parser < cmdline.ggo"
# Jens Jakobsen <jj@openggsn.org> # to generate cmdline.c and cmdline.h
#
# Contributor(s):
option "fg" f "Run in foreground" flag off option "fg" f "Run in foreground" flag off
option "debug" d "Run in debug mode" flag off option "debug" d "Run in debug mode" flag off

View File

@ -1,17 +1,12 @@
/* /*
* OpenGGSN - Gateway GPRS Support Node * OpenGGSN - Gateway GPRS Support Node
* Copyright (C) 2002, 2003 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* ggsn.c /* ggsn.c
@ -22,6 +17,11 @@
#define _GNU_SOURCE 1 /* strdup() prototype, broken arpa/inet.h */ #define _GNU_SOURCE 1 /* strdup() prototype, broken arpa/inet.h */
#endif #endif
#include "../config.h"
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <syslog.h> #include <syslog.h>
#include <ctype.h> #include <ctype.h>
@ -47,8 +47,6 @@
#include <time.h> #include <time.h>
#include "config.h"
#include "tun.h" #include "tun.h"
#include "ippool.h" #include "ippool.h"
#include "syserr.h" #include "syserr.h"

View File

@ -9,6 +9,12 @@
* *
*/ */
#include "../config.h"
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> /* in_addr */ #include <netinet/in.h> /* in_addr */
#include <stdlib.h> /* calloc */ #include <stdlib.h> /* calloc */

View File

@ -1,17 +1,12 @@
/* /*
* Syslog functions. * Syslog functions.
* Copyright (C) 2003 Mondru AB. * Copyright (C) 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#include <stdarg.h> #include <stdarg.h>

View File

@ -7,11 +7,6 @@
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#ifndef _SYSERR_H #ifndef _SYSERR_H

View File

@ -1,17 +1,12 @@
/* /*
* TUN interface functions. * TUN interface functions.
* Copyright (C) 2002, 2003 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*
@ -55,6 +50,9 @@
#include <net/if.h> #include <net/if.h>
#include <net/if_tun.h> #include <net/if_tun.h>
#elif defined (__APPLE__)
#include <net/if.h>
#elif defined (__sun__) #elif defined (__sun__)
#include <stropts.h> #include <stropts.h>
#include <sys/sockio.h> #include <sys/sockio.h>
@ -336,7 +334,7 @@ int tun_addaddr(struct tun_t *this,
this->addrs++; this->addrs++;
return 0; return 0;
#elif defined (__FreeBSD__) #elif defined (__FreeBSD__) || defined (__APPLE__)
int fd; int fd;
struct ifaliasreq areq; struct ifaliasreq areq;
@ -415,7 +413,7 @@ int tun_setaddr(struct tun_t *this,
#if defined(__linux__) #if defined(__linux__)
ifr.ifr_netmask.sa_family = AF_INET; ifr.ifr_netmask.sa_family = AF_INET;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
((struct sockaddr_in *) &ifr.ifr_addr)->sin_len = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_len =
sizeof (struct sockaddr_in); sizeof (struct sockaddr_in);
((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_len = ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_len =
@ -467,7 +465,7 @@ int tun_setaddr(struct tun_t *this,
((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr = ((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr =
netmask->s_addr; netmask->s_addr;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr =
netmask->s_addr; netmask->s_addr;
@ -494,7 +492,7 @@ int tun_setaddr(struct tun_t *this,
/* TODO: How does it work on Solaris? */ /* TODO: How does it work on Solaris? */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined (__APPLE__)
tun_sifflags(this, IFF_UP | IFF_RUNNING); /* TODO */ tun_sifflags(this, IFF_UP | IFF_RUNNING); /* TODO */
return tun_addroute(this, addr, addr, netmask); return tun_addroute(this, addr, addr, netmask);
#else #else
@ -543,7 +541,7 @@ int tun_addroute(struct tun_t *this,
close(fd); close(fd);
return 0; return 0;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
struct { struct {
struct rt_msghdr rt; struct rt_msghdr rt;
@ -610,7 +608,7 @@ int tun_new(struct tun_t **tun)
#if defined(__linux__) #if defined(__linux__)
struct ifreq ifr; struct ifreq ifr;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
char devname[IFNAMSIZ+5]; /* "/dev/" + ifname */ char devname[IFNAMSIZ+5]; /* "/dev/" + ifname */
int devnum; int devnum;
struct ifaliasreq areq; struct ifaliasreq areq;
@ -657,7 +655,7 @@ int tun_new(struct tun_t **tun)
ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */ ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */
return 0; return 0;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
/* Find suitable device */ /* Find suitable device */
for (devnum = 0; devnum < 255; devnum++) { /* TODO 255 */ for (devnum = 0; devnum < 255; devnum++) { /* TODO 255 */
@ -784,7 +782,7 @@ int tun_set_cb_ind(struct tun_t *this,
int tun_decaps(struct tun_t *this) int tun_decaps(struct tun_t *this)
{ {
#if defined(__linux__) || defined (__FreeBSD__) #if defined(__linux__) || defined (__FreeBSD__) || defined (__APPLE__)
unsigned char buffer[PACKET_MAX]; unsigned char buffer[PACKET_MAX];
int status; int status;
@ -825,7 +823,7 @@ int tun_decaps(struct tun_t *this)
int tun_encaps(struct tun_t *tun, void *pack, unsigned len) int tun_encaps(struct tun_t *tun, void *pack, unsigned len)
{ {
#if defined(__linux__) || defined (__FreeBSD__) #if defined(__linux__) || defined (__FreeBSD__) || defined (__APPLE__)
return write(tun->fd, pack, len); return write(tun->fd, pack, len);

View File

@ -7,11 +7,6 @@
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#ifndef _TUN_H #ifndef _TUN_H

View File

@ -1,17 +1,12 @@
/* /*
* OpenGGSN - Gateway GPRS Support Node * OpenGGSN - Gateway GPRS Support Node
* Copyright (C) 2002 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*
@ -27,6 +22,10 @@
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#endif #endif
#include "../config.h"
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <syslog.h> #include <syslog.h>
#include <stdio.h> #include <stdio.h>
@ -48,7 +47,6 @@
/* #include <stdint.h> ISO C99 types */ /* #include <stdint.h> ISO C99 types */
#include "../config.h"
#include "pdp.h" #include "pdp.h"
#include "gtp.h" #include "gtp.h"
#include "gtpie.h" #include "gtpie.h"
@ -407,7 +405,7 @@ int gtp_req(struct gsn_t *gsn, int version, struct pdp_t *pdp,
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr = *inetaddr; addr.sin_addr = *inetaddr;
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__APPLE__)
addr.sin_len = sizeof(addr); addr.sin_len = sizeof(addr);
#endif #endif
@ -766,7 +764,7 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/ addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/
addr.sin_port = htons(GTP0_PORT); addr.sin_port = htons(GTP0_PORT);
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__APPLE__)
addr.sin_len = sizeof(addr); addr.sin_len = sizeof(addr);
#endif #endif
@ -787,7 +785,7 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/ addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/
addr.sin_port = htons(GTP1C_PORT); addr.sin_port = htons(GTP1C_PORT);
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__APPLE__)
addr.sin_len = sizeof(addr); addr.sin_len = sizeof(addr);
#endif #endif
@ -808,7 +806,7 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/ addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/
addr.sin_port = htons(GTP1U_PORT); addr.sin_port = htons(GTP1U_PORT);
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__APPLE__)
addr.sin_len = sizeof(addr); addr.sin_len = sizeof(addr);
#endif #endif
@ -2944,7 +2942,7 @@ int gtp_data_req(struct gsn_t *gsn, struct pdp_t* pdp,
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__APPLE__)
addr.sin_len = sizeof(addr); addr.sin_len = sizeof(addr);
#endif #endif

View File

@ -1,17 +1,12 @@
/* /*
* OpenGGSN - Gateway GPRS Support Node * OpenGGSN - Gateway GPRS Support Node
* Copyright (C) 2002 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#ifndef _GTP_H #ifndef _GTP_H
@ -217,7 +212,7 @@ union gtp_packet {
struct gtp0_packet gtp0; struct gtp0_packet gtp0;
struct gtp1_packet_short gtp1s; struct gtp1_packet_short gtp1s;
struct gtp1_packet_long gtp1l; struct gtp1_packet_long gtp1l;
} __attribute__((packed)) h; } __attribute__((packed));

View File

@ -7,11 +7,6 @@
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*
@ -31,6 +26,12 @@
* *
*/ */
#include <../config.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>

View File

@ -1,17 +1,12 @@
/* /*
* OpenGGSN - Gateway GPRS Support Node * OpenGGSN - Gateway GPRS Support Node
* Copyright (C) 2002 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#ifndef _GTPIE_H #ifndef _GTPIE_H

View File

@ -1,17 +1,12 @@
/* /*
* OpenGGSN - Gateway GPRS Support Node * OpenGGSN - Gateway GPRS Support Node
* Copyright (C) 2002, 2003 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*
@ -19,6 +14,12 @@
* *
*/ */
#include <../config.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>

View File

@ -7,11 +7,6 @@
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#ifndef _PDP_H #ifndef _PDP_H

View File

@ -1,17 +1,12 @@
/* /*
* OpenGGSN - Gateway GPRS Support Node * OpenGGSN - Gateway GPRS Support Node
* Copyright (C) 2002 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*
@ -19,6 +14,11 @@
* Reliable delivery of signalling messages * Reliable delivery of signalling messages
*/ */
#include <../config.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>

View File

@ -7,11 +7,6 @@
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*
@ -22,15 +17,15 @@
#ifndef _QUEUE_H #ifndef _QUEUE_H
#define _QUEUE_H #define _QUEUE_H
#define QUEUE_DEBUG 0 /* Print debug information */ #define QUEUE_DEBUG 0 /* Print debug information */
#define QUEUE_SIZE 1024 /* Size of retransmission queue */ #define QUEUE_SIZE 1024 /* Size of retransmission queue */
#define QUEUE_HASH_SIZE 65536 /* Size of hash table (2^16) */ #define QUEUE_HASH_SIZE 65536 /* Size of hash table (2^16) */
struct qmsg_t { /* Holder for queued packets */ struct qmsg_t { /* Holder for queued packets */
int state; /* 0=empty, 1=full */ int state; /* 0=empty, 1=full */
uint16_t seq; /* The sequence number */ uint16_t seq; /* The sequence number */
uint8_t type; /* The type of packet */ uint8_t type; /* The type of packet */
void *cbp; /* Application specific pointer */ void *cbp; /* Application specific pointer */
union gtp_packet p; /* The packet stored */ union gtp_packet p; /* The packet stored */
int l; /* Length of the packet */ int l; /* Length of the packet */

View File

@ -1,17 +1,11 @@
# OpenGGSN - Gateway GPRS Support Node # OpenGGSN - Gateway GPRS Support Node
# Copyright (C) 2002, 2003 Mondru AB. # Copyright (C) 2002, 2003, 2004 Mondru AB.
# #
# The contents of this file may be used under the terms of the GNU # The contents of this file may be used under the terms of the GNU
# General Public License Version 2, provided that the above copyright # General Public License Version 2, provided that the above copyright
# notice and this permission notice is included in all copies or # notice and this permission notice is included in all copies or
# substantial portions of the software. # substantial portions of the software.
# #
# The initial developer of the original code is
# Jens Jakobsen <jj@openggsn.org>
#
# Contributor(s):
#
#
# Use "gengetopt --conf-parser < cmdline.ggo" # Use "gengetopt --conf-parser < cmdline.ggo"
# to generate cmdline.c and cmdline.h # to generate cmdline.c and cmdline.h

View File

@ -9,6 +9,12 @@
* *
*/ */
#include "../config.h"
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> /* in_addr */ #include <netinet/in.h> /* in_addr */
#include <stdlib.h> /* calloc */ #include <stdlib.h> /* calloc */

View File

@ -1,17 +1,12 @@
/* /*
* OpenGGSN - Gateway GPRS Support Node * OpenGGSN - Gateway GPRS Support Node
* Copyright (C) 2002, 2003 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*

View File

@ -1,17 +1,12 @@
/* /*
* Syslog functions. * Syslog functions.
* Copyright (C) 2003 Mondru AB. * Copyright (C) 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#include <stdarg.h> #include <stdarg.h>

View File

@ -7,11 +7,6 @@
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#ifndef _SYSERR_H #ifndef _SYSERR_H

View File

@ -1,17 +1,12 @@
/* /*
* TUN interface functions. * TUN interface functions.
* Copyright (C) 2002, 2003 Mondru AB. * Copyright (C) 2002, 2003, 2004 Mondru AB.
* *
* The contents of this file may be used under the terms of the GNU * The contents of this file may be used under the terms of the GNU
* General Public License Version 2, provided that the above copyright * General Public License Version 2, provided that the above copyright
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
/* /*
@ -55,6 +50,9 @@
#include <net/if.h> #include <net/if.h>
#include <net/if_tun.h> #include <net/if_tun.h>
#elif defined (__APPLE__)
#include <net/if.h>
#elif defined (__sun__) #elif defined (__sun__)
#include <stropts.h> #include <stropts.h>
#include <sys/sockio.h> #include <sys/sockio.h>
@ -336,7 +334,7 @@ int tun_addaddr(struct tun_t *this,
this->addrs++; this->addrs++;
return 0; return 0;
#elif defined (__FreeBSD__) #elif defined (__FreeBSD__) || defined (__APPLE__)
int fd; int fd;
struct ifaliasreq areq; struct ifaliasreq areq;
@ -415,7 +413,7 @@ int tun_setaddr(struct tun_t *this,
#if defined(__linux__) #if defined(__linux__)
ifr.ifr_netmask.sa_family = AF_INET; ifr.ifr_netmask.sa_family = AF_INET;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
((struct sockaddr_in *) &ifr.ifr_addr)->sin_len = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_len =
sizeof (struct sockaddr_in); sizeof (struct sockaddr_in);
((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_len = ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_len =
@ -467,7 +465,7 @@ int tun_setaddr(struct tun_t *this,
((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr = ((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr =
netmask->s_addr; netmask->s_addr;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr =
netmask->s_addr; netmask->s_addr;
@ -494,7 +492,7 @@ int tun_setaddr(struct tun_t *this,
/* TODO: How does it work on Solaris? */ /* TODO: How does it work on Solaris? */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined (__APPLE__)
tun_sifflags(this, IFF_UP | IFF_RUNNING); /* TODO */ tun_sifflags(this, IFF_UP | IFF_RUNNING); /* TODO */
return tun_addroute(this, addr, addr, netmask); return tun_addroute(this, addr, addr, netmask);
#else #else
@ -543,7 +541,7 @@ int tun_addroute(struct tun_t *this,
close(fd); close(fd);
return 0; return 0;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
struct { struct {
struct rt_msghdr rt; struct rt_msghdr rt;
@ -610,7 +608,7 @@ int tun_new(struct tun_t **tun)
#if defined(__linux__) #if defined(__linux__)
struct ifreq ifr; struct ifreq ifr;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
char devname[IFNAMSIZ+5]; /* "/dev/" + ifname */ char devname[IFNAMSIZ+5]; /* "/dev/" + ifname */
int devnum; int devnum;
struct ifaliasreq areq; struct ifaliasreq areq;
@ -657,7 +655,7 @@ int tun_new(struct tun_t **tun)
ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */ ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */
return 0; return 0;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined (__APPLE__)
/* Find suitable device */ /* Find suitable device */
for (devnum = 0; devnum < 255; devnum++) { /* TODO 255 */ for (devnum = 0; devnum < 255; devnum++) { /* TODO 255 */
@ -784,7 +782,7 @@ int tun_set_cb_ind(struct tun_t *this,
int tun_decaps(struct tun_t *this) int tun_decaps(struct tun_t *this)
{ {
#if defined(__linux__) || defined (__FreeBSD__) #if defined(__linux__) || defined (__FreeBSD__) || defined (__APPLE__)
unsigned char buffer[PACKET_MAX]; unsigned char buffer[PACKET_MAX];
int status; int status;
@ -825,7 +823,7 @@ int tun_decaps(struct tun_t *this)
int tun_encaps(struct tun_t *tun, void *pack, unsigned len) int tun_encaps(struct tun_t *tun, void *pack, unsigned len)
{ {
#if defined(__linux__) || defined (__FreeBSD__) #if defined(__linux__) || defined (__FreeBSD__) || defined (__APPLE__)
return write(tun->fd, pack, len); return write(tun->fd, pack, len);

View File

@ -7,11 +7,6 @@
* notice and this permission notice is included in all copies or * notice and this permission notice is included in all copies or
* substantial portions of the software. * substantial portions of the software.
* *
* The initial developer of the original code is
* Jens Jakobsen <jj@openggsn.org>
*
* Contributor(s):
*
*/ */
#ifndef _TUN_H #ifndef _TUN_H