├── .dockerignore
├── .gitignore
├── .gitmodules
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── build
├── cmake_modules
│ ├── CMakeParseArguments.cmake
│ ├── CMakeUserFindMySQL.cmake
│ ├── CMakeUserUseBison.cmake
│ ├── CMakeUserUseFlex.cmake
│ ├── FindCheck.cmake
│ ├── FindEvent.cmake
│ ├── FindFreeDiameter.cmake
│ ├── FindGCCXML.cmake
│ ├── FindGcrypt.cmake
│ ├── FindGnuTLS.cmake
│ ├── FindKbuild.cmake
│ ├── FindLibXml2.cmake
│ ├── FindMySQL.cmake
│ ├── FindNettle.cmake
│ ├── FindPostgreSQL.cmake
│ ├── FindSCTP.cmake
│ ├── FindThreads.cmake
│ ├── Kbuild.cmake
│ ├── cmake_useful.cmake
│ ├── kbuild_system.cmake
│ ├── kmodule.cmake
│ └── path_prefixes.cmake
├── scripts
│ ├── build_helper
│ ├── build_helper.fb_folly
│ ├── build_helper.libconfig
│ ├── build_helper.spgw
│ └── build_spgwu
└── spgw_u
│ └── CMakeLists.txt
├── ci-scripts
├── Jenkinsfile-GitHub-Docker
├── README.txt
├── checkCodingFormattingRules.sh
├── cppcheck_suppressions.list
├── doGitHubPullRequestTempMerge.sh
├── docker
│ ├── Dockerfile.ci.clang-format
│ └── Dockerfile.ci.cppcheck
├── fail.sh
├── flatten_image.py
├── generateConfigFiles.py
├── generateHtmlReport.py
├── sanityCheckDeploy.py
└── verifySanityCheckDeployment.py
├── docker
├── Dockerfile.rhel8
├── Dockerfile.rocky8
└── Dockerfile.ubuntu
├── docs
├── FEATURE_SET.md
├── FEATURE_SET_PGW.md
├── FEATURE_SET_SGW.md
└── images
│ ├── oai_cn_block_diagram.png
│ └── oai_final_logo.png
├── etc
├── README.md
└── spgw_u.conf
├── openshift
├── README.md
├── bc-base-builder.yaml
├── bc-dev.yaml
├── bc-target.yaml
├── is-base.yml
├── is-dev.yml
└── is-target.yml
├── scripts
├── entrypoint.py
└── healthcheck.sh
└── src
├── .clang-format
├── common
├── 3gpp_23.003.h
├── 3gpp_24.008.h
├── 3gpp_29.244.h
├── 3gpp_29.274.h
├── 3gpp_29.281.h
├── 3gpp_29.500.h
├── 3gpp_29.510.h
├── 3gpp_commons.h
├── CMakeLists.txt
├── common_defs.h
├── common_root_types.c
├── common_root_types.h
├── endpoint.hpp
├── logger.hpp
├── msg
│ ├── itti_async_shell_cmd.hpp
│ ├── itti_msg_s11.hpp
│ ├── itti_msg_s1u.hpp
│ ├── itti_msg_s5s8.hpp
│ ├── itti_msg_sx_restore.hpp
│ └── itti_msg_sxab.hpp
├── rfc_1332.h
├── rfc_1877.h
├── serializable.hpp
└── utils
│ ├── 3gpp_conversions.cpp
│ ├── 3gpp_conversions.hpp
│ ├── CMakeLists.txt
│ ├── async_shell_cmd.cpp
│ ├── async_shell_cmd.hpp
│ ├── conversions.cpp
│ ├── conversions.hpp
│ ├── epc.cpp
│ ├── epc.h
│ ├── fqdn.cpp
│ ├── fqdn.hpp
│ ├── get_gateway_netlink.cpp
│ ├── get_gateway_netlink.hpp
│ ├── if.cpp
│ ├── if.hpp
│ ├── pid_file.cpp
│ ├── pid_file.hpp
│ ├── string.cpp
│ ├── string.hpp
│ ├── thread_sched.cpp
│ ├── thread_sched.hpp
│ └── uint_generator.hpp
├── gtpv1u
├── 3gpp_29.281.cpp
├── 3gpp_29.281.hpp
├── CMakeLists.txt
├── gtpu.h
├── gtpv1u.cpp
├── gtpv1u.hpp
└── msg_gtpv1u.hpp
├── gtpv2c
├── 3gpp_29.274.cpp
├── 3gpp_29.274.hpp
├── CMakeLists.txt
├── gtpv2c.cpp
├── gtpv2c.hpp
└── msg_gtpv2c.hpp
├── itti
├── itti.cpp
├── itti.hpp
├── itti_msg.cpp
└── itti_msg.hpp
├── oai_spgwu
├── CMakeLists.txt
├── main.cpp
├── options.cpp
└── options.hpp
├── pfcp
├── 3gpp_29.244.cpp
├── 3gpp_29.244.hpp
├── CMakeLists.txt
├── msg_pfcp.hpp
├── pfcp.cpp
└── pfcp.hpp
├── spgwu
├── CMakeLists.txt
├── simpleswitch
│ ├── CMakeLists.txt
│ ├── pfcp_far.cpp
│ ├── pfcp_far.hpp
│ ├── pfcp_pdr.cpp
│ ├── pfcp_pdr.hpp
│ ├── pfcp_session.cpp
│ ├── pfcp_session.hpp
│ ├── pfcp_switch.cpp
│ ├── pfcp_switch.hpp
│ ├── spgwu_s1u.cpp
│ └── spgwu_s1u.hpp
├── spgwu_app.cpp
├── spgwu_app.hpp
├── spgwu_config.cpp
├── spgwu_config.hpp
├── spgwu_nrf.cpp
├── spgwu_nrf.hpp
├── spgwu_pfcp_association.cpp
├── spgwu_pfcp_association.hpp
├── spgwu_profile.cpp
├── spgwu_profile.hpp
├── spgwu_sx.cpp
└── spgwu_sx.hpp
└── udp
├── CMakeLists.txt
├── udp.cpp
└── udp.hpp
/.dockerignore:
--------------------------------------------------------------------------------
1 | # Any CI/CD artifact
2 | openair-spgwu.tar.bz2
3 | archives
4 | *-cfg.sh
5 | *-env.list
6 | src/oai_rules_result*txt
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "src/common-src"]
2 | path = src/common-src
3 | url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-src.git
4 | [submodule "build/common-build"]
5 | path = build/common-build
6 | url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-build.git
7 | [submodule "ci-scripts/common-ci"]
8 | path = ci-scripts/common-ci
9 | url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-ci.git
10 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # RELEASE NOTES: #
2 |
3 | ## v1.5.1 -- May 2023 ##
4 |
5 | * Support for rocky linux 8.7
6 | * Increasing size of hashmap tables
7 | * Code Refactoring for:
8 | * Logging mechanism (runtime log level selection)
9 | * Published image on Docker-Hub is using now Ubuntu-20 as base image
10 | * We will soon obsolete the build system for Ubuntu18.04
11 |
12 | ## v1.5.0 -- January 2023 ##
13 |
14 | * feat(fqdn): giving some time for FQDN resolution
15 | * Docker image improvements
16 | * Fixed docker exit by catching SIGTERM
17 | * Ubuntu22 full support
18 |
19 | ## v1.4.0 -- July 2022 ##
20 |
21 | * Fix for handling S-NSSAI
22 | * Add support for multiple slices via config file
23 | * Allowed reusing GTPv1-U socket
24 | * Fix GTPU offset sequence number
25 | * Fix configurable number of DL threads for data path
26 | * Official images produced by CI are pushed to `oaisoftwarealliance` Docker-Hub Team account
27 | * Reduce image size
28 | * Skipping release tag v1.3.0 to be in sync with OAI CN 5G network functions
29 |
30 | ## v1.2.0 -- February 2022 ##
31 |
32 | * Obsolescence of Legacy OAI-MME
33 | * Build fixes
34 | * Docker image layer optimization
35 |
36 | ## v1.1.5 -- December 2021 ##
37 |
38 | * Disable association request if NF registration is enabled
39 |
40 | ## v1.1.4 -- October 2021 ##
41 |
42 | * Fix build issue
43 | * Fix GTPU DL encapsulation: 8 extraneous bytes
44 |
45 | ## v1.1.3 -- October 2021 ##
46 |
47 | * Adding 5G features
48 | - HTTP2 support
49 |
50 | ## v1.1.2 -- July 2021 ##
51 |
52 | * Adding 5G features
53 | - NRF discovery and FQDN support
54 |
55 | ## v1.1.1 -- March 2021 ##
56 |
57 | * GTP-U extension headers for 5G support
58 | - disabled by default for 4G usage
59 |
60 | ## v1.1.0 -- February 2021 ##
61 |
62 | * Cloud-native support
63 | * RHEL8 support
64 | * A lot of bug fixes/improvements
65 | - TCP checksum fix --> better TCP throughput
66 | - Multi-Threading
67 | - Protection to prevent running multiple times the executable
68 | - ...
69 | * Last release before Multi-SPGW-U-instance support
70 |
71 | ## v1.0.0 -- May 2019 ##
72 |
73 | * First release, Able to serve a MME with basic attach, detach, release, paging procedures, default bearer only.
74 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to OpenAir-CN #
2 |
3 | We want to make contributing to this project as easy and transparent as possible.
4 |
5 | Please refer to the steps described on our website: [How to contribute to OAI](https://www.openairinterface.org/?page_id=112)
6 |
7 | 1. Sign and return a Contributor License Agreement to OAI team.
8 | 2. Create an account on [GitHub](https://github.com).
9 | 3. Provide the identifiant of this account to the OAI team (mailto:contact@openairinterface.org) so you have developer rights on this repository.
10 | 4. The policies are described in these wiki pages: [OAI Policies](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/oai-policies-home)
11 | - You can fork onto another hosting system. But we will **NOT** accept a pull request from a forked repository.
12 | * This decision was made for the license reasons.
13 | * The Continuous Integration will reject your pull request.
14 | - All pull requests SHALL have **`develop`** branch as target branch.
15 |
16 | ## Synchronizing GIT sub-modules ##
17 |
18 | We are using nested GIT submodules. To synchronize them, the 2 most important commands to know are :
19 |
20 | 1. `git submodule deinit --force .`
21 | 2. `git submodule update --init --recursive`
22 |
23 | If you have non-tracked files or modified files within git submodules, these commands may not work.
24 |
25 | Use the `--verbose` option to see the execution of each command.
26 |
27 | If the synchronization fails, you may need to go into the path of the failing git-submodule(s) and clean the workspace from non-tracked/modified files.
28 |
29 | ## Coding Styles ##
30 |
31 | We are using `clang-format` as formatting tool on the C/C++ code.
32 |
33 | At the time of writing (March 30th, 2020), we are using `clang-format` version 8.0.0 or above. By default, on a Ubuntu bionic Desktop edition, you would install version 6.0.0.
34 |
35 | So it is very likely you will have to install it manually. Again, at the time of writing, the working version we found was 9.0.0.
36 |
37 | ```bash
38 | $ wget https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
39 | $ mkdir clang_tmp
40 | $ tar xvfJ clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -C ./clang_tmp
41 | $ sudo cp clang_tmp/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format /usr/bin/clang-format
42 | $ rm -Rf clang*
43 | $ clang-format --version
44 | clang-format version 9.0.0 (tags/RELEASE_900/final)
45 | ```
46 |
47 | How to format:
48 |
49 | ```bash
50 | $ cd myClonedWorkspace/src
51 | $ clang-format -i theFilesYouWantToFormat
52 | ```
53 |
54 | ## License ##
55 |
56 | By contributing to OpenAirInterface, you agree that your contributions will be licensed under the [LICENSE](LICENSE) file in the root directory of this source tree.
57 |
58 | ## Continuous Integration process ##
59 |
60 | 1. You push your modified code with the new branch onto our [official GitHub repository](https://github.com/OPENAIRINTERFACE/openair-spgwu-tiny).
61 | - Please make the name of the branch explicit and short.
62 | 2. You create a pull request from the [dedicated web page](https://github.com/OPENAIRINTERFACE/openair-spgwu-tiny/pulls).
63 | - The `target` (`base` in the web-page) branch **SHALL be `develop`**.
64 | - The `source` (`compare` in the web-page) branch is your branch.
65 | 3. Our Continuous Integration (CI) process will be triggered automatically on your proposed modified code and check the validity.
66 | - Check build
67 | - Check some formatting rules
68 | - Run a bunch of tests
69 | 4. If at least one of these steps fails, you will have to push corrections onto your source branch.
70 | - The step 3. will be again automatically triggered on this new commit.
71 | - Please wait that your run is finished before committing and pushing new modifications on your source branch.
72 | - That will allow fairness on the CI usage to other contributors.
73 | 4. When this automated process passes, one of our CI administrators will review your changes or assign a senior contributor
74 | to do a peer-review.
75 | 5. Once the peer reviewer accepts your modification, one of our CI administrators will accept and merge your pull request
76 | - The CI will run again on the new `develop` branch commit.
77 | - The source branch WILL be deleted by one of our CI administrators.
78 |
79 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ------------------------------------------------------------------------------
6 |
7 | OPENAIR-CN
8 | An implementation of the Evolved Packet Core network.
9 |
10 | ------------------------------------------------------------------------------
11 |
12 |
13 |
14 |
15 |
16 |
17 | Openair-cn is an implementation of the 3GPP specifications concerning the
18 | Evolved Packet Core Networks, that means it contains the implementation of the
19 | following network elements:
20 |
21 | * MME,
22 | * HSS,
23 | * S-GW+P-GW.
24 |
25 | Each element implementation has its own repository: this repository (`openair-spgwu-tiny`) is meant for SPGW-U.
26 |
27 | # openair-spgwu-tiny
28 |
29 | In the `Control / User Planes Separation` (a.k.a. `CUPS`) of SPGW, only the SPGW-U (User Plane) implementation is available in this repo.
30 |
31 | This component can be deployed:
32 |
33 | * As first intended as `4G-LTE` Core Network User Plane function.
34 | * But now also as a `5G` Core Network User Plane function (a.k.a. `UPF`)
35 |
36 | It is distributed under `OAI Public License V1.1`. See [OAI Website for more details](https://www.openairinterface.org/?page_id=698).
37 |
38 | The text for `OAI Public License V1.1` is also available under [LICENSE](LICENSE) file in the same directory.
39 |
40 | # Where to start
41 |
42 | The Openair-cn SPGW-U code is written, executed, and tested on `UBUNTU` server `bionic` version.
43 |
44 | It is also built and tested on `RHEL8` platform (such as `Openshift`).
45 |
46 | More details on the deployment options and the supported feature set is available on this [page](docs/FEATURE_SET.md).
47 |
48 | # Collaborative work
49 |
50 | This source code is managed through a GITHUB, a collaborative development platform
51 |
52 | Process is explained in [CONTRIBUTING](CONTRIBUTING.md) file.
53 |
54 | # Directory structure
55 |
56 |
57 | openair-spgwu-tiny
58 | ├── build : Build directory, contains targets and object files generated by compilation of network functions.
59 | │ ├── log : Directory containing build log files.
60 | │ ├── scripts : Directory containing scripts for building network functions.
61 | │ └── spgw_u : Directory containing CMakefile.txt and object files generated by compilation of SPGW-U network function.
62 | ├── ci-scripts : Directory containing scripts for the CI process.
63 | ├── docker : Directory containing dockerfiles to create images.
64 | ├── docs : Directory containing documentation on the supported feature set.
65 | │ └── images : Directory containing images for the documentation.
66 | ├── etc : Directory containing the configuration files to be deployed for each network function.
67 | ├── openshift : Directory containing YAML files for build within OpenShift context.
68 | ├── scripts : Directory containing entrypoint script for container images.
69 | └── src : Source files of network functions.
70 | ├── common : Common header files
71 | │ ├── msg : ITTI messages definitions.
72 | │ └── utils : Common utilities.
73 | ├── gtpv1u : Generic GTPV1-U stack implementation
74 | ├── gtpv2c : Generic GTPV2-C stack implementation
75 | ├── itti : Inter task interface
76 | ├── oai_spgwu : SPGW-U main directory, contains the "main" CMakeLists.txt file.
77 | │ └── simpleswitch : Very Basic Switch implementation.
78 | ├── pfcp : Generic PFCP stack implementation.
79 | └── udp : UDP server implementation.
80 |
81 |
82 |
--------------------------------------------------------------------------------
/build/cmake_modules/CMakeParseArguments.cmake:
--------------------------------------------------------------------------------
1 | # Analogue for standard CMake module with same name, appeared in CMake 2.8.3.
2 | #
3 | # Used for compatibility with older versions of cmake.
4 |
5 | function(cmake_parse_arguments prefix options one_value_keywords multi_value_keywords)
6 | set(all_keywords ${options} ${one_value_keywords} ${multi_value_keywords})
7 | # Clear variables before parsing.
8 | foreach(arg ${one_value_keywords} ${multie_value_keywords})
9 | set(cpa_${arg})
10 | endforeach()
11 |
12 | foreach(arg ${options})
13 | set(cpa_${arg} FALSE)
14 | endforeach()
15 |
16 | set(cpa_UNPARSED_ARGUMENTS)
17 |
18 | set(current_keyword)
19 | # Classification for current_keyword:
20 | # 'ONE' or 'MULTY'.
21 | set(current_keyword_type)
22 |
23 | # now iterate over all arguments and fill the result variables
24 | foreach(arg ${ARGN})
25 | list(FIND all_keywords ${arg} keyword_index)
26 |
27 | if(keyword_index EQUAL -1)
28 | if(current_keyword)
29 | if(current_keyword_type STREQUAL "ONE")
30 | set(cpa_${current_keyword} ${arg})
31 | set(current_keyword)
32 | else(current_keyword_type STREQUAL "ONE")
33 | list(APPEND cpa_${current_keyword} ${arg})
34 | endif(current_keyword_type STREQUAL "ONE")
35 | else(current_keyword)
36 | list(APPEND cpa_UNPARSED_ARGUMENTS ${arg})
37 | endif(current_keyword)
38 | else(keyword_index EQUAL -1)
39 | if(current_keyword AND current_keyword_type STREQUAL "ONE")
40 | message(SEND_ERROR "Value is expected for one-value-keyword ${current_keyword}")
41 | endif(current_keyword AND current_keyword_type STREQUAL "ONE")
42 | list(FIND options ${arg} option_index)
43 | if(option_index EQUAL -1)
44 | set(current_keyword ${arg})
45 | list(FIND one_value_keywords ${arg} one_value_index)
46 | if(one_value_index EQUAL -1)
47 | set(current_keyword_type "MULTI")
48 | else(one_value_index EQUAL -1)
49 | set(current_keyword_type "ONE")
50 | endif(one_value_index EQUAL -1)
51 | else(option_index EQUAL -1)
52 | set(current_keyword)
53 | set(cpa_${arg} TRUE)
54 | endif(option_index EQUAL -1)
55 | endif(keyword_index EQUAL -1)
56 | endforeach(arg ${ARGN})
57 |
58 | if(current_keyword AND current_keyword_type STREQUAL "ONE")
59 | message(SEND_ERROR "Value is expected for one-value-keyword ${current_keyword}")
60 | endif(current_keyword AND current_keyword_type STREQUAL "ONE")
61 |
62 | # propagate the result variables to the caller:
63 | foreach(keyword ${all_keywords} UNPARSED_ARGUMENTS)
64 | set(${prefix}_${keyword} ${cpa_${keyword}} PARENT_SCOPE)
65 | endforeach(keyword ${all_keywords})
66 | endfunction(cmake_parse_arguments prefix options one_value_keywords multi_value_keywords)
67 |
--------------------------------------------------------------------------------
/build/cmake_modules/CMakeUserFindMySQL.cmake:
--------------------------------------------------------------------------------
1 | # - Find mysqlclient
2 | # Find the native MySQL includes and library
3 | #
4 | # MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
5 | # MYSQL_LIBRARIES - List of libraries when using MySQL.
6 | # MYSQL_FOUND - True if MySQL found.
7 |
8 | IF (MYSQL_INCLUDE_DIR)
9 | # Already in cache, be silent
10 | SET(MYSQL_FIND_QUIETLY TRUE)
11 | ENDIF (MYSQL_INCLUDE_DIR)
12 |
13 | FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
14 | /usr/local/include/mysql
15 | /usr/include/mysql
16 | )
17 |
18 | SET(MYSQL_NAMES mysqlclient mysqlclient_r)
19 | FIND_LIBRARY(MYSQL_LIBRARY
20 | NAMES ${MYSQL_NAMES}
21 | PATHS /usr/lib /usr/local/lib
22 | PATH_SUFFIXES mysql
23 | )
24 |
25 | IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
26 | SET(MYSQL_FOUND TRUE)
27 | SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
28 | ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
29 | SET(MYSQL_FOUND FALSE)
30 | SET( MYSQL_LIBRARIES )
31 | ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
32 |
33 | IF (MYSQL_FOUND)
34 | IF (NOT MYSQL_FIND_QUIETLY)
35 | MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
36 | ENDIF (NOT MYSQL_FIND_QUIETLY)
37 | ELSE (MYSQL_FOUND)
38 | IF (MYSQL_FIND_REQUIRED)
39 | MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
40 | MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
41 | ENDIF (MYSQL_FIND_REQUIRED)
42 | ENDIF (MYSQL_FOUND)
43 |
44 | MARK_AS_ADVANCED(
45 | MYSQL_LIBRARY
46 | MYSQL_INCLUDE_DIR
47 | )
48 |
49 |
--------------------------------------------------------------------------------
/build/cmake_modules/CMakeUserUseBison.cmake:
--------------------------------------------------------------------------------
1 | # - Look for GNU Bison, the parser generator
2 | # Based off a news post from Andy Cedilnik at Kitware
3 | # Defines the following:
4 | # BISON_EXECUTABLE - path to the bison executable
5 | # BISON_FILE - parse a file with bison
6 | # BISON_PREFIX_OUTPUTS - Set to true to make BISON_FILE produce prefixed
7 | # symbols in the generated output based on filename.
8 | # So for ${filename}.y, you'll get ${filename}parse(), etc.
9 | # instead of yyparse().
10 | # BISON_GENERATE_DEFINES - Set to true to make BISON_FILE output the matching
11 | # .h file for a .c file. You want this if you're using
12 | # flex.
13 |
14 | IF(NOT DEFINED BISON_PREFIX_OUTPUTS)
15 | SET(BISON_PREFIX_OUTPUTS FALSE)
16 | ENDIF(NOT DEFINED BISON_PREFIX_OUTPUTS)
17 |
18 | IF(NOT DEFINED BISON_GENERATE_DEFINES)
19 | SET(BISON_GENERATE_DEFINES FALSE)
20 | ENDIF(NOT DEFINED BISON_GENERATE_DEFINES)
21 |
22 | IF(NOT BISON_EXECUTABLE)
23 | MESSAGE(STATUS "Looking for bison")
24 | FIND_PROGRAM(BISON_EXECUTABLE bison)
25 | IF(BISON_EXECUTABLE)
26 | MESSAGE(STATUS "Looking for bison -- ${BISON_EXECUTABLE}")
27 | ENDIF(BISON_EXECUTABLE)
28 | ENDIF(NOT BISON_EXECUTABLE)
29 |
30 | IF(BISON_EXECUTABLE)
31 | MACRO(BISON_FILE FILENAME)
32 | GET_FILENAME_COMPONENT(PATH "${FILENAME}" PATH)
33 | IF("${PATH}" STREQUAL "")
34 | SET(PATH_OPT "")
35 | ELSE("${PATH}" STREQUAL "")
36 | SET(PATH_OPT "/${PATH}")
37 | ENDIF("${PATH}" STREQUAL "")
38 | GET_FILENAME_COMPONENT(HEAD "${FILENAME}" NAME_WE)
39 | IF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
40 | FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
41 | ENDIF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
42 | IF(BISON_PREFIX_OUTPUTS)
43 | SET(PREFIX "${HEAD}")
44 | ELSE(BISON_PREFIX_OUTPUTS)
45 | SET(PREFIX "yy")
46 | ENDIF(BISON_PREFIX_OUTPUTS)
47 | SET(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}/${HEAD}.tab.c")
48 | IF(BISON_GENERATE_DEFINES)
49 | SET(HEADER "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}/${HEAD}.tab.h")
50 | ADD_CUSTOM_COMMAND(
51 | OUTPUT "${OUTFILE}" "${HEADER}"
52 | COMMAND "${BISON_EXECUTABLE}"
53 | ARGS "--name-prefix=${PREFIX}"
54 | "--defines"
55 | "--output-file=${OUTFILE}"
56 | "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
57 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
58 | SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" "${HEADER}" PROPERTIES GENERATED TRUE)
59 | SET_SOURCE_FILES_PROPERTIES("${HEADER}" PROPERTIES HEADER_FILE_ONLY TRUE)
60 | ELSE(BISON_GENERATE_DEFINES)
61 | ADD_CUSTOM_COMMAND(
62 | OUTPUT "${OUTFILE}"
63 | COMMAND "${BISON_EXECUTABLE}"
64 | ARGS "--name-prefix=${PREFIX}"
65 | "--output-file=${OUTFILE}"
66 | "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
67 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
68 | SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
69 | ENDIF(BISON_GENERATE_DEFINES)
70 | ENDMACRO(BISON_FILE)
71 | ENDIF(BISON_EXECUTABLE)
72 |
--------------------------------------------------------------------------------
/build/cmake_modules/CMakeUserUseFlex.cmake:
--------------------------------------------------------------------------------
1 | # - Look for GNU flex, the lexer generator.
2 | # Defines the following:
3 | # FLEX_EXECUTABLE - path to the flex executable
4 | # FLEX_FILE - parse a file with flex
5 | # FLEX_PREFIX_OUTPUTS - Set to true to make FLEX_FILE produce outputs of
6 | # lex.${filename}.c, not lex.yy.c . Passes -P to flex.
7 |
8 | IF(NOT DEFINED FLEX_PREFIX_OUTPUTS)
9 | SET(FLEX_PREFIX_OUTPUTS FALSE)
10 | ENDIF(NOT DEFINED FLEX_PREFIX_OUTPUTS)
11 |
12 | IF(NOT FLEX_EXECUTABLE)
13 | MESSAGE(STATUS "Looking for flex")
14 | FIND_PROGRAM(FLEX_EXECUTABLE flex)
15 | IF(FLEX_EXECUTABLE)
16 | MESSAGE(STATUS "Looking for flex -- ${FLEX_EXECUTABLE}")
17 | ENDIF(FLEX_EXECUTABLE)
18 | ENDIF(NOT FLEX_EXECUTABLE)
19 |
20 | IF(FLEX_EXECUTABLE)
21 | MACRO(FLEX_FILE FILENAME)
22 | GET_FILENAME_COMPONENT(PATH "${FILENAME}" PATH)
23 | IF("${PATH}" STREQUAL "")
24 | SET(PATH_OPT "")
25 | ELSE("${PATH}" STREQUAL "")
26 | SET(PATH_OPT "/${PATH}")
27 | ENDIF("${PATH}" STREQUAL "")
28 | IF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
29 | FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
30 | ENDIF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
31 | IF(FLEX_PREFIX_OUTPUTS)
32 | GET_FILENAME_COMPONENT(PREFIX "${FILENAME}" NAME_WE)
33 | ELSE(FLEX_PREFIX_OUTPUTS)
34 | SET(PREFIX "yy")
35 | ENDIF(FLEX_PREFIX_OUTPUTS)
36 | SET(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}/lex.${PREFIX}.c")
37 | ADD_CUSTOM_COMMAND(
38 | OUTPUT "${OUTFILE}"
39 | COMMAND "${FLEX_EXECUTABLE}"
40 | ARGS "--prefix=${PREFIX}"
41 | "--outfile=${OUTFILE}"
42 | "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
43 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
44 | SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
45 | ENDMACRO(FLEX_FILE)
46 | ENDIF(FLEX_EXECUTABLE)
47 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindCheck.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find the CHECK libraries
2 | # Once done this will define
3 | #
4 | # CHECK_FOUND - system has check
5 | # CHECK_INCLUDE_DIR - the check include directory
6 | # CHECK_LIBRARIES - check library
7 | #
8 | # This configuration file for finding libcheck is originally from
9 | # the opensync project. The originally was downloaded from here:
10 | # opensync.org/browser/branches/3rd-party-cmake-modules/modules/FindCheck.cmake
11 | #
12 | # Copyright (c) 2007 Daniel Gollub
13 | # Copyright (c) 2007 Bjoern Ricks
14 | #
15 | # Redistribution and use is allowed according to the terms of the New
16 | # BSD license.
17 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
18 |
19 |
20 | INCLUDE( FindPkgConfig )
21 |
22 | # Take care about check.pc settings
23 | PKG_SEARCH_MODULE( CHECK check )
24 |
25 | # Look for CHECK include dir and libraries
26 | IF( NOT CHECK_FOUND )
27 | IF ( CHECK_INSTALL_DIR )
28 | MESSAGE ( STATUS "Using override CHECK_INSTALL_DIR to find check" )
29 | SET ( CHECK_INCLUDE_DIR "${CHECK_INSTALL_DIR}/include" )
30 | SET ( CHECK_INCLUDE_DIRS "${CHECK_INCLUDE_DIR}" )
31 | FIND_LIBRARY( CHECK_LIBRARY NAMES check PATHS "${CHECK_INSTALL_DIR}/lib" )
32 | FIND_LIBRARY( COMPAT_LIBRARY NAMES compat PATHS "${CHECK_INSTALL_DIR}/lib" )
33 | SET ( CHECK_LIBRARIES "${CHECK_LIBRARY}" "${COMPAT_LIBRARY}" )
34 | ELSE ( CHECK_INSTALL_DIR )
35 | FIND_PATH( CHECK_INCLUDE_DIR check.h )
36 | FIND_LIBRARY( CHECK_LIBRARIES NAMES check )
37 | ENDIF ( CHECK_INSTALL_DIR )
38 |
39 | IF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
40 | SET( CHECK_FOUND 1 )
41 | IF ( NOT Check_FIND_QUIETLY )
42 | MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" )
43 | ENDIF ( NOT Check_FIND_QUIETLY )
44 | ELSE ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
45 | IF ( Check_FIND_REQUIRED )
46 | MESSAGE( FATAL_ERROR "Could NOT find CHECK" )
47 | ELSE ( Check_FIND_REQUIRED )
48 | IF ( NOT Check_FIND_QUIETLY )
49 | MESSAGE( STATUS "Could NOT find CHECK" )
50 | ENDIF ( NOT Check_FIND_QUIETLY )
51 | ENDIF ( Check_FIND_REQUIRED )
52 | ENDIF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
53 | ENDIF( NOT CHECK_FOUND )
54 |
55 | # Hide advanced variables from CMake GUIs
56 | MARK_AS_ADVANCED( CHECK_INCLUDE_DIR CHECK_LIBRARIES )
57 |
58 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindEvent.cmake:
--------------------------------------------------------------------------------
1 | # Find Libevent
2 | # http://monkey.org/~provos/libevent/
3 | #
4 | # Once done, this will define:
5 | #
6 | # Event_FOUND - system has Event
7 | # Event_INCLUDE_DIRS - the Event include directories
8 | # Event_LIBRARIES - link these to use Event
9 | #
10 |
11 | if (EVENT_INCLUDE_DIR AND EVENT_LIBRARY)
12 | # Already in cache, be silent
13 | set(EVENT_FIND_QUIETLY TRUE)
14 | endif (EVENT_INCLUDE_DIR AND EVENT_LIBRARY)
15 |
16 | find_path(EVENT_INCLUDE_DIR event.h
17 | PATHS /usr/include
18 | PATH_SUFFIXES event
19 | )
20 |
21 | find_library(EVENT_LIBRARY
22 | NAMES event
23 | PATHS /usr/lib /usr/local/lib
24 | )
25 |
26 | set(EVENT_LIBRARIES ${EVENT_LIBRARY} )
27 |
28 | add_definitions(-DLIBNET_LIL_ENDIAN)
29 |
30 | include(FindPackageHandleStandardArgs)
31 | find_package_handle_standard_args(EVENT
32 | DEFAULT_MSG
33 | EVENT_INCLUDE_DIR
34 | EVENT_LIBRARIES
35 | )
36 |
37 | mark_as_advanced(EVENT_INCLUDE_DIR EVENT_LIBRARY)
38 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindFreeDiameter.cmake:
--------------------------------------------------------------------------------
1 | # - Find freediameter
2 | # Find the native FreeDiameter includes and libraries
3 | #
4 | # FREEDIAMETER_FOUND - True if FreeDiameter found.
5 | # FREEDIAMETER_INCLUDE_DIR - where to find gnutls.h, etc.
6 | # FREEDIAMETER_LIBRARIES - List of libraries when using gnutls.
7 | # FREEDIAMETER_HSS_S6A_ENABLED - true if FreeDiameter enabled for S6A interface
8 |
9 |
10 | if (FREEDIAMETER_INCLUDE_DIR AND FREEDIAMETER_LIBRARIES)
11 | set(FREEDIAMETER_FIND_QUIETLY TRUE)
12 | endif (FREEDIAMETER_INCLUDE_DIR AND FREEDIAMETER_LIBRARIES)
13 |
14 | # Include dir
15 | find_path(FREEDIAMETER_INCLUDE_DIR
16 | NAMES
17 | freeDiameter/freeDiameter-host.h
18 | freeDiameter/libfdcore.h
19 | freeDiameter/libfdproto.h
20 | )
21 |
22 | # Library
23 | find_library(FREEDIAMETER_LIBRARY
24 | NAMES fdcore
25 | )
26 |
27 | # handle the QUIETLY and REQUIRED arguments and set FREEDIAMETER_FOUND to TRUE if
28 | # all listed variables are TRUE
29 | INCLUDE(FindPackageHandleStandardArgs)
30 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREEDIAMETER DEFAULT_MSG FREEDIAMETER_LIBRARY FREEDIAMETER_INCLUDE_DIR)
31 |
32 | IF(FREEDIAMETER_FOUND)
33 | SET( FREEDIAMETER_LIBRARIES ${FREEDIAMETER_LIBRARY} )
34 | ELSE(FREEDIAMETER_FOUND)
35 | SET( FREEDIAMETER_LIBRARIES )
36 | ENDIF(FREEDIAMETER_FOUND)
37 |
38 | find_library(FREEDIAMETER_LIBRARY2
39 | NAMES fdproto
40 | )
41 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREEDIAMETER2 DEFAULT_MSG FREEDIAMETER_LIBRARY2 FREEDIAMETER_INCLUDE_DIR)
42 | IF(FREEDIAMETER2_FOUND)
43 | SET( FREEDIAMETER_LIBRARIES ${FREEDIAMETER_LIBRARIES} ${FREEDIAMETER_LIBRARY2} )
44 | ELSE(FREEDIAMETER2_FOUND)
45 | SET( FREEDIAMETER_LIBRARIES )
46 | ENDIF(FREEDIAMETER2_FOUND)
47 |
48 |
49 | # Lastly make it so that the FREEDIAMETER_LIBRARY and FREEDIAMETER_INCLUDE_DIR variables
50 | # only show up under the advanced options in the gui cmake applications.
51 | MARK_AS_ADVANCED( FREEDIAMETER_LIBRARY FREEDIAMETER_INCLUDE_DIR )
52 |
53 | # Now check if the library is patched for OPENAIR HSS S6A.
54 | IF(FREEDIAMETER_FOUND)
55 | IF( FREEDIAMETER_INCLUDE_DIR )
56 | # Extract FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR from freeDiameter-host.h
57 | # Read the whole file:
58 | #
59 | FILE(READ "${FREEDIAMETER_INCLUDE_DIR}/freeDiameter/freeDiameter-host.h" _freeDiameter_HOST_H_CONTENTS)
60 |
61 | STRING(REGEX REPLACE ".*#define FD_PROJECT_VERSION_MAJOR ([0-9]+).*" "\\1" FD_PROJECT_VERSION_MAJOR "${_freeDiameter_HOST_H_CONTENTS}")
62 | STRING(REGEX REPLACE ".*#define FD_PROJECT_VERSION_MINOR ([0-9]+).*" "\\1" FD_PROJECT_VERSION_MINOR "${_freeDiameter_HOST_H_CONTENTS}")
63 |
64 | IF(FD_PROJECT_VERSION_MAJOR GREATER 0)
65 | MATH(EXPR FREEDIAMETER_VERSION_VALUE "${FD_PROJECT_VERSION_MAJOR} * 100 + ${FD_PROJECT_VERSION_MINOR} * 10")
66 | SET(FREEDIAMETER_VERSION "${FREEDIAMETER_VERSION_VALUE}" CACHE INTERNAL "Freediameter release version")
67 | MESSAGE(STATUS "freeDiameter version found ${FREEDIAMETER_VERSION}")
68 | ENDIF(FD_PROJECT_VERSION_MAJOR GREATER 0)
69 | ENDIF( FREEDIAMETER_INCLUDE_DIR )
70 | GET_FILENAME_COMPONENT(FREEDIAMETER_PATH ${FREEDIAMETER_LIBRARY} PATH)
71 | IF( NOT( "${FREEDIAMETER_VERSION_TEST_FOR}" STREQUAL "${FREEDIAMETER_LIBRARIES}" ))
72 | INCLUDE (CheckLibraryExists)
73 | MESSAGE(STATUS "Checking freeDiameter patched for S6A")
74 | UNSET(FREEDIAMETER_HSS_S6A_ENABLED)
75 | UNSET(FREEDIAMETER_HSS_S6A_ENABLED CACHE)
76 | UNSET(DICT_S6A_FOUND)
77 | UNSET(DICT_S6A_FOUND CACHE)
78 |
79 |
80 | FIND_FILE(DICT_S6A_FOUND NAMES dict_s6a.fdx PATHS ${FREEDIAMETER_PATH} ${FREEDIAMETER_PATH}/freeDiameter)
81 | IF(DICT_S6A_FOUND)
82 | SET( FREEDIAMETER_HSS_S6A_ENABLED TRUE CACHE INTERNAL "dict_s6a.fdx Found")
83 | ELSE(DICT_S6A_FOUND)
84 | SET( FREEDIAMETER_HSS_S6A_ENABLED FALSE CACHE INTERNAL "dict_s6a.fdx not Found")
85 | ENDIF(DICT_S6A_FOUND)
86 | SET( FREEDIAMETER_VERSION_TEST_FOR ${FREEDIAMETER_LIBRARIES} CACHE INTERNAL "Version the test was made against" )
87 | ENDIF (NOT( "${FREEDIAMETER_VERSION_TEST_FOR}" STREQUAL "${FREEDIAMETER_LIBRARIES}" ))
88 | ENDIF(FREEDIAMETER_FOUND)
89 |
90 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindGCCXML.cmake:
--------------------------------------------------------------------------------
1 | # FindGCCXML
2 | # ----------
3 | find_program(GCCXML
4 | NAMES gccxml
5 | PATHS "/usr/bin"
6 | "usr/local/bin"
7 | )
8 | mark_as_advanced(GCCXML)
9 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindGcrypt.cmake:
--------------------------------------------------------------------------------
1 | # - Find gnutls
2 | # Find the native GCRYPT includes and library
3 | #
4 | # GCRYPT_FOUND - True if gnutls found.
5 | # GCRYPT_INCLUDE_DIR - where to find gnutls.h, etc.
6 | # GCRYPT_LIBRARIES - List of libraries when using gnutls.
7 |
8 | if (GCRYPT_INCLUDE_DIR AND GCRYPT_LIBRARIES)
9 | set(GCRYPT_FIND_QUIETLY TRUE)
10 | endif (GCRYPT_INCLUDE_DIR AND GCRYPT_LIBRARIES)
11 |
12 | # Include dir
13 | find_path(GCRYPT_INCLUDE_DIR
14 | NAMES
15 | gcrypt.h
16 | )
17 |
18 | # Library
19 | find_library(GCRYPT_LIBRARY
20 | NAMES gcrypt
21 | )
22 |
23 | # handle the QUIETLY and REQUIRED arguments and set GCRYPT_FOUND to TRUE if
24 | # all listed variables are TRUE
25 | INCLUDE(FindPackageHandleStandardArgs)
26 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GCRYPT DEFAULT_MSG GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR)
27 |
28 | IF(GCRYPT_FOUND)
29 | SET( GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} )
30 | ELSE(GCRYPT_FOUND)
31 | SET( GCRYPT_LIBRARIES )
32 | ENDIF(GCRYPT_FOUND)
33 |
34 | # Lastly make it so that the GCRYPT_LIBRARY and GCRYPT_INCLUDE_DIR variables
35 | # only show up under the advanced options in the gui cmake applications.
36 | MARK_AS_ADVANCED( GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR )
37 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindGnuTLS.cmake:
--------------------------------------------------------------------------------
1 | # - Find gnutls
2 | # Find the native GNUTLS includes and library
3 | #
4 | # GNUTLS_FOUND - True if gnutls found.
5 | # GNUTLS_INCLUDE_DIR - where to find gnutls.h, etc.
6 | # GNUTLS_LIBRARIES - List of libraries when using gnutls.
7 | # GNUTLS_VERSION_210 - true if GnuTLS version is >= 2.10.0 (does not require additional separate gcrypt initialization)
8 | # GNUTLS_VERSION_212 - true if GnuTLS version is >= 2.12.0 (supports gnutls_transport_set_vec_push_function)
9 | # GNUTLS_VERSION_300 - true if GnuTLS version is >= 3.00.0 (x509 verification functions changed)
10 | # GNUTLS_VERSION_310 - true if GnuTLS version is >= 3.01.0 (stabilization branch with new APIs)
11 |
12 | if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARIES)
13 | set(GNUTLS_FIND_QUIETLY TRUE)
14 | endif (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARIES)
15 |
16 | # Include dir
17 | find_path(GNUTLS_INCLUDE_DIR
18 | NAMES
19 | gnutls.h
20 | gnutls/gnutls.h
21 | )
22 |
23 | # Library
24 | find_library(GNUTLS_LIBRARY
25 | NAMES gnutls
26 | )
27 |
28 | # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if
29 | # all listed variables are TRUE
30 | INCLUDE(FindPackageHandleStandardArgs)
31 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNUTLS DEFAULT_MSG GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR)
32 |
33 | IF(GNUTLS_FOUND)
34 | SET( GNUTLS_LIBRARIES ${GNUTLS_LIBRARY} )
35 | ELSE(GNUTLS_FOUND)
36 | SET( GNUTLS_LIBRARIES )
37 | ENDIF(GNUTLS_FOUND)
38 |
39 | # Lastly make it so that the GNUTLS_LIBRARY and GNUTLS_INCLUDE_DIR variables
40 | # only show up under the advanced options in the gui cmake applications.
41 | MARK_AS_ADVANCED( GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR )
42 |
43 | # Now check if the library is recent. gnutls_hash was added in 2.10.0.
44 | # Also test library is even more recent. gnutls_x509_trust_list_verify_crt was added in 3.00.0.
45 | IF(GNUTLS_FOUND)
46 | IF( NOT( "${GNUTLS_VERSION_TEST_FOR}" STREQUAL "${GNUTLS_LIBRARY}" ))
47 | INCLUDE (CheckLibraryExists)
48 | MESSAGE(STATUS "Checking GNUTLS version")
49 | UNSET(GNUTLS_VERSION_210)
50 | UNSET(GNUTLS_VERSION_210 CACHE)
51 | UNSET(GNUTLS_VERSION_212)
52 | UNSET(GNUTLS_VERSION_212 CACHE)
53 | UNSET(GNUTLS_VERSION_300)
54 | UNSET(GNUTLS_VERSION_300 CACHE)
55 | UNSET(GNUTLS_VERSION_310)
56 | UNSET(GNUTLS_VERSION_310 CACHE)
57 | GET_FILENAME_COMPONENT(GNUTLS_PATH ${GNUTLS_LIBRARY} PATH)
58 | CHECK_LIBRARY_EXISTS(gnutls gnutls_hash ${GNUTLS_PATH} GNUTLS_VERSION_210)
59 | CHECK_LIBRARY_EXISTS(gnutls gnutls_transport_set_vec_push_function ${GNUTLS_PATH} GNUTLS_VERSION_212)
60 | CHECK_LIBRARY_EXISTS(gnutls gnutls_x509_trust_list_verify_crt ${GNUTLS_PATH} GNUTLS_VERSION_300)
61 | CHECK_LIBRARY_EXISTS(gnutls gnutls_handshake_set_timeout ${GNUTLS_PATH} GNUTLS_VERSION_310)
62 | SET( GNUTLS_VERSION_TEST_FOR ${GNUTLS_LIBRARY} CACHE INTERNAL "Version the test was made against" )
63 | ENDIF (NOT( "${GNUTLS_VERSION_TEST_FOR}" STREQUAL "${GNUTLS_LIBRARY}" ))
64 | ENDIF(GNUTLS_FOUND)
65 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindKbuild.cmake:
--------------------------------------------------------------------------------
1 | # - Support for building kernel modules
2 |
3 | # This module defines several variables which may be used when build
4 | # kernel modules.
5 | #
6 | # The following variables are set here:
7 | # Kbuild_VERSION_STRING - kernel version.
8 | # Kbuild_ARCH - architecture.
9 | # Kbuild_BUILD_DIR - directory for build kernel and/or its components.
10 | # Kbuild_VERSION_{MAJOR|MINOR|TWEAK} - kernel version components
11 | # Kbuild_VERSION_STRING_CLASSIC - classic representation of version,
12 | # where parts are delimited by dots.
13 | #
14 | # Cache variables which affect on this package:
15 | # CMAKE_SYSTEM_VERSION - change Kbuild_VERSION_STRING
16 | # Also, setting CMAKE_SYSTEM_VERSION will be interpreted by cmake as crosscompile.
17 | #
18 | # Cache variables(ADVANCED) which affect on this package:
19 | # ARCH - if not empty, change Kbuild_ARCH
20 | # KBUILD_DIR - change Kbuild_BUILD_DIR
21 |
22 | set(Kbuild_VERSION_STRING ${CMAKE_SYSTEM_VERSION})
23 |
24 | # Form classic version view.
25 | string(REGEX MATCH "([0-9]+)\\.([0-9]+)[.-]([0-9]+)"
26 | _kernel_version_match
27 | "${Kbuild_VERSION_STRING}"
28 | )
29 |
30 | if(NOT _kernel_version_match)
31 | message(FATAL_ERROR "Kernel version has unexpected format: ${Kbuild_VERSION_STRING}")
32 | endif(NOT _kernel_version_match)
33 |
34 | set(Kbuild_VERSION_MAJOR ${CMAKE_MATCH_1})
35 | set(Kbuild_VERSION_MINOR ${CMAKE_MATCH_2})
36 | set(Kbuild_VERSION_TWEAK ${CMAKE_MATCH_3})
37 | # Version string for compare
38 | set(Kbuild_VERSION_STRING_CLASSIC "${Kbuild_VERSION_MAJOR}.${Kbuild_VERSION_MINOR}.${Kbuild_VERSION_TWEAK}")
39 |
40 | set(KBUILD_DIR "/lib/modules/${Kbuild_VERSION_STRING}/build" CACHE PATH
41 | "Directory for build linux kernel and/or its components."
42 | )
43 | mark_as_advanced(KBUILD_DIR)
44 |
45 | set(Kbuild_BUILD_DIR "${KBUILD_DIR}")
46 |
47 | set(ARCH "" CACHE STRING
48 | "Architecture for build linux kernel components for, empty string means autodetect."
49 | )
50 | mark_as_advanced(ARCH)
51 |
52 | if(NOT ARCH)
53 | # Autodetect arch.
54 | execute_process(COMMAND uname -m
55 | RESULT_VARIABLE uname_m_result
56 | OUTPUT_VARIABLE ARCH_DEFAULT
57 | )
58 | if(NOT uname_m_result EQUAL 0)
59 | message("'uname -m' failed:")
60 | message("${ARCH_DEFAULT}")
61 | message(FATAL_ERROR "Failed to determine system architecture.")
62 | endif(NOT uname_m_result EQUAL 0)
63 |
64 | string(REGEX REPLACE "\n$" "" ARCH_DEFAULT "${ARCH_DEFAULT}")
65 |
66 | # Pairs of pattern-replace for postprocess architecture string from
67 | # 'uname -m'.
68 | # Taken from ./Makefile of the kernel build.
69 | set(_kbuild_arch_replacers
70 | "i.86" "x86"
71 | "x86_64" "x86"
72 | "sun4u" "sparc64"
73 | "arm.*" "arm"
74 | "sa110" "arm"
75 | "s390x" "s390"
76 | "parisc64" "parisc"
77 | "ppc.*" "powerpc"
78 | "mips.*" "mips"
79 | "sh[234].*" "sh"
80 | "aarch64.*" "arm64"
81 | )
82 |
83 | set(_current_pattern)
84 | foreach(p ${_kbuild_arch_replacers})
85 | if(_current_pattern)
86 | string(REGEX REPLACE "${_current_pattern}" "${p}" ARCH_DEFAULT "${ARCH_DEFAULT}")
87 | set(_current_pattern)
88 | else(_current_pattern)
89 | set(_current_pattern "${p}")
90 | endif(_current_pattern)
91 | endforeach(p ${_kbuild_arch_replacers})
92 |
93 | set(Kbuild_ARCH "${ARCH_DEFAULT}")
94 | else(NOT ARCH)
95 | # User-provided value is used.
96 | set(Kbuild_ARCH "${ARCH}")
97 | endif(NOT ARCH)
98 |
99 |
100 |
101 | include(FindPackageHandleStandardArgs)
102 | find_package_handle_standard_args(Kbuild
103 | REQUIRED_VARS Kbuild_BUILD_DIR
104 | VERSION_VAR KBuild_VERSION_STRING_CLASSIC
105 | )
106 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindLibXml2.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find the LibXml2 xml processing library
2 | # Once done this will define
3 | #
4 | # LIBXML2_FOUND - System has LibXml2
5 | # LIBXML2_INCLUDE_DIR - The LibXml2 include directory
6 | # LIBXML2_LIBRARIES - The libraries needed to use LibXml2
7 | # LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2
8 | # LIBXML2_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with LibXml2
9 |
10 | #=============================================================================
11 | # Copyright 2006-2009 Kitware, Inc.
12 | # Copyright 2006 Alexander Neundorf
13 | #
14 | # Distributed under the OSI-approved BSD License (the "License");
15 | # see accompanying file Copyright.txt for details.
16 | #
17 | # This software is distributed WITHOUT ANY WARRANTY; without even the
18 | # See the License for more information.
19 | #=============================================================================
20 | # (To distributed this file outside of CMake, substitute the full
21 | # License text for the above reference.)
22 |
23 | # use pkg-config to get the directories and then use these values
24 | # in the FIND_PATH() and FIND_LIBRARY() calls
25 | FIND_PACKAGE(PkgConfig)
26 | PKG_CHECK_MODULES(PC_LIBXML libxml-2.0)
27 | SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})
28 |
29 | FIND_PATH(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
30 | HINTS
31 | ${PC_LIBXML_INCLUDEDIR}
32 | ${PC_LIBXML_INCLUDE_DIRS}
33 | PATH_SUFFIXES libxml2
34 | )
35 |
36 | FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2
37 | HINTS
38 | ${PC_LIBXML_LIBDIR}
39 | ${PC_LIBXML_LIBRARY_DIRS}
40 | )
41 |
42 | FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint)
43 | # for backwards compat. with KDE 4.0.x:
44 | SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}")
45 |
46 | # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
47 | # all listed variables are TRUE
48 | INCLUDE(FindPackageHandleStandardArgs)
49 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
50 |
51 | MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE)
52 |
53 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindMySQL.cmake:
--------------------------------------------------------------------------------
1 | # - Find mysqlclient
2 | #
3 | # -*- cmake -*-
4 | #
5 | # Find the native MySQL includes and library
6 | #
7 | # MySQL_INCLUDE_DIR - where to find mysql.h, etc.
8 | # MySQL_LIBRARIES - List of libraries when using MySQL.
9 | # MySQL_FOUND - True if MySQL found.
10 |
11 | IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
12 | # Already in cache, be silent
13 | SET(MySQL_FIND_QUIETLY TRUE)
14 | ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
15 |
16 | # Include dir
17 | FIND_PATH(MySQL_INCLUDE_DIR
18 | NAMES mysql.h
19 | PATH_SUFFIXES mysql
20 | )
21 |
22 | # Library
23 | #SET(MySQL_NAMES mysqlclient mysqlclient_r)
24 | SET(MySQL_NAMES mysqlclient)
25 | FIND_LIBRARY(MySQL_LIBRARY
26 | NAMES ${MySQL_NAMES}
27 | PATHS /usr/lib /usr/local/lib
28 | PATH_SUFFIXES mysql
29 | )
30 |
31 | IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
32 | SET(MySQL_FOUND TRUE)
33 | SET( MySQL_LIBRARIES ${MySQL_LIBRARY} )
34 | ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
35 | SET(MySQL_FOUND FALSE)
36 | SET( MySQL_LIBRARIES )
37 | ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
38 |
39 |
40 | IF (MySQL_FOUND)
41 | IF (NOT MySQL_FIND_QUIETLY)
42 | MESSAGE(STATUS "Found MySQL: ${MySQL_LIBRARY}")
43 | ENDIF (NOT MySQL_FIND_QUIETLY)
44 | ELSE (MySQL_FOUND)
45 | IF (MySQL_FIND_REQUIRED)
46 | MESSAGE(STATUS "Looked for MySQL libraries named ${MySQL_NAMES}.")
47 | MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
48 | ENDIF (MySQL_FIND_REQUIRED)
49 | ENDIF (MySQL_FOUND)
50 |
51 | MARK_AS_ADVANCED(
52 | MySQL_LIBRARY
53 | MySQL_INCLUDE_DIR
54 | )
55 |
56 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindNettle.cmake:
--------------------------------------------------------------------------------
1 | # Find the native Nettle includes, library, and flags
2 | #
3 | # NETTLE_INCLUDE_DIR - where to find nettle.h, etc.
4 | # NETTLE_LIBRARIES - List of libraries when using Nettle.
5 | # NETTLE_FOUND - True if Nettle found.
6 | IF (NETTLE_INCLUDE_DIR)
7 | # Already in cache, be silent
8 | SET(NETTLE_FIND_QUIETLY TRUE)
9 | ENDIF (NETTLE_INCLUDE_DIR)
10 | FIND_PATH(NETTLE_INCLUDE_DIR nettle/nettle-meta.h)
11 | SET(NETTLE_NAMES nettle)
12 | FIND_LIBRARY(NETTLE_LIBRARY NAMES ${NETTLE_NAMES} )
13 | # handle the QUIETLY and REQUIRED arguments and set NETTLE_FOUND to TRUE if
14 | # all listed variables are TRUE
15 | INCLUDE(FindPackageHandleStandardArgs)
16 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETTLE DEFAULT_MSG NETTLE_LIBRARY NETTLE_INCLUDE_DIR)
17 | IF(NETTLE_FOUND)
18 | SET(NETTLE_LIBRARIES ${NETTLE_LIBRARY})
19 | ELSE(NETTLE_FOUND)
20 | SET(NETTLE_LIBRARIES )
21 | ENDIF(NETTLE_FOUND)
22 | MARK_AS_ADVANCED(NETTLE_LIBRARY NETTLE_INCLUDE_DIR)
23 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindPostgreSQL.cmake:
--------------------------------------------------------------------------------
1 | # - Find PostgreSQL library
2 | #
3 | # This module defines:
4 | # POSTGRESQL_FOUND - True if the package is found
5 | # POSTGRESQL_INCLUDE_DIR - containing libpq-fe.h
6 | # POSTGRESQL_LIBRARIES - Libraries to link to use PQ functions.
7 |
8 | if (POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
9 | set(POSTGRESQL_FIND_QUIETLY TRUE)
10 | endif (POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
11 |
12 | # Include dir
13 | find_path(POSTGRESQL_INCLUDE_DIR
14 | NAMES libpq-fe.h
15 | PATH_SUFFIXES pgsql postgresql
16 | )
17 |
18 | # Library
19 | find_library(POSTGRESQL_LIBRARY
20 | NAMES pq
21 | )
22 |
23 | # handle the QUIETLY and REQUIRED arguments and set POSTGRESQL_FOUND to TRUE if
24 | # all listed variables are TRUE
25 | INCLUDE(FindPackageHandleStandardArgs)
26 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(POSTGRESQL DEFAULT_MSG POSTGRESQL_LIBRARY POSTGRESQL_INCLUDE_DIR)
27 |
28 | IF(POSTGRESQL_FOUND)
29 | SET( POSTGRESQL_LIBRARIES ${POSTGRESQL_LIBRARY} )
30 | ELSE(POSTGRESQL_FOUND)
31 | SET( POSTGRESQL_LIBRARIES )
32 | ENDIF(POSTGRESQL_FOUND)
33 |
34 | # Lastly make it so that the POSTGRESQL_LIBRARY and POSTGRESQL_INCLUDE_DIR variables
35 | # only show up under the advanced options in the gui cmake applications.
36 | MARK_AS_ADVANCED( POSTGRESQL_LIBRARY POSTGRESQL_INCLUDE_DIR )
37 |
--------------------------------------------------------------------------------
/build/cmake_modules/FindSCTP.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find SCTP library and headers
2 | # Once done, this will define
3 | #
4 | # SCTP_FOUND - system has SCTP
5 | # SCTP_INCLUDE_DIR - the SCTP include directories
6 | # SCTP_LIBRARIES - link these to use SCTP
7 |
8 | if (SCTP_INCLUDE_DIR AND SCTP_LIBRARIES)
9 | set(SCTP_FIND_QUIETLY TRUE)
10 | endif (SCTP_INCLUDE_DIR AND SCTP_LIBRARIES)
11 |
12 | # Include dir
13 | find_path(SCTP_INCLUDE_DIR
14 | NAMES netinet/sctp.h
15 | )
16 |
17 | # Library
18 | find_library(SCTP_LIBRARY
19 | NAMES sctp
20 | )
21 |
22 | # Set the include dir variables and the libraries and let libfind_process do the rest.
23 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on.
24 | #set(SCTP_PROCESS_INCLUDES SCTP_INCLUDE_DIR)
25 | #set(SCTP_PROCESS_LIBS SCTP_LIBRARY)
26 | #libfind_process(SCTP)
27 |
28 |
29 | # handle the QUIETLY and REQUIRED arguments and set SCTP_FOUND to TRUE if
30 | # all listed variables are TRUE
31 | INCLUDE(FindPackageHandleStandardArgs)
32 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(SCTP DEFAULT_MSG SCTP_LIBRARY SCTP_INCLUDE_DIR)
33 |
34 | # If we successfully found the sctp library then add the library to the
35 | # SCTP_LIBRARIES cmake variable otherwise set SCTP_LIBRARIES to nothing.
36 | IF(SCTP_FOUND)
37 | SET( SCTP_LIBRARIES ${SCTP_LIBRARY} )
38 | ELSE(SCTP_FOUND)
39 | SET( SCTP_LIBRARIES )
40 | ENDIF(SCTP_FOUND)
41 |
42 |
43 | # Lastly make it so that the SCTP_LIBRARY and SCTP_INCLUDE_DIR variables
44 | # only show up under the advanced options in the gui cmake applications.
45 | MARK_AS_ADVANCED( SCTP_LIBRARY SCTP_INCLUDE_DIR )
46 |
47 |
--------------------------------------------------------------------------------
/build/cmake_modules/Kbuild.cmake:
--------------------------------------------------------------------------------
1 | src=${dir}
2 | obj-m += ${name}.o
3 | ${name}-y += ${objs}
4 | ccflags-y += ${module_cc_opt}
5 |
--------------------------------------------------------------------------------
/build/scripts/build_helper.libconfig:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The OpenAirInterface Software Alliance licenses this file to You under
6 | # the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.openairinterface.org/?page_id=698
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #-------------------------------------------------------------------------------
18 | # For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # contact@openairinterface.org
20 | ################################################################################
21 |
22 | # file build_helper.libconfig
23 | # brief
24 | # author Lionel GAUTHIER
25 | #
26 | #######################################
27 | SCRIPT=$(readlink -f ${BASH_SOURCE})
28 | THIS_SCRIPT_PATH=`dirname $SCRIPT`
29 | source $THIS_SCRIPT_PATH/build_helper
30 |
31 | #-------------------------------------------------------------------------------
32 | # Motivation: seems libconfig++ need to be compiled with same application C++ compiler,
33 | # otherwise you encounter strange linker errors. (ubuntu 16.04)
34 |
35 | #arg1 is force (0 or 1) (no interactive script)
36 | #arg2 is debug (0 or 1) (install debug libraries)
37 | install_libconfig_from_source(){
38 | if [ $1 -eq 0 ]; then
39 | OPTION=""
40 | read -p "Do you want to install libconfig (github)? " prompt
41 | else
42 | prompt='y'
43 | OPTION="-y"
44 | fi
45 | if [ $2 -eq 0 ]; then
46 | debug=0
47 | else
48 | debug=1
49 | fi
50 |
51 |
52 | if [[ $prompt =~ [yY](es)* ]]
53 | then
54 | if [[ "$OS_DISTRO" == "ubuntu" ]]; then
55 | PACKAGE_LIST="\
56 | autoconf \
57 | automake \
58 | bison \
59 | build-essential \
60 | flex \
61 | gcc \
62 | libtool"
63 | elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
64 | PACKAGE_LIST="\
65 | autoconf \
66 | automake \
67 | bison \
68 | patch \
69 | flex \
70 | gcc \
71 | libtool \
72 | textinfo"
73 | else
74 | echo_fatal "$OS_DISTRO is not a supported distribution."
75 | fi
76 | $SUDO $INSTALLER install $OPTION $PACKAGE_LIST
77 |
78 |
79 | pushd /tmp
80 | $SUDO rm -rf /tmp/libconfig
81 | git clone https://github.com/hyperrealm/libconfig.git
82 | ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
83 | cd libconfig
84 | autoreconf -fi
85 | ./configure
86 | ret=$?;[[ $ret -ne 0 ]] && return $ret
87 | make -j `nproc` > /tmp/log_compile_config 2>&1
88 | ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
89 | $SUDO make install
90 | ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
91 | popd
92 | fi
93 | return 0
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/build/spgw_u/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The OpenAirInterface Software Alliance licenses this file to You under
6 | # the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.openairinterface.org/?page_id=698
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #-------------------------------------------------------------------------------
18 | # For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # contact@openairinterface.org
20 | ################################################################################
21 | cmake_minimum_required (VERSION 3.0.2)
22 | # Override options for SPGW
23 | set ( PACKAGE_NAME "S/P-GW-U" )
24 | set ( STATIC_LINKING False )
25 | #############################################
26 | # Base directories, compatible with legacy OAI building
27 | ################################################
28 | set (OPENAIRCN_DIR $ENV{OPENAIRCN_DIR})
29 | set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build)
30 | set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src)
31 |
32 | ################################################
33 | # For common-src usage
34 | ################################################
35 | set ( NF_TARGET spgwu )
36 | set ( MOUNTED_COMMON common-src)
37 |
38 | include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai_spgwu/CMakeLists.txt)
39 |
40 | ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/spgwu ${CMAKE_CURRENT_BINARY_DIR}/spgw_u)
41 |
--------------------------------------------------------------------------------
/ci-scripts/README.txt:
--------------------------------------------------------------------------------
1 | -----
2 | This folder contains all the public scripts that are used by the CI process
3 |
--------------------------------------------------------------------------------
/ci-scripts/cppcheck_suppressions.list:
--------------------------------------------------------------------------------
1 | // *INDENT-OFF* cppcheck doesn't like "astyling" this file!!!!
2 | // /*
3 | // * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
4 | // * contributor license agreements. See the NOTICE file distributed with
5 | // * this work for additional information regarding copyright ownership.
6 | // * The OpenAirInterface Software Alliance licenses this file to You under
7 | // * the OAI Public License, Version 1.1 (the "License"); you may not use this file
8 | // * except in compliance with the License.
9 | // * You may obtain a copy of the License at
10 | // *
11 | // * http://www.openairinterface.org/?page_id=698
12 | // *
13 | // * Unless required by applicable law or agreed to in writing, software
14 | // * distributed under the License is distributed on an "AS IS" BASIS,
15 | // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // * See the License for the specific language governing permissions and
17 | // * limitations under the License.
18 | // *-------------------------------------------------------------------------------
19 | // * For more information about the OpenAirInterface (OAI) Software Alliance:
20 | // * contact@openairinterface.org
21 | // */
22 | //*****************************************************************************
23 | //-----------------------------------------------------------------------------
24 | // *INDENT-ON*
25 |
--------------------------------------------------------------------------------
/ci-scripts/doGitHubPullRequestTempMerge.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #/*
3 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
4 | # * contributor license agreements. See the NOTICE file distributed with
5 | # * this work for additional information regarding copyright ownership.
6 | # * The OpenAirInterface Software Alliance licenses this file to You under
7 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
8 | # * except in compliance with the License.
9 | # * You may obtain a copy of the License at
10 | # *
11 | # * http://www.openairinterface.org/?page_id=698
12 | # *
13 | # * Unless required by applicable law or agreed to in writing, software
14 | # * distributed under the License is distributed on an "AS IS" BASIS,
15 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # * See the License for the specific language governing permissions and
17 | # * limitations under the License.
18 | # *-------------------------------------------------------------------------------
19 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
20 | # * contact@openairinterface.org
21 | # */
22 |
23 | function usage {
24 | echo "OAI GitHub Pull Request script that creates a temporary merge commit locally"
25 | echo " Original Author: Raphael Defosseux"
26 | echo ""
27 | echo "Usage:"
28 | echo "------"
29 | echo ""
30 | echo " doGitHubPullRequestTempMerge.sh [OPTIONS] [MANDATORY_OPTIONS]"
31 | echo ""
32 | echo "Mandatory Options:"
33 | echo "------------------"
34 | echo ""
35 | echo " --src-branch #### OR -sb ####"
36 | echo " Specify the source branch of the merge request."
37 | echo ""
38 | echo " --src-commit #### OR -sc ####"
39 | echo " Specify the source commit ID (SHA-1) of the merge request."
40 | echo ""
41 | echo " --target-branch #### OR -tb ####"
42 | echo " Specify the target branch of the merge request (usually develop)."
43 | echo ""
44 | echo " --target-commit #### OR -tc ####"
45 | echo " Specify the target commit ID (SHA-1) of the merge request."
46 | echo ""
47 | echo "Options:"
48 | echo "--------"
49 | echo " --help OR -h"
50 | echo " Print this help message."
51 | echo ""
52 | }
53 |
54 | if [ $# -ne 8 ] && [ $# -ne 1 ]
55 | then
56 | echo "Syntax Error: not the correct number of arguments"
57 | echo ""
58 | usage
59 | exit 1
60 | fi
61 |
62 | checker=0
63 | while [[ $# -gt 0 ]]
64 | do
65 | key="$1"
66 |
67 | case $key in
68 | -h|--help)
69 | shift
70 | usage
71 | exit 0
72 | ;;
73 | -sb|--src-branch)
74 | SOURCE_BRANCH="$2"
75 | let "checker|=0x1"
76 | shift
77 | shift
78 | ;;
79 | -sc|--src-commit)
80 | SOURCE_COMMIT_ID="$2"
81 | let "checker|=0x2"
82 | shift
83 | shift
84 | ;;
85 | -tb|--target-branch)
86 | TARGET_BRANCH="$2"
87 | let "checker|=0x4"
88 | shift
89 | shift
90 | ;;
91 | -tc|--target-commit)
92 | TARGET_COMMIT_ID="$2"
93 | let "checker|=0x8"
94 | shift
95 | shift
96 | ;;
97 | *)
98 | echo "Syntax Error: unknown option: $key"
99 | echo ""
100 | usage
101 | exit 1
102 | esac
103 |
104 | done
105 |
106 | echo "Source Branch is : $SOURCE_BRANCH"
107 | echo "Source Commit ID is : $SOURCE_COMMIT_ID"
108 | echo "Target Branch is : $TARGET_BRANCH"
109 | echo "Target Commit ID is : $TARGET_COMMIT_ID"
110 |
111 | if [ $checker -ne 15 ]
112 | then
113 | echo ""
114 | echo "Syntax Error: missing option"
115 | echo ""
116 | usage
117 | exit 1
118 | fi
119 |
120 | git config user.email "jenkins@openairinterface.org"
121 | git config user.name "OAI Jenkins"
122 |
123 | git checkout -f $SOURCE_COMMIT_ID
124 | # Keeping the source commit for the GitHub notifications
125 | git rev-parse HEAD > .git/current-commit
126 | # Keeping the committer email for the GitHub notifications
127 | git log -1 --pretty=format:"%ce" > .git/commit-email
128 | # Workaround for GitHub merge button issue
129 | if [ `egrep -c "noreply@github.com" .git/commit-email` -eq 1 ]
130 | then
131 | echo "raphael.defosseux@openairinterface.org" > .git/commit-email
132 | fi
133 |
134 | # Doing a temporary merge
135 | git merge --ff $TARGET_COMMIT_ID -m "Temporary merge for CI - from $SOURCE_BRANCH to $TARGET_BRANCH"
136 |
137 | STATUS=`git status | egrep -c "You have unmerged paths.|fix conflicts"`
138 | if [ $STATUS -ne 0 ]
139 | then
140 | echo "There are merge conflicts.. Cannot perform further build tasks"
141 | STATUS=-1
142 | fi
143 | exit $STATUS
144 |
--------------------------------------------------------------------------------
/ci-scripts/docker/Dockerfile.ci.clang-format:
--------------------------------------------------------------------------------
1 | #/*
2 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # * contributor license agreements. See the NOTICE file distributed with
4 | # * this work for additional information regarding copyright ownership.
5 | # * The OpenAirInterface Software Alliance licenses this file to You under
6 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # * except in compliance with the License.
8 | # * You may obtain a copy of the License at
9 | # *
10 | # * http://www.openairinterface.org/?page_id=698
11 | # *
12 | # * Unless required by applicable law or agreed to in writing, software
13 | # * distributed under the License is distributed on an "AS IS" BASIS,
14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # * See the License for the specific language governing permissions and
16 | # * limitations under the License.
17 | # *-------------------------------------------------------------------------------
18 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # * contact@openairinterface.org
20 | # */
21 | #---------------------------------------------------------------------
22 | #
23 | FROM ubuntu:focal as spgwu-clang-format-check
24 | ARG MERGE_REQUEST_CHECK
25 | ARG SOURCE_BRANCH
26 | ARG TARGET_BRANCH
27 |
28 | RUN apt-get update && \
29 | apt-get upgrade -y && \
30 | apt-get install --yes \
31 | git \
32 | tree \
33 | clang-format-9 && \
34 | update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-9 20 && \
35 | clang-format --version
36 |
37 | WORKDIR /home
38 | COPY . .
39 |
40 | RUN /bin/bash -c "if [[ -v MERGE_REQUEST_CHECK ]]; then ./ci-scripts/checkCodingFormattingRules.sh --src-branch $SOURCE_BRANCH --target-branch $TARGET_BRANCH; else ./ci-scripts/checkCodingFormattingRules.sh; fi"
41 |
--------------------------------------------------------------------------------
/ci-scripts/docker/Dockerfile.ci.cppcheck:
--------------------------------------------------------------------------------
1 | #/*
2 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # * contributor license agreements. See the NOTICE file distributed with
4 | # * this work for additional information regarding copyright ownership.
5 | # * The OpenAirInterface Software Alliance licenses this file to You under
6 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # * except in compliance with the License.
8 | # * You may obtain a copy of the License at
9 | # *
10 | # * http://www.openairinterface.org/?page_id=698
11 | # *
12 | # * Unless required by applicable law or agreed to in writing, software
13 | # * distributed under the License is distributed on an "AS IS" BASIS,
14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # * See the License for the specific language governing permissions and
16 | # * limitations under the License.
17 | # *-------------------------------------------------------------------------------
18 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # * contact@openairinterface.org
20 | # */
21 | #---------------------------------------------------------------------
22 | #
23 | FROM ubuntu:focal as spgwu-cppcheck
24 |
25 | RUN apt-get update && \
26 | apt-get upgrade -y && \
27 | apt-get install --yes cppcheck
28 |
29 | WORKDIR /home
30 | COPY . .
31 |
32 | RUN cppcheck --enable=warning --force \
33 | --xml --xml-version=2 \
34 | --suppressions-list=ci-scripts/cppcheck_suppressions.list src \
35 | 2> cppcheck.xml \
36 | 1> cppcheck_build.log
37 |
--------------------------------------------------------------------------------
/ci-scripts/fail.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #/*
3 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
4 | # * contributor license agreements. See the NOTICE file distributed with
5 | # * this work for additional information regarding copyright ownership.
6 | # * The OpenAirInterface Software Alliance licenses this file to You under
7 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
8 | # * except in compliance with the License.
9 | # * You may obtain a copy of the License at
10 | # *
11 | # * http://www.openairinterface.org/?page_id=698
12 | # *
13 | # * Unless required by applicable law or agreed to in writing, software
14 | # * distributed under the License is distributed on an "AS IS" BASIS,
15 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # * See the License for the specific language governing permissions and
17 | # * limitations under the License.
18 | # *-------------------------------------------------------------------------------
19 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
20 | # * contact@openairinterface.org
21 | # */
22 |
23 | exit -1
24 |
--------------------------------------------------------------------------------
/ci-scripts/flatten_image.py:
--------------------------------------------------------------------------------
1 | """
2 | Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | contributor license agreements. See the NOTICE file distributed with
4 | this work for additional information regarding copyright ownership.
5 | The OpenAirInterface Software Alliance licenses this file to You under
6 | the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.openairinterface.org/?page_id=698
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | -------------------------------------------------------------------------------
18 | For more information about the OpenAirInterface (OAI) Software Alliance:
19 | contact@openairinterface.org
20 | """
21 |
22 | import argparse
23 | import re
24 | import subprocess
25 | import sys
26 |
27 | def main() -> None:
28 | args = _parse_args()
29 | status = perform_flattening(args.tag)
30 | sys.exit(status)
31 |
32 | def _parse_args() -> argparse.Namespace:
33 | parser = argparse.ArgumentParser(description='Flattening Image')
34 |
35 | parser.add_argument(
36 | '--tag', '-t',
37 | action='store',
38 | required=True,
39 | help='Image Tag in image-name:image tag format',
40 | )
41 | return parser.parse_args()
42 |
43 | def perform_flattening(tag):
44 | # First detect which docker/podman command to use
45 | cli = ''
46 | image_prefix = ''
47 | cmd = 'which podman || true'
48 | podman_check = subprocess.check_output(cmd, shell=True, universal_newlines=True)
49 | if re.search('podman', podman_check.strip()):
50 | cli = 'sudo podman'
51 | image_prefix = 'localhost/'
52 | # since HEALTHCHECK is not supported by podman import
53 | # we don't flatten
54 | return 0
55 | if cli == '':
56 | cmd = 'which docker || true'
57 | docker_check = subprocess.check_output(cmd, shell=True, universal_newlines=True)
58 | if re.search('docker', docker_check.strip()):
59 | cli = 'docker'
60 | image_prefix = ''
61 | if cli == '':
62 | print ('No docker / podman installed: quitting')
63 | return -1
64 | print (f'Flattening {tag}')
65 | # Creating a container
66 | cmd = cli + ' run --name test-flatten --entrypoint /bin/true -d ' + tag
67 | print (cmd)
68 | subprocess.check_output(cmd, shell=True, universal_newlines=True)
69 |
70 | # Export / Import trick
71 | cmd = cli + ' export test-flatten | ' + cli + ' import '
72 | # Bizarro syntax issue with podman
73 | if cli == 'docker':
74 | cmd += ' --change "ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" '
75 | else:
76 | cmd += ' --change "ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" '
77 | cmd += ' --change "WORKDIR /openair-spgwu-tiny" '
78 | cmd += ' --change "EXPOSE 2152/udp" '
79 | cmd += ' --change "EXPOSE 8805/udp" '
80 | cmd += ' --change "LABEL support-multi-sgwu-instances=\\"true\\"" '
81 | cmd += ' --change "LABEL support-nrf-fdqn=\\"true\\"" '
82 | cmd += ' --change "HEALTHCHECK --interval=10s --timeout=15s --retries=6 CMD /openair-spgwu-tiny/bin/healthcheck.sh" '
83 | cmd += ' --change "CMD [\\"/openair-spgwu-tiny/bin/oai_spgwu\\", \\"-c\\", \\"/openair-spgwu-tiny/etc/spgw_u.conf\\", \\"-o\\"]" '
84 | cmd += ' --change "ENTRYPOINT [\\"python3\\", \\"/openair-spgwu-tiny/bin/entrypoint.py\\"]" '
85 | cmd += ' - ' + image_prefix + tag
86 | print (cmd)
87 | subprocess.check_output(cmd, shell=True, universal_newlines=True)
88 |
89 | # Remove container
90 | cmd = cli + ' rm -f test-flatten'
91 | print (cmd)
92 | subprocess.check_output(cmd, shell=True, universal_newlines=True)
93 |
94 | # At this point the original image is a dangling image.
95 | # CI pipeline will clean up (`image prune --force`)
96 | return 0
97 |
98 | if __name__ == '__main__':
99 | main()
100 |
--------------------------------------------------------------------------------
/ci-scripts/verifySanityCheckDeployment.py:
--------------------------------------------------------------------------------
1 | #/*
2 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # * contributor license agreements. See the NOTICE file distributed with
4 | # * this work for additional information regarding copyright ownership.
5 | # * The OpenAirInterface Software Alliance licenses this file to You under
6 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # * except in compliance with the License.
8 | # * You may obtain a copy of the License at
9 | # *
10 | # * http://www.openairinterface.org/?page_id=698
11 | # *
12 | # * Unless required by applicable law or agreed to in writing, software
13 | # * distributed under the License is distributed on an "AS IS" BASIS,
14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # * See the License for the specific language governing permissions and
16 | # * limitations under the License.
17 | # *-------------------------------------------------------------------------------
18 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # * contact@openairinterface.org
20 | # */
21 | #---------------------------------------------------------------------
22 |
23 | import os
24 | import re
25 | import sys
26 | import subprocess
27 |
28 | class verifySanityCheckDeployment():
29 | def __init__(self):
30 | self.job_name = ''
31 |
32 | def checkLogs(self):
33 | spgwc_status = self.analyze_check_run_log('SPGW-C')
34 | spgwu_status = self.analyze_check_run_log('SPGW-U')
35 | if not spgwc_status:
36 | print ('SPGW-C did not deploy properly')
37 | if not spgwu_status:
38 | print ('SPGW-U did not deploy properly')
39 | if not spgwc_status or not spgwu_status:
40 | sys.exit('Sanity Check Deployment went wrong')
41 | else:
42 | print ('Sanity Check Deployment is OK')
43 |
44 | def analyze_check_run_log(self, nfType):
45 | logFileName = nfType.lower().replace('-','') + '_check_run.log'
46 |
47 | cwd = os.getcwd()
48 | status = False
49 | if os.path.isfile(cwd + '/archives/' + logFileName):
50 | nb_pfcp_hb_proc = 0
51 | nb_sx_hb_resp = 0
52 | nb_sx_hb_req = 0
53 | with open(cwd + '/archives/' + logFileName, 'r') as logfile:
54 | for line in logfile:
55 | result = re.search('PFCP HEARTBEAT PROCEDURE', line)
56 | if result is not None:
57 | nb_pfcp_hb_proc += 1
58 | result = re.search('SX HEARTBEAT RESPONSE', line)
59 | if result is not None:
60 | nb_sx_hb_resp += 1
61 | result = re.search('SX HEARTBEAT REQUEST', line)
62 | if result is not None:
63 | nb_sx_hb_req += 1
64 | logfile.close()
65 | if nfType == 'SPGW-C':
66 | if nb_pfcp_hb_proc > 0:
67 | status = True
68 | if nfType == 'SPGW-U':
69 | if nb_pfcp_hb_proc > 0 and nb_sx_hb_resp > 0 and nb_sx_hb_req > 0:
70 | status = True
71 |
72 | return status
73 |
74 | def Usage():
75 | print('----------------------------------------------------------------------------------------------------------------------')
76 | print('verifySanityCheckDeployment.py')
77 | print(' Verify the Sanity Check Deployment in the pipeline.')
78 | print('----------------------------------------------------------------------------------------------------------------------')
79 | print('Usage: python3 verifySanityCheckDeployment.py [options]')
80 | print(' --help Show this help.')
81 | print('---------------------------------------------------------------------------------------------- Mandatory Options -----')
82 | print(' --job_name=[Jenkins Job name]')
83 | print(' --job_id=[Jenkins Job Build ID]')
84 |
85 | #--------------------------------------------------------------------------------------------------------
86 | #
87 | # Start of main
88 | #
89 | #--------------------------------------------------------------------------------------------------------
90 |
91 | argvs = sys.argv
92 | argc = len(argvs)
93 |
94 | vscd = verifySanityCheckDeployment()
95 |
96 | while len(argvs) > 1:
97 | myArgv = argvs.pop(1)
98 | if re.match('^\-\-help$', myArgv, re.IGNORECASE):
99 | Usage()
100 | sys.exit(0)
101 | elif re.match('^\-\-job_name=(.+)$', myArgv, re.IGNORECASE):
102 | matchReg = re.match('^\-\-job_name=(.+)$', myArgv, re.IGNORECASE)
103 | vscd.job_name = matchReg.group(1)
104 | elif re.match('^\-\-job_id=(.+)$', myArgv, re.IGNORECASE):
105 | matchReg = re.match('^\-\-job_id=(.+)$', myArgv, re.IGNORECASE)
106 | vscd.job_id = matchReg.group(1)
107 | else:
108 | sys.exit('Invalid Parameter: ' + myArgv)
109 |
110 | if vscd.job_name == '' or vscd.job_id == '':
111 | sys.exit('Missing Parameter in job description')
112 |
113 | vscd.checkLogs()
114 |
--------------------------------------------------------------------------------
/docker/Dockerfile.rocky8:
--------------------------------------------------------------------------------
1 | #/*
2 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # * contributor license agreements. See the NOTICE file distributed with
4 | # * this work for additional information regarding copyright ownership.
5 | # * The OpenAirInterface Software Alliance licenses this file to You under
6 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # * except in compliance with the License.
8 | # * You may obtain a copy of the License at
9 | # *
10 | # * http://www.openairinterface.org/?page_id=698
11 | # *
12 | # * Unless required by applicable law or agreed to in writing, software
13 | # * distributed under the License is distributed on an "AS IS" BASIS,
14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # * See the License for the specific language governing permissions and
16 | # * limitations under the License.
17 | # *-------------------------------------------------------------------------------
18 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # * contact@openairinterface.org
20 | # */
21 | #---------------------------------------------------------------------
22 | #
23 | # Dockerfile for the Open-Air-Interface SPGW-U-TINY service
24 | # Valid for Rocky Linux 8.7
25 | #
26 | #---------------------------------------------------------------------
27 |
28 | #---------------------------------------------------------------------
29 | # BUILDER IMAGE
30 | #---------------------------------------------------------------------
31 | FROM docker.io/rockylinux:8.7 as oai-spgwu-tiny-builder
32 |
33 | RUN dnf install 'dnf-command(config-manager)' -y && \
34 | dnf config-manager --set-enabled powertools && \
35 | dnf install epel-release -y && crb enable && \
36 | dnf update -y && \
37 | dnf -y install \
38 | diffutils \
39 | file \
40 | wget \
41 | psmisc \
42 | git
43 |
44 | # Copy the workspace as is
45 | WORKDIR /openair-spgwu-tiny
46 | COPY . /openair-spgwu-tiny
47 |
48 | # Installing and Building SPGW-U-TINY
49 | WORKDIR /openair-spgwu-tiny/build/scripts
50 | RUN ./build_spgwu --install-deps --force
51 |
52 | RUN ./build_spgwu --clean --build-type Release --jobs --Verbose && \
53 | ldd /openair-spgwu-tiny/build/spgw_u/build/spgwu && \
54 | mv /openair-spgwu-tiny/build/spgw_u/build/spgwu /openair-spgwu-tiny/build/spgw_u/build/oai_spgwu
55 |
56 | #---------------------------------------------------------------------
57 | # TARGET IMAGE
58 | #---------------------------------------------------------------------
59 | FROM docker.io/rockylinux:8.7-minimal as oai-spgwu-tiny
60 | ENV TZ=Europe/Paris
61 |
62 | # We install some debug tools for the moment in addition of mandatory libraries
63 | RUN microdnf update -y && \
64 | microdnf install -y \
65 | python3 \
66 | python3-pip \
67 | tzdata \
68 | procps-ng \
69 | psmisc \
70 | net-tools \
71 | ethtool \
72 | iproute \
73 | iptables \
74 | initscripts \
75 | libicu \
76 | boost \
77 | libevent \
78 | findutils \
79 | libconfig && \
80 | pip3 install jinja2 && \
81 | microdnf clean all -y && \
82 | rm -rf /var/cache/dnf
83 |
84 | # Copying executable and generated libraries
85 | WORKDIR /openair-spgwu-tiny/bin
86 | COPY --from=oai-spgwu-tiny-builder \
87 | /openair-spgwu-tiny/build/spgw_u/build/oai_spgwu \
88 | /openair-spgwu-tiny/scripts/entrypoint.py \
89 | /openair-spgwu-tiny/scripts/healthcheck.sh \
90 | ./
91 |
92 | # Copying installed libraries from builder
93 | COPY --from=oai-spgwu-tiny-builder \
94 | # Currently we keep these folly dependencies from the builder
95 | /lib64/libgflags.so.2.1 \
96 | /lib64/libglog.so.0 \
97 | /lib64/libdouble-conversion.so.3 \
98 | /usr/local/lib64/libspdlog.so \
99 | /usr/local/lib64/libfmt.so \
100 | /lib64/
101 | RUN ldconfig && \
102 | ldd /openair-spgwu-tiny/bin/oai_spgwu
103 |
104 | # Copying template configuration files
105 | # The configuration folder will be flat
106 | WORKDIR /openair-spgwu-tiny/etc
107 | COPY --from=oai-spgwu-tiny-builder /openair-spgwu-tiny/etc/spgw_u.conf .
108 |
109 | WORKDIR /openair-spgwu-tiny
110 |
111 | # expose ports
112 | EXPOSE 2152/udp 8805/udp
113 | # healthcheck
114 | HEALTHCHECK --interval=10s \
115 | --timeout=15s \
116 | --retries=6 \
117 | CMD /openair-spgwu-tiny/bin/healthcheck.sh
118 |
119 | CMD ["/openair-spgwu-tiny/bin/oai_spgwu", "-c", "/openair-spgwu-tiny/etc/spgw_u.conf", "-o"]
120 | ENTRYPOINT ["python3", "/openair-spgwu-tiny/bin/entrypoint.py"]
121 |
--------------------------------------------------------------------------------
/docs/FEATURE_SET.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | |
9 |
10 | OpenAirInterface Core Network Feature Set
11 | |
12 |
13 |
14 |
15 | **Table of Contents**
16 |
17 | 1. [OpenAirInterface Core Network Block Diagram](#1-openairinterface-core-network-block-diagram)
18 | 2. [OpenAirInterface Core Network Fundamentals](#2-oai-core-network-fundamentals)
19 | 3. [OpenAirInterface Core Network Deployment](#3-oai-core-network-deployment)
20 | 4. [OpenAirInterface SPGW-CUPS Fundamentals](#4-oai-spgw-cups-fundamentals)
21 | 5. [OpenAirInterface SGW Feature List](./FEATURE_SET_SGW.md)
22 | 6. [OpenAirInterface PGW Feature List](./FEATURE_SET_PGW.md)
23 |
24 | # 1. OpenAirInterface Core Network Block Diagram #
25 |
26 | 
27 |
28 | # 2. OAI Core Network Fundamentals #
29 |
30 | * Network Access Control Functions
31 | - Authentication and authorization
32 | - Admission control
33 | - Policy and charging enforcement
34 | * Packet Routing and Transfer Functions
35 | - IP header compression function
36 | - Packet screening.
37 | * Mobility Management Functions
38 | - Reachability management for UE in ECM IDLE state
39 | * Security Functions
40 | * Radio Resource Management Functions
41 | * Network Management Functions (O&M)
42 | - `GTP` C signaling based Load and Overload Control
43 | - Load balancing between `MME` instances
44 | - `MME` control of overload
45 | - PDN Gateway control of overload
46 |
47 | # 3. OAI Core Network Deployment #
48 |
49 | * Target OS
50 | - Ubuntu 18.04 (bionic) server edition
51 | - Red Hat Entreprise Linux 8
52 | * Hardware Requirements
53 | - x86-64 Intel/AMD CPU
54 | - At least one 1 network device
55 | * Linux Kernel
56 | - Generic kernel is enough
57 | * Deployment feasible on:
58 | - PC
59 | - Server
60 | - Container
61 | - Virtual Machine
62 |
63 | **We strongly recommend a container-based deployment (either in a `docker-compose` fashion, or in a `Kubernetes`-like cluster).**
64 |
65 | # 4. OAI SPGW-CUPS Fundamentals #
66 |
67 | CUPS = Control-User Planes Separation
68 |
69 | So SPGW is composed of almost 2 network functions:
70 |
71 | * 1 SPGW-C
72 | * 1 SPGW-U
73 |
74 | Multiple instances of `SPGW-U` may be connected to a single instance of `SPGW-C`.
75 |
76 | Fully written in C++ (-std=c++17)
77 |
78 | * Internal design still asynchronous (ITTI based API)
79 | * Usage of submodules: spdlog, libfolly (nolock collections)
80 |
81 | Main differences with previous SPGW (tag `v0.7.0`)
82 |
83 | * Handles `GTP` fragmentation
84 | * Enables Network Address Translation (`NAT`), based on iptables
85 | * Easier to install (no kernel dependencies)
86 | * Switch-talking natively `PFCP`
87 | * Data is copied/handled in user space
88 |
--------------------------------------------------------------------------------
/docs/images/oai_cn_block_diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OPENAIRINTERFACE/openair-spgwu-tiny/93df89971f8bce5595489d8a8a02a4c1fd6a17b2/docs/images/oai_cn_block_diagram.png
--------------------------------------------------------------------------------
/docs/images/oai_final_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OPENAIRINTERFACE/openair-spgwu-tiny/93df89971f8bce5595489d8a8a02a4c1fd6a17b2/docs/images/oai_final_logo.png
--------------------------------------------------------------------------------
/etc/README.md:
--------------------------------------------------------------------------------
1 | # jinj2-generated configuration file #
2 |
3 | We are switching to `python3-jinja2` tool in order to generate more complex configuration for our 5G core network functions.
4 |
5 | Pre-requisites: install python3 and jinja2 packages:
6 |
7 | ```bash
8 | sudo apt-get install -y python3 python3-jinja2
9 | # or
10 | sudo yum install -y python3 python3-pip
11 | pip3 install jinja2
12 | ```
13 |
14 | In a container deployment, you will still have to provide environment variables through a `docker-compose-file` or helm charts.
15 |
16 | But you can also emulate how the entrypoint behaves locally on your workspace
17 |
18 | ## LTE 4G Legacy configuration ##
19 |
20 | Create a `test-jinja.sh` file and edit it:
21 |
22 | ```bash
23 | $ vi test-jinja.sh
24 | #!/bin/bash
25 |
26 | cp etc/spgw_u.conf etc/spgw_u_copy.conf
27 | export CONFIG_FILE=./etc/spgw_u_copy.conf
28 | export MOUNT_CONFIG=NO
29 | export TZ=Europe/Paris
30 | export PID_DIRECTORY=/var/run
31 | #export SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP=eth0
32 | #export PGW_INTERFACE_NAME_FOR_SGI=eth0
33 | #export SGW_INTERFACE_NAME_FOR_SX=eth0
34 | export SPGWC0_IP_ADDRESS=192.168.61.70
35 | export NETWORK_UE_IP=12.0.0.0/24
36 | export NETWORK_UE_NAT_OPTION=yes
37 | export MCC=208
38 | export MNC=96
39 | export MNC03=096
40 | export TAC=1
41 | export GW_ID=1
42 | export REALM=openairinterface.org
43 |
44 | ./scripts/entrypoint.py
45 | $ chmod 755 test-jinja.sh
46 | $ ./test-jinja.sh
47 | Configuration file ./etc/spgw_u_copy.conf is ready
48 | ```
49 |
50 | ## 5G SA Core Network configuration ##
51 |
52 | Create a `test-jinja-5g.sh` file and edit it:
53 |
54 | ```bash
55 | $ vi test-jinja-5g.sh
56 | #!/bin/bash
57 |
58 | cp etc/spgw_u.conf etc/spgw_u_copy.conf
59 | export CONFIG_FILE=./etc/spgw_u_copy.conf
60 | export MOUNT_CONFIG=NO
61 | export TZ=Europe/Paris
62 | export PID_DIRECTORY=/var/run
63 | export SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP=eth0
64 | export SGW_INTERFACE_NAME_FOR_SX=eth0
65 | export PGW_INTERFACE_NAME_FOR_SGI=eth0
66 | export NETWORK_UE_NAT_OPTION=yes
67 | export NETWORK_UE_IP=12.1.1.0/24
68 | export BYPASS_UL_PFCP_RULES=no
69 | export MCC=208
70 | export MNC=95
71 | export MNC03=095
72 | export TAC=40960
73 | export GW_ID=1
74 | export THREAD_S1U_PRIO=80
75 | export S1U_THREADS=8
76 | export THREAD_SX_PRIO=81
77 | export SX_THREADS=1
78 | export THREAD_SGI_PRIO=80
79 | export SGI_THREADS=8
80 | export REALM=openairinterface.org
81 | export ENABLE_5G_FEATURES=yes
82 | export REGISTER_NRF=yes
83 | export USE_FQDN_NRF=yes
84 | export UPF_FQDN_5G=oai-spgwu
85 | export NRF_IPV4_ADDRESS=192.168.70.130
86 | export NRF_PORT=80
87 | export NRF_API_VERSION=v1
88 | export NRF_FQDN=oai-nrf
89 | export NSSAI_SST_0=1
90 | export NSSAI_SD_0=0xFFFFFF
91 | export DNN_0=oai
92 | export NSSAI_SST_1=1
93 | export NSSAI_SD_1=1
94 | export DNN_1=oai.ipv4
95 | export NSSAI_SST_2=222
96 | export NSSAI_SD_2=123
97 | export DNN_2=default
98 |
99 | ./scripts/entrypoint.py
100 | $ chmod 755 test-jinja-5g.sh
101 | $ ./test-jinja-5g.sh
102 | Configuration file ./etc/spgw_u_copy.conf is ready
103 | ```
104 |
105 | ## List of fields ##
106 |
107 | Here is the current list of fields, with their mandatory status and any default values.
108 |
109 | If there is no default value associated to a field, it means it is **MANDATORY** to provide one.
110 |
111 | | Field Name | Mandatory / Optional | 4G / 5G / Both | Default value if any |
112 | |:-----------|----------------------|----------------|---------------------:|
113 | | GW_ID | Mandatory | 4G | |
114 | | MNC03 | Mandatory | 4G | |
115 | | MCC | Mandatory | 4G | |
116 | | REALM | Mandatory | 4G | |
117 | | PID_DIRECTORY | Mandatory | 4G and 5G | |
118 | | SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP | Optional | 4G and 5G | eth0 |
119 | | THREAD_S1U_PRIO | Optional | 4G and 5G | 80 |
120 | | S1U_THREADS | Optional | 4G and 5G | 8 |
121 | | SGW_INTERFACE_NAME_FOR_SX | Optional | 4G and 5G | eth0 |
122 | | THREAD_SX_PRIO | Optional | 4G and 5G | 81 |
123 | | SX_THREADS | Optional | 4G and 5G | 1 |
124 | | PGW_INTERFACE_NAME_FOR_SGI | Optional | 4G and 5G | eth0 |
125 | | THREAD_SGI_PRIO | Optional | 4G and 5G | 80 |
126 | | SGI_THREADS | Optional | 4G and 5G | 8 |
127 | | NETWORK_UE_NAT_OPTION | Optional | 4G and 5G | no |
128 | | NETWORK_UE_IP | Mandatory | 4G and 5G | |
129 | | BYPASS_UL_PFCP_RULES | Optional | 4G and 5G | no |
130 | | SPGWC_HOSTNAME | Optional | 4G | |
131 | | SPGWC0_IP_ADDRESS | Mandatory | 4G | mandatory if SPGWC_HOSTNAME undefined |
132 | | ENABLE_5G_FEATURES | Optional | 5G | no |
133 | | REGISTER_NRF | Optional | 5G | no |
134 | | USE_FQDN_NRF | Optional | 5G | no |
135 | | UPF_FQDN_5G | Optional | 5G | |
136 | | NRF_HOSTNAME | Optional | 5G | |
137 | | NRF_PORT | Optional | 5G | 80 |
138 | | HTTP_VERSION | Optional | 5G | 1 |
139 | | NRF_API_VERSION | Optional | 5G | v1 |
140 | | NRF_FQDN | Optional | 5G | |
141 | | NSSAI_SST_0 | Optional | 5G | |
142 | | NSSAI_SD_0 | Optional | 5G | 0xFFFFFF |
143 | | DNN_0 | Optional | 5G | |
144 |
145 |
--------------------------------------------------------------------------------
/openshift/README.md:
--------------------------------------------------------------------------------
1 | # Build and deploying OAI-SPGW-U in OpenShift cluster #
2 |
3 | ## Pre-requisite ##
4 |
5 | To build our images, we SHALL use the `codeready-builder-for-rhel-8-x86_64-rpms` repository with all the proper development libraries.
6 |
7 | This repository is not directly accessible from the UBI RHEL8 image (`registry.access.redhat.com/ubi8/ubi:latest`).
8 |
9 | So we need to copy, from a registered RHEL8 machine, certificates and subsccription manager configuration files.
10 |
11 | On a `RHEL8` physical machine (or a virtual machine) connected to the OpenShift Cluster, recover the entitlement and the RH subscription manager configs:
12 |
13 | ```bash
14 | oc create configmap rhsm-conf --from-file /etc/rhsm/rhsm.conf
15 | oc create configmap rhsm-ca --from-file /etc/rhsm/ca/redhat-uep.pem
16 |
17 | oc create secret generic etc-pki-entitlement --from-file /etc/pki/entitlement/{NUMBER_ON_YOUR_COMPUTER}.pem --from-file /etc/pki/entitlement/{NUMBER_ON_YOUR_COMPUTER}-key.pem
18 | ```
19 |
20 | These configmaps and secret will be shared by all the build configs in your OC project. No need to do it each time.
21 |
22 | ## Launching the Build ##
23 |
24 | On a machine connected to the OpenShift Cluster, create the target image stream and the build configuration.
25 |
26 | Note that the project name is currently hard-coded to `oai`.
27 |
28 | **TODO: pass as env variables: branch name, image tag and project name**
29 |
30 | ```bash
31 | git clone https://github.com/OPENAIRINTERFACE/openair-spgwu-tiny.git
32 | cd openair-spgwu-tiny
33 | git checkout develop
34 | oc apply -f openshift/oai-spgwu-tiny-image-stream.yml
35 | oc apply -f openshift/oai-spgwu-tiny-build-config.yml
36 | ```
37 |
38 | Note that this step has to be done once before the first build and if you modify the yaml files.
39 |
40 | Then anytime you want to build:
41 |
42 | ```bash
43 | oc start-build oai-spgwu-tiny-build-config --follow
44 | ```
45 |
46 | The `--follow` might break.
47 |
48 | ```bash
49 | oc logs build/oai-spgwu-tiny-build-config-XYZ --follow
50 | ```
51 |
52 | where `XYZ` is the build number.
53 |
54 | You should see a successful buid when :
55 |
56 | ```bash
57 | ...
58 | Pushing image image-registry.openshift-image-registry.svc:5000/oai/oai-spgwu-tiny:onap-0.1.0 ...
59 | Getting image source signatures
60 | Copying blob sha256:087e0da17c56af1aaf0a1eba37169b46f6c46936b554b7e13f11165dac4ba8ef
61 | ...
62 | Copying blob sha256:0adcf0e0c86fbba84ed7a22a57a2cd4d7695c1ce858dd03f03dc3002880b8061
63 | Copying config sha256:73330dfa1a733335355324848a02ba1899f9d125559979f9911f3dedcd4450ca
64 | Writing manifest to image destination
65 | Storing signatures
66 | Successfully pushed image-registry.openshift-image-registry.svc:5000/oai/oai-spgwu-tiny@sha256:c1de087af5515d22e40486fb181f6ff65a7f34788d8174aa122d686667042cf9
67 | Push successful
68 | ```
69 |
--------------------------------------------------------------------------------
/openshift/bc-dev.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: build.openshift.io/v1
3 | kind: BuildConfig
4 | metadata:
5 | name: oai-spgwu-tiny-dev
6 | spec:
7 | output:
8 | to:
9 | kind: ImageStreamTag
10 | name: "oai-spgwu-tiny-dev:oai-oc"
11 | runPolicy: Serial
12 | strategy:
13 | type: Docker
14 | source:
15 | secrets:
16 | - destinationDir: etc-pki-entitlement
17 | secret:
18 | name: etc-pki-entitlement
19 | configMaps:
20 | - configMap:
21 | name: rhsm-conf
22 | destinationDir: rhsm-conf
23 | - configMap:
24 | name: rhsm-ca
25 | destinationDir: rhsm-ca
26 | dockerfile: |
27 | ################################################################
28 | # Builder Image (can also be used as developer's image)
29 | ################################################################
30 | FROM image-registry.openshift-image-registry.svc:5000/oai4g/oai-spgwu-tiny-base-builder:oai-oc as oai-spgwu-tiny-builder
31 | ENV TZ=Europe/Paris
32 |
33 | WORKDIR /
34 | RUN git clone -b develop https://github.com/lionelgo/openair-spgwu-tiny.git
35 |
36 | WORKDIR /openair-spgwu-tiny/build/ext
37 | RUN ln -s /spdlog /openair-spgwu-tiny/build/ext/spdlog \
38 | && ln -s /json /openair-spgwu-tiny/build/ext/json
39 | WORKDIR /openair-spgwu-tiny/build/scripts
40 | RUN ./build_spgwu --clean --build-type Release --jobs --Verbose \
41 | && ldd /openair-spgwu-tiny/build/spgw_u/build/spgwu \
42 | && mv /openair-spgwu-tiny/build/spgw_u/build/spgwu \
43 | /openair-spgwu-tiny/build/spgw_u/build/oai_spgwu \
44 | && mkdir /openair-spgwu-tiny/bin \
45 | && cp /openair-spgwu-tiny/build/spgw_u/build/oai_spgwu \
46 | /openair-spgwu-tiny/scripts/entrypoint.sh \
47 | /openair-spgwu-tiny/bin
48 |
49 |
50 | RUN ldconfig && \
51 | ldd /openair-spgwu-tiny/bin/oai_spgwu
52 |
53 | WORKDIR /openair-spgwu-tiny
54 |
55 | # expose ports
56 | EXPOSE 2152/udp 8805/udp
57 |
58 | CMD ["/openair-spgwu-tiny/bin/oai_spgwu", "-c", "/openair-spgwu-tiny/etc/spgw_u.conf", "-o"]
59 | ENTRYPOINT ["/openair-spgwu-tiny/bin/entrypoint.sh"]
60 |
--------------------------------------------------------------------------------
/openshift/bc-target.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: build.openshift.io/v1
3 | kind: BuildConfig
4 | metadata:
5 | name: oai-spgwu-tiny
6 | spec:
7 | output:
8 | to:
9 | kind: ImageStreamTag
10 | name: "oai-spgwu-tiny:oai-oc"
11 | runPolicy: Serial
12 | strategy:
13 | type: Docker
14 | source:
15 | secrets:
16 | - destinationDir: etc-pki-entitlement
17 | secret:
18 | name: etc-pki-entitlement
19 | configMaps:
20 | - configMap:
21 | name: rhsm-conf
22 | destinationDir: rhsm-conf
23 | - configMap:
24 | name: rhsm-ca
25 | destinationDir: rhsm-ca
26 | dockerfile: |
27 | ################################################################
28 | # Target Image
29 | ################################################################
30 | FROM image-registry.openshift-image-registry.svc:5000/oai4g/oai-spgwu-tiny-dev:oai-oc as oai-spgwu-tiny-dev
31 | FROM registry.access.redhat.com/ubi8/ubi:latest as spgwu
32 |
33 | ENV TZ=Europe/Paris
34 |
35 | # We install some debug tools for the moment in addition of mandatory libraries
36 | RUN yum update -y && \
37 | yum -y install --enablerepo="ubi-8-codeready-builder" \
38 | tzdata \
39 | procps-ng \
40 | psmisc \
41 | net-tools \
42 | ethtool \
43 | iproute \
44 | iptables \
45 | initscripts \
46 | libevent && \
47 | yum clean all -y && \
48 | rm -rf /var/cache/yum /var/cache/dnf
49 |
50 | # Copying executable and generated libraries
51 | WORKDIR /openair-spgwu-tiny/bin
52 | COPY --from=oai-spgwu-tiny-dev \
53 | /openair-spgwu-tiny/build/spgw_u/build/oai_spgwu \
54 | /openair-spgwu-tiny/scripts/entrypoint.sh \
55 | ./
56 |
57 | # Copying installed libraries from builder
58 | COPY --from=oai-spgwu-tiny-dev \
59 | /lib64/libgflags.so.2.1 \
60 | /lib64/libglog.so.0 \
61 | /lib64/libdouble-conversion.so.1 \
62 | /lib64/libconfig++.so.9 \
63 | /lib64/libboost_system.so.1.66.0 \
64 | /lib64/
65 | RUN ldconfig && \
66 | ldd /openair-spgwu-tiny/bin/oai_spgwu
67 |
68 | # Copying template configuration files
69 | # The configuration folder will be flat
70 | WORKDIR /openair-spgwu-tiny/etc
71 | COPY --from=oai-spgwu-tiny-dev /openair-spgwu-tiny/etc/spgw_u.conf .
72 |
73 | WORKDIR /openair-spgwu-tiny
74 |
75 | # expose ports
76 | EXPOSE 2152/udp 8805/udp
77 |
78 | CMD ["/openair-spgwu-tiny/bin/oai_spgwu", "-c", "/openair-spgwu-tiny/etc/spgw_u.conf", "-o"]
79 | ENTRYPOINT ["/openair-spgwu-tiny/bin/entrypoint.sh"]
80 |
--------------------------------------------------------------------------------
/openshift/is-base.yml:
--------------------------------------------------------------------------------
1 | #/*
2 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # * contributor license agreements. See the NOTICE file distributed with
4 | # * this work for additional information regarding copyright ownership.
5 | # * The OpenAirInterface Software Alliance licenses this file to You under
6 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # * except in compliance with the License.
8 | # * You may obtain a copy of the License at
9 | # *
10 | # * http://www.openairinterface.org/?page_id=698
11 | # *
12 | # * Unless required by applicable law or agreed to in writing, software
13 | # * distributed under the License is distributed on an "AS IS" BASIS,
14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # * See the License for the specific language governing permissions and
16 | # * limitations under the License.
17 | # *-------------------------------------------------------------------------------
18 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # * contact@openairinterface.org
20 | # */
21 | #
22 | apiVersion: image.openshift.io/v1
23 | kind: ImageStream
24 | metadata:
25 | name: oai-spgwu-tiny-base-builder
26 | namespace: oai4g
27 | status:
28 | tag: oai-oc
29 | spec:
30 | lookupPolicy:
31 | local: true
--------------------------------------------------------------------------------
/openshift/is-dev.yml:
--------------------------------------------------------------------------------
1 | #/*
2 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # * contributor license agreements. See the NOTICE file distributed with
4 | # * this work for additional information regarding copyright ownership.
5 | # * The OpenAirInterface Software Alliance licenses this file to You under
6 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # * except in compliance with the License.
8 | # * You may obtain a copy of the License at
9 | # *
10 | # * http://www.openairinterface.org/?page_id=698
11 | # *
12 | # * Unless required by applicable law or agreed to in writing, software
13 | # * distributed under the License is distributed on an "AS IS" BASIS,
14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # * See the License for the specific language governing permissions and
16 | # * limitations under the License.
17 | # *-------------------------------------------------------------------------------
18 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # * contact@openairinterface.org
20 | # */
21 | #
22 | apiVersion: image.openshift.io/v1
23 | kind: ImageStream
24 | metadata:
25 | name: oai-spgwu-tiny-dev
26 | namespace: oai4g
27 | status:
28 | tag: oai-oc
29 | spec:
30 | lookupPolicy:
31 | local: true
--------------------------------------------------------------------------------
/openshift/is-target.yml:
--------------------------------------------------------------------------------
1 | #/*
2 | # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # * contributor license agreements. See the NOTICE file distributed with
4 | # * this work for additional information regarding copyright ownership.
5 | # * The OpenAirInterface Software Alliance licenses this file to You under
6 | # * the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # * except in compliance with the License.
8 | # * You may obtain a copy of the License at
9 | # *
10 | # * http://www.openairinterface.org/?page_id=698
11 | # *
12 | # * Unless required by applicable law or agreed to in writing, software
13 | # * distributed under the License is distributed on an "AS IS" BASIS,
14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # * See the License for the specific language governing permissions and
16 | # * limitations under the License.
17 | # *-------------------------------------------------------------------------------
18 | # * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # * contact@openairinterface.org
20 | # */
21 | #
22 | apiVersion: image.openshift.io/v1
23 | kind: ImageStream
24 | metadata:
25 | name: oai-spgwu-tiny
26 | namespace: oai4g
27 | status:
28 | tag: oai-oc
29 | spec:
30 | lookupPolicy:
31 | local: true
--------------------------------------------------------------------------------
/scripts/entrypoint.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | ################################################################################
3 | # Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The OpenAirInterface Software Alliance licenses this file to You under
7 | # the OAI Public License, Version 1.1 (the "License"); you may not use this file
8 | # except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.openairinterface.org/?page_id=698
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #-------------------------------------------------------------------------------
19 | # For more information about the OpenAirInterface (OAI) Software Alliance:
20 | # contact@openairinterface.org
21 | ################################################################################
22 |
23 | from jinja2 import Environment, FileSystemLoader
24 | import socket
25 | import os
26 | import sys
27 |
28 | CONFIG_FILE = str(os.getenv('CONFIG_FILE','/openair-spgwu-tiny/etc/spgw_u.conf'))
29 | MOUNT_CONFIG = str(os.getenv('MOUNT_CONFIG','no')).lower()
30 |
31 | def resolve(hostname):
32 | try:
33 | return socket.gethostbyname(hostname)
34 | except socket.error:
35 | print(f"Not able to resolve {hostname}")
36 |
37 | def render(filepath,funcs,values):
38 | env = Environment(loader=FileSystemLoader(os.path.dirname(filepath)))
39 | jinja_template = env.get_template(os.path.basename(filepath))
40 | jinja_template.globals.update(funcs)
41 | template_string = jinja_template.render(env=values)
42 | return template_string
43 |
44 | env_variables = dict()
45 | #list of all the environment variables
46 | for name, value in os.environ.items():
47 | env_variables.update({name:value})
48 |
49 | if MOUNT_CONFIG != "yes":
50 | output = render(CONFIG_FILE,{"resolve":resolve},env_variables)
51 | with open(CONFIG_FILE, "w") as fh:
52 | fh.write(output)
53 | print(f"Configuration file {CONFIG_FILE} is ready")
54 | else:
55 | print("Configuration file is mounted to the network function")
56 | if len(sys.argv) == 1:
57 | sys.exit(0)
58 | os.execvp(sys.argv[1], sys.argv[1:]) #important for running the network function it works like exec $@
--------------------------------------------------------------------------------
/scripts/healthcheck.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eo pipefail
3 |
4 | STATUS=0
5 | SGW_PORT_FOR_S1U_S12_S4_UP=2152
6 | SGW_PORT_FOR_SX=8805
7 | SGW_IP_S1U_INTERFACE=$(ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP | grep inet | awk {'print $2'})
8 | SGW_IP_SX_INTERFACE=$(ifconfig $SGW_INTERFACE_NAME_FOR_SX | grep inet | awk {'print $2'})
9 | S1U_S12_S4_UP_PORT_STATUS=$(netstat -unpl | grep -o "$SGW_IP_S1U_INTERFACE:$SGW_PORT_FOR_S1U_S12_S4_UP")
10 | SX_PORT_STATUS=$(netstat -unpl | grep -o "$SGW_IP_SX_INTERFACE:$SGW_PORT_FOR_SX")
11 | #Check if entrypoint properly configured the conf file and no parameter is unset (optional)
12 | NB_UNREPLACED_AT=`cat /openair-spgwu/etc/*.conf | grep -v contact@openairinterface.org | grep -c @ || true`
13 | if [ $NB_UNREPLACED_AT -ne 0 ]; then
14 | STATUS=1
15 | echo "Healthcheck error: UNHEALTHY configuration file is not configured properly"
16 | fi
17 |
18 | if [[ -z $S1U_S12_S4_UP_PORT_STATUS ]]; then
19 | STATUS=1
20 | echo "Healthcheck error: UNHEALTHY S1U port $SGW_PORT_FOR_S1U_S12_S4_UP is not listening."
21 | fi
22 |
23 | if [[ -z $SX_PORT_STATUS ]]; then
24 | STATUS=1
25 | echo "Healthcheck error: UNHEALTHY SX port $SGW_PORT_FOR_SX is not listening."
26 | fi
27 |
28 | exit $STATUS
--------------------------------------------------------------------------------
/src/.clang-format:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2015, EURECOM (www.eurecom.fr)
3 | # All rights reserved.
4 | #
5 | # Redistribution and use in source and binary forms, with or without
6 | # modification, are permitted provided that the following conditions are met:
7 | #
8 | # 1. Redistributions of source code must retain the above copyright notice, this
9 | # list of conditions and the following disclaimer.
10 | # 2. Redistributions in binary form must reproduce the above copyright notice,
11 | # this list of conditions and the following disclaimer in the documentation
12 | # and/or other materials provided with the distribution.
13 | #
14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | #
25 | # The views and conclusions contained in the software and documentation are those
26 | # of the authors and should not be interpreted as representing official policies,
27 | # either expressed or implied, of the FreeBSD Project.
28 | #
29 |
30 | # see https://clang.llvm.org/docs/ClangFormatStyleOptions.html for explanation
31 | # of style options
32 |
33 | BasedOnStyle: Google
34 | Language: Cpp
35 | IndentWidth: 2
36 | ColumnLimit: 80
37 |
38 | IncludeBlocks: Preserve
39 | SortIncludes: false
40 |
41 | # alignment
42 | AlignAfterOpenBracket: AlwaysBreak
43 | AlignConsecutiveAssignments: true
44 | AlignConsecutiveDeclarations: false
45 | AlignEscapedNewlines: Right
46 | AlignOperands: true
47 | AlignTrailingComments: true
48 | DerivePointerAlignment: false
49 | PointerAlignment: Left
50 |
51 | # function style
52 | AllowAllParametersOfDeclarationOnNextLine: false
53 | AllowShortFunctionsOnASingleLine: Inline
54 | AlwaysBreakAfterReturnType: None
55 | IndentWrappedFunctionNames: false
56 |
57 | # template style
58 | AlwaysBreakTemplateDeclarations: Yes
59 |
60 | # preprocessor style
61 | IndentPPDirectives: None
62 |
63 | # block style
64 | AllowShortBlocksOnASingleLine: false
65 | KeepEmptyLinesAtTheStartOfBlocks: false
66 |
67 | # break style
68 | BreakBeforeBinaryOperators: None
69 | BreakBeforeBraces: Attach
70 | BreakBeforeTernaryOperators: false
71 | BreakStringLiterals: true
72 | CompactNamespaces: false
73 | ContinuationIndentWidth: 4
74 | MaxEmptyLinesToKeep: 1
75 | ReflowComments: true
76 |
77 | # spacing style
78 | UseTab: Never
79 | SpaceAfterCStyleCast: true
80 | SpaceAfterTemplateKeyword: false
81 | SpaceBeforeAssignmentOperators: true
82 | SpaceBeforeInheritanceColon: true
83 | SpaceBeforeParens: ControlStatements
84 | SpaceBeforeRangeBasedForLoopColon: true
85 | SpaceInEmptyParentheses: false
86 | SpacesBeforeTrailingComments: 2
87 | SpacesInAngles: false
88 | SpacesInCStyleCastParentheses: false
89 | SpacesInContainerLiterals: false
90 | SpacesInParentheses: false
91 | SpacesInSquareBrackets: false
92 |
93 | # class style
94 | BreakConstructorInitializers: BeforeColon
95 | BreakInheritanceList: BeforeColon
96 | ConstructorInitializerAllOnOneLineOrOnePerLine: true
97 | ConstructorInitializerIndentWidth: 4
98 |
99 | # case statements
100 | IndentCaseLabels: true
101 |
102 | # cpp
103 | Cpp11BracedListStyle: true
104 | FixNamespaceComments: true
105 | NamespaceIndentation: None
106 | SortUsingDeclarations: true
107 |
108 | # todo
109 | # AlwaysBreakBeforeMultilineStrings: bool
110 | # PenaltyBreakAssignment (unsigned)
111 | # PenaltyBreakBeforeFirstCallParameter (unsigned)
112 | # PenaltyBreakComment (unsigned)
113 | # PenaltyBreakFirstLessLess (unsigned)
114 | # PenaltyBreakString (unsigned)
115 | # PenaltyBreakTemplateDeclaration (unsigned)
116 | # PenaltyExcessCharacter (unsigned)
117 | # PenaltyReturnTypeOnItsOwnLine (unsigned)
118 |
--------------------------------------------------------------------------------
/src/common/3gpp_23.003.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file 3gpp_23.003.h
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 | #ifndef FILE_3GPP_23_003_SEEN
29 | #define FILE_3GPP_23_003_SEEN
30 |
31 | #define SST_MAX_STANDARDIZED_VALUE 127
32 | #define SD_NO_VALUE 0xFFFFFF
33 |
34 | #endif /* FILE_3GPP_23_003_SEEN */
35 |
--------------------------------------------------------------------------------
/src/common/3gpp_29.510.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | #ifndef FILE_3GPP_29_510_NRF_SEEN
23 | #define FILE_3GPP_29_510_NRF_SEEN
24 |
25 | #include
26 | #include
27 |
28 | // Section 28.4, TS23.003
29 | typedef struct s_nssai {
30 | uint8_t sST;
31 | std::string sD;
32 | s_nssai(const uint8_t& sst, const std::string sd) : sST(sst), sD(sd) {}
33 | s_nssai() : sST(), sD() {}
34 | s_nssai(const s_nssai& p) : sST(p.sST), sD(p.sD) {}
35 | bool operator==(const struct s_nssai& s) const {
36 | if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) {
37 | return true;
38 | } else {
39 | return false;
40 | }
41 | }
42 | s_nssai& operator=(const s_nssai& s) {
43 | sST = s.sST;
44 | sD = s.sD;
45 | return *this;
46 | }
47 |
48 | } snssai_t;
49 |
50 | typedef struct dnai_s {
51 | } dnai_t;
52 |
53 | typedef struct dnn_upf_info_item_s {
54 | std::string dnn;
55 | // std::vector dnai_list
56 | // std::vector pdu_session_types
57 | dnn_upf_info_item_s& operator=(const dnn_upf_info_item_s& d) {
58 | dnn = d.dnn;
59 | return *this;
60 | }
61 | } dnn_upf_info_item_t;
62 |
63 | typedef struct snssai_upf_info_item_s {
64 | snssai_t snssai;
65 | std::vector dnn_upf_info_list;
66 | snssai_upf_info_item_s& operator=(const snssai_upf_info_item_s& s) {
67 | dnn_upf_info_list = s.dnn_upf_info_list;
68 | snssai = s.snssai;
69 | return *this;
70 | }
71 | } snssai_upf_info_item_t;
72 |
73 | typedef struct upf_info_s {
74 | std::vector snssai_upf_info_list;
75 | void add_snssai(snssai_t snssai, std::string dnn) {
76 | bool found_snssai = false;
77 | dnn_upf_info_item_t dnn_item = {};
78 | dnn_item.dnn = dnn;
79 | for (int i = 0; i < snssai_upf_info_list.size(); i++) {
80 | if (snssai_upf_info_list[i].snssai == snssai) {
81 | // Add DNN to the dnn_upf_info_list if not exist
82 | bool found_dnn = false;
83 | for (int j = 0; j < snssai_upf_info_list[i].dnn_upf_info_list.size();
84 | j++) {
85 | if (snssai_upf_info_list[i].dnn_upf_info_list[j].dnn.compare(dnn) ==
86 | 0) {
87 | found_dnn = true;
88 | break;
89 | }
90 | }
91 | if (!found_dnn) {
92 | snssai_upf_info_list[i].dnn_upf_info_list.push_back(dnn_item);
93 | }
94 | found_snssai = true;
95 | }
96 | }
97 | if (!found_snssai) {
98 | snssai_upf_info_item_t snssai_item = {};
99 | snssai_item.snssai = snssai;
100 | snssai_item.dnn_upf_info_list.push_back(dnn_item);
101 | snssai_upf_info_list.push_back(snssai_item);
102 | }
103 | }
104 | void add_snssai(snssai_upf_info_item_t snssai_item) {
105 | snssai_upf_info_list.push_back(snssai_item);
106 | }
107 | upf_info_s& operator=(const upf_info_s& s) {
108 | snssai_upf_info_list = s.snssai_upf_info_list;
109 | return *this;
110 | }
111 |
112 | } upf_info_t;
113 |
114 | typedef struct patch_item_s {
115 | std::string op;
116 | std::string path;
117 | // std::string from;
118 | std::string value;
119 |
120 | nlohmann::json to_json() const {
121 | nlohmann::json json_data = {};
122 | json_data["op"] = op;
123 | json_data["path"] = path;
124 | json_data["value"] = value;
125 | return json_data;
126 | }
127 | } patch_item_t;
128 |
129 | #define NRF_CURL_TIMEOUT_MS 100L
130 | #define NNRF_NFM_BASE "/nnrf-nfm/"
131 | #define NNRF_NF_REGISTER_URL "/nf-instances/"
132 |
133 | #endif
134 |
--------------------------------------------------------------------------------
/src/common/3gpp_commons.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file 3gpp_commons.h
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_3GPP_COMMONS_SEEN
30 | #define FILE_3GPP_COMMONS_SEEN
31 |
32 | #include
33 |
34 | // 8.2 Recovery
35 | typedef struct recovery_s {
36 | uint8_t restart_counter;
37 | } recovery_t;
38 |
39 | #endif /* FILE_3GPP_COMMONS_SEEN */
40 |
--------------------------------------------------------------------------------
/src/common/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The OpenAirInterface Software Alliance licenses this file to You under
6 | # the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.openairinterface.org/?page_id=698
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #-------------------------------------------------------------------------------
18 | # For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # contact@openairinterface.org
20 | ################################################################################
21 | set(ITTI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/itti)
22 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/itti)
23 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/msg)
24 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
25 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
26 |
27 | add_library(3GPP_COMMON_TYPES STATIC
28 | )
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/common/common_defs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file common_defs.h
23 | \brief
24 | \author Sebastien ROUX, Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_COMMON_DEFS_SEEN
30 | #define FILE_COMMON_DEFS_SEEN
31 |
32 | #include
33 |
34 | #define RETURNclear (int) 2
35 | #define RETURNerror (int) 1
36 | #define RETURNok (int) 0
37 |
38 | //------------------------------------------------------------------------------
39 | #define IPV4_STR_ADDR_TO_INADDR(AdDr_StR, InAdDr, MeSsAgE) \
40 | do { \
41 | if (inet_aton(AdDr_StR, &InAdDr) <= 0) { \
42 | throw(MeSsAgE); \
43 | } \
44 | } while (0)
45 |
46 | #define NIPADDR(addr) \
47 | (uint8_t)(addr & 0x000000FF), (uint8_t)((addr & 0x0000FF00) >> 8), \
48 | (uint8_t)((addr & 0x00FF0000) >> 16), \
49 | (uint8_t)((addr & 0xFF000000) >> 24)
50 |
51 | #ifndef UNUSED
52 | #define UNUSED(x) (void) (x)
53 | #endif
54 |
55 | #endif /* FILE_COMMON_DEFS_SEEN */
56 |
--------------------------------------------------------------------------------
/src/common/common_root_types.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file common_root_types.c
23 | \brief
24 | \company Eurecom
25 | \email: lionel.gauthier@eurecom.fr
26 | */
27 |
--------------------------------------------------------------------------------
/src/common/common_root_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file common_root_types.h
23 | \brief
24 | \company Eurecom
25 | \email: lionel.gauthier@eurecom.fr
26 | */
27 |
28 | #ifndef FILE_COMMON_ROOT_TYPES_SEEN
29 | #define FILE_COMMON_ROOT_TYPES_SEEN
30 |
31 | #include
32 | #include
33 | #include
34 |
35 | //------------------------------------------------------------------------------
36 | #define PRIORITY_LEVEL_MAX (15)
37 | #define PRIORITY_LEVEL_MIN (1)
38 | #define BEARERS_PER_UE (11)
39 | #define IMEI_DIGITS_MAX (15)
40 | #define IMEISV_DIGITS_MAX (16)
41 | #define MAX_APN_PER_UE (5)
42 |
43 | #define PROC_ID_FMT "0x%" PRIx64
44 |
45 | // TEIDs
46 | typedef uint32_t teid_t;
47 | #define TEID_FMT "0x%" PRIx32
48 | #define TEID_SCAN_FMT SCNx32
49 | #define INVALID_TEID ((teid_t) 0x00000000)
50 | #define UNASSIGNED_TEID ((teid_t) 0x00000000)
51 |
52 | // SEIDs
53 | typedef uint64_t seid_t;
54 | #define SEID_FMT "0x%" PRIx64
55 | #define SEID_SCAN_FMT SCNx64
56 | #define INVALID_SEID ((seid_t) 0x00000000)
57 | #define UNASSIGNED_SEID ((seid_t) 0x00000000)
58 |
59 | //------------------------------------------------------------------------------
60 | // IMSI
61 | typedef uint64_t imsi64_t;
62 | #define IMSI_64_FMT "%" SCNu64
63 | #define INVALID_IMSI64 (imsi64_t) 0
64 |
65 | //------------------------------------------------------------------------------
66 | typedef uint64_t bitrate_t;
67 | #define PRIORITY_LEVEL_FMT "0x%" PRIu8
68 | #define QCI_FMT "0x%" PRIu8
69 | #define QCI_SCAN_FMT SCNu8
70 |
71 | #define PRE_EMPTION_CAPABILITY_FMT "0x%" PRIu8
72 | #define PRE_EMPTION_VULNERABILITY_FMT "0x%" PRIu8
73 |
74 | #endif /* FILE_COMMON_ROOT_TYPES_SEEN */
75 |
--------------------------------------------------------------------------------
/src/common/endpoint.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file endpoint.hpp
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_ENDPOINT_HPP_SEEN
30 | #define FILE_ENDPOINT_HPP_SEEN
31 |
32 | #include "conversions.hpp"
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | class endpoint {
40 | public:
41 | struct sockaddr_storage addr_storage;
42 | socklen_t addr_storage_len;
43 | endpoint()
44 | : addr_storage(), addr_storage_len(sizeof(struct sockaddr_storage)){};
45 | endpoint(const endpoint& e)
46 | : addr_storage(e.addr_storage), addr_storage_len(e.addr_storage_len){};
47 | endpoint(const struct sockaddr_storage& addr, const socklen_t len)
48 | : addr_storage(addr), addr_storage_len(len){};
49 | endpoint(const struct in_addr& addr, const uint16_t port) {
50 | struct sockaddr_in* addr_in = (struct sockaddr_in*) &addr_storage;
51 | addr_in->sin_family = AF_INET;
52 | addr_in->sin_port = htons(port);
53 | addr_in->sin_addr.s_addr = addr.s_addr;
54 |
55 | addr_storage_len = sizeof(struct sockaddr_in);
56 | };
57 |
58 | endpoint(const struct in6_addr& addr6, const uint16_t port) {
59 | struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*) &addr_storage;
60 | addr_in6->sin6_family = AF_INET6;
61 | addr_in6->sin6_port = htons(port);
62 | addr_in6->sin6_flowinfo = 0;
63 | memcpy(&addr_in6->sin6_addr, &addr6, sizeof(struct in6_addr));
64 | addr_in6->sin6_scope_id = 0;
65 |
66 | addr_storage_len = sizeof(struct sockaddr_in6);
67 | };
68 |
69 | uint16_t port() const {
70 | return ntohs(((struct sockaddr_in*) &addr_storage)->sin_port);
71 | }
72 |
73 | sa_family_t family() const { return addr_storage.ss_family; }
74 |
75 | std::string toString() const {
76 | std::string str;
77 | if (addr_storage.ss_family == AF_INET) {
78 | struct sockaddr_in* addr_in = (struct sockaddr_in*) &addr_storage;
79 | str.append(conv::toString(addr_in->sin_addr));
80 | str.append(":").append(std::to_string(ntohs(addr_in->sin_port)));
81 | } else if (addr_storage.ss_family == AF_INET6) {
82 | struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*) &addr_storage;
83 | str.append(conv::toString(addr_in6->sin6_addr));
84 | str.append(":").append(std::to_string(ntohs(addr_in6->sin6_port)));
85 | }
86 | return str;
87 | }
88 | };
89 |
90 | #endif
91 |
--------------------------------------------------------------------------------
/src/common/logger.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Sprint
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #pragma once
18 |
19 | #include
20 | #include
21 | #include
22 | #include "logger_base.hpp"
23 |
24 | static const std::string ASYNC_CMD = "async_cmd";
25 | static const std::string GTPV1_U = "gtpv1_u";
26 | static const std::string GTPV2_C = "gtpv2_c";
27 | static const std::string ITTI = "itti";
28 | static const std::string SPGWU_APP = "spgwu_app";
29 | static const std::string SPGWU_S1U = "spgwu_s1u";
30 | static const std::string SPGWU_SX = "spgwu_sx";
31 | static const std::string SYSTEM = "system";
32 | static const std::string UDP = "udp";
33 | static const std::string PFCP = "pfcp";
34 | static const std::string PFCP_SWITCH = "pfcp_switch";
35 |
36 | class Logger {
37 | public:
38 | static void init(
39 | const std::string& name, const bool log_stdout, const bool log_rot_file) {
40 | oai::logger::logger_registry::register_logger(
41 | name, ASYNC_CMD, log_stdout, log_rot_file);
42 | oai::logger::logger_registry::register_logger(
43 | name, GTPV1_U, log_stdout, log_rot_file);
44 | oai::logger::logger_registry::register_logger(
45 | name, GTPV2_C, log_stdout, log_rot_file);
46 | oai::logger::logger_registry::register_logger(
47 | name, ITTI, log_stdout, log_rot_file);
48 | oai::logger::logger_registry::register_logger(
49 | name, SPGWU_APP, log_stdout, log_rot_file);
50 | oai::logger::logger_registry::register_logger(
51 | name, SPGWU_S1U, log_stdout, log_rot_file);
52 | oai::logger::logger_registry::register_logger(
53 | name, SPGWU_SX, log_stdout, log_rot_file);
54 | oai::logger::logger_registry::register_logger(
55 | name, SYSTEM, log_stdout, log_rot_file);
56 | oai::logger::logger_registry::register_logger(
57 | name, UDP, log_stdout, log_rot_file);
58 | oai::logger::logger_registry::register_logger(
59 | name, PFCP, log_stdout, log_rot_file);
60 | oai::logger::logger_registry::register_logger(
61 | name, PFCP_SWITCH, log_stdout, log_rot_file);
62 | }
63 | static void set_level(spdlog::level::level_enum level) {
64 | oai::logger::logger_registry::set_level(level);
65 | }
66 | static bool should_log(spdlog::level::level_enum level) {
67 | return oai::logger::logger_registry::should_log(level);
68 | }
69 |
70 | static const oai::logger::printf_logger& async_cmd() {
71 | return oai::logger::logger_registry::get_logger(ASYNC_CMD);
72 | }
73 | static const oai::logger::printf_logger& gtpv1_u() {
74 | return oai::logger::logger_registry::get_logger(GTPV1_U);
75 | }
76 | static const oai::logger::printf_logger& gtpv2_c() {
77 | return oai::logger::logger_registry::get_logger(GTPV2_C);
78 | }
79 | static const oai::logger::printf_logger& itti() {
80 | return oai::logger::logger_registry::get_logger(ITTI);
81 | }
82 | static const oai::logger::printf_logger& spgwu_app() {
83 | return oai::logger::logger_registry::get_logger(SPGWU_APP);
84 | }
85 | static const oai::logger::printf_logger& spgwu_s1u() {
86 | return oai::logger::logger_registry::get_logger(SPGWU_S1U);
87 | }
88 | static const oai::logger::printf_logger& spgwu_sx() {
89 | return oai::logger::logger_registry::get_logger(SPGWU_SX);
90 | }
91 | static const oai::logger::printf_logger& system() {
92 | return oai::logger::logger_registry::get_logger(SYSTEM);
93 | }
94 | static const oai::logger::printf_logger& udp() {
95 | return oai::logger::logger_registry::get_logger(UDP);
96 | }
97 | static const oai::logger::printf_logger& pfcp() {
98 | return oai::logger::logger_registry::get_logger(PFCP);
99 | }
100 | static const oai::logger::printf_logger& pfcp_switch() {
101 | return oai::logger::logger_registry::get_logger(PFCP_SWITCH);
102 | }
103 | };
104 |
--------------------------------------------------------------------------------
/src/common/msg/itti_async_shell_cmd.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file itti_async_shell_cmd.hpp
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_ITTI_ASYNC_SHELL_CMD_SEEN
30 | #define FILE_ITTI_ASYNC_SHELL_CMD_SEEN
31 |
32 | #include "itti_msg.hpp"
33 |
34 | class itti_async_shell_cmd : public itti_msg {
35 | public:
36 | itti_async_shell_cmd(
37 | const task_id_t origin, const task_id_t destination,
38 | const std::string& system_cmd, bool is_abort_on_error,
39 | const char* src_file, const int src_line)
40 | : itti_msg(ASYNC_SHELL_CMD, origin, destination),
41 | system_command(system_cmd),
42 | is_abort_on_error(is_abort_on_error),
43 | src_file(src_file),
44 | src_line(src_line) {}
45 | itti_async_shell_cmd(const itti_async_shell_cmd& i)
46 | : itti_msg(i),
47 | system_command(i.system_command),
48 | is_abort_on_error(i.is_abort_on_error),
49 | src_file(i.src_file),
50 | src_line(i.src_line) {}
51 | const char* get_msg_name() { return typeid(itti_msg_ping).name(); };
52 | std::string system_command;
53 | bool is_abort_on_error;
54 | // debug
55 | std::string src_file;
56 | int src_line;
57 | };
58 |
59 | #endif /* FILE_ITTI_ASYNC_SHELL_CMD_SEEN */
60 |
--------------------------------------------------------------------------------
/src/common/msg/itti_msg_sx_restore.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*
23 | * itti_msg_sx_restore.hpp
24 | *
25 | * Created on: March 27, 2019
26 | * Author: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef ITTI_MSG_SX_RESTORE_HPP_INCLUDED_
30 | #define ITTI_MSG_SX_RESTORE_HPP_INCLUDED_
31 |
32 | #include "3gpp_29.244.h"
33 | #include "itti_msg.hpp"
34 | #include
35 |
36 | class itti_sx_restore : public itti_msg {
37 | public:
38 | itti_sx_restore(const task_id_t origin, const task_id_t destination)
39 | : itti_msg(RESTORE_SX_SESSIONS, origin, destination), sessions() {}
40 | itti_sx_restore(const itti_sx_restore& i)
41 | : itti_msg(i), sessions(i.sessions) {}
42 | itti_sx_restore(
43 | const itti_sx_restore& i, const task_id_t orig, const task_id_t dest)
44 | : itti_sx_restore(i) {
45 | origin = orig;
46 | destination = dest;
47 | }
48 | const char* get_msg_name() { return "SX_RESTORE"; };
49 |
50 | std::set sessions;
51 | };
52 |
53 | #endif /* ITTI_MSG_SX_RESTORE_HPP_INCLUDED_ */
54 |
--------------------------------------------------------------------------------
/src/common/rfc_1332.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file rfc_1332.h
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 | #ifndef FILE_RFC_1332_SEEN
29 | #define FILE_RFC_1332_SEEN
30 |
31 | // 2 A PPP Network Control Protocol (NCP) for IP
32 |
33 | // Data Link Layer Protocol Field
34 | // Exactly one IPCP packet is encapsulated in the Information field
35 | // of PPP Data Link Layer frames where the Protocol field indicates
36 | // type hex 8021 (IP Control Protocol)
37 |
38 | // Code field
39 | // Only Codes 1 through 7 (Configure-Request, Configure-Ack,
40 | // Configure-Nak, Configure-Reject, Terminate-Request, Terminate-Ack
41 | // and Code-Reject) are used. Other Codes should be treated as
42 | // unrecognized and should result in Code-Rejects.
43 | #define IPCP_CODE_CONFIGURE_REQUEST (0x01)
44 | #define IPCP_CODE_CONFIGURE_ACK (0x02)
45 | #define IPCP_CODE_CONFIGURE_NACK (0x03)
46 | #define IPCP_CODE_CONFIGURE_REJECT (0x04)
47 | #define IPCP_CODE_TERMINATE_REQUEST (0x05)
48 | #define IPCP_CODE_TERMINATE_ACK (0x06)
49 | #define IPCP_CODE_REJECT (0x07)
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/common/rfc_1877.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file rfc_1877.h
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_RFC_1877_SEEN
30 | #define FILE_RFC_1877_SEEN
31 |
32 | #define IPCP_OPTION_PRIMARY_DNS_SERVER_IP_ADDRESS (0x81)
33 | #define IPCP_OPTION_PRIMARY_NBNS_SERVER_IP_ADDRESS (0x82)
34 | #define IPCP_OPTION_SECONDARY_DNS_SERVER_IP_ADDRESS (0x83)
35 | #define IPCP_OPTION_SECONDARY_NBNS_SERVER_IP_ADDRESS (0x84)
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/common/serializable.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file serializable.hpp
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_SERIALIZABLE_HPP_SEEN
30 | #define FILE_SERIALIZABLE_HPP_SEEN
31 |
32 | #include
33 | #include
34 |
35 | class stream_serializable {
36 | public:
37 | virtual void dump_to(std::ostream& os) = 0;
38 | virtual void load_from(std::istream& is) = 0;
39 | // virtual ~serializable() = 0;
40 | };
41 |
42 | #endif /* FILE_SERIALIZABLE_HPP_SEEN */
43 |
--------------------------------------------------------------------------------
/src/common/utils/3gpp_conversions.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file 3gpp_conversions.hpp
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_3GPP_CONVERSIONS_HPP_SEEN
30 | #define FILE_3GPP_CONVERSIONS_HPP_SEEN
31 | #include "3gpp_29.274.h"
32 | #include "3gpp_29.244.h"
33 | #include "3gpp_29.281.h"
34 | #include "endpoint.hpp"
35 |
36 | namespace xgpp_conv {
37 |
38 | void paa_to_pfcp_ue_ip_address(
39 | const paa_t& paa, pfcp::ue_ip_address_t& ue_ip_address);
40 | void pdn_ip_to_pfcp_ue_ip_address(
41 | const pdn_type_t& pdn_type, const struct in_addr& ipv4_address,
42 | const struct in6_addr ipv6_address, pfcp::ue_ip_address_t& ue_ip_address);
43 | void pfcp_to_core_fteid(const pfcp::fteid_t& pfteid, fteid_t& fteid);
44 | void pfcp_from_core_fteid(pfcp::fteid_t& pfteid, const fteid_t& fteid);
45 | void pfcp_cause_to_core_cause(const pfcp::cause_t& pc, cause_t& c);
46 | bool endpoint_to_gtp_u_peer_address(
47 | const endpoint& ep, gtp_u_peer_address_t& gpa);
48 | } // namespace xgpp_conv
49 |
50 | #endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
51 |
--------------------------------------------------------------------------------
/src/common/utils/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The OpenAirInterface Software Alliance licenses this file to You under
6 | # the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.openairinterface.org/?page_id=698
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #-------------------------------------------------------------------------------
18 | # For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # contact@openairinterface.org
20 | ################################################################################
21 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
22 | include_directories(${SRC_TOP_DIR}/common)
23 | include_directories(${SRC_TOP_DIR}/common/msg)
24 | include_directories(${SRC_TOP_DIR}/common/utils)
25 | include_directories(${SRC_TOP_DIR}/itti)
26 | include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
27 |
28 | set(CN_UTILS_SRC STATIC
29 | ${CMAKE_CURRENT_SOURCE_DIR}/3gpp_conversions.cpp
30 | ${CMAKE_CURRENT_SOURCE_DIR}/async_shell_cmd.cpp
31 | ${CMAKE_CURRENT_SOURCE_DIR}/conversions.cpp
32 | ${CMAKE_CURRENT_SOURCE_DIR}/epc.cpp
33 | ${CMAKE_CURRENT_SOURCE_DIR}/get_gateway_netlink.cpp
34 | ${CMAKE_CURRENT_SOURCE_DIR}/if.cpp
35 | ${CMAKE_CURRENT_SOURCE_DIR}/pid_file.cpp
36 | ${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
37 | ${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
38 | ${CMAKE_CURRENT_SOURCE_DIR}/fqdn.cpp
39 | )
40 |
41 |
42 | add_library(CN_UTILS ${CN_UTILS_SRC})
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/common/utils/async_shell_cmd.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file async_shell_cmd.hpp
23 | \brief We still use some unix commands for convenience, and we did not have
24 | to replace them by system calls \ Instead of calling C system(...) that can
25 | take a lot of time (creation of a process, etc), in many cases \ it doesn't
26 | hurt to do this asynchronously, may be we must tweak thread priority, pin it
27 | to a CPU, etc (TODO later) \author Lionel GAUTHIER \date 2017 \email:
28 | lionel.gauthier@eurecom.fr
29 | */
30 |
31 | #ifndef FILE_ASYNC_SHELL_CMD_HPP_SEEN
32 | #define FILE_ASYNC_SHELL_CMD_HPP_SEEN
33 |
34 | #include "itti_msg.hpp"
35 | #include "thread_sched.hpp"
36 | #include
37 | #include
38 |
39 | namespace util {
40 |
41 | class async_shell_cmd {
42 | private:
43 | std::thread::id thread_id;
44 | std::thread thread;
45 |
46 | public:
47 | explicit async_shell_cmd(util::thread_sched_params& sched_params);
48 | ~async_shell_cmd() {}
49 | async_shell_cmd(async_shell_cmd const&) = delete;
50 | void operator=(async_shell_cmd const&) = delete;
51 |
52 | int run_command(
53 | const task_id_t sender_itti_task, const bool is_abort_on_error,
54 | const char* src_file, const int src_line, const std::string& cmd_str);
55 | };
56 |
57 | } // namespace util
58 | #endif /* FILE_ASYNC_SHELL_CMD_HPP_SEEN */
59 |
--------------------------------------------------------------------------------
/src/common/utils/conversions.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file conversions.hpp
23 | \brief
24 | \author Sebastien ROUX, Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #ifndef FILE_CONVERSIONS_HPP_SEEN
30 | #define FILE_CONVERSIONS_HPP_SEEN
31 | #include
32 | #include
33 | #include
34 |
35 | /* Used to format an uint32_t containing an ipv4 address */
36 | #define IN_ADDR_FMT "%u.%u.%u.%u"
37 | #define PRI_IN_ADDR(aDDRESS) \
38 | (uint8_t)((aDDRESS.s_addr) & 0x000000ff), \
39 | (uint8_t)(((aDDRESS.s_addr) & 0x0000ff00) >> 8), \
40 | (uint8_t)(((aDDRESS.s_addr) & 0x00ff0000) >> 16), \
41 | (uint8_t)(((aDDRESS.s_addr) & 0xff000000) >> 24)
42 |
43 | #define IPV4_ADDR_DISPLAY_8(aDDRESS) \
44 | (aDDRESS)[0], (aDDRESS)[1], (aDDRESS)[2], (aDDRESS)[3]
45 |
46 | class conv {
47 | public:
48 | static void hexa_to_ascii(uint8_t* from, char* to, size_t length);
49 | static int ascii_to_hex(uint8_t* dst, const char* h);
50 | static struct in_addr fromString(const std::string addr4);
51 | static std::string toString(const struct in_addr& inaddr);
52 | static std::string toString(const struct in6_addr& in6addr);
53 | static std::string mccToString(
54 | const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
55 | static std::string mncToString(
56 | const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
57 | };
58 | #endif /* FILE_CONVERSIONS_HPP_SEEN */
59 |
--------------------------------------------------------------------------------
/src/common/utils/fqdn.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | #include "fqdn.hpp"
23 | #include "logger.hpp"
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #define MAX_NB_RESOLVE_TRIES 4
30 | #define TIME_IN_SECS_BETWEEN_TRIES 2
31 |
32 | bool fqdn::resolve(
33 | const std::string& host_name, std::string& address, uint32_t& port,
34 | uint8_t& addr_type, const std::string& protocol) {
35 | int tries = 0;
36 | Logger::spgwu_app().debug("Resolving a DNS (name %s)", host_name.c_str());
37 | while (tries < MAX_NB_RESOLVE_TRIES) {
38 | try {
39 | boost::asio::io_context io_context = {};
40 | Logger::spgwu_app().debug("Resolving DNS Try #%u", tries);
41 |
42 | boost::asio::ip::tcp::resolver resolver{io_context};
43 | boost::asio::ip::tcp::resolver::results_type endpoints =
44 | resolver.resolve(host_name, protocol);
45 |
46 | addr_type = 0; // IPv4 by default
47 | for (auto it = endpoints.cbegin(); it != endpoints.cend(); it++) {
48 | // get the first Endpoint
49 | boost::asio::ip::tcp::endpoint endpoint = *it;
50 | address = endpoint.address().to_string();
51 | port = endpoint.port();
52 | Logger::spgwu_app().debug(
53 | "Resolved a DNS (name %s, protocol %s): Ip Addr %s, port %u",
54 | host_name.c_str(), protocol.c_str(), address.c_str(), port);
55 | if (endpoint.address().is_v4())
56 | addr_type = 0;
57 | else
58 | addr_type = 1;
59 | return true;
60 | }
61 | } catch (std::exception& e) {
62 | tries++;
63 | if (tries == MAX_NB_RESOLVE_TRIES) {
64 | throw std::runtime_error(
65 | "Cannot resolve a DNS name " + std::string(e.what()) + " after " +
66 | std::to_string(tries) + " tries");
67 | return false;
68 | }
69 | std::this_thread::sleep_for(
70 | std::chrono::seconds(TIME_IN_SECS_BETWEEN_TRIES));
71 | }
72 | }
73 |
74 | return false;
75 | }
76 |
--------------------------------------------------------------------------------
/src/common/utils/fqdn.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file fqdn.hpp
23 | \brief
24 | \author
25 | \company Eurecom
26 | \email:
27 | */
28 | #ifndef FILE_FQDN_HPP_SEEN
29 | #define FILE_FQDN_HPP_SEEN
30 | #include
31 | class fqdn {
32 | public:
33 | /*
34 | * Resolve a DNS name to get host's IP Addr
35 | * @param [const std::string &] host_name: host's name/url
36 | * @param [const std::string &] protocol: protocol
37 | * @param [uint8_t &] addr_type: addr_type (Ipv4/v6)
38 | * @return void
39 | */
40 | static bool resolve(
41 | const std::string& host_name, std::string& address, uint32_t& port,
42 | uint8_t& addr_type, const std::string& protocol = "http");
43 | };
44 |
45 | #endif /* FILE_FQDN_HPP_SEEN */
46 |
--------------------------------------------------------------------------------
/src/common/utils/get_gateway_netlink.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file get_gateway_netlink.hpp
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 | #ifndef FILE_GET_GATEWAY_NETLINK_HPP_SEEN
29 | #define FILE_GET_GATEWAY_NETLINK_HPP_SEEN
30 |
31 | #include
32 |
33 | namespace util {
34 | bool get_iface_l2_addr(const std::string& iface, std::string& mac);
35 | bool get_gateway_and_iface(std::string& gw, std::string& iface);
36 | } // namespace util
37 | #endif /* FILE_GET_GATEWAY_NETLINK_HPP_SEEN */
38 |
--------------------------------------------------------------------------------
/src/common/utils/if.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file get_gateway_netlink.h
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 | #ifndef FILE_IF_HPP_SEEN
29 | #define FILE_IF_HPP_SEEN
30 | #include
31 |
32 | int get_gateway_and_iface(std::string* gw /*OUT*/, std::string* iface /*OUT*/);
33 | int get_inet_addr_from_iface(
34 | const std::string& if_name, struct in_addr& inet_addr);
35 | int get_mtu_from_iface(const std::string& if_name, uint32_t& mtu);
36 | int get_inet_addr_infos_from_iface(
37 | const std::string& if_name, struct in_addr& inet_addr,
38 | struct in_addr& inet_netmask, unsigned int& mtu);
39 |
40 | #endif /* FILE_IF_HPP_SEEN */
41 |
--------------------------------------------------------------------------------
/src/common/utils/pid_file.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file pid_file.cpp
23 | \brief
24 | \author Lionel GAUTHIER
25 | \date 2016
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 |
29 | #include "logger.hpp"
30 | #include "pid_file.hpp"
31 |
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | int g_fd_pid_file = -1;
42 | __pid_t g_pid = -1;
43 | //------------------------------------------------------------------------------
44 | std::string util::get_exe_absolute_path(
45 | const std::string& basepath, const unsigned int instance) {
46 | #define MAX_FILE_PATH_LENGTH 255
47 | char pid_file_name[MAX_FILE_PATH_LENGTH + 1] = {0};
48 | char* exe_basename = NULL;
49 | int rv = 0;
50 | int num_chars = 0;
51 |
52 | // get executable name
53 | rv = readlink("/proc/self/exe", pid_file_name, 256);
54 | if (-1 == rv) {
55 | return NULL;
56 | }
57 | pid_file_name[rv] = 0;
58 | exe_basename = basename(pid_file_name);
59 |
60 | // Add 6 for the other 5 characters in the path + null terminator + 2 chars
61 | // for instance.
62 | num_chars = basepath.size() + strlen(exe_basename) + 6 + 2;
63 | if (num_chars > MAX_FILE_PATH_LENGTH) {
64 | num_chars = MAX_FILE_PATH_LENGTH;
65 | }
66 | snprintf(
67 | pid_file_name, num_chars, "%s/%s%02u.pid", basepath.c_str(), exe_basename,
68 | instance);
69 | return std::string(pid_file_name);
70 | }
71 |
72 | //------------------------------------------------------------------------------
73 | int util::lockfile(int fd, int lock_type) {
74 | // lock on fd only, not on file on disk (do not prevent another process from
75 | // modifying the file)
76 | return lockf(fd, F_TLOCK, 0);
77 | }
78 |
79 | //------------------------------------------------------------------------------
80 | bool util::is_pid_file_lock_success(const char* pid_file_name) {
81 | char pid_dec[64] = {0};
82 |
83 | g_fd_pid_file = open(
84 | pid_file_name, O_RDWR | O_CREAT,
85 | S_IRUSR | S_IWUSR | S_IRGRP |
86 | S_IROTH); /* Read/write by owner, read by grp, others */
87 | if (0 > g_fd_pid_file) {
88 | Logger::spgwu_app().error(
89 | "open filename %s failed %d:%s\n", pid_file_name, errno,
90 | strerror(errno));
91 | return false;
92 | }
93 |
94 | if (0 > util::lockfile(g_fd_pid_file, F_TLOCK)) {
95 | Logger::spgwu_app().error(
96 | "lockfile filename %s failed %d:%s\n", pid_file_name, errno,
97 | strerror(errno));
98 | if (EACCES == errno || EAGAIN == errno) {
99 | close(g_fd_pid_file);
100 | }
101 | return false;
102 | }
103 | // fruncate file content
104 | if (ftruncate(g_fd_pid_file, 0)) {
105 | Logger::spgwu_app().error(
106 | "truncate %s failed %d:%s\n", pid_file_name, errno, strerror(errno));
107 | close(g_fd_pid_file);
108 | return false;
109 | }
110 | // write PID in file
111 | g_pid = getpid();
112 | snprintf(pid_dec, 64 /* should be big enough */, "%ld", (long) g_pid);
113 | if ((ssize_t) -1 == write(g_fd_pid_file, pid_dec, strlen(pid_dec))) {
114 | Logger::spgwu_app().error(
115 | "write PID to filename %s failed %d:%s\n", pid_file_name, errno,
116 | strerror(errno));
117 | return false;
118 | }
119 | return true;
120 | }
121 |
122 | //------------------------------------------------------------------------------
123 | void util::pid_file_unlock(void) {
124 | util::lockfile(g_fd_pid_file, F_ULOCK);
125 | close(g_fd_pid_file);
126 | g_fd_pid_file = -1;
127 | }
128 |
--------------------------------------------------------------------------------
/src/common/utils/pid_file.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file pid_file.hpp
23 | \brief
24 | \author Lionel GAUTHIER
25 | \date 2016
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 | #ifndef FILE_PID_FILE_SEEN
29 | #define FILE_PID_FILE_SEEN
30 | #include
31 |
32 | namespace util {
33 |
34 | /*
35 | * Generate the exe absolute path using a specified base_path.
36 | *
37 | * @param base_path
38 | * the root directory to use.
39 | *
40 | * @return a string for the exe absolute path.
41 | */
42 | std::string get_exe_absolute_path(
43 | const std::string& base_path, const unsigned int instance);
44 |
45 | bool is_pid_file_lock_success(const char* pid_file_name);
46 |
47 | void pid_file_unlock(void);
48 |
49 | int lockfile(int fd, int lock_type);
50 |
51 | } // namespace util
52 | #endif
53 |
--------------------------------------------------------------------------------
/src/common/utils/string.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 | #include "string.hpp"
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | template
30 | class Buffer {
31 | public:
32 | explicit Buffer(size_t size) {
33 | msize = size;
34 | mbuf = new T[msize];
35 | }
36 | ~Buffer() {
37 | if (mbuf) delete[] mbuf;
38 | }
39 | T* get() { return mbuf; }
40 |
41 | private:
42 | Buffer();
43 | size_t msize;
44 | T* mbuf;
45 | };
46 |
47 | std::string util::string_format(const char* format, ...) {
48 | va_list args;
49 |
50 | va_start(args, format);
51 | size_t size = vsnprintf(NULL, 0, format, args) + 1; // Extra space for '\0'
52 | va_end(args);
53 |
54 | Buffer buf(size);
55 |
56 | va_start(args, format);
57 | vsnprintf(buf.get(), size, format, args);
58 | va_end(args);
59 |
60 | return std::string(buf.get(), size - 1); // We don't want the '\0' inside
61 | }
62 |
63 | // Licence : https://creativecommons.org/licenses/by-sa/4.0/legalcode
64 | // https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring#217605
65 |
66 | // trim from start
67 | std::string& util::ltrim(std::string& s) {
68 | s.erase(
69 | s.begin(),
70 | std::find_if(
71 | s.begin(), s.end(), std::not1(std::ptr_fun(std::isspace))));
72 | return s;
73 | }
74 |
75 | // trim from end
76 | std::string& util::rtrim(std::string& s) {
77 | s.erase(
78 | std::find_if(
79 | s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace)))
80 | .base(),
81 | s.end());
82 | return s;
83 | }
84 |
85 | // trim from both ends
86 | std::string& util::trim(std::string& s) {
87 | return util::ltrim(util::rtrim(s));
88 | }
89 |
--------------------------------------------------------------------------------
/src/common/utils/string.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file string.hpp
23 | \brief
24 | \author Lionel GAUTHIER
25 | \date 2018
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 | #ifndef FILE_STRING_HPP_FILE_SEEN
29 | #define FILE_STRING_HPP_FILE_SEEN
30 |
31 | #include
32 |
33 | namespace util {
34 |
35 | std::string string_format(const char* format, ...);
36 |
37 | std::string& ltrim(std::string& s);
38 | // trim from end
39 | std::string& rtrim(std::string& s);
40 | // trim from both ends
41 | std::string& trim(std::string& s);
42 | } // namespace util
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/common/utils/thread_sched.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file thread_sched.cpp
23 | \brief
24 | \company Eurecom
25 | \email: lionel.gauthier@eurecom.fr
26 | */
27 |
28 | #include "thread_sched.hpp"
29 |
30 | //------------------------------------------------------------------------------
31 | void util::thread_sched_params::apply(
32 | const int task_id, const oai::logger::printf_logger& logger) const {
33 | if (cpu_id >= 0) {
34 | cpu_set_t cpuset;
35 | CPU_SET(cpu_id, &cpuset);
36 | if (int rc = pthread_setaffinity_np(
37 | pthread_self(), sizeof(cpu_set_t), &cpuset)) {
38 | logger.warn(
39 | "Could not set affinity to ITTI task %d, err=%d", task_id, rc);
40 | }
41 | }
42 |
43 | struct sched_param sparam;
44 | memset(&sparam, 0, sizeof(sparam));
45 | sparam.sched_priority = sched_priority;
46 | if (int rc = pthread_setschedparam(pthread_self(), sched_policy, &sparam)) {
47 | logger.warn(
48 | "Could not set schedparam to ITTI task %d, err=%d", task_id, rc);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/common/utils/thread_sched.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file thread_sched.hpp
23 | \brief
24 | \company Eurecom
25 | \email: lionel.gauthier@eurecom.fr
26 | */
27 |
28 | #ifndef FILE_THREAD_SCHED_HPP_SEEN
29 | #define FILE_THREAD_SCHED_HPP_SEEN
30 |
31 | #include
32 | #include "logger.hpp"
33 |
34 | namespace util {
35 |
36 | class thread_sched_params {
37 | public:
38 | thread_sched_params()
39 | : cpu_id(0),
40 | sched_policy(SCHED_FIFO),
41 | sched_priority(84),
42 | thread_pool_size(1) {}
43 | int cpu_id;
44 | int sched_policy;
45 | int sched_priority;
46 | unsigned int thread_pool_size;
47 | void apply(const int task_id, const oai::logger::printf_logger& logger) const;
48 | };
49 |
50 | } // namespace util
51 | #endif /* FILE_THREAD_SCHED_HPP_SEEN */
52 |
--------------------------------------------------------------------------------
/src/common/utils/uint_generator.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file uint_uid_generator.hpp
23 | \author Lionel GAUTHIER
24 | \date 2019
25 | \email: lionel.gauthier@eurecom.fr
26 | */
27 |
28 | #ifndef FILE_UINT_GENERATOR_HPP_SEEN
29 | #define FILE_UINT_GENERATOR_HPP_SEEN
30 |
31 | #include
32 | #include
33 |
34 | namespace util {
35 |
36 | template
37 | class uint_generator {
38 | private:
39 | UINT uid_generator;
40 | std::mutex m_uid_generator;
41 |
42 | std::set uid_generated;
43 | std::mutex m_uid_generated;
44 |
45 | public:
46 | uint_generator() : m_uid_generator(), m_uid_generated() {
47 | uid_generator = 0;
48 | uid_generated = {};
49 | };
50 |
51 | uint_generator(uint_generator const&) = delete;
52 | void operator=(uint_generator const&) = delete;
53 |
54 | UINT get_uid() {
55 | std::unique_lock lr(m_uid_generator);
56 | UINT uid = ++uid_generator;
57 | while (true) {
58 | // may happen race conditions here
59 | std::unique_lock ld(m_uid_generated);
60 | if (uid_generated.count(uid) == 0) {
61 | uid_generated.insert(uid);
62 | ld.unlock();
63 | lr.unlock();
64 | return uid;
65 | }
66 | uid = ++uid_generator;
67 | }
68 | }
69 |
70 | void free_uid(UINT uid) {
71 | std::unique_lock l(m_uid_generated);
72 | uid_generated.erase(uid);
73 | l.unlock();
74 | }
75 | };
76 |
77 | template
78 | class uint_uid_generator {
79 | private:
80 | UINT uid_generator;
81 | std::mutex m_uid_generator;
82 |
83 | std::set uid_generated;
84 | std::mutex m_uid_generated;
85 |
86 | uint_uid_generator() : m_uid_generator(), m_uid_generated() {
87 | uid_generator = 0;
88 | uid_generated = {};
89 | };
90 |
91 | public:
92 | static uint_uid_generator& get_instance() {
93 | static uint_uid_generator instance;
94 | return instance;
95 | }
96 |
97 | uint_uid_generator(uint_uid_generator const&) = delete;
98 | void operator=(uint_uid_generator const&) = delete;
99 |
100 | UINT get_uid() {
101 | std::unique_lock lr(m_uid_generator);
102 | UINT uid = ++uid_generator;
103 | while (true) {
104 | // may happen race conditions here
105 | std::unique_lock ld(m_uid_generated);
106 | if (uid_generated.count(uid) == 0) {
107 | uid_generated.insert(uid);
108 | lr.unlock();
109 | ld.unlock();
110 | return uid;
111 | }
112 | uid = ++uid_generator;
113 | }
114 | }
115 |
116 | void free_uid(UINT uid) {
117 | std::unique_lock l(m_uid_generated);
118 | uid_generated.erase(uid);
119 | l.unlock();
120 | }
121 | };
122 |
123 | } // namespace util
124 | #endif // FILE_UINT_GENERATOR_HPP_SEEN
125 |
--------------------------------------------------------------------------------
/src/gtpv1u/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The OpenAirInterface Software Alliance licenses this file to You under
6 | # the OAI Public License, Version 1.1 (the "License"); you may not use this file
7 | # except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.openairinterface.org/?page_id=698
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #-------------------------------------------------------------------------------
18 | # For more information about the OpenAirInterface (OAI) Software Alliance:
19 | # contact@openairinterface.org
20 | ################################################################################
21 | add_library(GTPV1U STATIC
22 | 3gpp_29.281.cpp
23 | gtpv1u.cpp
24 | )
25 |
26 | include_directories(${SRC_TOP_DIR}/common)
27 | include_directories(${SRC_TOP_DIR}/common/msg)
28 | include_directories(${SRC_TOP_DIR}/common/utils)
29 | include_directories(${SRC_TOP_DIR}/itti)
30 | include_directories(${SRC_TOP_DIR}/gtpv1u)
31 | include_directories(${SRC_TOP_DIR}/udp)
32 | include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
33 |
--------------------------------------------------------------------------------
/src/gtpv1u/gtpu.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 | /*! \file gtpu.h
22 | * \brief
23 | * \author Lionel Gauthier
24 | * \company Eurecom
25 | * \email: lionel.gauthier@eurecom.fr
26 | */
27 |
28 | #ifndef FILE_GTPU_SEEN
29 | #define FILE_GTPU_SEEN
30 |
31 | #include
32 | #include
33 |
34 | #define GTPU_MESSAGE_PN_MASK 0x1
35 | #define GTPU_MESSAGE_SN_MASK 0x2
36 | #define GTPU_MESSAGE_EXT_HEADER_MASK 0x4
37 | #define GTPU_MESSAGE_PT_MASK 0x10
38 | #define GTPU_MESSAGE_VERSION_MASK 0xE
39 |
40 | struct gtpuhdr {
41 | #if __BYTE_ORDER == __LITTLE_ENDIAN
42 | unsigned int pn : 1;
43 | unsigned int s : 1;
44 | unsigned int e : 1;
45 | unsigned int spare : 1;
46 | unsigned int pt : 1;
47 | unsigned int version : 3;
48 | #elif __BYTE_ORDER == __BIG_ENDIAN
49 | unsigned int version : 3;
50 | unsigned int pt : 1;
51 | unsigned int spare : 1;
52 | unsigned int e : 1;
53 | unsigned int s : 1;
54 | unsigned int pn : 1;
55 | #else
56 | #error "Please fix "
57 | #endif
58 | // Message Type: This field indicates the type of GTP-U message.
59 | uint8_t message_type;
60 | // Length: This field indicates the length in octets of the payload, i.e. the
61 | // rest of the packet following the mandatory part of the GTP header (that is
62 | // the first 8 octets). The Sequence Number, the N-PDU Number or any Extension
63 | // headers shall be considered to be part of the payload, i.e. included in the
64 | // length count.
65 | uint16_t message_length;
66 | // Tunnel Endpoint Identifier (TEID): This field unambiguously identifies a
67 | // tunnel endpoint in the receiving GTP-U protocol entity. The receiving end
68 | // side of a GTP tunnel locally assigns the TEID value the transmitting side
69 | // has to use. The TEID value shall be assigned in a non-predictable manner
70 | // for PGW S5/S8/S2a/S2b interfaces (see 3GPP TS 33.250 [32]). The TEID shall
71 | // be used by the receiving entity to find the PDP context, except for the
72 | // following cases:
73 | // -) The Echo Request/Response and Supported Extension Headers notification
74 | // messages, where the Tunnel
75 | // Endpoint Identifier shall be set to all zeroes
76 | // -) The Error Indication message where the Tunnel Endpoint Identifier shall
77 | // be set to all zeros.
78 | uint32_t teid;
79 |
80 | /*The options start here. */
81 | uint16_t sequence;
82 | uint8_t pdu_number;
83 | uint8_t next_ext_type;
84 | };
85 | #endif
86 |
87 | struct gtpu_extn_pdu_session_container {
88 | uint8_t message_length;
89 | // PDU Type - This value indicates the structure of the PDU session UP frame.
90 | // The field takes the value of the PDU Type it identifies; i.e. "0" for PDU
91 | // Type 0. The PDU type is in bit 4 to bit 7 in the first octet of the frame.
92 | uint8_t pdu_type;
93 | // QoS Flow Identifier (QFI): This parameter indicates the QoS Flow Identifier
94 | // of the QoS flow to which the transferred packet bel
95 | uint8_t qfi;
96 | // Next Extension Header Type - This field defines the type of Extension
97 | // Header that follows this field in the GTP-PDU
98 | uint8_t next_ext_type;
99 | };
100 |
--------------------------------------------------------------------------------
/src/gtpv1u/gtpv1u.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The OpenAirInterface Software Alliance licenses this file to You under
6 | * the OAI Public License, Version 1.1 (the "License"); you may not use this
7 | * file except in compliance with the License. You may obtain a copy of the
8 | * License at
9 | *
10 | * http://www.openairinterface.org/?page_id=698
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *-------------------------------------------------------------------------------
18 | * For more information about the OpenAirInterface (OAI) Software Alliance:
19 | * contact@openairinterface.org
20 | */
21 |
22 | /*! \file gtpv1u.hpp
23 | \brief
24 | \author Lionel Gauthier
25 | \company Eurecom
26 | \email: lionel.gauthier@eurecom.fr
27 | */
28 | #ifndef FILE_GTPV1U_HPP_SEEN
29 | #define FILE_GTPV1U_HPP_SEEN
30 |
31 | #include "3gpp_29.281.hpp"
32 | #include "itti.hpp"
33 | #include "msg_gtpv1u.hpp"
34 | #include "thread_sched.hpp"
35 | #include "udp.hpp"
36 |
37 | #include
38 | #include