diff options
author | jjako <jjako> | 2004-01-19 18:37:58 +0000 |
---|---|---|
committer | jjako <jjako> | 2004-01-19 18:37:58 +0000 |
commit | 06e9f125889471f27bb5fc415afaa1a9d703438a (patch) | |
tree | 848661cef6cdcc4efa5278a02c810b030f9df8a0 | |
parent | e66a1ba8685cfe062cb0597b7f112a9e49ddd8c3 (diff) |
FreeBSD porting and IMSI bugfix
-rw-r--r-- | ggsn/ippool.c | 1 | ||||
-rw-r--r-- | ggsn/syserr.c | 1 | ||||
-rw-r--r-- | ggsn/tun.c | 17 | ||||
-rw-r--r-- | gtp/gtp.c | 16 | ||||
-rw-r--r-- | sgsnemu/ippool.c | 1 | ||||
-rw-r--r-- | sgsnemu/sgsnemu.c | 6 | ||||
-rw-r--r-- | sgsnemu/syserr.c | 1 | ||||
-rw-r--r-- | sgsnemu/tun.c | 17 |
8 files changed, 45 insertions, 15 deletions
diff --git a/ggsn/ippool.c b/ggsn/ippool.c index 331306f..321824b 100644 --- a/ggsn/ippool.c +++ b/ggsn/ippool.c @@ -14,6 +14,7 @@ * */ +#include <sys/types.h> #include <netinet/in.h> /* in_addr */ #include <stdlib.h> /* calloc */ #include <stdio.h> /* sscanf */ diff --git a/ggsn/syserr.c b/ggsn/syserr.c index 9d793e0..7223414 100644 --- a/ggsn/syserr.c +++ b/ggsn/syserr.c @@ -15,6 +15,7 @@ */ #include <stdarg.h> +#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h> @@ -56,6 +56,9 @@ #include <net/if.h> #include <net/if_tun.h> /*#include "sun_if_tun.h"*/ +#elif defined (__FreeBSD__) +#include <net/if.h> +#include <net/if_tun.h> #endif @@ -347,7 +350,7 @@ int tun_setaddr(struct tun_t *this, memset (&ifr, '\0', sizeof (ifr)); ifr.ifr_addr.sa_family = AF_INET; ifr.ifr_dstaddr.sa_family = AF_INET; -#ifndef __sun__ +#ifdef __linux__ ifr.ifr_netmask.sa_family = AF_INET; #endif strncpy(ifr.ifr_name, this->devname, IFNAMSIZ); @@ -391,7 +394,7 @@ int tun_setaddr(struct tun_t *this, if (netmask) { /* Set the netmask */ this->netmask.s_addr = netmask->s_addr; -#ifdef __sun__ +#if defined(__sun__) | defined(__FreeBSD__) ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_addr.s_addr = dstaddr->s_addr; #else @@ -417,8 +420,8 @@ int tun_addroute(struct tun_t *this, struct in_addr *mask) { - /* TODO: Learn how to set routing table on sun */ -#ifndef __sun__ + /* TODO: Learn how to set routing table on sun and FreeBSD */ +#ifdef __linux__ struct rtentry r; int fd; @@ -457,11 +460,11 @@ int tun_addroute(struct tun_t *this, int tun_new(struct tun_t **tun) { -#ifndef __sun__ - struct ifreq ifr; -#else +#ifdef __sun__ int if_fd, ppa = -1; static int ip_fd = 0; +#else + struct ifreq ifr; #endif if (!(*tun = calloc(1, sizeof(struct tun_t)))) { @@ -407,6 +407,9 @@ int gtp_req(struct gsn_t *gsn, int version, struct pdp_t *pdp, memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr = *inetaddr; +#ifdef __FreeBSD__ + addr.sin_len = sizeof(addr); +#endif if ((packet->flags & 0xe0) == 0x00) { /* Version 0 */ addr.sin_port = htons(GTP0_PORT); @@ -763,6 +766,9 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen, addr.sin_family = AF_INET; addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/ addr.sin_port = htons(GTP0_PORT); +#ifdef __FreeBSD__ + addr.sin_len = sizeof(addr); +#endif if (bind((*gsn)->fd0, (struct sockaddr *) &addr, sizeof(addr)) < 0) { (*gsn)->err_socket++; @@ -781,6 +787,9 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen, addr.sin_family = AF_INET; addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/ addr.sin_port = htons(GTP1C_PORT); +#ifdef __FreeBSD__ + addr.sin_len = sizeof(addr); +#endif if (bind((*gsn)->fd1c, (struct sockaddr *) &addr, sizeof(addr)) < 0) { (*gsn)->err_socket++; @@ -799,6 +808,9 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen, addr.sin_family = AF_INET; addr.sin_addr = *listen; /* Same IP for user traffic and signalling*/ addr.sin_port = htons(GTP1U_PORT); +#ifdef __FreeBSD__ + addr.sin_len = sizeof(addr); +#endif if (bind((*gsn)->fd1u, (struct sockaddr *) &addr, sizeof(addr)) < 0) { (*gsn)->err_socket++; @@ -2932,6 +2944,10 @@ int gtp_data_req(struct gsn_t *gsn, struct pdp_t* pdp, memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; +#ifdef __FreeBSD__ + addr.sin_len = sizeof(addr); +#endif + memcpy(&addr.sin_addr, pdp->gsnru.v,pdp->gsnru.l); /* TODO range check */ if (pdp->version == 0) { diff --git a/sgsnemu/ippool.c b/sgsnemu/ippool.c index 331306f..321824b 100644 --- a/sgsnemu/ippool.c +++ b/sgsnemu/ippool.c @@ -14,6 +14,7 @@ * */ +#include <sys/types.h> #include <netinet/in.h> /* in_addr */ #include <stdlib.h> /* calloc */ #include <stdio.h> /* sscanf */ diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index ecf8ee8..53a1cc0 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -374,7 +374,9 @@ int process_options(int argc, char **argv) { printf("Invalid IMSI\n"); return -1; } - options.imsi = ((uint64_t) (args_info.imsi_arg[ 0]-48)); + + options.imsi = 0xf000000000000000; + options.imsi |= ((uint64_t) (args_info.imsi_arg[ 0]-48)); options.imsi |= ((uint64_t) (args_info.imsi_arg[ 1]-48)) << 4; options.imsi |= ((uint64_t) (args_info.imsi_arg[ 2]-48)) << 8; options.imsi |= ((uint64_t) (args_info.imsi_arg[ 3]-48)) << 12; @@ -655,6 +657,8 @@ int imsi_add(uint64_t src, uint64_t *dst, int add) { i64 = i64 / 10; } + *dst |= 0xf000000000000000; + return 0; } diff --git a/sgsnemu/syserr.c b/sgsnemu/syserr.c index 9d793e0..7223414 100644 --- a/sgsnemu/syserr.c +++ b/sgsnemu/syserr.c @@ -15,6 +15,7 @@ */ #include <stdarg.h> +#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h> diff --git a/sgsnemu/tun.c b/sgsnemu/tun.c index 0369796..219d040 100644 --- a/sgsnemu/tun.c +++ b/sgsnemu/tun.c @@ -56,6 +56,9 @@ #include <net/if.h> #include <net/if_tun.h> /*#include "sun_if_tun.h"*/ +#elif defined (__FreeBSD__) +#include <net/if.h> +#include <net/if_tun.h> #endif @@ -347,7 +350,7 @@ int tun_setaddr(struct tun_t *this, memset (&ifr, '\0', sizeof (ifr)); ifr.ifr_addr.sa_family = AF_INET; ifr.ifr_dstaddr.sa_family = AF_INET; -#ifndef __sun__ +#ifdef __linux__ ifr.ifr_netmask.sa_family = AF_INET; #endif strncpy(ifr.ifr_name, this->devname, IFNAMSIZ); @@ -391,7 +394,7 @@ int tun_setaddr(struct tun_t *this, if (netmask) { /* Set the netmask */ this->netmask.s_addr = netmask->s_addr; -#ifdef __sun__ +#if defined(__sun__) | defined(__FreeBSD__) ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_addr.s_addr = dstaddr->s_addr; #else @@ -417,8 +420,8 @@ int tun_addroute(struct tun_t *this, struct in_addr *mask) { - /* TODO: Learn how to set routing table on sun */ -#ifndef __sun__ + /* TODO: Learn how to set routing table on sun and FreeBSD */ +#ifdef __linux__ struct rtentry r; int fd; @@ -457,11 +460,11 @@ int tun_addroute(struct tun_t *this, int tun_new(struct tun_t **tun) { -#ifndef __sun__ - struct ifreq ifr; -#else +#ifdef __sun__ int if_fd, ppa = -1; static int ip_fd = 0; +#else + struct ifreq ifr; #endif if (!(*tun = calloc(1, sizeof(struct tun_t)))) { |