Commit d8888a24 authored by 陈纪航's avatar 陈纪航

classfy

parent e963ac8a
......@@ -69,6 +69,9 @@
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"*.h++": "cpp"
"*.h++": "cpp",
"csetjmp": "cpp",
"filesystem": "cpp",
"variant": "cpp"
}
}
\ No newline at end of file
#/*
# * 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
# */
#---------------------------------------------------------------------
#
# Dockerfile for the Open-Air-Interface AMF service
# Valid for Ubuntu-18.04 (bionic)
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# BUILDER IMAGE
#---------------------------------------------------------------------
FROM oai-amf-base:latest as oai-amf-builder
# Copying source code
WORKDIR /openair-amf/
COPY . /openair-amf
RUN cp -Rf /openair-amf-ext-ref /openair-amf/build/ext
# Building AMF
WORKDIR /openair-amf/build/scripts
RUN ldconfig && \
./build_amf --clean --Verbose --build-type Release --jobs && \
ldd /openair-amf/build/amf/build/amf && \
mv /openair-amf/build/amf/build/amf /openair-amf/build/amf/build/oai_amf
#---------------------------------------------------------------------
# TARGET IMAGE
#---------------------------------------------------------------------
FROM ubuntu:bionic as oai-amf
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
# 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 \
tzdata \
psmisc \
net-tools \
bc \
openssl \
perl \
libasan4 \
libgssapi-krb5-2 \
libldap-2.4-2 \
libconfig++9v5 \
libsctp1 \
&& rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries
WORKDIR /openair-amf/bin
COPY --from=oai-amf-builder \
/openair-amf/build/amf/build/oai_amf \
/openair-amf/scripts/entrypoint.sh \
./
WORKDIR /usr/lib/x86_64-linux-gnu
COPY --from=oai-amf-builder \
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 \
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0 \
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \
/usr/lib/x86_64-linux-gnu/librtmp.so.1 \
/usr/lib/x86_64-linux-gnu/libpsl.so.5 \
./
WORKDIR /usr/local/lib
COPY --from=oai-amf-builder \
/usr/local/lib/libnghttp2.so.14 \
/usr/local/lib/libnghttp2_asio.so.1 \
/usr/lib/libboost_system.so.1.67.0 \
/usr/lib/libboost_thread.so.1.67.0 \
/usr/lib/libboost_chrono.so.1.67.0 \
/usr/local/lib/libpistache.so \
./
RUN ldconfig && \
ldd /openair-amf/bin/oai_amf
# Copying template configuration files
WORKDIR /openair-amf/etc
COPY --from=oai-amf-builder /openair-amf/etc/amf.conf .
WORKDIR /openair-amf
# expose ports
EXPOSE 80/tcp 9090/tcp 38412/sctp
ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
#!/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
- 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
- AUSF_FQDN=localhost
- UDM_IPV4_ADDRESS=0.0.0.0
- UDM_PORT=80
- UDM_API_VERSION=v1
- UDM_FQDN=localhost
- NSSF_IPV4_ADDRESS=0.0.0.0
- NSSF_PORT=80
- NSSF_API_VERSION=v1
- NSSF_FQDN=localhost
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.
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN export http_proxy=http://10.112.93.158:8123
RUN export https_proxy=http://10.112.93.158:8123
RUN mkdir amf
RUN cd amf
COPY ./amf /amf
RUN apt-get update -y && \
apt-get install --no-install-recommends -y net-tools vim inetutils-ping git
RUN apt-get install -y update-notifier-common
RUN git config --global http.proxy http://10.112.93.158:8123
RUN git config --global https.proxy http://10.112.93.158:8123
RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi"
RUN git config --global https.postBuffer 123289600
RUN git config --global http.sslverify false
RUN ./amf/build/scripts/build_amf -I -f
RUN ./amf/build/scripts/build_amf -c -b Debug -j
EXPOSE 8282 38412/sctp
CMD ["/bin/bash"]
#/*
# * 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
# */
#---------------------------------------------------------------------
#
# Dockerfile for the Open-Air-Interface AMF service
# Valid for RHEL 8.2
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# BUILDER IMAGE
#---------------------------------------------------------------------
FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-amf-builder
ARG NEEDED_GIT_PROXY
# Copy the entitlements
COPY ./etc-pki-entitlement /etc/pki/entitlement
# Copy the subscription manager configurations
COPY ./rhsm-conf /etc/rhsm
COPY ./rhsm-ca /etc/rhsm/ca
RUN rm -f /etc/rhsm-host && \
yum repolist --disablerepo=* && \
subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms && \
yum update -y && \
yum install -y \
psmisc \
git \
diffutils \
file \
gcc-c++ \
cmake3 \
ninja-build \
boost-devel \
openssl-devel \
openssl \
libasan && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \
echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf
# Some GIT configuration command quite useful
RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi"
RUN git config --global https.postBuffer 123289600 && \
git config --global http.sslverify false
# Copying source code
WORKDIR /openair-amf/
COPY . /openair-amf
# Installing all the needed libraries/packages to build and run AMF
WORKDIR /openair-amf/build/scripts
RUN ./build_amf --install-deps --force
# Building AMF
WORKDIR /openair-amf/build/scripts
RUN ldconfig && \
./build_amf --clean --Verbose --build-type Release --jobs && \
ldd /openair-amf/build/amf/build/amf && \
mv /openair-amf/build/amf/build/amf /openair-amf/build/amf/build/oai_amf
#---------------------------------------------------------------------
# TARGET IMAGE
#---------------------------------------------------------------------
FROM registry.access.redhat.com/ubi8/ubi:latest as oai-amf
ENV TZ=Europe/Paris
# We install some debug tools for the moment in addition of mandatory libraries
RUN yum update -y && \
yum install -y --enablerepo="ubi-8-codeready-builder" \
tzdata \
libasan \
procps-ng \
psmisc \
net-tools \
libevent && \
yum clean all -y && \
rm -rf /var/cache/yum /var/cache/dnf
# Copying executable and generated libraries
WORKDIR /openair-amf/bin
COPY --from=oai-amf-builder \
/openair-amf/build/amf/build/oai_amf \
/openair-amf/scripts/entrypoint.sh \
./
COPY --from=oai-amf-builder \
/usr/lib64/libconfig++.so.9 \
/usr/lib64/libboost_system.so.1.66.0 \
/usr/local/lib64/libpistache.so.0 \
/usr/local/lib/libnghttp2_asio.so \
/usr/local/lib/libnghttp2_asio.so.1 \
/usr/lib64/mysql/libmysqlclient.so.21 \
/usr/lib64/libsctp.so.1 \
/usr/local/lib64/libcpprest.so.2.10 \
/usr/lib64/libboost_random.so.1.66.0 \
/usr/lib64/libboost_thread.so.1.66.0 \
/usr/lib64/libboost_filesystem.so.1.66.0 \
/usr/lib64/libboost_chrono.so.1.66.0 \
/usr/lib64/libboost_atomic.so.1.66.0 \
/usr/lib64/libboost_date_time.so.1.66.0 \
/usr/lib64/libboost_regex.so.1.66.0 \
/usr/lib64/libicudata.so.60 \
/usr/lib64/libicui18n.so.60 \
/usr/lib64/libicuuc.so.60 \
/usr/lib64/
RUN ldconfig && \
ldd /openair-amf/bin/oai_amf
# Copying template configuration files
WORKDIR /openair-amf/etc
COPY --from=oai-amf-builder /openair-amf/etc/amf.conf .
WORKDIR /openair-amf
# expose ports
EXPOSE 80/tcp 9090/tcp 38412/sctp
ENTRYPOINT ["/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
......@@ -33,21 +33,24 @@ FROM ubuntu:bionic as oai-amf-builder
ARG NEEDED_GIT_PROXY
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
git \
vim \
ENV TZ=Europe/Paris
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
software-properties-common \
git \
vim \
&& rm -rf /var/lib/apt/lists/*
# Some GIT configuration commands quite useful
RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi"
RUN git config --global https.postBuffer 123289600
RUN git config --global http.sslverify false
RUN git config --global https.postBuffer 123289600 && \
git config --global http.sslverify false
# Copying source code
WORKDIR /openair-amf/
COPY ./ /openair-amf
COPY . /openair-amf
# Installing all the needed libraries/packages to build and run AMF
WORKDIR /openair-amf/build/scripts
......@@ -55,61 +58,71 @@ RUN ./build_amf --install-deps --force
# Building AMF
WORKDIR /openair-amf/build/scripts
RUN ./build_amf --clean --Verbose --build-type Release --jobs
RUN ldconfig && \
./build_amf --clean --Verbose --build-type Release --jobs && \
ldd /openair-amf/build/amf/build/amf && \
mv /openair-amf/build/amf/build/amf /openair-amf/build/amf/build/oai_amf
#---------------------------------------------------------------------
# TARGET IMAGE
#---------------------------------------------------------------------
FROM ubuntu:bionic as oai-amf
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV TZ=Europe/Paris
# 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 \
psmisc \
net-tools \
bc \
tshark \
libconfig++9v5 \
libsctp1 \
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
tzdata \
psmisc \
net-tools \
bc \
openssl \
perl \
libasan4 \
libgssapi-krb5-2 \
libldap-2.4-2 \
libconfig++9v5 \
libsctp1 \
&& rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries
WORKDIR /openair-amf/bin
COPY --from=oai-amf-builder /openair-amf/build/amf/build/amf oai_amf
COPY --from=oai-amf-builder \
/openair-amf/build/amf/build/oai_amf \
/openair-amf/scripts/entrypoint.sh \
./
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/libcrypto.so.1.1 .
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/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/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/libmysqlclient.so.20 \
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0 \
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \
/usr/lib/x86_64-linux-gnu/librtmp.so.1 \
/usr/lib/x86_64-linux-gnu/libpsl.so.5 \
./
WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
COPY --from=oai-amf-builder \
/usr/local/lib/libnghttp2.so.14 \
/usr/local/lib/libnghttp2_asio.so.1 \
/usr/lib/libboost_system.so.1.67.0 \
/usr/lib/libboost_thread.so.1.67.0 \
/usr/lib/libboost_chrono.so.1.67.0 \
/usr/local/lib/libpistache.so \
./
RUN ldconfig
RUN ldconfig && \
ldd /openair-amf/bin/oai_amf
# Copying template configuration files
WORKDIR /openair-amf/etc
COPY --from=oai-amf-builder /openair-amf/etc/amf.conf .
COPY --from=oai-amf-builder /openair-amf/etc/modules.conf .
WORKDIR /openair-amf
# expose ports
EXPOSE 80/tcp 9090/tcp 38412/sctp
ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
#!/bin/bash
set -euo pipefail
CONFIG_DIR="/openair-amf/etc"
# Default values
EXTERNAL_NRF=${EXTERNAL_NRF:-no}
EXTERNAL_NSSF=${EXTERNAL_NSSF:-no}
EXTERNAL_AUSF=${EXTERNAL_AUSF:-no}
EXTERNAL_UDM=${EXTERNAL_UDM:-no}
UDM_IPV4_ADDRESS=${UDM_IPV4_ADDRESS:-0.0.0.0}
UDM_PORT=${UDM_PORT:-80}
UDM_API_VERSION=${UDM_API_VERSION:-v2}
UDM_FQDN=${UDM_FQDN:-oai-udm}
EXTERNAL_NRF=${EXTERNAL_NRF:-no}
NRF_SELECTION=${NRF_SELECTION:-no}
EXTERNAL_NSSF=${EXTERNAL_NSSF:-no}
NSSF_IPV4_ADDRESS=${NSSF_IPV4_ADDRESS:-0.0.0.0}
NSSF_PORT=${NSSF_PORT:-80}
NSSF_API_VERSION=${NSSF_API_VERSION:-v2}
NSSF_FQDN=${NSSF_FQDN:-oai-nssf}
INT_ALGO_LIST=${INT_ALGO_LIST:-'[ "NIA0" , "NIA1" , "NIA2" ]'}
CIPH_ALGO_LIST=${CIPH_ALGO_LIST:-'[ "NEA0" , "NEA1" , "NEA2" ]'}
USE_HTTP2=${USE_HTTP2:-no}
SST_0=${SST_0:-128}
SD_0=${SD_0:-128}
SST_1=${SST_1:-1}
SD_1=${SD_1:-0xFFFFFF}
SST_2=${SST_2:-130}
SD_2=${SD_2:-130}
OPERATOR_KEY=${OPERATOR_KEY:-'63bfa50ee6523365ff14c1f45f88737d'}
if [[ ${USE_FQDN_DNS} == "yes" ]];then
NSSF_IPV4_ADDR=${NSSF_IPV4_ADDR_0:-0.0.0.0}
SMF_IPV4_ADDR_0=${SMF_IPV4_ADDR_0:-0.0.0.0}
SMF_IPV4_ADDR_1=${SMF_IPV4_ADDR_1:-0.0.0.0}
NRF_IPV4_ADDRESS=${NRF_IPV4_ADDRESS:-0.0.0.0}
AUSF_IPV4_ADDRESS=${AUSF_IPV4_ADDRESS:-0.0.0.0}
UDM_IPV4_ADDRESS=${UDM_IPV4_ADDRESS:-0.0.0.0}
fi
for c in ${CONFIG_DIR}/*.conf; do
# grep variable names (format: ${VAR}) from template to be rendered
if ! grep -oP '@[a-zA-Z0-9_]+@' ${c}; then
echo "Configuration is already set"
exec "$@"
fi
VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs)
echo "Now setting these variables '${VARS}'"
# create sed expressions for substituting each occurrence of ${VAR}
# with the value of the environment variable "VAR"
EXPRESSIONS=""
for v in ${VARS}; do
NEW_VAR=`echo $v | sed -e "s#@##g"`
if [[ -z ${!NEW_VAR+x} ]]; then
echo "Error: Environment variable '${NEW_VAR}' is not set." \
"Config file '$(basename $c)' requires all of $VARS."
exit 1
fi
EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g"
done
EXPRESSIONS="${EXPRESSIONS#';'}"
# render template and inline replace config file
sed -i "${EXPRESSIONS}" ${c}
done
echo "Done setting the configuration"
exec "$@"
......@@ -258,10 +258,10 @@ void amf_app_task(void*) {
last_delay_nudsf_size = delay_nudsf.size();
#endif
}break;
case TASK_AMF_APP_TIMEOUT_NRF_HEARTBEAT:
amf_app_inst->timer_nrf_heartbeat_timeout(
to->timer_id, to->arg2_user);
break;
// case TASK_AMF_APP_TIMEOUT_NRF_HEARTBEAT:
// amf_app_inst->timer_nrf_heartbeat_timeout(
// to->timer_id, to->arg2_user);
// break;
default:
Logger::amf_app().info(
"No handler for timer(%d) with arg1_user(%d) ", to->timer_id,
......@@ -283,7 +283,7 @@ long amf_app::generate_amf_ue_ngap_id() {
//tm* t_tm = localtime(&now_time);
//long current = t_tm->tm_mday*24*60*60 + t_tm->tm_hour*60*60 + t_tm->tm_min*60 + t_tm->tm_sec;
//long tmp = (rand()+current)%100000 + 1;
long tmp = __sync_fetch_and_add(&amf_cfg.amf_id_region, 1);
long tmp = __sync_fetch_and_add(&amf_cfg.amf_id_region, 1) + 1;
//srand(time(NULL));
//tmp = rand()%1000 + 1;
//return tmp & 0xffffffffff;
......
......@@ -320,7 +320,7 @@ int amf_config::load(const std::string& config_file) {
} catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1;
//return -1;
}
const Setting& new_if_cfg = amf_cfg[AMF_CONFIG_STRING_INTERFACES];
const Setting& nrf_cfg = new_if_cfg[AMF_CONFIG_STRING_NRF];
......@@ -329,39 +329,39 @@ int amf_config::load(const std::string& config_file) {
std::string nrf_api_version = {};
string address = {};
if (!use_fqdn_dns) {
nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_IPV4_ADDRESS, address);
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
if (!(nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_PORT, nrf_port))) {
Logger::amf_app().error(AMF_CONFIG_STRING_NRF_PORT "failed");
throw(AMF_CONFIG_STRING_NRF_PORT "failed");
}
nrf_addr.port = nrf_port;
if (!(nrf_cfg.lookupValue(
AMF_CONFIG_STRING_API_VERSION, nrf_api_version))) {
Logger::amf_app().error(AMF_CONFIG_STRING_API_VERSION "failed");
throw(AMF_CONFIG_STRING_API_VERSION "failed");
}
nrf_addr.api_version = nrf_api_version;
} else {
std::string nrf_fqdn = {};
nrf_cfg.lookupValue(AMF_CONFIG_STRING_FQDN_DNS, nrf_fqdn);
uint8_t addr_type = {};
//fqdn::resolve(nrf_fqdn, address, nrf_port, addr_type);
if (addr_type != 0) { // IPv6: TODO
throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
} else { // IPv4
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
nrf_addr.port = nrf_port;
nrf_addr.api_version = "v1"; // TODO: get API version
}
}
// if (!use_fqdn_dns) {
// nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_IPV4_ADDRESS, address);
// IPV4_STR_ADDR_TO_INADDR(
// util::trim(address).c_str(), nrf_ipv4_addr,
// "BAD IPv4 ADDRESS FORMAT FOR NRF !");
// nrf_addr.ipv4_addr = nrf_ipv4_addr;
// if (!(nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_PORT, nrf_port))) {
// Logger::amf_app().error(AMF_CONFIG_STRING_NRF_PORT "failed");
// throw(AMF_CONFIG_STRING_NRF_PORT "failed");
// }
// nrf_addr.port = nrf_port;
// if (!(nrf_cfg.lookupValue(
// AMF_CONFIG_STRING_API_VERSION, nrf_api_version))) {
// Logger::amf_app().error(AMF_CONFIG_STRING_API_VERSION "failed");
// throw(AMF_CONFIG_STRING_API_VERSION "failed");
// }
// nrf_addr.api_version = nrf_api_version;
// } else {
// std::string nrf_fqdn = {};
// nrf_cfg.lookupValue(AMF_CONFIG_STRING_FQDN_DNS, nrf_fqdn);
// uint8_t addr_type = {};
// //fqdn::resolve(nrf_fqdn, address, nrf_port, addr_type);
// if (addr_type != 0) { // IPv6: TODO
// throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
// } else { // IPv4
// IPV4_STR_ADDR_TO_INADDR(
// util::trim(address).c_str(), nrf_ipv4_addr,
// "BAD IPv4 ADDRESS FORMAT FOR NRF !");
// nrf_addr.ipv4_addr = nrf_ipv4_addr;
// nrf_addr.port = nrf_port;
// nrf_addr.api_version = "v1"; // TODO: get API version
// }
// }
try {
const Setting& nas = amf_cfg[AMF_CONFIG_STRING_NAS];
......
......@@ -212,6 +212,7 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer &itti_msg) {
i->get_msg_name());
}
} else { // PDU SESSION RESOURCE SETUP_REQUEST
Logger::amf_n1().debug("trigger pdu session resource setup req");
itti_pdu_session_resource_setup_request *psrsr =
new itti_pdu_session_resource_setup_request(TASK_AMF_N1, TASK_AMF_N2);
psrsr->nas = protected_nas;
......
This diff is collapsed.
This diff is collapsed.
......@@ -51,6 +51,7 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_new_sctp_association& new_assoc);
void handle_itti_message(itti_ng_setup_request& ngsetupreq);
void handle_itti_message(itti_initial_ue_message& init_ue_msg);
void handle_itti_message(itti_path_switch_request& path_switch_request);
void handle_itti_message(itti_ul_nas_transport& ul_nas_transport);
void handle_itti_message(itti_dl_nas_transport& dl_nas_transport);
void handle_itti_message(itti_initial_context_setup_request& itti_msg);
......@@ -64,6 +65,7 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_handover_notify& itti_msg);
void handle_itti_message(itti_uplinkranstatsutransfer& itti_msg);
void handle_itti_message(itti_paging& itti_msg);
void handle_itti_message(itti_path_switch_request_ack& itti_msg);
bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t> get_common_plmn(
......
......@@ -62,6 +62,8 @@ typedef enum {
NEW_SCTP_ASSOCIATION,
NG_SETUP_REQ,
INITIAL_UE_MSG,
PATH_SWITCH_REQUEST,
PATH_SWITCH_REQ_ACK,
ITTI_UL_NAS_TRANSPORT,
ITTI_DL_NAS_TRANSPORT,
INITIAL_CONTEXT_SETUP_REQUEST,
......
......@@ -13,6 +13,7 @@
#include "HandoverRequiredMsg.hpp"
#include "HandoverNotifyMsg.hpp"
#include "UplinkRANStatusTransfer.hpp"
#include "PathSwitchRequest.hpp"
using namespace ngap;
using namespace sctp;
......@@ -46,6 +47,21 @@ class itti_ng_setup_request : public itti_msg_n2 {
NGSetupRequestMsg* ngSetupReq;
};
class itti_path_switch_request : public itti_msg_n2 {
public:
itti_path_switch_request(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(PATH_SWITCH_REQUEST, origin, destination) {}
itti_path_switch_request(const itti_path_switch_request& i) : itti_msg_n2(i) {
is_pdu_exist = false;
isn2sm_avaliable = false;
}
PathSwitchRequestMsg* pathSwitchRequestMsg;
bstring n2sm;
bool is_pdu_exist; //true is no pdu context
bool isn2sm_avaliable;
};
class itti_initial_ue_message : public itti_msg_n2 {
public:
itti_initial_ue_message(const task_id_t origin, const task_id_t destination)
......@@ -211,4 +227,23 @@ class itti_uplinkranstatsutransfer : public itti_msg_n2 {
UplinkRANStatusTransfer* uplinkrantransfer;
};
class itti_path_switch_request_ack : public itti_msg_n2 {
public:
itti_path_switch_request_ack(
const task_id_t origin, const task_id_t destination)
: itti_msg_n2(PATH_SWITCH_REQ_ACK, origin, destination) {}
itti_path_switch_request_ack(
const itti_path_switch_request_ack& i)
: itti_msg_n2(i) {}
std::string supi;
bstring n1sm;
bstring n2sm;
bool is_n2sm_set;
bool is_n1sm_set;
uint8_t pdu_session_id;
std::string n2sm_info_type;
// other parameters
};
#endif
......@@ -93,6 +93,16 @@ typedef struct {
std::string sd;
} S_Nssai;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pathSwitchRequestTransfer;
} PduSessionResourceToBeSwitchedDLItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pathSwitchRequestAcknowledgeTransfer;
} PduSessionResourceSwitchedItem_t;
typedef struct {
uint8_t pduSessionId;
uint8_t* pduSessionNAS_PDU;
......
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#include "PDUSessionResourceSwitchedItem.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceSwitchedItem::PDUSessionResourceSwitchedItem() {
pDUSessionID = NULL;
}
//------------------------------------------------------------------------------
PDUSessionResourceSwitchedItem::~PDUSessionResourceSwitchedItem() {}
//------------------------------------------------------------------------------
void PDUSessionResourceSwitchedItem::setPDUSessionResourceSwitchedItem(
PDUSessionID* m_pDUSessionID,
OCTET_STRING_t m_pathSwitchRequestAcknowledgeTransfer) {
pDUSessionID = m_pDUSessionID;
pathSwitchRequestAcknowledgeTransfer =
m_pathSwitchRequestAcknowledgeTransfer;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceSwitchedItem::encode2PDUSessionResourceSwitchedItem(
Ngap_PDUSessionResourceSwitchedItem_t*
pduSessionResourceSwitchedItem) {
if (!pDUSessionID->encode2PDUSessionID(
pduSessionResourceSwitchedItem->pDUSessionID))
return false;
pduSessionResourceSwitchedItem->pathSwitchRequestAcknowledgeTransfer =
pathSwitchRequestAcknowledgeTransfer;
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceSwitchedItem::
decodefromPDUSessionResourceSwitchedItem(
Ngap_PDUSessionResourceSwitchedItem_t*
pduSessionResourceSwitchedItem) {
pDUSessionID = new PDUSessionID();
if (!pDUSessionID->decodefromPDUSessionID(
pduSessionResourceSwitchedItem->pDUSessionID))
return false;
pathSwitchRequestAcknowledgeTransfer =
pduSessionResourceSwitchedItem->pathSwitchRequestAcknowledgeTransfer;
return true;
}
//------------------------------------------------------------------------------
void PDUSessionResourceSwitchedItem::getPDUSessionResourceSwitchedItem(
PDUSessionID*& m_pDUSessionID,
OCTET_STRING_t& m_pathSwitchRequestAcknowledgeTransfer) {
m_pDUSessionID = pDUSessionID;
m_pathSwitchRequestAcknowledgeTransfer =
pathSwitchRequestAcknowledgeTransfer;
}
} // namespace ngap
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#ifndef _PDUSESSIONRESOURCESWITCHEDITEM_H_
#define _PDUSESSIONRESOURCESWITCHEDITEM_H_
#include "PDUSessionID.hpp"
//#include "pathSwitchRequestAcknowledgeTransfer.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceSwitchedItem.h"
}
namespace ngap {
class PDUSessionResourceSwitchedItem {
public:
PDUSessionResourceSwitchedItem();
virtual ~PDUSessionResourceSwitchedItem();
void setPDUSessionResourceSwitchedItem(
PDUSessionID* m_pDUSessionID,
OCTET_STRING_t m_pathSwitchRequestAcknowledgeTransfer);
void getPDUSessionResourceSwitchedItem(
PDUSessionID*& m_pDUSessionID,
OCTET_STRING_t& m_pathSwitchRequestAcknowledgeTransfer);
bool encode2PDUSessionResourceSwitchedItem(
Ngap_PDUSessionResourceSwitchedItem_t*
pduSessionResourceSwitchedItem);
bool decodefromPDUSessionResourceSwitchedItem(
Ngap_PDUSessionResourceSwitchedItem_t*
pduSessionResourceSwitchedItem);
private:
PDUSessionID* pDUSessionID;
OCTET_STRING_t pathSwitchRequestAcknowledgeTransfer;
};
} // namespace ngap
#endif
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#include "PDUSessionResourceSwitchedList.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceSwitchedList::PDUSessionResourceSwitchedList() {
pduSessionResourceSwitchedItem = NULL;
numofpduSessionResourceSwitchedItem = 0;
}
//------------------------------------------------------------------------------
PDUSessionResourceSwitchedList::~PDUSessionResourceSwitchedList() {}
//------------------------------------------------------------------------------
void PDUSessionResourceSwitchedList::setPDUSessionResourceSwitchedList(
PDUSessionResourceSwitchedItem* m_pduSessionResourceSwitchedItem,
int num) {
pduSessionResourceSwitchedItem = m_pduSessionResourceSwitchedItem;
numofpduSessionResourceSwitchedItem = num;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceSwitchedList::encode2PDUSessionResourceSwitchedList(
Ngap_PDUSessionResourceSwitchedList_t*
pduSessionResourceSwitchedList) {
for (int i = 0; i < numofpduSessionResourceSwitchedItem; i++) {
Ngap_PDUSessionResourceSwitchedItem_t* request =
(Ngap_PDUSessionResourceSwitchedItem_t*)calloc(
1, sizeof(Ngap_PDUSessionResourceSwitchedItem_t));
if (!request) return false;
if (!pduSessionResourceSwitchedItem[i]
.encode2PDUSessionResourceSwitchedItem(request))
return false;
if (ASN_SEQUENCE_ADD(&pduSessionResourceSwitchedList->list, request) != 0)
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceSwitchedList::
decodefromPDUSessionResourceSwitchedList(
Ngap_PDUSessionResourceSwitchedList_t*
pduSessionResourceSwitchedList) {
numofpduSessionResourceSwitchedItem =
pduSessionResourceSwitchedList->list.count;
pduSessionResourceSwitchedItem = new PDUSessionResourceSwitchedItem
[numofpduSessionResourceSwitchedItem]();
for (int i = 0; i < numofpduSessionResourceSwitchedItem; i++) {
if (!pduSessionResourceSwitchedItem[i]
.decodefromPDUSessionResourceSwitchedItem(
pduSessionResourceSwitchedList->list.array[i]))
return false;
}
return true;
}
//------------------------------------------------------------------------------
void PDUSessionResourceSwitchedList::getPDUSessionResourceSwitchedList(
PDUSessionResourceSwitchedItem*& m_pduSessionResourceSwitchedItem,
int& num) {
m_pduSessionResourceSwitchedItem = pduSessionResourceSwitchedItem;
num = numofpduSessionResourceSwitchedItem;
}
} // namespace ngap
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#ifndef _PDUSESSIONRESOURCESWITCHEDLIST_H_
#define _PDUSESSIONRESOURCESWITCHEDLIST_H_
#include "PDUSessionResourceSwitchedItem.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceSwitchedList.h"
}
namespace ngap {
class PDUSessionResourceSwitchedList {
public:
PDUSessionResourceSwitchedList();
virtual ~PDUSessionResourceSwitchedList();
void setPDUSessionResourceSwitchedList(
PDUSessionResourceSwitchedItem* m_pduSessionResourceSwitchedItem,
int num);
void getPDUSessionResourceSwitchedList(
PDUSessionResourceSwitchedItem*& m_pduSessionResourceSwitchedItem,
int& num);
bool encode2PDUSessionResourceSwitchedList(
Ngap_PDUSessionResourceSwitchedList_t*
pduSessionResourceSwitchedList);
bool decodefromPDUSessionResourceSwitchedList(
Ngap_PDUSessionResourceSwitchedList_t*
pduSessionResourceSwitchedList);
private:
PDUSessionResourceSwitchedItem* pduSessionResourceSwitchedItem;
int numofpduSessionResourceSwitchedItem;
};
} // namespace ngap
#endif
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#include "PDUSessionResourceToBeSwitchedDLItem.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceToBeSwitchedDLItem::PDUSessionResourceToBeSwitchedDLItem() {
pDUSessionID = NULL;
}
//------------------------------------------------------------------------------
PDUSessionResourceToBeSwitchedDLItem::~PDUSessionResourceToBeSwitchedDLItem() {}
//------------------------------------------------------------------------------
void PDUSessionResourceToBeSwitchedDLItem::setPDUSessionResourceToBeSwitchedDLItem(
PDUSessionID* m_pDUSessionID,
OCTET_STRING_t m_pathSwitchRequestTransfer) {
pDUSessionID = m_pDUSessionID;
pathSwitchRequestTransfer =
m_pathSwitchRequestTransfer;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToBeSwitchedDLItem::encode2PDUSessionResourceToBeSwitchedDLItem(
Ngap_PDUSessionResourceToBeSwitchedDLItem_t* pduSessionResourceToBeSwitchedDLItem) {
if (!pDUSessionID->encode2PDUSessionID(
pduSessionResourceToBeSwitchedDLItem->pDUSessionID))
return false;
pduSessionResourceToBeSwitchedDLItem->pathSwitchRequestTransfer =
pathSwitchRequestTransfer;
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToBeSwitchedDLItem::
decodefromPDUSessionResourceToBeSwitchedDLItem(
Ngap_PDUSessionResourceToBeSwitchedDLItem_t*
pduSessionResourceToBeSwitchedDLItem) {
pDUSessionID = new PDUSessionID();
if (!pDUSessionID->decodefromPDUSessionID(
pduSessionResourceToBeSwitchedDLItem->pDUSessionID))
return false;
pathSwitchRequestTransfer =
pduSessionResourceToBeSwitchedDLItem->pathSwitchRequestTransfer;
return true;
}
//------------------------------------------------------------------------------
void PDUSessionResourceToBeSwitchedDLItem::getPDUSessionResourceToBeSwitchedDLItem(
PDUSessionID*& m_pDUSessionID,
OCTET_STRING_t& m_pathSwitchRequestTransfer) {
m_pDUSessionID = pDUSessionID;
m_pathSwitchRequestTransfer =
pathSwitchRequestTransfer;
}
} // namespace ngap
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#ifndef _PDUSESSIONRESOURCETOBESWITCHEDDLITEM_H_
#define _PDUSESSIONRESOURCETOBESWITCHEDDLITEM_H_
#include "PDUSessionID.hpp"
//#include "PathSwitchRequestTransfer.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceToBeSwitchedDLItem.h"
}
namespace ngap {
class PDUSessionResourceToBeSwitchedDLItem {
public:
PDUSessionResourceToBeSwitchedDLItem();
virtual ~PDUSessionResourceToBeSwitchedDLItem();
void setPDUSessionResourceToBeSwitchedDLItem(
PDUSessionID* m_pDUSessionID,
OCTET_STRING_t m_pathSwitchRequestTransfer);
void getPDUSessionResourceToBeSwitchedDLItem(
PDUSessionID*& m_pDUSessionID,
OCTET_STRING_t& m_pathSwitchRequestTransfer);
bool encode2PDUSessionResourceToBeSwitchedDLItem(
Ngap_PDUSessionResourceToBeSwitchedDLItem_t*
pduSessionResourceToBeSwitchedDLItem);
bool decodefromPDUSessionResourceToBeSwitchedDLItem(
Ngap_PDUSessionResourceToBeSwitchedDLItem_t*
pduSessionResourceToBeSwitchedDLItem);
private:
PDUSessionID* pDUSessionID;
OCTET_STRING_t pathSwitchRequestTransfer;
};
} // namespace ngap
#endif
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#include "PDUSessionResourceToBeSwitchedDLList.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceToBeSwitchedDLList::PDUSessionResourceToBeSwitchedDLList() {
pduSessionResourceToBeSwitchedDLItem = NULL;
numofpduSessionResourceToBeSwitchedDLItem = 0;
}
//------------------------------------------------------------------------------
PDUSessionResourceToBeSwitchedDLList::~PDUSessionResourceToBeSwitchedDLList() {}
//------------------------------------------------------------------------------
void PDUSessionResourceToBeSwitchedDLList::setPDUSessionResourceToBeSwitchedDLList(
PDUSessionResourceToBeSwitchedDLItem* m_pduSessionResourceToBeSwitchedDLItem,
int num) {
pduSessionResourceToBeSwitchedDLItem = m_pduSessionResourceToBeSwitchedDLItem;
numofpduSessionResourceToBeSwitchedDLItem = num;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToBeSwitchedDLList::encode2PDUSessionResourceToBeSwitchedDLList(
Ngap_PDUSessionResourceToBeSwitchedDLList_t*
pduSessionResourceToBeSwitchedDLList) {
for (int i = 0; i < numofpduSessionResourceToBeSwitchedDLItem; i++) {
cout << "encoding items" << endl;
Ngap_PDUSessionResourceToBeSwitchedDLItem_t* request =
(Ngap_PDUSessionResourceToBeSwitchedDLItem_t*)calloc(
1, sizeof(Ngap_PDUSessionResourceToBeSwitchedDLItem_t));
if (!request) return false;
if (!pduSessionResourceToBeSwitchedDLItem[i]
.encode2PDUSessionResourceToBeSwitchedDLItem(request))
return false;
if (ASN_SEQUENCE_ADD(&pduSessionResourceToBeSwitchedDLList->list, request) != 0)
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToBeSwitchedDLList::
decodefromPDUSessionResourceToBeSwitchedDLList(
Ngap_PDUSessionResourceToBeSwitchedDLList_t*
pduSessionResourceToBeSwitchedDLList) {
numofpduSessionResourceToBeSwitchedDLItem =
pduSessionResourceToBeSwitchedDLList->list.count;
pduSessionResourceToBeSwitchedDLItem = new PDUSessionResourceToBeSwitchedDLItem
[numofpduSessionResourceToBeSwitchedDLItem]();
for (int i = 0; i < numofpduSessionResourceToBeSwitchedDLItem; i++) {
if (!pduSessionResourceToBeSwitchedDLItem[i]
.decodefromPDUSessionResourceToBeSwitchedDLItem(
pduSessionResourceToBeSwitchedDLList->list.array[i]))
return false;
}
return true;
}
//------------------------------------------------------------------------------
void PDUSessionResourceToBeSwitchedDLList::getPDUSessionResourceToBeSwitchedDLList(
PDUSessionResourceToBeSwitchedDLItem*& m_pduSessionResourceToBeSwitchedDLItem,
int& num) {
m_pduSessionResourceToBeSwitchedDLItem = pduSessionResourceToBeSwitchedDLItem;
num = numofpduSessionResourceToBeSwitchedDLItem;
}
} // namespace ngap
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#ifndef _PDUSESSIONRESOURCETOBESWITCHEDDLLIST_H_
#define _PDUSESSIONRESOURCETOBESWITCHEDDLLIST_H_
#include "PDUSessionResourceToBeSwitchedDLItem.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceToBeSwitchedDLList.h"
}
namespace ngap {
class PDUSessionResourceToBeSwitchedDLList {
public:
PDUSessionResourceToBeSwitchedDLList();
virtual ~PDUSessionResourceToBeSwitchedDLList();
void setPDUSessionResourceToBeSwitchedDLList(
PDUSessionResourceToBeSwitchedDLItem* m_pduSessionResourceToBeSwitchedDLItem,
int num);
void getPDUSessionResourceToBeSwitchedDLList(
PDUSessionResourceToBeSwitchedDLItem*& m_pduSessionResourceToBeSwitchedDLItem,
int& num);
bool encode2PDUSessionResourceToBeSwitchedDLList(
Ngap_PDUSessionResourceToBeSwitchedDLList_t*
pduSessionResourceToBeSwitchedDLList);
bool decodefromPDUSessionResourceToBeSwitchedDLList(
Ngap_PDUSessionResourceToBeSwitchedDLList_t*
pduSessionResourceToBeSwitchedDLList);
private:
PDUSessionResourceToBeSwitchedDLItem* pduSessionResourceToBeSwitchedDLItem;
int numofpduSessionResourceToBeSwitchedDLItem;
};
} // namespace ngap
#endif
This diff is collapsed.
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#ifndef _PATHSWITCHREQUEST_H_
#define _PATHSWITCHREQUEST_H_
#include "NgapIEsStruct.hpp"
#include "MessageType.hpp"
#include "RAN-UE-NGAP-ID.hpp"
//TODO:SourceAMF-UE-NGAP-IN.hpp
//SourceeAMF-UE-NGAP-ID 与 AMF-UE-NGAP-ID 可以理解为类似,都表示amf 给ue 分配的一个标识。
//但是具体不同,因为后面一个是100,一个是10
//暂时不考虑差别,之后注意纠正
#include "AMF-UE-NGAP-ID.hpp"
#include "UserLocationInformation.hpp"
#include "UESecurityCapabilities.hpp"
#include "PDUSessionResourceToBeSwitchedDLList.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_PathSwitchRequest.h"
}
namespace ngap {
class PathSwitchRequestMsg{
public:
PathSwitchRequestMsg();
virtual ~PathSwitchRequestMsg();
void setMessageType();
void setRanUENgapID(uint32_t ran_ue_ngap_id);
//TODO:AMF的标识不同!
void setAmfUeNgapID(unsigned long id);
void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai);
void setUESecurityCapability(
uint16_t NR_EncryptionAlgs, uint16_t NR_IntegrityProtectionAlgs,
uint16_t E_UTRA_EncryptionAlgs, uint16_t E_UTRA_IntegrityProtectionAlgs);
//相关文件也进行过修改!
void setPduSessionResourceToBeSwitchedDLList(
std::vector<PduSessionResourceToBeSwitchedDLItem_t> list);
int encode2buffer(uint8_t* buf, int buf_size);
// Decapsulation
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
uint32_t getRanUENgapID();
unsigned long getAmfUeNgapID();
bool getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai);
bool getUESecurityCapability(
uint16_t& NR_EncryptionAlgs, uint16_t& NR_IntegrityProtectionAlgs,
uint16_t& E_UTRA_EncryptionAlgs,
uint16_t& E_UTRA_IntegrityProtectionAlgs);
bool getPduSessionResourceToBeSwitchedDLList(
std::vector<PduSessionResourceToBeSwitchedDLItem_t>& list);
private:
Ngap_NGAP_PDU_t* pathSwitchRequestPdu;
Ngap_PathSwitchRequest_t* pathSwitchRequestIEs;
RAN_UE_NGAP_ID* ranUeNgapId;
AMF_UE_NGAP_ID* amfUeNgapId;
UserLocationInformation* userLocationInformation;
UESecurityCapabilities* uESecurityCapabilities;
PDUSessionResourceToBeSwitchedDLList* pduSessionResourceToBeSwitchedDLList;
};
}
//namespace ngap
#endif
This diff is collapsed.
/*
* Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
* Software Alliance under one or more contributor license agreements. The
* initial OpenXG series projects are derided from OAI projects, the files from
* OAI projects are all in compliance with OAI Public License, Version 1.1.
* codes and files developed from OpenXG projects and from OS-RAN Alliance
* are all under OS-RAN licenses; you may not use this file except in compliance
* with the license. You may get a copy of the license at:
* http://www.openxg.org.cn/?falu_69.html
* For more information about OpenXG, please contact:
* contact@openxg.org.cn
*/
#ifndef _PATHSWITCHREQUESTACKNOWLEDGE_H_
#define _PATHSWITCHREQUESTACKNOWLEDGE_H_
#include "NgapIEsStruct.hpp"
#include "MessageType.hpp"
#include "AMF-UE-NGAP-ID.hpp"
#include "RAN-UE-NGAP-ID.hpp"
#include "UESecurityCapabilities.hpp"
#include "SecurityKey.hpp"
#include "PDUSessionResourceSwitchedList.hpp"
#include "AllowedNssai.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_PathSwitchRequestAcknowledge.h"
}
namespace ngap {
class PathSwitchRequestAcknowledgeMsg {
public:
PathSwitchRequestAcknowledgeMsg();
virtual ~PathSwitchRequestAcknowledgeMsg();
void setMessageType();
void setAmfUeNgapID(unsigned long id);
void setRanUENgapID(uint32_t ran_ue_ngap_id);
void setUESecurityCapability(
uint16_t NR_EncryptionAlgs, uint16_t NR_IntegrityProtectionAlgs,
uint16_t E_UTRA_EncryptionAlgs, uint16_t E_UTRA_IntegrityProtectionAlgs);
void setSecurityContext(long count, uint8_t* buffer);
void setPduSessionResourceSwitchedList(
std::vector<PduSessionResourceSwitchedItem_t> list);
void setAllowedNssai(std::vector<S_Nssai> list);
int encode2buffer(uint8_t* buf, int buf_size);
// Decapsulation
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapID();
uint32_t getRanUENgapID();
bool getUESecurityCapability(
uint16_t& NR_EncryptionAlgs, uint16_t& NR_IntegrityProtectionAlgs,
uint16_t& E_UTRA_EncryptionAlgs,
uint16_t& E_UTRA_IntegrityProtectionAlgs);
// ? bool getSecurityContext(long count, uint8_t* buffer);
bool getPduSessionResourceSwitchedList(
std::vector<PduSessionResourceSwitchedItem_t>& list);
bool getAllowedNssai(std::vector<S_Nssai>& list);
private:
Ngap_NGAP_PDU_t* pathSwitchRequestAcknowledgePdu;
Ngap_PathSwitchRequestAcknowledge_t* pathSwitchRequestAcknowledgeIEs;
AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId;
UESecurityCapabilities* uESecurityCapabilities;
Ngap_SecurityContext_t* securityContext;
PDUSessionResourceSwitchedList* pduSessionResourceSwitchedList;
AllowedNSSAI* allowedNssai;
};
} //namespace ngap
#endif
......@@ -31,6 +31,23 @@
#include "logger.hpp"
#include "amf_module_from_config.hpp"
#include "ngap_message_callback.hpp"
#include "logger.hpp"
#include <nlohmann/json.hpp>
#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include "amf_n11.hpp"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <signal.h>
#include<iostream>
extern "C" {
#include "Ngap_NGAP-PDU.h"
......@@ -52,16 +69,87 @@ ngap_app::ngap_app(const std::string& address, const uint16_t port_num)
//------------------------------------------------------------------------------
ngap_app::~ngap_app() {}
int clientSocket;
void hand(int val){
//4. 结束
close(clientSocket);
printf("bye bye!\n");
exit(0);
}
//------------------------------------------------------------------------------
// received sctp payload and decode it to NGAP message and send itti message to
// TASK_AMF_N2
void UdpSend(uint8_t buffer[],int n,string ip,int port){
//signal(SIGINT,hand);
struct timeval time;
//1. 创建socket 参数一: 协议类型(版本) 参数二: 通信媒介 参数三: 保护方式
clientSocket = socket(AF_INET,SOCK_DGRAM,0);
//2. 创建服务器协议地址簇
struct sockaddr_in cAddr = {0};
const char* ipAddr = ip.c_str();
cAddr.sin_family = AF_INET; //协议类型 和socket函数第一个参数一致
cAddr.sin_addr.s_addr = inet_addr(ipAddr); //将字符串转整数
cAddr.sin_port = htons(port); //整数转整数 小端转大端
//3.通信
char temp[256];
int r;
int len = sizeof cAddr;
int sendNum;
sendNum = sendto(clientSocket,buffer,n,0,
(struct sockaddr*)&cAddr,len);
close(clientSocket);
gettimeofday(&time, NULL);
Logger::ngap().info("udpsend complete, ms: %ld\n", (time.tv_sec*1000 + time.tv_usec/1000));
// //收消息
// r = recvfrom(clientSocket,temp,255,0,
// (struct sockaddr*)&cAddr,&len);
// if(r > 0){
// temp[r] = 0;
// printf("服务器发来信息>> %s\n",temp);
// }
}
// void SplitString(string s, vector<string>& v, string c)
// {
// string::size_type pos1, pos2;
// pos2 = s.find(c);
// pos1 = 0;
// while(string::npos != pos2)
// {
// v.push_back(s.substr(pos1, pos2-pos1));
// pos1 = pos2 + c.size();
// pos2 = s.find(c, pos1);
// }
// if(pos1 != s.length())
// v.push_back(s.substr(pos1));
// }
int serverSocket;
//------------------------------------------------------------------------------
// received sctp payload and decode it to NGAP message and send itti message to
// TASK_AMF_N2
void ngap_app::handle_receive(
bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream,
sctp_stream_id_t instreams, sctp_stream_id_t outstreams) {
sctp_stream_id_t instreams, sctp_stream_id_t outstreams, uint8_t buffer[], int n) {
Logger::ngap().debug(
"Handling SCTP payload from sctp_server on assoc_id (%d), stream_id "
"(%d), instreams (%d), outstreams (%d)",
assoc_id, stream, instreams, outstreams);
bool priority = false;
struct timeval time;
gettimeofday(&time, NULL);
Logger::ngap().info("handreceive start, ms: %ld\n", (time.tv_sec*1000 + time.tv_usec/1000));
Logger::ngap().debug(
"Handling SCTP payload from SCTP Server on assoc_id (%d), stream_id "
"(%d), instreams (%d), outstreams (%d)",
assoc_id, stream, instreams, outstreams);
Ngap_NGAP_PDU_t* ngap_msg_pdu =
(Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
asn_dec_rval_t rc = asn_decode(
......@@ -71,12 +159,46 @@ void ngap_app::handle_receive(
"Decoded NGAP message, procedure code %d, present %d",
ngap_msg_pdu->choice.initiatingMessage->procedureCode,
ngap_msg_pdu->present);
printf("after decoding ...\n");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, ngap_msg_pdu);
printf("end decoding ...\n");
//if handover send it to other amf
if(ngap_msg_pdu->choice.initiatingMessage->procedureCode != 25 && priority == true
&& ngap_msg_pdu->choice.initiatingMessage->procedureCode != 21)
{
gettimeofday(&time, NULL);
Logger::ngap().info("ngap decode end, ms: %ld", (time.tv_sec*1000 + time.tv_usec/1000));
Logger::ngap().info("starting udp send");
Logger::ngap().debug("assoc_id = %d",assoc_id);
for(int i = 0; i < n; i++)
{
std::stringstream data;
data << std::hex << (int)buffer[i];
std::cout << data.str();
}
std::cout<<std::endl;
buffer[n] = assoc_id;
buffer[n+1] = stream;
for(int i = 0; i < n+2; i++)
{
std::stringstream data;
data << std::hex << (int)buffer[i];
std::cout << data.str();
}
std::cout<<std::endl;
// std::string ngapmsg;
// octet_stream_2_hex_stream2((uint8_t*) bdata(payload), blength(payload), ngapmsg);
//curl_http_another_amf(assoc_id,stream,ngapmsg);
UdpSend(buffer,n+2,"10.103.238.72",9000);
}
else{
//Handle the message
(*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode]
[ngap_msg_pdu->present - 1])(
assoc_id, stream, ngap_msg_pdu);
}
}
//------------------------------------------------------------------------------
......
......@@ -51,7 +51,7 @@ class ngap_app : public sctp_application {
void handle_receive(
bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream,
sctp_stream_id_t instreams, sctp_stream_id_t outstreams);
sctp_stream_id_t instreams, sctp_stream_id_t outstreams,uint8_t buffer[],int n);
void handle_sctp_new_association(
sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams,
sctp_stream_id_t outstreams);
......
......@@ -45,6 +45,7 @@
#include "pdu_session_context.hpp"
#include "nas_context.hpp"
#include "amf_n2.hpp"
#include "PathSwitchRequest.hpp"
using namespace sctp;
using namespace ngap;
using namespace amf_application;
......@@ -702,6 +703,29 @@ int ngap_amf_handle_path_switch_request(
struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug(
"sending itti ngap amf handle path switch request to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
PathSwitchRequestMsg* pathSwitchRequestMsg = new PathSwitchRequestMsg();
if (!pathSwitchRequestMsg->decodefrompdu(message_p)) {
Logger::ngap().error("decoding pathSwitchRequest message error");
return -1;
}
itti_path_switch_request* path_switch_request =
new itti_path_switch_request(TASK_NGAP, TASK_AMF_N2);
path_switch_request->assoc_id = assoc_id;
Logger::ngap().debug(
"Test path_switch_request assoc_id: assoc_id (%d),path_switch_request->assoc_id(%d)",assoc_id,path_switch_request->assoc_id);
path_switch_request->stream = stream;
path_switch_request->pathSwitchRequestMsg = pathSwitchRequestMsg;
std::shared_ptr<itti_path_switch_request> i =
std::shared_ptr<itti_path_switch_request>(path_switch_request);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
return 0;
}
......
#include "ngap_app.hpp"
#include "logger.hpp"
#include <nlohmann/json.hpp>
#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include "amf_n11.hpp"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <signal.h>
#include <iostream>
#include "udp.hpp"
#include <thread>
#include "bstrlib.h"
#include "sstream"
extern "C" {
#include "Ngap_InitiatingMessage.h"
#include "Ngap_NGAP-PDU.h"
}
using namespace std;
udp_server::udp_server(const char* udp_address,uint16_t udp_port_num){
cout<<"start create socket"<<endl;
create_socket(udp_address,udp_port_num);
cout<<"start receive"<<endl;
start_receive(udp_);
}
udp_server::~udp_server(){}
int udp_server::create_socket(const char* udp_address,uint16_t udp_port_num){
//1. 创建socket 参数一: 协议类型(版本) 参数二: 通信媒介 参数三: 保护方式
cout<<"start"<<endl;
serverSocket = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if(-1 == serverSocket) printf("创建socket失败:%m\n"),exit(-1);
printf("创建socket成功!\n");
//2. 创建服务器协议地址簇
struct sockaddr_in sAddr = {0};
//uint16_t port = 8000;
//const char* ip_address= "10.103.239.24";
sAddr.sin_family = AF_INET; //协议类型 和socket函数第一个参数一致
sAddr.sin_addr.s_addr = inet_addr(udp_address); //将字符串转整数
sAddr.sin_port = htons(udp_port_num); //整数转整数 小端转大端
//3.绑定
int r = bind(serverSocket,(struct sockaddr*)&sAddr,sizeof sAddr);
if(-1 == r) printf("绑定失败:%m\n"),close(serverSocket),exit(-2);
printf("绑定成功!\n");
return serverSocket;
// struct sockaddr_in addr = {};
// int sd = 0;
// /*
// * Create UDP socket
// */
// if ((sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
// /*
// * Socket creation has failed...
// */
// printf("Socket creation failed (%s)\n", strerror(errno));
// return errno;
// }
// addr.sin_family = AF_INET;
// addr.sin_port = htons(udp_port_num);
// addr.sin_addr.s_addr = inet_addr(udp_address);
// std::string ipv4 = udp_address;
// printf(
// "Creating new listen socket on address %s and port %" PRIu16 " ",
// ipv4.c_str(), udp_port_num);
// if (bind(sd, (struct sockaddr*) &addr, sizeof(struct sockaddr_in)) < 0) {
// /*
// * Bind failed
// */
// printf(
// "Socket bind failed (%s) for address %s and port %" PRIu16 " \n",
// strerror(errno), ipv4.c_str(), udp_port_num);
// close(sd);
// return errno;
// }
}
void udp_server::start_receive(udp_server* udp){
udp_ = udp;
//pthread_create(&udp_thread, NULL, udp_receiver_thread, (void*) this);
//pthread_exit(NULL);
thread_ = std::thread(&udp_server::udp_read_from_socket,this);
thread_.detach();
}
// void* udp_server::udp_receiver_thread(void* arg) {
// udp_server* ptr = (udp_server*) arg;
// //Logger::udp().info("Create pthread to receive udp message");
// ptr->udp_read_from_socket();
// }
int udp_server::getSocket(){
return serverSocket;
}
int udp_server::getPpid(){
return ppid;
}
int udp_server::udp_read_from_socket() {
//4.通信
uint8_t udp_recv[UDP_RECV_BUFFER_SIZE];
//bstring udp_recv;
//struct sockaddr_in cAddr = {0};
//socklen_t len = sizeof(cAddr);
endpoint r_endpoint = {};
//socklen_t addr_len;
int udp_len;
size_t bytes_received = 0;
cout<<"start receive"<<endl;
assoc_id = 0;
stream = 0;
struct timeval time;
while(1){
r_endpoint.addr_storage_len=sizeof(struct sockaddr_storage);
//如果还需要向客户端发送东西用recvfrom
//udp精髓 向一个协议地址簇发东西
//收消息
//r = recvfrom(serverSocket,udp_recv,udp_len,0,(struct sockaddr*)&cAddr,&len);
bytes_received = recvfrom(serverSocket, (void *)udp_recv, UDP_RECV_BUFFER_SIZE , 0, (struct sockaddr*)&r_endpoint.addr_storage, &r_endpoint.addr_storage_len);
//bytes_received = recvfrom(serverSocket, udp_recv, UDP_RECV_BUFFER_SIZE , 0, (struct sockaddr*)&r_endpoint.addr_storage, &r_endpoint.addr_storage_len);
if(bytes_received > 0){
printf("receive udp success\n");
gettimeofday(&time, NULL);
std::cout<<"receive from plugin, ms: "<<(time.tv_sec*1000 + time.tv_usec/1000)<<std::endl;
// cout<<"bytes"<<bytes_received<<endl;
// cout<<"content:"<<udp_recv<<endl;
// string udp_recv_str(&udp_recv[0],&udp_recv[strlen(udp_recv)]);
// cout<<"content:"<<udp_recv_str<<endl;
handle_receive_udp(bytes_received,udp_recv);
// assoc_id++;
// stream++;
//ngap_app("0",0).handle_receive(udp_recv_str,assoc_id,stream,0,0);
}
}
return 0;
}
vector<string> SplitString(string s, string c){
string::size_type pos1, pos2;
vector<string> v;
pos2 = s.find(c);
pos1 = 0;
while(string::npos != pos2)
{
v.push_back(s.substr(pos1, pos2-pos1));
pos1 = pos2 + c.size();
pos2 = s.find(c, pos1);
}
if(pos1 != s.length())
v.push_back(s.substr(pos1));
return v;
}
void udp_server::handle_receive_udp(int r,uint8_t udp_recv[]){
stringstream ngap_msg_stream;
sctp_stream_id_t stream;
sctp_assoc_id_t assoc_id;
vector<string> MsgVec;
uint8_t buffer[2048];
//拆分字符串分出连接号
// ngap_msg_stream<<udp_recv;
// ngap_msg_stream>>ngap_msg;
//MsgVec = SplitString(ngap_msg,"|");
//数组赋值
for(int i=0;i<r-2;i++){
buffer[i] = udp_recv[i];
}
int _assoc_id = udp_recv[r-2];
int _stream = udp_recv[r-1];
//打印buffer检查数据
// std::cout<<"buffer: ";
// for(int i = 0; i < r-2; i++)
// {
// std::stringstream data;
// data << std::hex << (int)buffer[i];
// std::cout << data.str();
// }
// std::cout<<std::endl;
assoc_id = _assoc_id;
bstring payload=blk2bstr(buffer,r-2);
// //bstring udp_recv_bstr=bfromcstr(content.c_str());
// cout<<"data:"<<payload->data<<endl;
// cout<<"slen"<<payload->slen<<endl;
// cout<<"mlen"<<payload->mlen<<endl;
cout<<"start handle"<<endl;
// ngap_app("0",0).handle_receive(payload,assoc_id,stream,0,0);
// Ngap_NGAP_PDU_t* ngap_msg_pdu =
// (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
// Logger::udp().info("start decode");
// asn_dec_rval_t rc = asn_decode(
// NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_NGAP_PDU,
// (void**) &ngap_msg_pdu, bdata(udp_recv_bstr), blength(udp_recv_bstr));
// Logger::udp().debug(
// "Decoded UDP message, procedure code %d, present %d",
// ngap_msg_pdu->choice.initiatingMessage->procedureCode,
// ngap_msg_pdu->present);
// asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, ngap_msg_pdu);
// (*messages_callback[ngap_msg_pdu->choice.initiatingMessage->procedureCode]
// [ngap_msg_pdu->present - 1])(
// assoc_id, stream, ngap_msg_pdu);
}
#ifndef __UDP_H
#define __UDP_H
#include "gNB_context.hpp"
#include "sctp_server.hpp"
#include <iostream>
#include <string>
#include <vector>
#include <thread>
#define UDP_RECV_BUFFER_SIZE 8192
using namespace std;
class udp_server{
private:
void* udp_recv;
struct sockaddr_in cAddr = {0};
socklen_t len = sizeof(cAddr);
int udp_len;
uint16_t m_port;
const char* m_address;
int serverSocket;
sctp_assoc_id_t assoc_id;
sctp_stream_id_t stream;
udp_server* udp_;
pthread_t udp_thread;
uint32_t ppid;
std::thread thread_;
public:
udp_server(const char* address,uint16_t port_num);
virtual ~udp_server();
int create_socket(const char* address,uint16_t port_num);
void start_receive(udp_server* udp);
void handle_receive();
static void* udp_receiver_thread(void* arg);
int udp_read_from_socket();
void handle_receive_udp(int r,uint8_t udp_recv[]);
int getSocket();
int getPpid();
//void SplitString(string s, vector<string>& v, string c);
};
#endif
\ No newline at end of file
......@@ -46,7 +46,7 @@
#include <string>
#include <cstring>
#include "normalizer.hh"
#include "udp.hpp"
using namespace std;
......@@ -103,7 +103,7 @@ int main(int argc, char** argv) {
amfApiServer.init(2);
std::thread amf_api_manager(&AMFApiServer::start, amfApiServer);
udp_server udp_("10.103.239.24",9000);
Logger::amf_app().debug("Initiating Done!");
pause();
......
......@@ -14,11 +14,12 @@
#include "IndividualSubscriptionDocumentApi.h"
#include "Helpers.h"
#include "TransData.hpp"
#include <sys/time.h>
namespace oai {
namespace amf {
namespace api {
struct timeval time;
using namespace org::openapitools::server::helpers;
using namespace oai::amf::model;
......@@ -62,6 +63,8 @@ void IndividualSubscriptionDocumentApi::gnb_message_from_plugin_handler(const Pi
//SubscriptionData subscriptionData;
TransData transdata;
std::cout<<request.body()<<std::endl;
gettimeofday(&time, NULL);
std::cout<<"receive from plugin, ms: "<<(time.tv_sec*1000 + time.tv_usec/1000)<<std::endl;
try {
nlohmann::json::parse(request.body()).get_to(transdata);
this->gnb_message_from_plugin(assoc_id, stream,transdata, response);
......
......@@ -43,7 +43,7 @@ class N1N2MessageCollectionDocumentApi {
virtual ~N1N2MessageCollectionDocumentApi() {}
void init();
const std::string base = "/namf-comm/v2";
const std::string base = "/namf-comm/v1";
private:
void setupRoutes();
......
......@@ -84,7 +84,7 @@ void IndividualSubscriptionDocumentApiImpl::gnb_message_from_plugin(const std::u
}else{
amf_n2_inst->handle_sctp_new_association(assoc_id,10,8);
}
amf_n2_inst->handle_receive(payload,assoc_id,stream,10,8);
amf_n2_inst->handle_receive(payload,assoc_id,stream,10,8,buffer,transdata.get_amf_data().length()/2+1);
response.send(Pistache::Http::Code::Ok, "plugin message\n");
//if (!amf_n2_inst->is_assoc_id_2_gnb_context(assoc_id)) {//to do - get context from udsf
......
......@@ -210,7 +210,7 @@ int sctp_server::sctp_read_from_socket(int sd, uint32_t ppid) {
// handle payload
app_->handle_receive(
payload, (sctp_assoc_id_t) sinfo.sinfo_assoc_id, sinfo.sinfo_stream,
association->instreams, association->outstreams);
association->instreams, association->outstreams,buffer,n);
}
}
......
......@@ -82,7 +82,7 @@ class sctp_application {
public:
virtual void handle_receive(
bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream,
sctp_stream_id_t instreams, sctp_stream_id_t outstreams) = 0;
sctp_stream_id_t instreams, sctp_stream_id_t outstreams,uint8_t buffer[],int n) = 0;
virtual void handle_sctp_new_association(
sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams,
sctp_stream_id_t outstreams) = 0;
......
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