forked from acouzens/open5gs
test: Porting FreeBSD
This commit is contained in:
parent
fea48f5a44
commit
852756f902
|
@ -1,131 +0,0 @@
|
|||
---
|
||||
title: FreeBSD
|
||||
head_inline: "<style> .blue { color: blue; } </style>"
|
||||
---
|
||||
|
||||
This guide is based on **FreeBSD Relase 11.1**.
|
||||
{: .blue}
|
||||
|
||||
### Getting MongoDB
|
||||
---
|
||||
|
||||
Install MongoDB with package manager.
|
||||
```bash
|
||||
$ sudo pkg install mongodb
|
||||
```
|
||||
|
||||
Run MongoDB server.
|
||||
```bash
|
||||
$ mkdir -p ./data/db
|
||||
$ mongod --dbpath ./data/db
|
||||
```
|
||||
|
||||
### Setting up TUN device (No persistent after rebooting)
|
||||
---
|
||||
|
||||
Configure the TUN device.
|
||||
```bash
|
||||
$ sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.6 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.7 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.8 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.9 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.10 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.11 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.12 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.13 netmask 255.255.255.255
|
||||
```
|
||||
|
||||
Enable IP forwarding
|
||||
```bash
|
||||
$ sudo sysctl -w net.inet.ip.forwarding=1
|
||||
```
|
||||
|
||||
**Tip:** The script provided in [$GIT_REPO/support/network/restart.sh](https://github.com/{{ site.github_username }}/open5gs/blob/master/support/network/restart.sh) makes it easy to configure the TUN device as follows:
|
||||
`$ sudo ./support/network/restart.sh`
|
||||
{: .notice--info}
|
||||
|
||||
### Building Open5GS
|
||||
---
|
||||
|
||||
Install the depedencies for building the source code.
|
||||
```bash
|
||||
$ sudo pkg install py36-pip ninja gcc bison gsed pkgconf git mongo-c-driver gnutls libgcrypt libidn libyaml libmicrohttpd curl
|
||||
```
|
||||
|
||||
Install Meson using Python.
|
||||
```bash
|
||||
$ sudo pip install --upgrade pip
|
||||
$ sudo pip install meson
|
||||
```
|
||||
|
||||
Git clone.
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/{{ site.github_username }}/open5gs
|
||||
```
|
||||
|
||||
To compile with meson:
|
||||
|
||||
```bash
|
||||
$ cd open5gs
|
||||
$ meson build --prefix=`pwd`/install
|
||||
$ ninja -C build
|
||||
```
|
||||
|
||||
Check whether the compilation is correct.
|
||||
|
||||
**Note:** This should require *sudo* due to access `/dev/tun0`.
|
||||
{: .notice--danger}
|
||||
|
||||
```bash
|
||||
$ sudo ./build/tests/attach/attach ## EPC Only
|
||||
$ sudo ./build/tests/registration/registration ## 5G Core Only
|
||||
```
|
||||
|
||||
Run all test programs as below.
|
||||
|
||||
**Note:** This should require *sudo* due to access `/dev/tun0`.
|
||||
{: .notice--danger}
|
||||
|
||||
```bash
|
||||
$ cd build
|
||||
$ sudo meson test -v
|
||||
```
|
||||
|
||||
**Tip:** You can also check the result of `ninja -C build test` with a tool that captures packets. If you are running `wireshark`, select the `loopback` interface and set FILTER to `s1ap || gtpv2 || pfcp || diameter || gtp || ngap || http2.data.data || http2.headers`. You can see the virtually created packets. [testattach.pcapng]({{ site.url }}{{ site.baseurl }}/assets/pcapng/testattach.pcapng)/[testregistration.pcapng]({{ site.url }}{{ site.baseurl }}/assets/pcapng/testregistration.pcapng)
|
||||
{: .notice--info}
|
||||
|
||||
You need to perform the **installation process**.
|
||||
```bash
|
||||
$ cd build
|
||||
$ ninja install
|
||||
$ cd ../
|
||||
```
|
||||
|
||||
### Building WebUI of Open5GS
|
||||
---
|
||||
|
||||
[Node.js](https://nodejs.org/) is required to build WebUI of Open5GS
|
||||
|
||||
```bash
|
||||
$ sudo pkg install node
|
||||
```
|
||||
|
||||
Install the dependencies to run WebUI
|
||||
|
||||
```bash
|
||||
$ cd webui
|
||||
$ npm install
|
||||
```
|
||||
|
||||
The WebUI runs as an [npm](https://www.npmjs.com/) script.
|
||||
|
||||
```bash
|
||||
$ npm run dev
|
||||
```
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
---
|
||||
title: FreeBSD
|
||||
head_inline: "<style> .blue { color: blue; } </style>"
|
||||
---
|
||||
|
||||
This guide is based on **FreeBSD-11.4-STABLE**.
|
||||
{: .blue}
|
||||
|
||||
## Install **FreeBSD-11.4-STABLE** from Vagrant box (optional)
|
||||
---
|
||||
Vagrant provides a simple way to create and deploy Virtual Machines from
|
||||
pre-built images using VirtualBox, libvirt, or VMWare as a hypervisor engine.
|
||||
This allows the user to quickly create a virtual machine without the hassle
|
||||
of installing the operating system by hand.
|
||||
|
||||
### Install Vagrant
|
||||
---
|
||||
|
||||
The instructions to install Vagrant are provided at
|
||||
[vagrantup.com](https://www.vagrantup.com/).
|
||||
|
||||
|
||||
### Create a FreeBSD-11.4-STABLE Virtual Machine using Vagrant
|
||||
---
|
||||
|
||||
Use the supplied `Vagrantfile` in the `vagrant` directory to create the
|
||||
virtual machine.
|
||||
|
||||
Note that this Vagrantfile is identical to the base FreeBSD 11 box, with
|
||||
the exception that the amount of virtual memory has been increased to 1GB:
|
||||
|
||||
```bash
|
||||
cd vagrant/freebsd
|
||||
vagrant up --provider virtualbox
|
||||
```
|
||||
|
||||
### Log into the newly created FreeBSD VM
|
||||
---
|
||||
|
||||
Use SSH to log into the FreeBSD 11 VM:
|
||||
|
||||
```bash
|
||||
vagrant ssh
|
||||
```
|
||||
|
||||
Note that the Open5GS source is *not* copied into the VM. The instructions
|
||||
below provide the step by step instructions for setting up Open5GS for
|
||||
either a bare metal or virtual FreeBSD 11 system.
|
||||
|
||||
The rest of the commands below are performed inside the FreeBSD VM as the
|
||||
user 'vagrant', or on your bare metal FreeBSD 11 system as any normal user.
|
||||
|
||||
### Getting MongoDB
|
||||
---
|
||||
|
||||
Install MongoDB with package manager.
|
||||
```bash
|
||||
$ sudo pkg install mongodb44
|
||||
```
|
||||
|
||||
Run MongoDB server.
|
||||
```bash
|
||||
$ mkdir -p ./data/db
|
||||
$ mongod --dbpath ./data/db
|
||||
```
|
||||
|
||||
### Setting up network (No persistent after rebooting)
|
||||
---
|
||||
|
||||
Configure the loopback interface.
|
||||
```bash
|
||||
$ sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.6 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.7 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.8 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.9 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.10 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.11 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.12 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.13 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.14 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.15 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.16 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.17 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.18 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.19 netmask 255.255.255.255
|
||||
$ sudo ifconfig lo0 alias 127.0.0.20 netmask 255.255.255.255
|
||||
```
|
||||
|
||||
Enable IP forwarding
|
||||
```bash
|
||||
$ sudo sysctl -w net.inet.ip.forwarding=1
|
||||
$ sudo sysctl -w net.inet6.ip6.forwarding=1
|
||||
```
|
||||
|
||||
**Tip:** The script provided in [$GIT_REPO/misc/netconf.sh](https://github.com/{{ site.github_username }}/open5gs/blob/master/misc/netconf.sh) makes it easy to configure the TUN device as follows:
|
||||
`$ sudo ./misc/netconf.sh`
|
||||
{: .notice--info}
|
||||
|
||||
### Building Open5GS
|
||||
---
|
||||
|
||||
Install the depedencies for building the source code.
|
||||
```bash
|
||||
$ sudo pkg install meson ninja gcc bison gsed pkgconf git mongo-c-driver gnutls libgcrypt libidn libyaml libmicrohttpd nghttp2
|
||||
```
|
||||
|
||||
Configure gcc PATH
|
||||
```bash
|
||||
$ setenv LIBRARY_PATH /usr/local/lib
|
||||
$ setenv C_INCLUDE_PATH /usr/local/include
|
||||
```
|
||||
|
||||
If you are using BASH instead of default CSH,
|
||||
```bash
|
||||
$ export LIBRARY_PATH=/usr/local/lib
|
||||
$ export C_INCLUDE_PATH=/usr/local/include
|
||||
```
|
||||
|
||||
Git clone.
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/{{ site.github_username }}/open5gs
|
||||
```
|
||||
|
||||
To compile with meson:
|
||||
|
||||
```bash
|
||||
$ cd open5gs
|
||||
$ meson build --prefix=`pwd`/install
|
||||
$ ninja -C build
|
||||
```
|
||||
|
||||
**Note:** No source code changes are required for FreeBSD 11.x version. However, in FreeBSD 12.x version, we'll getting a crash with segmentation fault when calling basename(3). To avoid this, you need to change the freeDiameter source code as below.
|
||||
{: .blue}
|
||||
|
||||
```diff
|
||||
$ cd open5gs/subprojects/freeDiameter
|
||||
|
||||
$ diff --git a/include/freeDiameter/libfdproto.h b/include/freeDiameter/libfdproto.h
|
||||
index 52c11ef..cd7f383 100644
|
||||
--- a/include/freeDiameter/libfdproto.h
|
||||
+++ b/include/freeDiameter/libfdproto.h
|
||||
@@ -293,7 +293,7 @@ extern int fd_g_debug_lvl;
|
||||
|
||||
/* A version of __FILE__ without the full path. This is specific to each C file being compiled */
|
||||
static char * file_bname = NULL;
|
||||
-static char * file_bname_init(char * full) { file_bname = basename(full); return file_bname; }
|
||||
+static char * file_bname_init(char * full) { file_bname = __old_basename(full); return file_bname; }
|
||||
#define __STRIPPED_FILE__ (file_bname ?: file_bname_init((char *)__FILE__))
|
||||
|
||||
```
|
||||
|
||||
Now, compile again:
|
||||
{: .blue}
|
||||
|
||||
```bash
|
||||
$ cd open5gs
|
||||
$ ninja -C build
|
||||
```
|
||||
|
||||
Check whether the compilation is correct.
|
||||
|
||||
**Note:** This should require *sudo* due to access `/dev/tun0`.
|
||||
{: .notice--danger}
|
||||
|
||||
```bash
|
||||
$ sudo ./build/tests/attach/attach ## EPC Only
|
||||
$ sudo ./build/tests/registration/registration ## 5G Core Only
|
||||
```
|
||||
|
||||
Run all test programs as below.
|
||||
|
||||
**Note:** This should require *sudo* due to access `/dev/tun0`.
|
||||
{: .notice--danger}
|
||||
|
||||
```bash
|
||||
$ cd build
|
||||
$ sudo meson test -v
|
||||
```
|
||||
|
||||
**Tip:** You can also check the result of `ninja -C build test` with a tool that captures packets. If you are running `wireshark`, select the `loopback` interface and set FILTER to `s1ap || gtpv2 || pfcp || diameter || gtp || ngap || http2.data.data || http2.headers`. You can see the virtually created packets. [testattach.pcapng]({{ site.url }}{{ site.baseurl }}/assets/pcapng/testattach.pcapng)/[testregistration.pcapng]({{ site.url }}{{ site.baseurl }}/assets/pcapng/testregistration.pcapng)
|
||||
{: .notice--info}
|
||||
|
||||
You need to perform the **installation process**.
|
||||
```bash
|
||||
$ cd build
|
||||
$ ninja install
|
||||
$ cd ../
|
||||
```
|
||||
|
||||
### Building WebUI of Open5GS
|
||||
---
|
||||
|
||||
[Node.js](https://nodejs.org/) is required to build WebUI of Open5GS
|
||||
|
||||
```bash
|
||||
$ sudo pkg install node
|
||||
```
|
||||
|
||||
Install the dependencies to run WebUI
|
||||
|
||||
```bash
|
||||
$ cd webui
|
||||
$ npm install
|
||||
```
|
||||
|
||||
The WebUI runs as an [npm](https://www.npmjs.com/) script.
|
||||
|
||||
```bash
|
||||
$ npm run dev
|
||||
```
|
|
@ -32,6 +32,7 @@ head_inline: "<style> ul { padding-bottom: 1em; } </style>"
|
|||
- [Fedora](platform/03-fedora)
|
||||
- [MacOSX(Apple Silicon)](platform/05-macosx-apple-silicon)
|
||||
- [MacOSX(Intel)](platform/06-macosx-intel)
|
||||
- [FreeBSD](platform/07-freebsd)
|
||||
|
||||
- Hardware Specific Notes
|
||||
- [Tested e/gNodeBs](hardware/01-genodebs)
|
||||
|
|
|
@ -245,7 +245,6 @@ libcore_sources = files('''
|
|||
ogs-socknode.h
|
||||
ogs-udp.h
|
||||
ogs-tcp.h
|
||||
ogs-tun.h
|
||||
ogs-queue.h
|
||||
ogs-poll.h
|
||||
ogs-notify.h
|
||||
|
@ -303,12 +302,6 @@ if have_func_kqueue
|
|||
libcore_sources += files('ogs-kqueue.c')
|
||||
endif
|
||||
|
||||
if host_system == 'darwin'
|
||||
libcore_sources += files('ogs-utun.c')
|
||||
else
|
||||
libcore_sources += files('ogs-tun.c')
|
||||
endif
|
||||
|
||||
libcore_inc = include_directories('.')
|
||||
|
||||
libcore = library('ogscore',
|
||||
|
|
|
@ -57,6 +57,9 @@
|
|||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "core/ogs-socknode.h"
|
||||
#include "core/ogs-udp.h"
|
||||
#include "core/ogs-tcp.h"
|
||||
#include "core/ogs-tun.h"
|
||||
#include "core/ogs-queue.h"
|
||||
#include "core/ogs-poll.h"
|
||||
#include "core/ogs-notify.h"
|
||||
|
|
|
@ -108,14 +108,7 @@ extern "C" {
|
|||
#define be64toh(x) OSSwapBigToHostInt64((x))
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
#define le16toh(x) letoh16(x)
|
||||
#define le32toh(x) letoh32(x)
|
||||
#define le64toh(x) letoh64(x)
|
||||
|
||||
#define be16toh(x) betoh16(x)
|
||||
#define be32toh(x) betoh32(x)
|
||||
#define be64toh(x) betoh64(x)
|
||||
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
|
|
|
@ -60,15 +60,10 @@
|
|||
#include <mach/clock.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_time.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "core-config-private.h"
|
||||
|
||||
#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "ogs-core.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#define HAVE_NTOHLL 1
|
||||
#endif
|
||||
|
||||
#include "freeDiameter/libfdcore.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
|
|
@ -110,7 +110,15 @@ strlcpy(dst, src, siz)
|
|||
}
|
||||
|
||||
|
||||
#endif /* __linux__ */
|
||||
/********************************************************
|
||||
* modifed by acetcom
|
||||
*
|
||||
* move down to remove sysctlbyname() in MacOSX and FreeBSD
|
||||
*/
|
||||
|
||||
/* #endif */ /* __linux__ */
|
||||
|
||||
/********************************************************/
|
||||
|
||||
|
||||
#if defined (EMULATE_SYSCTL)
|
||||
|
@ -359,6 +367,16 @@ skip: ;
|
|||
#endif /* __linux__ */
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* modifed by acetcom
|
||||
*
|
||||
* move down to remove sysctlbyname in MacOSX and FreeBSD
|
||||
*/
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
/********************************************************/
|
||||
|
||||
/*
|
||||
* The following two functions implement getsockopt/setsockopt
|
||||
* replacements to talk over a TCP socket.
|
||||
|
|
|
@ -52,6 +52,8 @@ ipfw_cc_flags = ['-D_DEFAULT_SOURCE', '-D_BSD_SOURCE', '-DUSERSPACE',
|
|||
|
||||
if host_system == 'linux'
|
||||
ipfw_cc_flags += ['-DNEED_SYSCTLBYNAME', '-DNEED_SIN_LEN']
|
||||
elif host_system == 'freebsd'
|
||||
ipfw_cc_flags += ['-DNEED_SYSCTLBYNAME']
|
||||
endif
|
||||
|
||||
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include "ogs-ipfw.h"
|
||||
|
||||
#include "ipfw2.h"
|
||||
#include "objs/include_e/netinet/ip_fw.h"
|
||||
|
||||
#include "ogs-ipfw.h"
|
||||
|
||||
#define MAX_NUM_OF_TOKEN 32
|
||||
#define MAX_NUM_OF_RULE_BUFFER 1024
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ subdir('ipfw')
|
|||
subdir('crypt')
|
||||
subdir('app')
|
||||
subdir('sctp')
|
||||
subdir('tun')
|
||||
subdir('dbi')
|
||||
subdir('diameter')
|
||||
subdir('asn1c')
|
||||
|
|
|
@ -44,11 +44,11 @@ libpfcp = library('ogspfcp',
|
|||
version : libogslib_version,
|
||||
c_args : '-DOGS_PFCP_COMPILATION',
|
||||
include_directories : [libpfcp_inc, libinc],
|
||||
dependencies : [libipfw_dep, libcore_dep, libapp_dep, libgtp_dep],
|
||||
dependencies : [libcore_dep, libipfw_dep, libapp_dep, libgtp_dep],
|
||||
install_rpath : libdir,
|
||||
install : true)
|
||||
|
||||
libpfcp_dep = declare_dependency(
|
||||
link_with : libpfcp,
|
||||
include_directories : [libpfcp_inc, libinc],
|
||||
dependencies : [libipfw_dep, libcore_dep, libapp_dep, libgtp_dep])
|
||||
dependencies : [libcore_dep, libipfw_dep, libapp_dep, libgtp_dep])
|
||||
|
|
|
@ -310,7 +310,7 @@ bool ogs_sbi_time_from_string(ogs_time_t *timestamp, char *str)
|
|||
{
|
||||
int rv, i, j, k;
|
||||
struct tm tm;
|
||||
bool is_seconds;
|
||||
bool is_subsecs, is_time, timezone_found;
|
||||
char seconds[MAX_TIMESTR_LEN];
|
||||
char subsecs[MAX_TIMESTR_LEN];
|
||||
ogs_time_t usecs;
|
||||
|
@ -321,18 +321,25 @@ bool ogs_sbi_time_from_string(ogs_time_t *timestamp, char *str)
|
|||
memset(seconds, 0, sizeof seconds);
|
||||
memset(subsecs, 0, sizeof subsecs);
|
||||
|
||||
is_seconds = true;
|
||||
is_subsecs = false;
|
||||
is_time = false;
|
||||
timezone_found = false;
|
||||
i = 0; j = 0, k = 0;
|
||||
while(str[i]) {
|
||||
if (is_seconds == true && str[i] == '.')
|
||||
is_seconds = false;
|
||||
else if (is_seconds == false && (str[i] < '0' || str[i] > '9'))
|
||||
is_seconds = true;
|
||||
if (is_subsecs == false && str[i] == '.')
|
||||
is_subsecs = true;
|
||||
else if (is_subsecs == false && str[i] == 'T')
|
||||
is_time = true;
|
||||
else if (is_subsecs == true && (str[i] < '0' || str[i] > '9'))
|
||||
is_subsecs = false;
|
||||
|
||||
if (is_seconds == true) {
|
||||
if (is_time == true && (str[i] == '+' || str[i] == '-'))
|
||||
timezone_found = true;
|
||||
|
||||
if (is_subsecs == false) {
|
||||
if (str[i] == ':' && i >= 3 &&
|
||||
(str[i-3] == '+' || str[i-3] == '-')) {
|
||||
/* skip timezone ':' character */
|
||||
/* remove ':' character in timezone string range */
|
||||
} else {
|
||||
seconds[j++] = str[i];
|
||||
}
|
||||
|
@ -344,7 +351,10 @@ bool ogs_sbi_time_from_string(ogs_time_t *timestamp, char *str)
|
|||
}
|
||||
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
if (timezone_found == true)
|
||||
ogs_strptime(seconds, "%Y-%m-%dT%H:%M:%S%z", &tm);
|
||||
else
|
||||
ogs_strptime(seconds, "%Y-%m-%dT%H:%M:%S", &tm);
|
||||
#if USE_MATH
|
||||
usecs = (ogs_time_t)floor(atof(subsecs) * 1000000.0 + 0.5);
|
||||
#else
|
||||
|
|
|
@ -34,10 +34,7 @@ libsctp_sources = files('''
|
|||
ogs-sctp.c
|
||||
'''.split())
|
||||
|
||||
sctp_dep = cc.find_library('sctp', required : false)
|
||||
if sctp_dep.found()
|
||||
libsctp_sources += files('ogs-lksctp.c')
|
||||
else
|
||||
if host_system == 'darwin'
|
||||
sctp_dep = dependency('usrsctp',
|
||||
version: ['>=1.0.0', '<2'],
|
||||
fallback: ['usrsctp', 'usrsctp_dep'],
|
||||
|
@ -48,6 +45,9 @@ else
|
|||
|
||||
libsctp_sources += files('ogs-usrsctp.c')
|
||||
libsctp_conf.set('HAVE_USRSCTP', 1)
|
||||
else
|
||||
sctp_dep = cc.find_library('sctp', required : false)
|
||||
libsctp_sources += files('ogs-lksctp.c')
|
||||
endif
|
||||
|
||||
configure_file(output : 'sctp-config.h', configuration : libsctp_conf)
|
||||
|
|
|
@ -22,17 +22,13 @@
|
|||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __ogs_sock_domain
|
||||
|
||||
#if !defined(WIN32)
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/if_tun.h>
|
||||
#endif
|
||||
|
||||
#ifndef IFNAMSIZ
|
||||
#define IFNAMSIZ 32
|
||||
|
@ -42,9 +38,6 @@ ogs_socket_t ogs_tun_open(char *ifname, int len, int is_tap)
|
|||
{
|
||||
ogs_socket_t fd = INVALID_SOCKET;
|
||||
|
||||
#if !defined(__linux__)
|
||||
return fd;
|
||||
#else
|
||||
const char *dev = "/dev/net/tun";
|
||||
int rc;
|
||||
struct ifreq ifr;
|
||||
|
@ -76,48 +69,9 @@ ogs_socket_t ogs_tun_open(char *ifname, int len, int is_tap)
|
|||
cleanup:
|
||||
close(fd);
|
||||
return INVALID_SOCKET;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ogs_tun_set_ip(char *ifname, ogs_ipsubnet_t *gw, ogs_ipsubnet_t *sub)
|
||||
{
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *ogs_tun_read(ogs_socket_t fd, ogs_pkbuf_pool_t *packet_pool)
|
||||
{
|
||||
ogs_pkbuf_t *recvbuf = NULL;
|
||||
int n;
|
||||
|
||||
ogs_assert(fd != INVALID_SOCKET);
|
||||
ogs_assert(packet_pool);
|
||||
|
||||
recvbuf = ogs_pkbuf_alloc(packet_pool, OGS_MAX_PKT_LEN);
|
||||
ogs_assert(recvbuf);
|
||||
ogs_pkbuf_reserve(recvbuf, OGS_TUN_MAX_HEADROOM);
|
||||
ogs_pkbuf_put(recvbuf, OGS_MAX_PKT_LEN-OGS_TUN_MAX_HEADROOM);
|
||||
|
||||
n = ogs_read(fd, recvbuf->data, recvbuf->len);
|
||||
if (n <= 0) {
|
||||
ogs_log_message(OGS_LOG_WARN, ogs_socket_errno, "ogs_read() failed");
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ogs_pkbuf_trim(recvbuf, n);
|
||||
|
||||
return recvbuf;
|
||||
}
|
||||
|
||||
int ogs_tun_write(ogs_socket_t fd, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
ogs_assert(fd != INVALID_SOCKET);
|
||||
ogs_assert(pkbuf);
|
||||
|
||||
if (ogs_write(fd, pkbuf->data, pkbuf->len) <= 0) {
|
||||
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "ogs_write() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "ogs-tun.h"
|
||||
#include "ipfw/ipfw2.h"
|
||||
|
||||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __ogs_sock_domain
|
||||
|
@ -31,13 +32,12 @@
|
|||
#include <netinet6/in6_var.h>
|
||||
#include <netinet6/nd6.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <net/if_utun.h>
|
||||
#include <sys/kern_event.h>
|
||||
#include <sys/kern_control.h>
|
||||
|
||||
static int unit = 0;
|
||||
|
||||
static int utun_open(char *ifname, socklen_t len)
|
||||
static int utun_open(int unit, char *ifname, socklen_t maxlen)
|
||||
{
|
||||
struct sockaddr_ctl addr;
|
||||
struct ctl_info info;
|
||||
|
@ -45,7 +45,7 @@ static int utun_open(char *ifname, socklen_t len)
|
|||
int err = 0;
|
||||
|
||||
ogs_assert(ifname);
|
||||
ogs_assert(len);
|
||||
ogs_assert(maxlen);
|
||||
|
||||
fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL);
|
||||
if (fd < 0) return fd;
|
||||
|
@ -65,7 +65,7 @@ static int utun_open(char *ifname, socklen_t len)
|
|||
err = connect(fd, (struct sockaddr *)&addr, sizeof (addr));
|
||||
if (err != 0) goto on_error;
|
||||
|
||||
err = getsockopt(fd, SYSPROTO_CONTROL, UTUN_OPT_IFNAME, ifname, &len);
|
||||
err = getsockopt(fd, SYSPROTO_CONTROL, UTUN_OPT_IFNAME, ifname, &maxlen);
|
||||
if (err != 0) goto on_error;
|
||||
|
||||
on_error:
|
||||
|
@ -76,18 +76,31 @@ on_error:
|
|||
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
ogs_socket_t ogs_tun_open(char *ifname, int len, int is_tap)
|
||||
ogs_socket_t ogs_tun_open(char *ifname, int maxlen, int is_tap)
|
||||
{
|
||||
ogs_socket_t fd = INVALID_SOCKET;
|
||||
int unit;
|
||||
|
||||
ogs_assert(ifname);
|
||||
|
||||
#define TUNTAP_ID_MAX 256
|
||||
for (unit = 0; unit < TUNTAP_ID_MAX; unit++) {
|
||||
if ((fd = utun_open(ifname, len)) > 0) {
|
||||
#if defined(__APPLE__)
|
||||
/* MacOSX "utun" device driver */
|
||||
if ((fd = utun_open(unit, ifname, maxlen)) > 0) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
/* FreeBSD "tun" device driver */
|
||||
char name[IFNAMSIZ];
|
||||
ogs_snprintf(name, sizeof(name), "/dev/tun%i", unit);
|
||||
if ((fd = open(name, O_RDWR)) > 0) {
|
||||
ogs_snprintf(ifname, maxlen, "tun%i", unit);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (fd < 0) {
|
||||
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "open() failed");
|
||||
|
@ -207,19 +220,6 @@ static int tun_set_ipv4(char *ifname,
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
static int contigmask(uint8_t *p, int len)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
for (i=0; i<len ; i++)
|
||||
if ( (p[i/8] & (1 << (7 - (i%8)))) == 0) /* first bit unset */
|
||||
break;
|
||||
for (n=i+1; n < len; n++)
|
||||
if ( (p[n/8] & (1 << (7 - (n%8)))) != 0)
|
||||
return -1; /* mask not contiguous */
|
||||
return i;
|
||||
}
|
||||
|
||||
static int tun_set_ipv6(char *ifname,
|
||||
ogs_ipsubnet_t *ipaddr, ogs_ipsubnet_t *ipsub)
|
||||
{
|
||||
|
@ -228,24 +228,23 @@ static int tun_set_ipv6(char *ifname,
|
|||
int ret = 0, out_return_code = 0;
|
||||
|
||||
const char *commandLine[OGS_ARG_MAX];
|
||||
char devname[32];
|
||||
char addr[128];
|
||||
|
||||
char buf[OGS_ADDRSTRLEN];
|
||||
int prefixlen;
|
||||
|
||||
ogs_assert(ifname);
|
||||
ogs_assert(ipsub);
|
||||
ogs_assert(ipaddr);
|
||||
|
||||
#define IPV6_BITLEN (OGS_IPV6_LEN * 8)
|
||||
prefixlen = contigmask((uint8_t *)ipsub->mask, IPV6_BITLEN);
|
||||
|
||||
ogs_snprintf(devname, sizeof devname, "utun%d", unit);
|
||||
ogs_snprintf(addr, sizeof addr, "%s/%d",
|
||||
OGS_INET6_NTOP(ipaddr->sub, buf), prefixlen);
|
||||
|
||||
commandLine[0] = "/sbin/ifconfig";
|
||||
commandLine[1] = devname;
|
||||
commandLine[1] = ifname;;
|
||||
commandLine[2] = "inet6";
|
||||
commandLine[3] = addr;
|
||||
commandLine[4] = "up";
|
||||
|
@ -413,63 +412,3 @@ int ogs_tun_set_ip(char *ifname, ogs_ipsubnet_t *gw, ogs_ipsubnet_t *sub)
|
|||
|
||||
return rv;
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *ogs_tun_read(ogs_socket_t fd, ogs_pkbuf_pool_t *packet_pool)
|
||||
{
|
||||
ogs_pkbuf_t *recvbuf = NULL;
|
||||
int n;
|
||||
|
||||
ogs_assert(fd != INVALID_SOCKET);
|
||||
ogs_assert(packet_pool);
|
||||
|
||||
recvbuf = ogs_pkbuf_alloc(packet_pool, OGS_MAX_PKT_LEN);
|
||||
ogs_assert(recvbuf);
|
||||
ogs_pkbuf_reserve(recvbuf, OGS_TUN_MAX_HEADROOM);
|
||||
ogs_pkbuf_put(recvbuf, OGS_MAX_PKT_LEN-OGS_TUN_MAX_HEADROOM);
|
||||
|
||||
n = ogs_read(fd, recvbuf->data, recvbuf->len);
|
||||
if (n <= 0) {
|
||||
ogs_log_message(OGS_LOG_WARN, ogs_socket_errno, "ogs_read() failed");
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ogs_pkbuf_trim(recvbuf, n);
|
||||
|
||||
/* Remove Null/Loopback Header (4bytes) */
|
||||
ogs_pkbuf_pull(recvbuf, 4);
|
||||
|
||||
return recvbuf;
|
||||
}
|
||||
|
||||
int ogs_tun_write(ogs_socket_t fd, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
uint8_t version;
|
||||
uint32_t family;
|
||||
|
||||
ogs_assert(fd != INVALID_SOCKET);
|
||||
ogs_assert(pkbuf);
|
||||
|
||||
version = (*((unsigned char *)pkbuf->data) >> 4) & 0xf;
|
||||
|
||||
if (version == 4) {
|
||||
family = htobe32(AF_INET);
|
||||
} else if (version == 6) {
|
||||
family = htobe32(AF_INET6);
|
||||
} else {
|
||||
ogs_error("Invalid packet [IP version:%d, Packet Length:%d]",
|
||||
version, pkbuf->len);
|
||||
ogs_log_hexdump(OGS_LOG_ERROR, pkbuf->data, pkbuf->len);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
ogs_pkbuf_push(pkbuf, sizeof(family));
|
||||
memcpy(pkbuf->data, &family, sizeof(family));
|
||||
|
||||
if (ogs_write(fd, pkbuf->data, pkbuf->len) <= 0) {
|
||||
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "ogs_write() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
# Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
|
||||
# This file is part of Open5GS.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
libtun_sources = files('''
|
||||
ogs-tun.h
|
||||
|
||||
tunio.c
|
||||
'''.split())
|
||||
|
||||
if host_system == 'linux'
|
||||
libtun_sources += files('linux-setup.c')
|
||||
elif host_system == 'windows'
|
||||
libtun_sources += files('windows-setup.c')
|
||||
else
|
||||
libtun_sources += files('mac-setup.c')
|
||||
endif
|
||||
|
||||
libtun_inc = include_directories('.')
|
||||
|
||||
libtun = library('ogstun',
|
||||
sources : libtun_sources,
|
||||
version : libogslib_version,
|
||||
c_args : '-DOGS_TUN_COMPILATION',
|
||||
include_directories : [libtun_inc, libinc],
|
||||
dependencies : [libcore_dep, libipfw_dep],
|
||||
install : true)
|
||||
|
||||
libtun_dep = declare_dependency(
|
||||
link_with : libtun,
|
||||
include_directories : [libtun_inc, libinc],
|
||||
dependencies : [libcore_dep, libipfw_dep])
|
|
@ -45,7 +45,7 @@ extern "C" {
|
|||
*/
|
||||
#define OGS_TUN_MAX_HEADROOM 16
|
||||
|
||||
ogs_socket_t ogs_tun_open(char *ifname, int len, int is_tap);
|
||||
ogs_socket_t ogs_tun_open(char *ifname, int maxlen, int is_tap);
|
||||
int ogs_tun_set_ip(char *ifname, ogs_ipsubnet_t *gw, ogs_ipsubnet_t *sub);
|
||||
|
||||
ogs_pkbuf_t *ogs_tun_read(ogs_socket_t fd, ogs_pkbuf_pool_t *packet_pool);
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ogs-tun.h"
|
||||
|
||||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __ogs_sock_domain
|
||||
|
||||
ogs_pkbuf_t *ogs_tun_read(ogs_socket_t fd, ogs_pkbuf_pool_t *packet_pool)
|
||||
{
|
||||
ogs_pkbuf_t *recvbuf = NULL;
|
||||
int n;
|
||||
|
||||
ogs_assert(fd != INVALID_SOCKET);
|
||||
ogs_assert(packet_pool);
|
||||
|
||||
recvbuf = ogs_pkbuf_alloc(packet_pool, OGS_MAX_PKT_LEN);
|
||||
ogs_assert(recvbuf);
|
||||
ogs_pkbuf_reserve(recvbuf, OGS_TUN_MAX_HEADROOM);
|
||||
ogs_pkbuf_put(recvbuf, OGS_MAX_PKT_LEN-OGS_TUN_MAX_HEADROOM);
|
||||
|
||||
n = ogs_read(fd, recvbuf->data, recvbuf->len);
|
||||
if (n <= 0) {
|
||||
ogs_log_message(OGS_LOG_WARN, ogs_socket_errno, "ogs_read() failed");
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ogs_pkbuf_trim(recvbuf, n);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* Remove Null/Loopback Header (4bytes) */
|
||||
ogs_pkbuf_pull(recvbuf, 4);
|
||||
#endif
|
||||
|
||||
return recvbuf;
|
||||
}
|
||||
|
||||
int ogs_tun_write(ogs_socket_t fd, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
uint8_t version;
|
||||
uint32_t family;
|
||||
#endif
|
||||
|
||||
ogs_assert(fd != INVALID_SOCKET);
|
||||
ogs_assert(pkbuf);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
version = (*((unsigned char *)pkbuf->data) >> 4) & 0xf;
|
||||
|
||||
if (version == 4) {
|
||||
family = htobe32(AF_INET);
|
||||
} else if (version == 6) {
|
||||
family = htobe32(AF_INET6);
|
||||
} else {
|
||||
ogs_error("Invalid packet [IP version:%d, Packet Length:%d]",
|
||||
version, pkbuf->len);
|
||||
ogs_log_hexdump(OGS_LOG_ERROR, pkbuf->data, pkbuf->len);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
ogs_pkbuf_push(pkbuf, sizeof(family));
|
||||
memcpy(pkbuf->data, &family, sizeof(family));
|
||||
#endif
|
||||
|
||||
if (ogs_write(fd, pkbuf->data, pkbuf->len) <= 0) {
|
||||
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "ogs_write() failed");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ogs-tun.h"
|
||||
|
||||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __ogs_sock_domain
|
||||
|
||||
ogs_socket_t ogs_tun_open(char *ifname, int len, int is_tap)
|
||||
{
|
||||
ogs_error("Not implemented");
|
||||
ogs_assert_if_reached();
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
int ogs_tun_set_ip(char *ifname, ogs_ipsubnet_t *gw, ogs_ipsubnet_t *sub)
|
||||
{
|
||||
ogs_error("Not implemented");
|
||||
ogs_assert_if_reached();
|
||||
return OGS_ERROR;
|
||||
}
|
|
@ -113,7 +113,7 @@ subdir('configs')
|
|||
subdir('lib')
|
||||
subdir('src')
|
||||
subdir('misc')
|
||||
# Don’t build the tests unless we can run them (either natively or in an exe wrapper)
|
||||
# Don't build the tests unless we can run them (either natively or in an exe wrapper)
|
||||
build_tests = not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper())
|
||||
if build_tests
|
||||
subdir('tests')
|
||||
|
|
|
@ -58,7 +58,6 @@ libamf_sources = files('''
|
|||
|
||||
libamf = static_library('amf',
|
||||
sources : libamf_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [libapp_dep,
|
||||
libsctp_dep,
|
||||
libngap_dep,
|
||||
|
|
|
@ -37,7 +37,6 @@ libausf_sources = files('''
|
|||
|
||||
libausf = static_library('ausf',
|
||||
sources : libausf_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [libapp_dep,
|
||||
libcrypt_dep,
|
||||
libsbi_dep],
|
||||
|
|
|
@ -32,7 +32,6 @@ libnrf_sources = files('''
|
|||
|
||||
libnrf = static_library('nrf',
|
||||
sources : libnrf_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [libapp_dep,
|
||||
libdbi_dep,
|
||||
libsbi_dep],
|
||||
|
|
|
@ -39,7 +39,6 @@ libpcf_sources = files('''
|
|||
|
||||
libpcf = static_library('pcf',
|
||||
sources : libpcf_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [libcrypt_dep,
|
||||
libapp_dep,
|
||||
libdbi_dep,
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef SMF_GTP_PATH_H
|
||||
#define SMF_GTP_PATH_H
|
||||
|
||||
#include "ogs-tun.h"
|
||||
#include "ogs-gtp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -96,15 +96,13 @@ libsmf_sources = files('''
|
|||
|
||||
libsmf = static_library('smf',
|
||||
sources : libsmf_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [libapp_dep,
|
||||
libsbi_dep,
|
||||
libngap_dep,
|
||||
libnas_5gs_dep,
|
||||
libdiameter_gx_dep,
|
||||
libgtp_dep,
|
||||
libpfcp_dep,
|
||||
libipfw_dep],
|
||||
libpfcp_dep],
|
||||
install : false)
|
||||
|
||||
libsmf_dep = declare_dependency(
|
||||
|
@ -115,8 +113,7 @@ libsmf_dep = declare_dependency(
|
|||
libnas_5gs_dep,
|
||||
libdiameter_gx_dep,
|
||||
libgtp_dep,
|
||||
libpfcp_dep,
|
||||
libipfw_dep])
|
||||
libpfcp_dep])
|
||||
|
||||
smf_sources = files('''
|
||||
app.c
|
||||
|
|
|
@ -37,7 +37,6 @@ libudm_sources = files('''
|
|||
|
||||
libudm = static_library('udm',
|
||||
sources : libudm_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [libapp_dep,
|
||||
libcrypt_dep,
|
||||
libsbi_dep],
|
||||
|
|
|
@ -33,7 +33,6 @@ libudr_sources = files('''
|
|||
|
||||
libudr = static_library('udr',
|
||||
sources : libudr_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [libapp_dep,
|
||||
libdbi_dep,
|
||||
libsbi_dep],
|
||||
|
|
|
@ -64,16 +64,15 @@ libupf_sources = files('''
|
|||
|
||||
libupf = static_library('upf',
|
||||
sources : libupf_sources,
|
||||
link_with : libipfw,
|
||||
dependencies : [
|
||||
libapp_dep, libdiameter_gx_dep, libgtp_dep, libpfcp_dep, libipfw_dep
|
||||
libapp_dep, libdiameter_gx_dep, libgtp_dep, libpfcp_dep, libtun_dep
|
||||
],
|
||||
install : false)
|
||||
|
||||
libupf_dep = declare_dependency(
|
||||
link_with : libupf,
|
||||
dependencies : [
|
||||
libapp_dep, libdiameter_gx_dep, libgtp_dep, libpfcp_dep, libipfw_dep
|
||||
libapp_dep, libdiameter_gx_dep, libgtp_dep, libpfcp_dep, libtun_dep
|
||||
])
|
||||
|
||||
upf_sources = files('''
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
#define _DEFAULT_SOURCE 1
|
||||
#define _BSD_SOURCE 1
|
||||
|
||||
#include "rule-match.h"
|
||||
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "rule-match.h"
|
||||
|
||||
static int decode_ipv6_header(
|
||||
struct ip6_hdr *ip6_h, uint8_t *proto, uint16_t *hlen)
|
||||
{
|
||||
|
|
|
@ -292,6 +292,7 @@ static void test1_func(abts_case *tc, void *data)
|
|||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
|
||||
#if !defined(__FreeBSD__)
|
||||
/* Send GTP-U ICMP Packet */
|
||||
rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV6);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
@ -300,6 +301,7 @@ static void test1_func(abts_case *tc, void *data)
|
|||
recvbuf = test_gtpu_read(gtpu);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
#endif
|
||||
|
||||
/* Send Attach Request */
|
||||
memset(&sess->pdn_connectivity_param,
|
||||
|
|
|
@ -20,9 +20,9 @@ testinc = include_directories('.')
|
|||
subdir('core')
|
||||
subdir('crypt')
|
||||
subdir('sctp')
|
||||
subdir('unit')
|
||||
subdir('common')
|
||||
subdir('app')
|
||||
subdir('unit')
|
||||
subdir('registration')
|
||||
subdir('vonr')
|
||||
subdir('minimal')
|
||||
|
|
|
@ -308,6 +308,7 @@ static void test1_func(abts_case *tc, void *data)
|
|||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
|
||||
#if !defined(__FreeBSD__)
|
||||
/* Send GTP-U ICMP Packet */
|
||||
rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV6);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
@ -316,6 +317,7 @@ static void test1_func(abts_case *tc, void *data)
|
|||
recvbuf = test_gtpu_read(gtpu);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
#endif
|
||||
|
||||
/* Send Registration request
|
||||
* - Update Registration request type
|
||||
|
@ -845,6 +847,7 @@ static void test2_func(abts_case *tc, void *data)
|
|||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
|
||||
#if !defined(__FreeBSD__)
|
||||
/* Send GTP-U ICMP Packet */
|
||||
rv = test_gtpu_send_ping(gtpu, qos_flow, TEST_PING_IPV6);
|
||||
ABTS_INT_EQUAL(tc, OGS_OK, rv);
|
||||
|
@ -853,6 +856,7 @@ static void test2_func(abts_case *tc, void *data)
|
|||
recvbuf = test_gtpu_read(gtpu);
|
||||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
#endif
|
||||
|
||||
/* Send Registration request
|
||||
* - Update Registration request type
|
||||
|
|
|
@ -1841,6 +1841,9 @@ static void vonr_qos_flow_test1_func(abts_case *tc, void *data)
|
|||
ABTS_PTR_NOTNULL(tc, recvbuf);
|
||||
ogs_pkbuf_free(recvbuf);
|
||||
|
||||
/* TODO: If there is no delay here, it won't work on FreeBSD */
|
||||
ogs_msleep(100);
|
||||
|
||||
/* Send De-registration request */
|
||||
gmmbuf = testgmm_build_de_registration_request(test_ue, 1);
|
||||
ABTS_PTR_NOTNULL(tc, gmmbuf);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test-app.h"
|
||||
#include "mme/mme-context.h"
|
||||
#include "ogs-core.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
abts_suite *test_s1ap_message(abts_suite *suite);
|
||||
abts_suite *test_nas_message(abts_suite *suite);
|
||||
|
@ -43,8 +43,6 @@ const struct testlist {
|
|||
|
||||
static void terminate(void)
|
||||
{
|
||||
mme_context_final();
|
||||
|
||||
ogs_pkbuf_default_destroy();
|
||||
|
||||
ogs_core_terminate();
|
||||
|
@ -85,14 +83,10 @@ int main(int argc, const char *const argv[])
|
|||
}
|
||||
|
||||
ogs_core_initialize();
|
||||
ogs_app_setup_log();
|
||||
|
||||
ogs_pkbuf_default_init(&config);
|
||||
ogs_pkbuf_default_create(&config);
|
||||
|
||||
ogs_app_context_init();
|
||||
mme_context_init();
|
||||
|
||||
atexit(terminate);
|
||||
|
||||
rv = ogs_log_config_domain(optarg.domain_mask, optarg.log_level);
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test-common.h"
|
||||
#include "ogs-s1ap.h"
|
||||
#include "ogs-crypt.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
static void test1_func(abts_case *tc, void *data)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test-common.h"
|
||||
#include "ogs-gtp.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
static void gtp_message_test1(abts_case *tc, void *data)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,10 @@ testunit_unit_sources = files('''
|
|||
testunit_unit_exe = executable('unit',
|
||||
sources : testunit_unit_sources,
|
||||
c_args : [testunit_core_cc_flags, sbi_cc_flags],
|
||||
dependencies : [libtestapp_dep, libmme_dep, libsbi_dep])
|
||||
dependencies : [libs1ap_dep,
|
||||
libgtp_dep,
|
||||
libngap_dep,
|
||||
libnas_eps_dep,
|
||||
libsbi_dep])
|
||||
|
||||
test('unit', testunit_unit_exe, is_parallel : false, suite: 'unit')
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ogs-nas-eps.h"
|
||||
#include "core/abts.h"
|
||||
#include "mme/nas-security.h"
|
||||
|
||||
static void ogs_nas_eps_message_test1(abts_case *tc, void *data)
|
||||
{
|
||||
|
@ -185,6 +185,7 @@ static void ogs_nas_eps_message_test4(abts_case *tc, void *data)
|
|||
ogs_pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void ogs_nas_eps_message_test5(abts_case *tc, void *data)
|
||||
{
|
||||
mme_ue_t ue;
|
||||
|
@ -198,6 +199,7 @@ static void ogs_nas_eps_message_test5(abts_case *tc, void *data)
|
|||
ue.ul_count.sqn = 0xef;
|
||||
ABTS_INT_EQUAL(tc, 0xabcdef, ue.ul_count.i32);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void ogs_nas_eps_message_test6(abts_case *tc, void *data)
|
||||
{
|
||||
|
@ -329,11 +331,15 @@ abts_suite *test_nas_message(abts_suite *suite)
|
|||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
ogs_log_install_domain(&__ogs_nas_domain, "nas", OGS_LOG_ERROR);
|
||||
|
||||
abts_run_test(suite, ogs_nas_eps_message_test1, NULL);
|
||||
abts_run_test(suite, ogs_nas_eps_message_test2, NULL);
|
||||
abts_run_test(suite, ogs_nas_eps_message_test3, NULL);
|
||||
abts_run_test(suite, ogs_nas_eps_message_test4, NULL);
|
||||
#if 0 /* Will remove it in order not to use mme-context.h */
|
||||
abts_run_test(suite, ogs_nas_eps_message_test5, NULL);
|
||||
#endif
|
||||
abts_run_test(suite, ogs_nas_eps_message_test6, NULL);
|
||||
abts_run_test(suite, ogs_nas_eps_message_test7, NULL);
|
||||
abts_run_test(suite, ogs_nas_eps_message_test8, NULL);
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
#include "core/abts.h"
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "amf/ngap-build.h"
|
||||
#include "test-common.h"
|
||||
#include "ogs-ngap.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
static void ngap_message_test1(abts_case *tc, void *data)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
#include "core/abts.h"
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "mme/s1ap-build.h"
|
||||
#include "ogs-s1ap.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
static void s1ap_message_test1(abts_case *tc, void *data)
|
||||
{
|
||||
|
@ -83,6 +101,7 @@ static void s1ap_message_test3(abts_case *tc, void *data)
|
|||
ogs_pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void s1ap_message_test4(abts_case *tc, void *data)
|
||||
{
|
||||
ogs_s1ap_message_t message;
|
||||
|
@ -110,7 +129,6 @@ static void s1ap_message_test4(abts_case *tc, void *data)
|
|||
|
||||
static void s1ap_message_test5(abts_case *tc, void *data)
|
||||
{
|
||||
#if 0
|
||||
ogs_s1ap_message_t message;
|
||||
int rv;
|
||||
ogs_pkbuf_t *pkbuf;
|
||||
|
@ -129,7 +147,6 @@ static void s1ap_message_test5(abts_case *tc, void *data)
|
|||
|
||||
ogs_s1ap_free(&message);
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void s1ap_message_test6(abts_case *tc, void *data)
|
||||
|
@ -161,6 +178,7 @@ static void s1ap_message_test6(abts_case *tc, void *data)
|
|||
s1apbuf->data, s1apbuf->len) == 0);
|
||||
ogs_pkbuf_free(s1apbuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void s1ap_message_test7(abts_case *tc, void *data)
|
||||
{
|
||||
|
@ -267,12 +285,16 @@ abts_suite *test_s1ap_message(abts_suite *suite)
|
|||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
ogs_log_install_domain(&__ogs_s1ap_domain, "s1ap", OGS_LOG_ERROR);
|
||||
|
||||
abts_run_test(suite, s1ap_message_test1, NULL);
|
||||
abts_run_test(suite, s1ap_message_test2, NULL);
|
||||
abts_run_test(suite, s1ap_message_test3, NULL);
|
||||
#if 0 /* Will remove it in order not to use mme-context.h */
|
||||
abts_run_test(suite, s1ap_message_test4, NULL);
|
||||
abts_run_test(suite, s1ap_message_test5, NULL);
|
||||
abts_run_test(suite, s1ap_message_test6, NULL);
|
||||
#endif
|
||||
abts_run_test(suite, s1ap_message_test7, NULL);
|
||||
abts_run_test(suite, s1ap_message_test8, NULL);
|
||||
abts_run_test(suite, s1ap_message_test9, NULL);
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "test-common.h"
|
||||
|
||||
#include "ogs-sbi.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
static void sbi_message_test1(abts_case *tc, void *data)
|
||||
{
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ogs-crypt.h"
|
||||
|
||||
#include "mme/nas-security.h"
|
||||
|
||||
#include "ogs-nas-common.h"
|
||||
#include "core/abts.h"
|
||||
|
||||
static void security_test1(abts_case *tc, void *data)
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://vagrantcloud.com/search.
|
||||
config.vm.box = "freebsd/FreeBSD-11.4-STABLE"
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# NOTE: This will enable public access to the opened port
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine and only allow access
|
||||
# via 127.0.0.1 to disable public access
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
# vb.memory = "1024"
|
||||
# end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# Customize the amount of memory on the VM:
|
||||
vb.memory = "3072"
|
||||
vb.cpus = "1"
|
||||
end
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
# config.vm.provision "shell", inline: <<-SHELL
|
||||
# apt-get update
|
||||
# apt-get install -y apache2
|
||||
# SHELL
|
||||
end
|
Loading…
Reference in New Issue