Commit 20f6ebef authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'develop' into n2_handover

parents 5f499912 025c481c
...@@ -128,6 +128,7 @@ check_supported_distribution() { ...@@ -128,6 +128,7 @@ check_supported_distribution() {
local distribution=$(get_distribution_release) local distribution=$(get_distribution_release)
case "$distribution" in case "$distribution" in
"ubuntu18.04") return 0 ;; "ubuntu18.04") return 0 ;;
"ubuntu20.04") return 0 ;;
"rhel8") return 0 ;; "rhel8") return 0 ;;
"rhel8.2") return 0 ;; "rhel8.2") return 0 ;;
"rhel8.3") return 0 ;; "rhel8.3") return 0 ;;
......
...@@ -300,6 +300,7 @@ check_install_amf_deps(){ ...@@ -300,6 +300,7 @@ check_install_amf_deps(){
doxygen \ doxygen \
flex \ flex \
gdb \ gdb \
wget \
git" git"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
...@@ -324,6 +325,18 @@ check_install_amf_deps(){ ...@@ -324,6 +325,18 @@ check_install_amf_deps(){
if [[ $OS_DISTRO == "ubuntu" ]]; then if [[ $OS_DISTRO == "ubuntu" ]]; then
case "$(get_distribution_release)" in case "$(get_distribution_release)" in
"ubuntu18.04") "ubuntu18.04")
# Currently Ubuntu18.04 has boost 1.65 as the latest
# We need at least 1.66
# PPA has 1.67
$SUDO add-apt-repository ppa:mhier/libboost-latest --yes
$SUDO $INSTALLER update
if [ $IS_CONTAINER -eq 0 ]; then
specific_packages="libconfig++-dev libasio-dev libboost-all-dev mysql-server"
else
specific_packages="libconfig++-dev"
fi
;;
*)
if [ $IS_CONTAINER -eq 0 ]; then if [ $IS_CONTAINER -eq 0 ]; then
specific_packages="libconfig++-dev libasio-dev libboost-all-dev mysql-server" specific_packages="libconfig++-dev libasio-dev libboost-all-dev mysql-server"
else else
...@@ -334,10 +347,10 @@ check_install_amf_deps(){ ...@@ -334,10 +347,10 @@ check_install_amf_deps(){
# removed libspdlog-dev # removed libspdlog-dev
PACKAGE_LIST="\ PACKAGE_LIST="\
$specific_packages \ $specific_packages \
libboost1.67-dev \
mysql-server \ mysql-server \
mysql-client \ mysql-client \
libmysqlclient-dev \ libmysqlclient-dev \
libcpprest-dev \
guile-2.0-dev \ guile-2.0-dev \
libcurl4-gnutls-dev \ libcurl4-gnutls-dev \
libevent-dev \ libevent-dev \
...@@ -359,6 +372,7 @@ check_install_amf_deps(){ ...@@ -359,6 +372,7 @@ check_install_amf_deps(){
net-tools \ net-tools \
pkg-config \ pkg-config \
ninja-build \ ninja-build \
wget \
libasan2" libasan2"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
...@@ -396,8 +410,8 @@ check_install_amf_deps(){ ...@@ -396,8 +410,8 @@ check_install_amf_deps(){
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
# Use fmt lib included in spdlog # Use fmt lib included in spdlog
install_fmt $1 # install_fmt $1
ret=$?;[[ $ret -ne 0 ]] && return $ret # ret=$?;[[ $ret -ne 0 ]] && return $ret
install_spdlog_from_git $1 $2 install_spdlog_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
......
...@@ -34,23 +34,30 @@ AMF_CONF[@SD_0@]='123' ...@@ -34,23 +34,30 @@ AMF_CONF[@SD_0@]='123'
AMF_CONF[@SST_1@]='1' AMF_CONF[@SST_1@]='1'
AMF_CONF[@SD_1@]='12' AMF_CONF[@SD_1@]='12'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='enx0050b6f4ba5b' AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='wlo1'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='enx0050b6f4ba5b' AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='wlo1'
AMF_CONF[@NF_REGISTRATION@]='no'
AMF_CONF[@SMF_SELECTION@]='no'
AMF_CONF[@SMF_INSTANCE_ID_0@]='1' AMF_CONF[@SMF_INSTANCE_ID_0@]='1'
AMF_CONF[@SMF_IPV4_ADDR_0@]='192.168.122.1' AMF_CONF[@SMF_IPV4_ADDR_0@]='192.168.122.1'
AMF_CONF[@SMF_HTTP_VERSION_0@]='v1' AMF_CONF[@SMF_HTTP_VERSION_0@]='v1'
AMF_CONF[@SMF_FQDN_0@]='localhost'
AMF_CONF[@SMF_INSTANCE_ID_1@]='2' AMF_CONF[@SMF_INSTANCE_ID_1@]='2'
AMF_CONF[@SMF_IPV4_ADDR_1@]='192.168.122.2' AMF_CONF[@SMF_IPV4_ADDR_1@]='192.168.122.2'
AMF_CONF[@SMF_HTTP_VERSION_1@]='v1' AMF_CONF[@SMF_HTTP_VERSION_1@]='v1'
AMF_CONF[@SMF_FQDN_1@]='localhost'
AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23' AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@NRF_PORT@]='80' AMF_CONF[@NRF_PORT@]='80'
AMF_CONF[@NRF_API_VERSION@]='v1' AMF_CONF[@NRF_API_VERSION@]='v1'
AMF_CONF[@NRF_FQDN@]='localhost'
AMF_CONF[@AUSF_IPV4_ADDRESS@]='192.168.1.23' AMF_CONF[@AUSF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@AUSF_PORT@]='80' AMF_CONF[@AUSF_PORT@]='80'
AMF_CONF[@AUSF_API_VERSION@]='v1' AMF_CONF[@AUSF_API_VERSION@]='v1'
AMF_CONF[@AUSF_FQDN@]='localhost'
AMF_CONF[@MYSQL_SERVER@]='127.0.0.1' AMF_CONF[@MYSQL_SERVER@]='127.0.0.1'
AMF_CONF[@MYSQL_USER@]='root' AMF_CONF[@MYSQL_USER@]='root'
......
This diff is collapsed.
...@@ -121,7 +121,8 @@ pipeline { ...@@ -121,7 +121,8 @@ pipeline {
script { script {
sh "git clean -x -d -f > /dev/null 2>&1" sh "git clean -x -d -f > /dev/null 2>&1"
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
gitlabMergeRequestLink = sh "curl --silent \"https://gitlab.eurecom.fr/api/v4/projects/oai%2Fcn5g%2Foai-cn5g-amf/merge_requests/${env.gitlabMergeRequestIid}\" | jq .web_url | sed 's#\"##g'" gitlabMergeRequestLink = sh returnStdout: true, script: "curl --silent 'https://gitlab.eurecom.fr/api/v4/projects/oai%2Fcn5g%2Foai-cn5g-amf/merge_requests/${env.gitlabMergeRequestIid}' | jq .web_url | sed 's#\"##g'"
gitlabMergeRequestLink = gitlabMergeRequestLink.trim()
echo "========= THIS IS A MERGE REQUEST ==========" echo "========= THIS IS A MERGE REQUEST =========="
echo "MR ID is ${env.gitlabMergeRequestIid}" echo "MR ID is ${env.gitlabMergeRequestIid}"
echo "MR LINK is ${gitlabMergeRequestLink}" echo "MR LINK is ${gitlabMergeRequestLink}"
...@@ -337,10 +338,41 @@ pipeline { ...@@ -337,10 +338,41 @@ pipeline {
} }
} }
} }
stage ('Testing in CN-5G-FED environment') { stage ('Bracket Testing with DsTester') {
steps { steps {
script { script {
gitlabCommitStatus(name: "Test with DsTester") { gitlabCommitStatus(name: "Bracket Test with DsTester") {
localStatus = build job: params.AMF_BT_PipelineName,
parameters: [
string(name: 'AMF_TAG', value: String.valueOf(amf_tag))
], propagate: false
localResult = localStatus.getResult()
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "Bracket Test Job is OK"
} else {
echo "Bracket Test Job is KO"
sh "ci-scripts/fail.sh"
}
}
}
}
post {
always {
script {
copyArtifacts(projectName: params.AMF_BT_PipelineName,
filter: '*_results_oai_amf_bt.html',
selector: lastCompleted())
}
}
}
}
stage('Testing whole 5g Core Network Functions') {
parallel {
stage ('Testing in CN-5G-FED Docker environment') {
steps {
script {
gitlabCommitStatus(name: "Test with DsTester on Docker environment") {
localStatus = build job: params.CN5G_FED_PipelineName, localStatus = build job: params.CN5G_FED_PipelineName,
parameters: [ parameters: [
string(name: 'AMF_TAG', value: String.valueOf(amf_tag)), string(name: 'AMF_TAG', value: String.valueOf(amf_tag)),
...@@ -349,9 +381,9 @@ pipeline { ...@@ -349,9 +381,9 @@ pipeline {
localResult = localStatus.getResult() localResult = localStatus.getResult()
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) { if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "Federation Test Job is OK" echo "Docker Federation Test Job is OK"
} else { } else {
echo "Federation Test Job is KO" echo "Docker Federation Test Job is KO"
sh "ci-scripts/fail.sh" sh "ci-scripts/fail.sh"
} }
} }
...@@ -367,6 +399,38 @@ pipeline { ...@@ -367,6 +399,38 @@ pipeline {
} }
} }
} }
stage ('Testing in CN-5G-FED OC environment') {
steps {
script {
gitlabCommitStatus(name: "Test with DsTester on OC environment") {
localStatus = build job: params.CN5G_FED_OC_PipelineName,
parameters: [
string(name: 'AMF_TAG', value: String.valueOf(amf_tag)),
string(name: 'AMF_BRANCH', value: String.valueOf(amf_branch))
], propagate: false
localResult = localStatus.getResult()
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "OC Federation Test Job is OK"
} else {
echo "OC Federation Test Job is KO"
sh "ci-scripts/fail.sh"
}
}
}
}
post {
always {
script {
copyArtifacts(projectName: params.CN5G_FED_OC_PipelineName,
filter: '*_results_oai_cn5g_oc.html',
selector: lastCompleted())
}
}
}
}
}
}
} }
post { post {
success { success {
...@@ -438,6 +502,14 @@ pipeline { ...@@ -438,6 +502,14 @@ pipeline {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_cn5g.html" sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_cn5g.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_cn5g.html" sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_cn5g.html"
} }
if (fileExists('test_results_oai_amf_bt.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_amf_bt.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_amf_bt.html"
}
if (fileExists('test_results_oai_cn5g_oc.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_cn5g_oc.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_cn5g_oc.html"
}
} else { } else {
sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${GIT_BRANCH} --git_src_commit=${GIT_COMMIT}" sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${GIT_BRANCH} --git_src_commit=${GIT_COMMIT}"
} }
...@@ -450,6 +522,14 @@ pipeline { ...@@ -450,6 +522,14 @@ pipeline {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' *_results_oai_cn5g.html" sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' *_results_oai_cn5g.html"
archiveArtifacts artifacts: '*_results_oai_cn5g.html' archiveArtifacts artifacts: '*_results_oai_cn5g.html'
} }
if (fileExists('test_results_oai_amf_bt.html')) {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' *_results_oai_amf_bt.html"
archiveArtifacts artifacts: '*_results_oai_amf_bt.html'
}
if (fileExists('test_results_oai_cn5g_oc.html')) {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' *_results_oai_cn5g_oc.html"
archiveArtifacts artifacts: '*_results_oai_cn5g_oc.html'
}
// Sending email to commiter // Sending email to commiter
if (params.sendToCommitterEmail != null) { if (params.sendToCommitterEmail != null) {
......
This diff is collapsed.
...@@ -52,7 +52,11 @@ RUN apt-get update && \ ...@@ -52,7 +52,11 @@ RUN apt-get update && \
psmisc \ psmisc \
net-tools \ net-tools \
bc \ bc \
openssl \
perl \
tshark \ tshark \
libasan4 \
libldap-2.4-2 \
libconfig++9v5 \ libconfig++9v5 \
libsctp1 \ libsctp1 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
...@@ -64,29 +68,14 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh ...@@ -64,29 +68,14 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh
WORKDIR /usr/lib/x86_64-linux-gnu WORKDIR /usr/lib/x86_64-linux-gnu
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcpprest.so.2.10 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libssl.so.1.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsasl2.so.2 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libgssapi.so.3 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libheimbase.so.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libkrb5.so.26 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasn1.so.8 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libroken.so.18 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libwind.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libhx509.so.5 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasan.so.4 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
......
#!/bin/bash
STATUS=0
RESULT=$(ps aux | grep -v nohup || true)
SUB='/openair-amf/bin/oai_amf -c /openair-amf/etc/amf.conf -o'
if [[ $RESULT =~ $SUB ]]; then
STATUS=0
else
STATUS=-1
fi
exit $STATUS
version: '3.8'
services:
cicd_mysql:
container_name: cicd-mysql-svr
image: mysql:5.7
ports:
- 3306
command: --init-file /docker-entrypoint-initdb.d/oai_db.sql
volumes:
- ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql:rw
environment:
- TZ=Europe/Paris
- MYSQL_DATABASE=oai_db
- MYSQL_USER=test
- MYSQL_PASSWORD=test
- MYSQL_ROOT_PASSWORD=linux
healthcheck:
test: "/usr/bin/mysql --user=root --password=linux -e 'show databases;'"
interval: 10s
timeout: 5s
retries: 5
networks:
cicd_public_net:
ipv4_address: 192.168.61.194
cicd_oai_amf:
container_name: cicd-oai-amf
image: oai-amf:AMF_IMAGE_TAG
ports:
- 38412
- 80
command: >
bash -c "nohup tshark -i eth0 -w /tmp/amf.pcap 2>&1 > /dev/null &
/openair-amf/bin/oai_amf -c /openair-amf/etc/amf.conf -o | tee /tmp/amf.log 2>&1
"
cap_add:
- NET_ADMIN
environment:
- INSTANCE=1
- PID_DIRECTORY=/var/run
- MCC=208
- MNC=95
- REGION_ID=128
- AMF_SET_ID=1
- SERVED_GUAMI_MCC_0=208
- SERVED_GUAMI_MNC_0=95
- SERVED_GUAMI_REGION_ID_0=128
- SERVED_GUAMI_AMF_SET_ID_0=1
- SERVED_GUAMI_MCC_1=460
- SERVED_GUAMI_MNC_1=11
- SERVED_GUAMI_REGION_ID_1=10
- SERVED_GUAMI_AMF_SET_ID_1=1
- PLMN_SUPPORT_MCC=208
- PLMN_SUPPORT_MNC=95
- PLMN_SUPPORT_TAC=0xa000
- SST_0=222
- SD_0=123
- SST_1=1
- SD_1=12
- AMF_INTERFACE_NAME_FOR_NGAP=eth0
- AMF_INTERFACE_NAME_FOR_N11=eth0
- SMF_INSTANCE_ID_0=1
- SMF_FQDN_0=localhost
- SMF_IPV4_ADDR_0=192.168.18.184
- SMF_HTTP_VERSION_0=v1
- SELECTED_0=true
- SMF_INSTANCE_ID_1=2
- SMF_FQDN_1=localhost
- SMF_IPV4_ADDR_1=0.0.0.0
- SMF_HTTP_VERSION_1=v1
- SELECTED_1=false
- MYSQL_SERVER=cicd-mysql-svr
- MYSQL_USER=root
- MYSQL_PASS=linux
- MYSQL_DB=oai_db
- OPERATOR_KEY=63bfa50ee6523365ff14c1f45f88737d
- NRF_IPV4_ADDRESS=0.0.0.0
- NRF_PORT=80
- NF_REGISTRATION=no
- SMF_SELECTION=no
- USE_FQDN_DNS=no
- NRF_API_VERSION=v1
- NRF_FQDN=localhost
- AUSF_IPV4_ADDRESS=0.0.0.0
- AUSF_PORT=80
- AUSF_API_VERSION=v1
depends_on:
- cicd_mysql
networks:
cicd_public_net:
ipv4_address: 192.168.61.196
volumes:
- ./amf-healthy-check.sh:/openair-amf/bin/amf-healthy-check.sh
healthcheck:
test: /bin/bash -c "/openair-amf/bin/amf-healthy-check.sh"
interval: 10s
timeout: 5s
retries: 5
networks:
cicd_public_net:
name: cicd-oai-public-net
driver: bridge
ipam:
config:
- subnet: 192.168.61.192/26
This diff is collapsed.
...@@ -111,7 +111,7 @@ class HtmlReport(): ...@@ -111,7 +111,7 @@ class HtmlReport():
buildSummary += ' </tr>\n' buildSummary += ' </tr>\n'
if self.git_pull_request: if self.git_pull_request:
buildSummary += ' <tr>\n' buildSummary += ' <tr>\n'
buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Source Branch</td>\n' buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Merge Request URL</td>\n'
buildSummary += ' <td><a href="TEMPLATE_MERGE_REQUEST_LINK">TEMPLATE_MERGE_REQUEST_LINK</a></td>\n' buildSummary += ' <td><a href="TEMPLATE_MERGE_REQUEST_LINK">TEMPLATE_MERGE_REQUEST_LINK</a></td>\n'
buildSummary += ' </tr>\n' buildSummary += ' </tr>\n'
buildSummary += ' <tr>\n' buildSummary += ' <tr>\n'
...@@ -158,7 +158,9 @@ class HtmlReport(): ...@@ -158,7 +158,9 @@ class HtmlReport():
self.file.write(buildSummary) self.file.write(buildSummary)
cwd = os.getcwd() cwd = os.getcwd()
for reportFile in glob.glob('./*results_oai_cn5g.html'): for reportFile in glob.glob('./*results_oai_*.html'):
if reportFile == './test_results_oai_amf.html':
continue
newEpcReport = open(cwd + '/' + str(reportFile) + '.new', 'w') newEpcReport = open(cwd + '/' + str(reportFile) + '.new', 'w')
buildSummaryDone = True buildSummaryDone = True
with open(cwd + '/' + str(reportFile), 'r') as originalEpcReport: with open(cwd + '/' + str(reportFile), 'r') as originalEpcReport:
...@@ -461,8 +463,6 @@ class HtmlReport(): ...@@ -461,8 +463,6 @@ class HtmlReport():
section_end_pattern = 'build_amf --clean --Verbose --build-type Release --jobs' section_end_pattern = 'build_amf --clean --Verbose --build-type Release --jobs'
section_status = False section_status = False
package_install = False package_install = False
fmt_build_start = False
fmt_build_status = False
folly_build_start = False folly_build_start = False
folly_build_status = False folly_build_status = False
spdlog_build_start = False spdlog_build_start = False
...@@ -498,12 +498,6 @@ class HtmlReport(): ...@@ -498,12 +498,6 @@ class HtmlReport():
result = re.search('cpprestsdk installation complete', line) result = re.search('cpprestsdk installation complete', line)
if result is not None and cpprest_build_start: if result is not None and cpprest_build_start:
cpprest_build_status = True cpprest_build_status = True
result = re.search('Starting to install fmt', line)
if result is not None:
fmt_build_start = True
result = re.search('fmt installation complete', line)
if result is not None and fmt_build_start:
fmt_build_status = True
result = re.search('Starting to install folly', line) result = re.search('Starting to install folly', line)
if result is not None: if result is not None:
folly_build_start = True folly_build_start = True
...@@ -551,12 +545,6 @@ class HtmlReport(): ...@@ -551,12 +545,6 @@ class HtmlReport():
cell_msg += ' ** cpprestsdk Installation: OK\n' cell_msg += ' ** cpprestsdk Installation: OK\n'
else: else:
cell_msg += ' ** cpprestsdk Installation: KO\n' cell_msg += ' ** cpprestsdk Installation: KO\n'
if base_image:
cell_msg += ' ** fmt Installation: N/A\n'
elif fmt_build_status:
cell_msg += ' ** fmt Installation: OK\n'
else:
cell_msg += ' ** fmt Installation: KO\n'
if base_image: if base_image:
cell_msg += ' ** folly Installation: N/A\n' cell_msg += ' ** folly Installation: N/A\n'
elif folly_build_status: elif folly_build_status:
...@@ -850,9 +838,11 @@ class HtmlReport(): ...@@ -850,9 +838,11 @@ class HtmlReport():
else: else:
result = re.search('oai-amf *develop', line) result = re.search('oai-amf *develop', line)
if result is not None: if result is not None:
result = re.search('ago *([0-9A-Z]+)', line) result = re.search('ago *([0-9A-Z ]+)', line)
if result is not None: if result is not None:
size = result.group(1) size = result.group(1)
if variant == 'docker':
size = re.sub('MB', ' MB', size)
status = True status = True
logfile.close() logfile.close()
if status: if status:
......
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
#---------------------------------------------------------------------
import os
import re
import sys
import subprocess
import yaml
class IpRouteCheck():
def __init__(self):
self.mode = ''
self.userName = ''
self.hostName = ''
self.subnet = ''
self.gatwayIp = ''
self.interfaceName = ''
def getSubnet(self):
cmd = "egrep 'subnet' ci-scripts/dsTesterDockerCompose/docker-compose.yml"
ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8')
if ret.returncode == 0:
if ret.stdout is not None:
result = re.search("(?:[0-9]{1,3}[.]){3}[0-9]{1,3}/[0-9]{1,2}", ret.stdout.strip())
if result is not None:
self.subnet = result.group(0)
#print("found subnet:", self.subnet)
else:
print("subnet not found in docker compose")
sys.exit(-1)
else:
print("docker-compose file not found")
sys.exit(-1)
def getGatwayIp(self):
cmd = "ifconfig | grep 192.168.18"
ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8')
if ret.returncode == 0:
result = re.search("inet (?:[0-9]{1,3}[.]){3}[0-9]{1,3}", ret.stdout.strip())
self.gatwayIp = result.group(0)
#print("Gatway IP Address:", self.gatwayIp)
else:
print("No Gatway IP address starts with 196.168.18")
sys.exit(-1)
def routeCheck(self):
# Get the interface name
cmd = "ip route | grep 192.168.18.0/24 | awk {'print $3'}"
ret = subprocess.run(f'ssh {self.userName}@{self.hostName} {cmd} || true', shell=True, stdout=subprocess.PIPE, encoding='utf-8')
#print('interface name:', ret.stdout.strip())
self.interfaceName = ret.stdout.strip()
# Check whether or not ip route exist
cmd = f'ip route | grep -c "{self.subnet}"'
ret = subprocess.run(f'ssh {self.userName}@{self.hostName} {cmd} || true', shell=True, stdout=subprocess.PIPE, encoding='utf-8')
if ret.stdout is not None:
if ret.stdout.strip() == '1':
#print('Route exits')
if IPRC.mode == 'Delete':
IPRC.routeDel()
else:
sys.exit(0)
else:
#print("Route not found")
if IPRC.mode == 'Add':
IPRC.routeAdd()
else:
sys.exit(0)
def routeAdd(self):
# Add the route
cmd = f"sudo ip route add {self.subnet} via {self.gatwayIp} dev {self.interfaceName}"
ret = subprocess.run(f'ssh {self.userName}@{self.hostName} {cmd} || true', shell=True, stdout=subprocess.PIPE, encoding='utf-8')
print("Added ip route")
def routeDel(self):
# Delete the route
cmd = f"sudo ip route del {self.subnet} via {self.gatwayIp} dev {self.interfaceName}"
ret = subprocess.run(f'ssh {self.userName}@{self.hostName} {cmd} || true', shell=True, stdout=subprocess.PIPE, encoding='utf-8')
print("Deleted ip route")
def Usage():
print('----------------------------------------------------------------------------------------------------------------------')
print('routecheck.py')
print(' Add and Delete the ip route on the Server.')
print('----------------------------------------------------------------------------------------------------------------------')
print('Usage: python3 routecheck.py [options]')
print(' --help Show this help.')
print('---------------------------------------------------------------------------------------------- Mandatory Options -----')
print(' --mode=[Add/Delete]')
print(' --userName=[server userName where to add/delete]')
print(' --hostName=[server hostName where to add/delete]')
print('------------------------------------------------------------------------------------------------- Actions Syntax -----')
print('python3 routeCheck.py --mode=Add [Mandatory Options]')
print('python3 routeCheck.py --mode=Delete [Mandatory Options]')
#--------------------------------------------------------------------------------------------------------
#
# Start of main
#
#--------------------------------------------------------------------------------------------------------
argvs = sys.argv
IPRC = IpRouteCheck()
while len(argvs) > 1:
myArgv = argvs.pop(1)
if re.match('^\-\-help$', myArgv, re.IGNORECASE):
Usage()
sys.exit(0)
elif re.match('^\-\-mode=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-mode=(.+)$', myArgv, re.IGNORECASE)
IPRC.mode = matchReg.group(1)
elif re.match('^\-\-userName=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-userName=(.+)$', myArgv, re.IGNORECASE)
IPRC.userName = matchReg.group(1)
elif re.match('^\-\-hostName=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-hostName=(.+)$', myArgv, re.IGNORECASE)
IPRC.hostName = matchReg.group(1)
else:
sys.exit('Invalid Parameter: ' + myArgv)
if IPRC.mode == '' or IPRC.userName == '' or IPRC.hostName == '':
sys.exit('Missing Parameter in job description')
IPRC.getSubnet()
IPRC.getGatwayIp()
IPRC.routeCheck()
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
#---------------------------------------------------------------------
import re
import sys
import subprocess
import yaml
import os
import time
locexist = False
cwd = os.getcwd()
try:
with open(cwd + '/DS-TEST-RESULTS/dsTester_Summary.txt') as f:
for line in f:
if re.search('Result file is available here', str(line)):
result = re.search('(?:\/.+?\/)(.+?)(?:\/.+)', str(line))
if result:
result1 = re.search('^(.*/)([^/]*)$', str(result.group(0)))
subprocess.check_output(f'cp {result1.group(1)}* DS-TEST-RESULTS/', stderr=subprocess.STDOUT, shell=True, universal_newlines=True)
locexist = True
except IOError:
sys.exit("File not accessible to check DSTester Summary: DS-TEST-RESULTS/dsTester_Summary.txt")
if locexist:
try:
with open(cwd + '/DS-TEST-RESULTS/dcamf.yaml') as f:
data = yaml.load(f)
if data["final-result"] == 'fail':
sys.exit('DsTester final result FAILED')
except IOError:
sys.exit("File not accessible to check DSTester result: DS-TEST-RESULTS/dcamf.yaml")
...@@ -34,9 +34,11 @@ ARG NEEDED_GIT_PROXY ...@@ -34,9 +34,11 @@ ARG NEEDED_GIT_PROXY
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe ENV TZ=Europe
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update && \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \ psmisc \
software-properties-common \
git \ git \
vim \ vim \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
...@@ -63,14 +65,19 @@ RUN ./build_amf --clean --Verbose --build-type Release --jobs ...@@ -63,14 +65,19 @@ RUN ./build_amf --clean --Verbose --build-type Release --jobs
FROM ubuntu:bionic as oai-amf FROM ubuntu:bionic as oai-amf
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# We install some debug tools for the moment in addition of mandatory libraries # We install some debug tools for the moment in addition of mandatory libraries
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DEBIAN_FRONTEND=noninteractive apt-get install --yes \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
tzdata \ tzdata \
psmisc \ psmisc \
net-tools \ net-tools \
bc \ bc \
openssl \
perl \
tshark \ tshark \
libasan4 \
libldap-2.4-2 \
libconfig++9v5 \ libconfig++9v5 \
libsctp1 \ libsctp1 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
...@@ -82,29 +89,14 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh ...@@ -82,29 +89,14 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh
WORKDIR /usr/lib/x86_64-linux-gnu WORKDIR /usr/lib/x86_64-linux-gnu
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcpprest.so.2.10 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libssl.so.1.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsasl2.so.2 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libgssapi.so.3 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libheimbase.so.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libkrb5.so.26 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasn1.so.8 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libroken.so.18 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libwind.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libhx509.so.5 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasan.so.4 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
...@@ -119,5 +111,4 @@ WORKDIR /openair-amf ...@@ -119,5 +111,4 @@ WORKDIR /openair-amf
EXPOSE 80/tcp 9090/tcp 38412/sctp EXPOSE 80/tcp 9090/tcp 38412/sctp
ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"] ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"] CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
...@@ -74,10 +74,9 @@ AMF = ...@@ -74,10 +74,9 @@ AMF =
PORT = 80; # YOUR NETWORK CONFIG HERE PORT = 80; # YOUR NETWORK CONFIG HERE
API_VERSION = "v1"; # YOUR AMF API VERSION CONFIG HERE API_VERSION = "v1"; # YOUR AMF API VERSION CONFIG HERE
SMF_INSTANCES_POOL = ( SMF_INSTANCES_POOL = (
{SMF_INSTANCE_ID = @SMF_INSTANCE_ID_0@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_0@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_0@"; SELECTED = "true"}, # YOUR SMF CONFIG HERE {SMF_INSTANCE_ID = @SMF_INSTANCE_ID_0@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_0@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_0@"; FQDN = "@SMF_FQDN_0@", SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = @SMF_INSTANCE_ID_1@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_1@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_1@"; SELECTED = "false"} # YOUR SMF CONFIG HERE {SMF_INSTANCE_ID = @SMF_INSTANCE_ID_1@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_1@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_1@"; FQDN = "@SMF_FQDN_1@", SELECTED = "false"} # YOUR SMF CONFIG HERE
); );
}; };
...@@ -86,6 +85,7 @@ AMF = ...@@ -86,6 +85,7 @@ AMF =
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80) PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
FQDN = "@NRF_FQDN@"
}; };
AUSF : AUSF :
...@@ -104,6 +104,7 @@ AMF = ...@@ -104,6 +104,7 @@ AMF =
SMF_SELECTION = "@SMF_SELECTION@"; # Set to yes to enable SMF discovery and selection SMF_SELECTION = "@SMF_SELECTION@"; # Set to yes to enable SMF discovery and selection
EXTERNAL_AUSF = "no"; # Set to yes if AMF works with an external AUSF EXTERNAL_AUSF = "no"; # Set to yes if AMF works with an external AUSF
EXTERNAL_UDM = "no"; # Set to yes if AMF works with an external UDM EXTERNAL_UDM = "no"; # Set to yes if AMF works with an external UDM
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF relies on a DNS to resolve NRF/SMF/UDM/AUSF's FQDN
} }
AUTHENTICATION: AUTHENTICATION:
......
...@@ -417,11 +417,7 @@ void amf_app::generate_amf_profile() { ...@@ -417,11 +417,7 @@ void amf_app::generate_amf_profile() {
nf_service.nf_service_status = "REGISTERED"; nf_service.nf_service_status = "REGISTERED";
// IP Endpoint // IP Endpoint
ip_endpoint_t endpoint = {}; ip_endpoint_t endpoint = {};
std::vector<struct in_addr> addrs; endpoint.ipv4_address = amf_cfg.n11.addr4;
nf_instance_profile.get_nf_ipv4_addresses(addrs);
for (auto a : addrs) {
endpoint.ipv4_addresses.push_back(a);
}
endpoint.transport = "TCP"; endpoint.transport = "TCP";
endpoint.port = amf_cfg.n11.port; endpoint.port = amf_cfg.n11.port;
nf_service.ip_endpoints.push_back(endpoint); nf_service.ip_endpoints.push_back(endpoint);
...@@ -465,12 +461,17 @@ void amf_app::trigger_nf_registration_request() { ...@@ -465,12 +461,17 @@ void amf_app::trigger_nf_registration_request() {
std::make_shared<itti_n11_register_nf_instance_request>( std::make_shared<itti_n11_register_nf_instance_request>(
TASK_AMF_APP, TASK_AMF_N11); TASK_AMF_APP, TASK_AMF_N11);
itti_msg->profile = nf_instance_profile; itti_msg->profile = nf_instance_profile;
amf_n11_inst->register_nf_instance(itti_msg);
/*
int ret = itti_inst->send_msg(itti_msg); int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) { if (RETURNok != ret) {
Logger::amf_app().error( Logger::amf_app().error(
"Could not send ITTI message %s to task TASK_AMF_N11", "Could not send ITTI message %s to task TASK_AMF_N11",
itti_msg->get_msg_name()); itti_msg->get_msg_name());
} }
*/
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
This diff is collapsed.
...@@ -104,6 +104,8 @@ ...@@ -104,6 +104,8 @@
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION "SMF_SELECTION" #define AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION "SMF_SELECTION"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF" #define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM" #define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define AMF_CONFIG_STRING_FQDN_DNS "FQDN"
using namespace libconfig; using namespace libconfig;
...@@ -166,6 +168,7 @@ typedef struct { ...@@ -166,6 +168,7 @@ typedef struct {
std::string port; std::string port;
std::string version; std::string version;
bool selected; bool selected;
std::string fqdn;
} smf_inst_t; } smf_inst_t;
class amf_config { class amf_config {
...@@ -196,6 +199,7 @@ class amf_config { ...@@ -196,6 +199,7 @@ class amf_config {
bool enable_smf_selection; bool enable_smf_selection;
bool enable_external_ausf; bool enable_external_ausf;
bool enable_external_udm; bool enable_external_udm;
bool use_fqdn_dns;
struct { struct {
struct in_addr ipv4_addr; struct in_addr ipv4_addr;
......
...@@ -437,7 +437,7 @@ void amf_n1::nas_signalling_establishment_request_handle( ...@@ -437,7 +437,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
case SERVICE_REQUEST: { case SERVICE_REQUEST: {
Logger::amf_n1().debug("Received service request message, handling..."); Logger::amf_n1().debug("Received service request message, handling...");
nc.get()->security_ctx->ul_count.seq_num = ulCount; if (nc.get()) nc.get()->security_ctx->ul_count.seq_num = ulCount;
service_request_handle( service_request_handle(
true, nc, ran_ue_ngap_id, amf_ue_ngap_id, plain_msg); true, nc, ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break; } break;
...@@ -1028,15 +1028,15 @@ void amf_n1::registration_request_handle( ...@@ -1028,15 +1028,15 @@ void amf_n1::registration_request_handle(
if (!regReq->getUeSecurityCapability( if (!regReq->getUeSecurityCapability(
encrypt_alg, integrity_alg, security_cap_eea, security_cap_eia)) { encrypt_alg, integrity_alg, security_cap_eea, security_cap_eia)) {
Logger::amf_n1().warn("No Optional IE UESecurityCapability available"); Logger::amf_n1().warn("No Optional IE UESecurityCapability available");
nc.get()->ueSecurityCaplen = regReq->ie_ue_security_capability->getLength();
} }
nc.get()->ueSecurityCapEnc = encrypt_alg; nc.get()->ueSecurityCapEnc = encrypt_alg;
nc.get()->ueSecurityCapInt = integrity_alg; nc.get()->ueSecurityCapInt = integrity_alg;
nc.get()->ueSecurityCapEEA = security_cap_eea; nc.get()->ueSecurityCapEEA = security_cap_eea;
nc.get()->ueSecurityCapEIA = security_cap_eia; nc.get()->ueSecurityCapEIA = security_cap_eia;
nc.get()->ueSecurityCaplen = regReq->ie_ue_security_capability->getLength();
// Get Requested NSSAI (Optional IE), if provided // Get Requested NSSAI (Optional IE), if provided
std::vector<SNSSAI_t> requestedNssai = {}; std::vector<SNSSAI_t> requestedNssai = {};
if (!regReq->getRequestedNssai(requestedNssai)) { if (!regReq->getRequestedNssai(requestedNssai)) {
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "SmContextCreateData.h" #include "SmContextCreateData.h"
#include "mime_parser.hpp" #include "mime_parser.hpp"
#include "ue_context.hpp" #include "ue_context.hpp"
#include "fqdn.hpp"
extern "C" { extern "C" {
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
...@@ -124,6 +125,14 @@ void amf_n11_task(void*) { ...@@ -124,6 +125,14 @@ void amf_n11_task(void*) {
dynamic_cast<itti_pdu_session_resource_setup_response*>(msg); dynamic_cast<itti_pdu_session_resource_setup_response*>(msg);
amf_n11_inst->handle_itti_message(ref(*m)); amf_n11_inst->handle_itti_message(ref(*m));
} break; } break;
case N11_REGISTER_NF_INSTANCE_REQUEST: {
Logger::amf_n11().info(
"Receive Register NF Instance Request, handling ...");
itti_n11_register_nf_instance_request* m =
dynamic_cast<itti_n11_register_nf_instance_request*>(msg);
// TODO: Handle ITTI
} break;
default: { default: {
Logger::amf_n11().info( Logger::amf_n11().info(
"Receive unknown message type %d", msg->msg_type); "Receive unknown message type %d", msg->msg_type);
...@@ -435,9 +444,27 @@ bool amf_n11::smf_selection_from_configuration( ...@@ -435,9 +444,27 @@ bool amf_n11::smf_selection_from_configuration(
std::string& smf_addr, std::string& smf_api_version) { std::string& smf_addr, std::string& smf_api_version) {
for (int i = 0; i < amf_cfg.smf_pool.size(); i++) { for (int i = 0; i < amf_cfg.smf_pool.size(); i++) {
if (amf_cfg.smf_pool[i].selected) { if (amf_cfg.smf_pool[i].selected) {
if (!amf_cfg.use_fqdn_dns) {
smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + amf_cfg.smf_pool[i].port; smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + amf_cfg.smf_pool[i].port;
smf_api_version = amf_cfg.smf_pool[i].version; smf_api_version = amf_cfg.smf_pool[i].version;
return true; return true;
} else {
// resolve IP addr from a FQDN/DNS name
uint8_t addr_type = 0;
uint32_t smf_port = 0;
fqdn::resolve(
amf_cfg.smf_pool[i].fqdn, amf_cfg.smf_pool[i].ipv4, smf_port,
addr_type);
if (addr_type != 0) { // IPv6: TODO
Logger::amf_n11().warn("Do not support IPv6 Addr for SMF");
return false;
} else { // IPv4
smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + std::to_string(smf_port);
smf_api_version = "v1"; // TODO: get API version
return true;
}
}
return true;
} }
} }
return false; return false;
...@@ -793,6 +820,80 @@ bool amf_n11::discover_smf( ...@@ -793,6 +820,80 @@ bool amf_n11::discover_smf(
return result; return result;
} }
//-----------------------------------------------------------------------------------------------------
void amf_n11::register_nf_instance(
std::shared_ptr<itti_n11_register_nf_instance_request> msg) {
Logger::amf_n11().debug(
"Send NF Instance Registration to NRF (HTTP version %d)",
msg->http_version);
nlohmann::json json_data = {};
msg->profile.to_json(json_data);
std::string url =
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(amf_cfg.nrf_addr.port) + "/nnrf-nfm/" +
amf_cfg.nrf_addr.api_version + "/nf-instances/" +
msg->profile.get_nf_instance_id();
Logger::amf_n11().debug(
"Send NF Instance Registration to NRF, NRF URL %s", url.c_str());
std::string body = json_data.dump();
Logger::amf_n11().debug(
"Send NF Instance Registration to NRF, msg body: \n %s", body.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, NRF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
// Response information.
long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
Logger::amf_n11().debug(
"NFDiscovery, response from NRF, HTTP Code: %d", httpCode);
if (httpCode == 200) {
Logger::amf_n11().debug(
"NFRegistration, got successful response from NRF");
nlohmann::json response_data = {};
try {
response_data = nlohmann::json::parse(*httpData.get());
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn(
"NFDiscovery, could not parse json from the NRF "
"response");
}
Logger::amf_n11().debug(
"NFDiscovery, response from NRF, json data: \n %s",
response_data.dump().c_str());
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
}
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
bool amf_n11::send_ue_authentication_request( bool amf_n11::send_ue_authentication_request(
oai::amf::model::AuthenticationInfo& auth_info, oai::amf::model::AuthenticationInfo& auth_info,
......
...@@ -76,7 +76,8 @@ class amf_n11 { ...@@ -76,7 +76,8 @@ class amf_n11 {
bool discover_smf( bool discover_smf(
std::string& smf_addr, std::string& smf_api_version, std::string& smf_addr, std::string& smf_api_version,
const snssai_t snssai, const plmn_t plmn, const std::string dnn); const snssai_t snssai, const plmn_t plmn, const std::string dnn);
void register_nf_instance(
std::shared_ptr<itti_n11_register_nf_instance_request> msg);
bool send_ue_authentication_request( bool send_ue_authentication_request(
oai::amf::model::AuthenticationInfo& auth_info, oai::amf::model::AuthenticationInfo& auth_info,
oai::amf::model::UEAuthenticationCtx& ue_auth_ctx, uint8_t http_version); oai::amf::model::UEAuthenticationCtx& ue_auth_ctx, uint8_t http_version);
......
...@@ -371,9 +371,7 @@ void amf_profile::to_json(nlohmann::json& data) const { ...@@ -371,9 +371,7 @@ void amf_profile::to_json(nlohmann::json& data) const {
for (auto endpoint : service.ip_endpoints) { for (auto endpoint : service.ip_endpoints) {
nlohmann::json ep_tmp = {}; nlohmann::json ep_tmp = {};
ep_tmp["ipv4Address"] = nlohmann::json::array(); ep_tmp["ipv4Address"] = nlohmann::json::array();
for (auto address : endpoint.ipv4_addresses) { ep_tmp["ipv4Address"] = inet_ntoa(endpoint.ipv4_address);
ep_tmp["ipv4Address"].push_back(inet_ntoa(address));
}
ep_tmp["transport"] = endpoint.transport; ep_tmp["transport"] = endpoint.transport;
ep_tmp["port"] = endpoint.port; ep_tmp["port"] = endpoint.port;
srv_tmp["ipEndPoints"].push_back(ep_tmp); srv_tmp["ipEndPoints"].push_back(ep_tmp);
......
...@@ -276,16 +276,14 @@ typedef struct nf_service_version_s { ...@@ -276,16 +276,14 @@ typedef struct nf_service_version_s {
} nf_service_version_t; } nf_service_version_t;
typedef struct ip_endpoint_s { typedef struct ip_endpoint_s {
std::vector<struct in_addr> ipv4_addresses; struct in_addr ipv4_address;
// std::vector<struct in6_addr> ipv6_addresses; // struct in6_addr ipv6_address;
std::string transport; // TCP std::string transport; // TCP
unsigned int port; unsigned int port;
std::string to_string() const { std::string to_string() const {
std::string s = {}; std::string s = {};
s.append("Ipv4 Addresses: "); s.append("Ipv4 Address: ");
for (auto ipv4 : ipv4_addresses) { s.append(inet_ntoa(ipv4_address));
s.append(inet_ntoa(ipv4));
}
s.append(", TransportProtocol: "); s.append(", TransportProtocol: ");
s.append(transport); s.append(transport);
s.append(", Port: "); s.append(", Port: ");
......
...@@ -35,32 +35,32 @@ using namespace nas; ...@@ -35,32 +35,32 @@ using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
RegistrationRequest::RegistrationRequest() { RegistrationRequest::RegistrationRequest() {
plain_header = NULL; plain_header = nullptr;
ie_5gsregistrationtype = NULL; ie_5gsregistrationtype = nullptr;
ie_ngKSI = NULL; ie_ngKSI = nullptr;
ie_5gs_mobility_id = NULL; ie_5gs_mobility_id = nullptr;
ie_non_current_native_nas_ksi = NULL; ie_non_current_native_nas_ksi = nullptr;
ie_5g_mm_capability = NULL; ie_5g_mm_capability = nullptr;
ie_ue_security_capability = NULL; ie_ue_security_capability = nullptr;
ie_requested_NSSAI = NULL; ie_requested_NSSAI = nullptr;
ie_s1_ue_network_capability = NULL; ie_s1_ue_network_capability = nullptr;
ie_uplink_data_status = NULL; ie_uplink_data_status = nullptr;
ie_last_visited_registered_TAI = NULL; ie_last_visited_registered_TAI = nullptr;
ie_PDU_session_status = NULL; ie_PDU_session_status = nullptr;
ie_MICO_indicationl = NULL; ie_MICO_indicationl = nullptr;
ie_ue_status = NULL; ie_ue_status = nullptr;
ie_additional_guti = NULL; ie_additional_guti = nullptr;
ie_allowed_PDU_session_status = NULL; ie_allowed_PDU_session_status = nullptr;
ie_ues_usage_setting = NULL; ie_ues_usage_setting = nullptr;
ie_5gs_drx_parameters = NULL; ie_5gs_drx_parameters = nullptr;
ie_eps_nas_message_container = NULL; ie_eps_nas_message_container = nullptr;
ie_ladn_indication = NULL; ie_ladn_indication = nullptr;
ie_payload_container_type = NULL; ie_payload_container_type = nullptr;
ie_payload_container = NULL; ie_payload_container = nullptr;
ie_network_slicing_indication = NULL; ie_network_slicing_indication = nullptr;
ie_5gs_update_type = NULL; ie_5gs_update_type = nullptr;
ie_nas_message_container = NULL; ie_nas_message_container = nullptr;
ie_eps_bearer_context_status = NULL; ie_eps_bearer_context_status = nullptr;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -94,11 +94,11 @@ void RegistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) { ...@@ -94,11 +94,11 @@ void RegistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t RegistrationRequest::getngKSI() { uint8_t RegistrationRequest::getngKSI() {
if (ie_ngKSI) { if (ie_ngKSI) {
uint8_t a = 0; return (
a = (ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier(); (ie_ngKSI->getTypeOfSecurityContext()) |
return a; ie_ngKSI->getasKeyIdentifier());
} else { } else {
return -1; return 0;
} }
} }
...@@ -122,7 +122,7 @@ uint8_t RegistrationRequest::getMobilityIdentityType() { ...@@ -122,7 +122,7 @@ uint8_t RegistrationRequest::getMobilityIdentityType() {
if (ie_5gs_mobility_id) { if (ie_5gs_mobility_id) {
return ie_5gs_mobility_id->gettypeOfIdentity(); return ie_5gs_mobility_id->gettypeOfIdentity();
} else { } else {
return -1; return 0;
} }
} }
...@@ -169,9 +169,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI( ...@@ -169,9 +169,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI(
bool RegistrationRequest::getAdditionalGuti(nas::_5G_GUTI_t& guti) { bool RegistrationRequest::getAdditionalGuti(nas::_5G_GUTI_t& guti) {
if (ie_additional_guti) { if (ie_additional_guti) {
ie_additional_guti->get5GGUTI(guti); ie_additional_guti->get5GGUTI(guti);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -203,7 +203,7 @@ uint8_t RegistrationRequest::getNonCurrentNativeNasKSI() { ...@@ -203,7 +203,7 @@ uint8_t RegistrationRequest::getNonCurrentNativeNasKSI() {
(ie_non_current_native_nas_ksi->getasKeyIdentifier()); (ie_non_current_native_nas_ksi->getasKeyIdentifier());
return a; return a;
} else { } else {
return -1; return 0;
} }
} }
...@@ -217,7 +217,7 @@ uint8_t RegistrationRequest::get5GMMCapability() { ...@@ -217,7 +217,7 @@ uint8_t RegistrationRequest::get5GMMCapability() {
if (ie_5g_mm_capability) if (ie_5g_mm_capability)
return ie_5g_mm_capability->getValue(); return ie_5g_mm_capability->getValue();
else else
return -1; return 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -239,7 +239,7 @@ bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) { ...@@ -239,7 +239,7 @@ bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) {
ea = ie_ue_security_capability->getEASel(); ea = ie_ue_security_capability->getEASel();
ia = ie_ue_security_capability->getIASel(); ia = ie_ue_security_capability->getIASel();
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -255,7 +255,7 @@ bool RegistrationRequest::getUeSecurityCapability( ...@@ -255,7 +255,7 @@ bool RegistrationRequest::getUeSecurityCapability(
eia = ie_ue_security_capability->getEIASel(); eia = ie_ue_security_capability->getEIASel();
} }
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -272,7 +272,7 @@ bool RegistrationRequest::getRequestedNssai( ...@@ -272,7 +272,7 @@ bool RegistrationRequest::getRequestedNssai(
if (ie_requested_NSSAI) { if (ie_requested_NSSAI) {
ie_requested_NSSAI->getValue(nssai); ie_requested_NSSAI->getValue(nssai);
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -297,7 +297,7 @@ bool RegistrationRequest::getS1UeNetworkCapability(uint8_t& eea, uint8_t& eia) { ...@@ -297,7 +297,7 @@ bool RegistrationRequest::getS1UeNetworkCapability(uint8_t& eea, uint8_t& eia) {
eea = ie_s1_ue_network_capability->getEEASel(); eea = ie_s1_ue_network_capability->getEEASel();
eia = ie_s1_ue_network_capability->getEIASel(); eia = ie_s1_ue_network_capability->getEIASel();
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -312,7 +312,7 @@ uint16_t RegistrationRequest::getUplinkDataStatus() { ...@@ -312,7 +312,7 @@ uint16_t RegistrationRequest::getUplinkDataStatus() {
if (ie_uplink_data_status) { if (ie_uplink_data_status) {
return ie_uplink_data_status->getValue(); return ie_uplink_data_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -326,7 +326,7 @@ uint16_t RegistrationRequest::getPduSessionStatus() { ...@@ -326,7 +326,7 @@ uint16_t RegistrationRequest::getPduSessionStatus() {
if (ie_PDU_session_status) { if (ie_PDU_session_status) {
return ie_PDU_session_status->getValue(); return ie_PDU_session_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -340,9 +340,9 @@ bool RegistrationRequest::getMicoIndication(uint8_t& sprti, uint8_t& raai) { ...@@ -340,9 +340,9 @@ bool RegistrationRequest::getMicoIndication(uint8_t& sprti, uint8_t& raai) {
if (ie_PDU_session_status) { if (ie_PDU_session_status) {
sprti = ie_MICO_indicationl->getSPRTI(); sprti = ie_MICO_indicationl->getSPRTI();
raai = ie_MICO_indicationl->getRAAI(); raai = ie_MICO_indicationl->getRAAI();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -356,9 +356,9 @@ bool RegistrationRequest::getUeStatus(uint8_t& n1ModeReg, uint8_t& s1ModeReg) { ...@@ -356,9 +356,9 @@ bool RegistrationRequest::getUeStatus(uint8_t& n1ModeReg, uint8_t& s1ModeReg) {
if (ie_ue_status) { if (ie_ue_status) {
n1ModeReg = ie_ue_status->getN1(); n1ModeReg = ie_ue_status->getN1();
s1ModeReg = ie_ue_status->getS1(); s1ModeReg = ie_ue_status->getS1();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -372,7 +372,7 @@ uint16_t RegistrationRequest::getAllowedPduSessionStatus() { ...@@ -372,7 +372,7 @@ uint16_t RegistrationRequest::getAllowedPduSessionStatus() {
if (ie_allowed_PDU_session_status) { if (ie_allowed_PDU_session_status) {
return ie_allowed_PDU_session_status->getValue(); return ie_allowed_PDU_session_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -386,7 +386,7 @@ uint8_t RegistrationRequest::getUEsUsageSetting() { ...@@ -386,7 +386,7 @@ uint8_t RegistrationRequest::getUEsUsageSetting() {
if (ie_ues_usage_setting) { if (ie_ues_usage_setting) {
return ie_ues_usage_setting->getValue(); return ie_ues_usage_setting->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -400,7 +400,7 @@ uint8_t RegistrationRequest::get5GSDrxParameters() { ...@@ -400,7 +400,7 @@ uint8_t RegistrationRequest::get5GSDrxParameters() {
if (ie_5gs_drx_parameters) { if (ie_5gs_drx_parameters) {
return ie_5gs_drx_parameters->getValue(); return ie_5gs_drx_parameters->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -413,9 +413,9 @@ void RegistrationRequest::setEPS_NAS_Message_Container(bstring value) { ...@@ -413,9 +413,9 @@ void RegistrationRequest::setEPS_NAS_Message_Container(bstring value) {
bool RegistrationRequest::getEpsNasMessageContainer(bstring& epsNas) { bool RegistrationRequest::getEpsNasMessageContainer(bstring& epsNas) {
if (ie_eps_nas_message_container) { if (ie_eps_nas_message_container) {
ie_eps_nas_message_container->getValue(epsNas); ie_eps_nas_message_container->getValue(epsNas);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -429,7 +429,7 @@ bool RegistrationRequest::getLadnIndication(std::vector<bstring>& ladnValue) { ...@@ -429,7 +429,7 @@ bool RegistrationRequest::getLadnIndication(std::vector<bstring>& ladnValue) {
if (ie_ladn_indication) { if (ie_ladn_indication) {
return ie_ladn_indication->getValue(ladnValue); return ie_ladn_indication->getValue(ladnValue);
} else { } else {
return -1; return 0;
} }
} }
...@@ -443,7 +443,7 @@ uint8_t RegistrationRequest::getPayloadContainerType() { ...@@ -443,7 +443,7 @@ uint8_t RegistrationRequest::getPayloadContainerType() {
if (ie_payload_container_type) { if (ie_payload_container_type) {
return ie_payload_container_type->getValue(); return ie_payload_container_type->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -458,9 +458,9 @@ bool RegistrationRequest::getPayloadContainer( ...@@ -458,9 +458,9 @@ bool RegistrationRequest::getPayloadContainer(
std::vector<PayloadContainerEntry>& content) { std::vector<PayloadContainerEntry>& content) {
if (ie_payload_container) { if (ie_payload_container) {
ie_payload_container->getValue(content); ie_payload_container->getValue(content);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -476,9 +476,9 @@ bool RegistrationRequest::getNetworkSlicingIndication( ...@@ -476,9 +476,9 @@ bool RegistrationRequest::getNetworkSlicingIndication(
if (ie_network_slicing_indication) { if (ie_network_slicing_indication) {
dcni = ie_network_slicing_indication->getDCNI(); dcni = ie_network_slicing_indication->getDCNI();
nssci = ie_network_slicing_indication->getNSSCI(); nssci = ie_network_slicing_indication->getNSSCI();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -498,9 +498,9 @@ bool RegistrationRequest::get5GSUpdateType( ...@@ -498,9 +498,9 @@ bool RegistrationRequest::get5GSUpdateType(
_5gs_pnb_ciot = ie_5gs_update_type->get_5GS_PNB_CIoT(); _5gs_pnb_ciot = ie_5gs_update_type->get_5GS_PNB_CIoT();
ng_ran_rcu = ie_5gs_update_type->getNG_RAN(); ng_ran_rcu = ie_5gs_update_type->getNG_RAN();
sms_requested = ie_5gs_update_type->getSMS(); sms_requested = ie_5gs_update_type->getSMS();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -513,9 +513,9 @@ void RegistrationRequest::setNAS_Message_Container(bstring value) { ...@@ -513,9 +513,9 @@ void RegistrationRequest::setNAS_Message_Container(bstring value) {
bool RegistrationRequest::getNasMessageContainer(bstring& nas) { bool RegistrationRequest::getNasMessageContainer(bstring& nas) {
if (ie_nas_message_container) { if (ie_nas_message_container) {
ie_nas_message_container->getValue(nas); ie_nas_message_container->getValue(nas);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -529,7 +529,7 @@ uint16_t RegistrationRequest::getEpsBearerContextStatus() { ...@@ -529,7 +529,7 @@ uint16_t RegistrationRequest::getEpsBearerContextStatus() {
if (ie_eps_bearer_context_status) { if (ie_eps_bearer_context_status) {
return ie_eps_bearer_context_status->getValue(); return ie_eps_bearer_context_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
......
...@@ -35,5 +35,6 @@ add_library (AMF_UTILS STATIC ...@@ -35,5 +35,6 @@ add_library (AMF_UTILS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp ${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp ${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fqdn.cpp
) )
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "fqdn.hpp"
#include "logger.hpp"
#include <boost/asio.hpp>
#include <iostream>
bool fqdn::resolve(
const std::string& host_name, std::string& address, uint32_t& port,
uint8_t& addr_type, const std::string& protocol) {
try {
boost::asio::io_context io_context = {};
boost::asio::ip::tcp::resolver resolver{io_context};
boost::asio::ip::tcp::resolver::results_type endpoints =
resolver.resolve(host_name, protocol);
addr_type = 0; // IPv4 by default
for (auto it = endpoints.cbegin(); it != endpoints.cend(); it++) {
// get the first Endpoint
boost::asio::ip::tcp::endpoint endpoint = *it;
address = endpoint.address().to_string();
port = endpoint.port();
Logger::amf_app().debug(
"Resolve a DNS (name %s, protocol %s): Ip Addr %s, port %u",
host_name.c_str(), protocol.c_str(), address.c_str(), port);
if (endpoint.address().is_v4())
addr_type = 0;
else
addr_type = 1;
return true;
}
} catch (std::exception& e) {
throw std::runtime_error(
"Cannot resolve a DNS name " + std::string(e.what()));
return false;
}
return false;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file fqdn.hpp
\brief
\author
\company Eurecom
\email:
*/
#ifndef FILE_FQDN_HPP_SEEN
#define FILE_FQDN_HPP_SEEN
#include <string>
class fqdn {
public:
/*
* Resolve a DNS name to get host's IP Addr
* @param [const std::string &] host_name: host's name/url
* @param [const std::string &] protocol: protocol
* @param [uint8_t &] addr_type: addr_type (Ipv4/v6)
* @return void
*/
static bool resolve(
const std::string& host_name, std::string& address, uint32_t& port,
uint8_t& addr_type, const std::string& protocol = "http");
};
#endif /* FILE_FQDN_HPP_SEEN */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment