diff --git a/.env b/.env index c91f298..a155c1a 100644 --- a/.env +++ b/.env @@ -98,3 +98,9 @@ BSF_IP=172.22.0.29 # ENTITLEMENT SERVER ENTITLEMENT_SERVER_IP=172.22.0.30 + +# OSMOMSC +OSMOMSC_IP=172.22.0.31 + +# OSMOHLR +OSMOHLR_IP=172.22.0.32 diff --git a/.gitignore b/.gitignore index 80dd262..83f5295 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ log/ +**/*.log +**/*.db +**/*.db-shm +**/*.db-wal diff --git a/docker-compose.yaml b/docker-compose.yaml index aecbaf3..6d15dd5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -333,6 +333,7 @@ services: - sgwu - smf - upf + - osmomsc container_name: mme env_file: - .env @@ -553,6 +554,43 @@ services: networks: default: ipv4_address: ${PCSCF_IP} + osmomsc: + build: ./osmomsc + image: docker_osmomsc + container_name: osmomsc + volumes: + - ./osmomsc:/mnt/osmomsc + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + env_file: + - .env + environment: + - COMPONENT_NAME=osmomsc-1 + depends_on: + - osmohlr + expose: + - "29118/sctp" + - "2775/tcp" + networks: + default: + ipv4_address: ${OSMOMSC_IP} + osmohlr: + build: ./osmohlr + image: docker_osmohlr + container_name: osmohlr + volumes: + - ./osmohlr:/mnt/osmohlr + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + env_file: + - .env + environment: + - COMPONENT_NAME=osmohlr-1 + expose: + - "4222/tcp" + networks: + default: + ipv4_address: ${OSMOHLR_IP} networks: default: ipam: diff --git a/mme/mme.yaml b/mme/mme.yaml index 57ecd19..1cfe94d 100644 --- a/mme/mme.yaml +++ b/mme/mme.yaml @@ -9,6 +9,19 @@ mme: dev: MME_IF gtpc: dev: MME_IF + sgsap: + addr: OSMOMSC_IP + map: + tai: + plmn_id: + mcc: MCC + mnc: MNC + tac: 1 + lai: + plmn_id: + mcc: MCC + mnc: MNC + lac: 1 gummei: plmn_id: mcc: MCC diff --git a/mme/mme_init.sh b/mme/mme_init.sh index cfb51ce..244cf29 100755 --- a/mme/mme_init.sh +++ b/mme/mme_init.sh @@ -39,6 +39,7 @@ sed -i 's|MNC|'$MNC'|g' install/etc/open5gs/mme.yaml sed -i 's|MCC|'$MCC'|g' install/etc/open5gs/mme.yaml sed -i 's|MME_IP|'$MME_IP'|g' install/etc/open5gs/mme.yaml sed -i 's|MME_IF|'$IF_NAME'|g' install/etc/open5gs/mme.yaml +sed -i 's|OSMOMSC_IP|'$OSMOMSC_IP'|g' install/etc/open5gs/mme.yaml sed -i 's|SGWC_IP|'$SGWC_IP'|g' install/etc/open5gs/mme.yaml sed -i 's|SMF_IP|'$SMF_IP'|g' install/etc/open5gs/mme.yaml sed -i 's|MME_IP|'$MME_IP'|g' install/etc/freeDiameter/mme.conf diff --git a/osmohlr/Dockerfile b/osmohlr/Dockerfile new file mode 100644 index 0000000..4e2ced6 --- /dev/null +++ b/osmohlr/Dockerfile @@ -0,0 +1,41 @@ +# BSD 2-Clause License + +# Copyright (c) 2020, Supreeth Herle +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +FROM ubuntu:focal + +ENV DEBIAN_FRONTEND=noninteractive + +# Install updates and dependencies +RUN apt-get update && \ + apt-get -y install wget gnupg telnet + +RUN wget https://download.opensuse.org/repositories/network:/osmocom:/latest/xUbuntu_20.04/Release.key && \ + apt-key add Release.key && \ + echo "deb https://download.opensuse.org/repositories/network:/osmocom:/latest/xUbuntu_20.04/ ./" > /etc/apt/sources.list.d/osmocom-latest.list && \ + apt-get update && apt-get -y install osmo-hlr + +CMD /mnt/osmohlr/osmohlr_init.sh && \ + cd /mnt/osmohlr && /bin/osmo-hlr -c /etc/osmocom/osmo-hlr.cfg diff --git a/osmohlr/osmo-hlr.cfg b/osmohlr/osmo-hlr.cfg new file mode 100644 index 0000000..d2599ac --- /dev/null +++ b/osmohlr/osmo-hlr.cfg @@ -0,0 +1,20 @@ +! +! OsmoHLR example configuration +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level all debug + logging level linp error +! +line vty + no login + bind 127.0.0.1 +ctrl + bind 127.0.0.1 +hlr + gsup + bind ip OSMOHLR_IP diff --git a/osmohlr/osmohlr_init.sh b/osmohlr/osmohlr_init.sh new file mode 100755 index 0000000..b66631a --- /dev/null +++ b/osmohlr/osmohlr_init.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# BSD 2-Clause License + +# Copyright (c) 2020, Supreeth Herle +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cp /mnt/osmohlr/osmo-hlr.cfg /etc/osmocom + +sed -i 's|OSMOHLR_IP|'$OSMOHLR_IP'|g' /etc/osmocom/osmo-hlr.cfg + +# Sync docker time +#ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone diff --git a/osmomsc/Dockerfile b/osmomsc/Dockerfile new file mode 100644 index 0000000..b51f9a6 --- /dev/null +++ b/osmomsc/Dockerfile @@ -0,0 +1,41 @@ +# BSD 2-Clause License + +# Copyright (c) 2020, Supreeth Herle +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +FROM ubuntu:focal + +ENV DEBIAN_FRONTEND=noninteractive + +# Install updates and dependencies +RUN apt-get update && \ + apt-get -y install wget gnupg telnet + +RUN wget https://download.opensuse.org/repositories/network:/osmocom:/latest/xUbuntu_20.04/Release.key && \ + apt-key add Release.key && \ + echo "deb https://download.opensuse.org/repositories/network:/osmocom:/latest/xUbuntu_20.04/ ./" > /etc/apt/sources.list.d/osmocom-latest.list && \ + apt-get update && apt-get -y install osmo-msc + +CMD /mnt/osmomsc/osmomsc_init.sh && \ + cd /mnt/osmomsc && /bin/osmo-msc -c /etc/osmocom/osmo-msc.cfg diff --git a/osmomsc/osmo-msc.cfg b/osmomsc/osmo-msc.cfg new file mode 100644 index 0000000..53bec99 --- /dev/null +++ b/osmomsc/osmo-msc.cfg @@ -0,0 +1,34 @@ +! +! OsmoMSC configuration saved from vty +! +line vty + no login + bind 127.0.0.1 +ctrl + bind 127.0.0.1 +! +network + network country code MCC + mobile network code MNC + short name OsmoMSC + long name OsmoMSC + encryption a5 0 + rrlp mode none + mm info 1 +msc + assign-tmsi + auth-tuple-max-reuse-count 3 + auth-tuple-reuse-on-error 1 +sgs + local-ip OSMOMSC_IP + local-port 29118 + vlr-name vlr.3GPP_REALM +hlr + ! IP address of the remote HLR: + remote-ip OSMOHLR_IP + ! default port is 4222, optionally configurable by: + remote-port 4222 +smpp + local-tcp-ip OSMOMSC_IP 2775 + policy accept-all + no smpp-first diff --git a/osmomsc/osmomsc_init.sh b/osmomsc/osmomsc_init.sh new file mode 100755 index 0000000..64cd237 --- /dev/null +++ b/osmomsc/osmomsc_init.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# BSD 2-Clause License + +# Copyright (c) 2020, Supreeth Herle +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +[ ${#MNC} == 3 ] && 3GPP_REALM="mnc${MNC}.mcc${MCC}.3gppnetwork.org" || 3GPP_REALM="mnc0${MNC}.mcc${MCC}.3gppnetwork.org" + +cp /mnt/osmomsc/osmo-msc.cfg /etc/osmocom + +sed -i 's|OSMOMSC_IP|'$OSMOMSC_IP'|g' /etc/osmocom/osmo-msc.cfg +sed -i 's|OSMOHLR_IP|'$OSMOHLR_IP'|g' /etc/osmocom/osmo-msc.cfg +sed -i 's|MNC|'$MNC'|g' /etc/osmocom/osmo-msc.cfg +sed -i 's|MCC|'$MCC'|g' /etc/osmocom/osmo-msc.cfg +sed -i 's|3GPP_REALM|'$3GPP_REALM'|g' /etc/osmocom/osmo-msc.cfg + +# Sync docker time +#ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone