├── .env ├── .gitignore ├── LICENSE ├── README.md ├── base └── Dockerfile ├── copy-env.sh ├── dns ├── Dockerfile ├── dns_init.sh └── dnsmasq.conf ├── docker-compose.yaml ├── fhoss ├── .gitignore ├── Dockerfile ├── config │ ├── DiameterPeerHSS.xml │ ├── c3p0.properties │ ├── configurator.sh │ ├── hibernate.properties │ ├── hss.properties │ └── log4j.properties ├── deploy │ ├── DiameterPeerHSS.xml │ ├── hibernate.properties │ └── webapps │ │ └── hss.web.console │ │ └── WEB-INF │ │ └── web.xml ├── download.sh ├── fhoss_init.sh ├── hss.sh ├── jdk-checksum └── scripts │ ├── configurator.sh │ ├── cpappend.cmd │ ├── dbdump.sh │ ├── hss_db.sql │ ├── hss_db_migrate_as_register.sql │ ├── hss_db_migrate_dsai.sql │ ├── startup.cmd │ ├── startup.sh │ └── userdata.sql ├── hss ├── Dockerfile ├── hss.yaml └── hss_init.sh ├── icscf ├── Dockerfile ├── default │ └── kamailio_icscf ├── icscf_init.sh ├── init.d │ └── kamailio_icscf └── kamailio_icscf │ ├── README.md │ ├── icscf.cfg │ ├── icscf.sql │ ├── icscf.xml │ └── kamailio_icscf.cfg ├── kamailio_base ├── Dockerfile ├── README.md └── modules.lst ├── log └── .keep ├── mme ├── Dockerfile ├── mme.yaml └── mme_init.sh ├── mongo ├── Dockerfile └── mongo_init.sh ├── mongodb └── .keep ├── mysql ├── Dockerfile ├── fhoss │ ├── hss_db.sql │ ├── init.sql │ └── userdata.sql ├── init.sql ├── init_mysql.sh └── mysqld.cnf ├── network-topology.dot ├── network-topology.png ├── pcrf ├── Dockerfile ├── pcrf.yaml └── pcrf_init.sh ├── pcscf ├── Dockerfile ├── default │ └── kamailio_pcscf ├── init.d │ └── kamailio_pcscf ├── kamailio_pcscf │ ├── README.md │ ├── dispatcher.list │ ├── kamailio_pcscf.cfg │ ├── pcscf.cfg │ ├── pcscf.xml │ ├── route │ │ ├── mo.cfg │ │ ├── mt.cfg │ │ ├── register.cfg │ │ ├── rtp.cfg │ │ ├── websocket.cfg │ │ └── xmlrpc.cfg │ ├── sems │ │ ├── etc │ │ │ ├── methodmap.conf │ │ │ ├── mo.sbcprofile.conf │ │ │ ├── monitoring.conf │ │ │ ├── mt.sbcprofile.conf │ │ │ ├── nocache.sbcprofile.conf │ │ │ ├── refuse.sbcprofile.conf │ │ │ ├── refuse_with_200.sbcprofile.conf │ │ │ ├── register.sbcprofile.conf │ │ │ ├── rurimap.conf │ │ │ ├── sbc.conf │ │ │ ├── stats.conf │ │ │ └── xmlrpc2di.conf │ │ └── sems.conf │ └── tls.cfg └── pcscf_init.sh ├── pgw ├── Dockerfile ├── pgw.yaml ├── pgw_init.sh └── tun_if.py ├── rtpengine ├── Dockerfile ├── rtpengine-recording.conf ├── rtpengine.conf └── rtpengine_init.sh ├── rtpproxy ├── Dockerfile └── rtpproxy ├── scscf ├── Dockerfile ├── default │ └── kamailio_scscf ├── init.d │ └── kamailio_scscf ├── kamailio_scscf │ ├── CxDataType_Rel6.xsd │ ├── CxDataType_Rel7.xsd │ ├── CxDataType_Rel8.xsd │ ├── README.md │ ├── dispatcher.list │ ├── kamailio_scscf.cfg │ ├── scscf.cfg │ └── scscf.xml └── scscf_init.sh ├── sgw ├── Dockerfile ├── sgw.yaml └── sgw_init.sh ├── srsenb.yaml ├── srslte ├── Dockerfile ├── conf │ ├── drb.conf │ ├── enb.conf │ ├── rr.conf │ └── sib.conf └── srsenb_init.sh └── test-dns.sh /.env: -------------------------------------------------------------------------------- 1 | SUBNET=172.18.0.0/24 2 | HSS_IP=172.18.0.2 3 | MME_IP=172.18.0.3 4 | SGW_IP=172.18.0.4 5 | PGW_IP=172.18.0.5 6 | PCRF_IP=172.18.0.6 7 | ENB_IP=172.18.0.7 8 | DNS_IP=172.18.0.10 9 | MONGO_IP=172.18.0.11 10 | PCSCF_IP=172.18.0.12 11 | ICSCF_IP=172.18.0.13 12 | SCSCF_IP=172.18.0.14 13 | FHOSS_IP=172.18.0.15 14 | MYSQL_IP=172.18.0.17 15 | RTPENGINE_IP=172.18.0.18 16 | DL_EARFCN=2525 17 | TX_GAIN=40 18 | RX_GAIN=40 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | log/ 2 | mongodb/ 3 | mysql_db/ 4 | */.env 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2019, Supreeth Herle 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /base/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM ubuntu:bionic 28 | 29 | # Install updates and dependencies 30 | RUN apt-get update && \ 31 | apt-get -y install python3-pip python3-setuptools python3-wheel ninja-build \ 32 | build-essential flex bison git libsctp-dev libgnutls28-dev \ 33 | libgcrypt-dev libssl-dev libidn11-dev libmongoc-dev libbson-dev \ 34 | libyaml-dev meson vim ifupdown mongodb curl gnupg gdb iptables net-tools \ 35 | iputils-ping 36 | RUN pip3 install click 37 | RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-get install -y nodejs && \ 38 | apt-get autoremove -y && apt-get clean 39 | 40 | # Get open5gs code and install 41 | RUN git clone --recursive https://github.com/open5gs/open5gs && cd open5gs && \ 42 | git checkout tags/v1.2.3 && meson build --prefix=`pwd`/install && \ 43 | ninja -C build && cd build && ninja install 44 | 45 | # Choose this one if you want to use Herle Supreeth's *no IPv6 hack* 46 | #RUN git clone --recursive https://github.com/herlesupreeth/open5gs && cd open5gs && \ 47 | # git checkout hacks && meson build --prefix=`pwd`/install && \ 48 | # ninja -C build && cd build && ninja install 49 | 50 | # Set the working directory to open5gs 51 | WORKDIR open5gs 52 | 53 | # Building WebUI of open5gs 54 | RUN cd webui && npm install 55 | -------------------------------------------------------------------------------- /copy-env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run this before you run a docker-compose build --no-cache 3 | # in order to generate files from .env 4 | 5 | cp -fv .env dns/ 6 | -------------------------------------------------------------------------------- /dns/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM docker_open5gs 28 | 29 | RUN apt-get install -y dnsmasq 30 | 31 | EXPOSE 53/udp 32 | 33 | CMD /mnt/dns/dns_init.sh 34 | -------------------------------------------------------------------------------- /dns/dns_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp /mnt/dns/dnsmasq.conf /etc/ 4 | set -a 5 | . /mnt/dns/.env 6 | set +a 7 | 8 | sed -i 's|HSS_IP|'$HSS_IP'|g' /etc/dnsmasq.conf 9 | sed -i 's|MME_IP|'$MME_IP'|g' /etc/dnsmasq.conf 10 | sed -i 's|SGW_IP|'$SGW_IP'|g' /etc/dnsmasq.conf 11 | sed -i 's|PGW_IP|'$PGW_IP'|g' /etc/dnsmasq.conf 12 | sed -i 's|PCRF_IP|'$PCRF_IP'|g' /etc/dnsmasq.conf 13 | sed -i 's|ENB_IP|'$ENB_IP'|g' /etc/dnsmasq.conf 14 | sed -i 's|DNS_IP|'$DNS_IP'|g' /etc/dnsmasq.conf 15 | sed -i 's|MONGO_IP|'$MONGO_IP'|g' /etc/dnsmasq.conf 16 | sed -i 's|PCSCF_IP|'$PCSCF_IP'|g' /etc/dnsmasq.conf 17 | sed -i 's|ICSCF_IP|'$ICSCF_IP'|g' /etc/dnsmasq.conf 18 | sed -i 's|SCSCF_IP|'$SCSCF_IP'|g' /etc/dnsmasq.conf 19 | sed -i 's|FHOSS_IP|'$FHOSS_IP'|g' /etc/dnsmasq.conf 20 | 21 | /usr/sbin/dnsmasq -d 22 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | dns: 4 | build: ./dns 5 | image: docker_open5gs_dns 6 | container_name: dns 7 | volumes: 8 | - ./dns:/mnt/dns 9 | expose: 10 | - "53/udp" 11 | networks: 12 | default: 13 | ipv4_address: ${DNS_IP} 14 | mongo: 15 | build: ./mongo 16 | image: docker_open5gs_mongo 17 | container_name: mongo 18 | volumes: 19 | - ./mongo:/mnt/mongo 20 | - ./mongodb:/var/lib/mongodb 21 | ports: 22 | - "27017:27017" 23 | networks: 24 | default: 25 | ipv4_address: ${MONGO_IP} 26 | hss: 27 | build: ./hss 28 | image: docker_open5gs_hss 29 | container_name: hss 30 | volumes: 31 | - ./hss:/mnt/hss 32 | - ./log:/open5gs/install/var/log/open5gs 33 | environment: 34 | - MONGO_IP=${MONGO_IP} 35 | - MME_IP=${MME_IP} 36 | - DB_URI=mongodb://${MONGO_IP}/open5gs 37 | depends_on: 38 | - dns 39 | - mongo 40 | dns: ${DNS_IP} 41 | ports: 42 | - "3000:3000" 43 | networks: 44 | default: 45 | ipv4_address: ${HSS_IP} 46 | sgw: 47 | build: ./sgw 48 | image: docker_open5gs_sgw 49 | container_name: sgw 50 | volumes: 51 | - ./sgw:/mnt/sgw 52 | - ./log:/open5gs/install/var/log/open5gs 53 | depends_on: 54 | - dns 55 | dns: ${DNS_IP} 56 | ports: 57 | - "2152:2152/udp" 58 | networks: 59 | default: 60 | ipv4_address: ${SGW_IP} 61 | pgw: 62 | build: ./pgw 63 | image: docker_open5gs_pgw 64 | container_name: pgw 65 | volumes: 66 | - ./pgw:/mnt/pgw 67 | - ./log:/open5gs/install/var/log/open5gs 68 | environment: 69 | - PCRF_IP=${PCRF_IP} 70 | - DNS_IP=${DNS_IP} 71 | - PCSCF_IP=${PCSCF_IP} 72 | depends_on: 73 | - dns 74 | dns: ${DNS_IP} 75 | cap_add: 76 | - NET_ADMIN 77 | devices: 78 | - "/dev/net/tun" 79 | sysctls: 80 | - net.ipv4.ip_forward=1 81 | networks: 82 | default: 83 | ipv4_address: ${PGW_IP} 84 | mme: 85 | build: ./mme 86 | image: docker_open5gs_mme 87 | depends_on: 88 | - hss 89 | - sgw 90 | - pgw 91 | container_name: mme 92 | volumes: 93 | - ./mme:/mnt/mme 94 | - ./log:/open5gs/install/var/log/open5gs 95 | depends_on: 96 | - dns 97 | dns: ${DNS_IP} 98 | # ports: 99 | # - "36412:36412/sctp" 100 | environment: 101 | - HSS_IP=${HSS_IP} 102 | - SGW_IP=${SGW_IP} 103 | - PGW_IP=${PGW_IP} 104 | networks: 105 | default: 106 | ipv4_address: ${MME_IP} 107 | pcrf: 108 | build: ./pcrf 109 | image: docker_open5gs_pcrf 110 | container_name: pcrf 111 | depends_on: 112 | - mongo 113 | - dns 114 | dns: ${DNS_IP} 115 | volumes: 116 | - ./pcrf:/mnt/pcrf 117 | - ./log:/open5gs/install/var/log/open5gs 118 | environment: 119 | - PGW_IP=${PGW_IP} 120 | - MONGO_IP=${MONGO_IP} 121 | - PCSCF_IP=${PCSCF_IP} 122 | networks: 123 | default: 124 | ipv4_address: ${PCRF_IP} 125 | mysql: 126 | build: ./mysql 127 | image: open5gs_mysql 128 | container_name: mysql 129 | volumes: 130 | - ./mysql_db:/var/lib/mysql 131 | - ./mysql:/mnt/mysql 132 | networks: 133 | default: 134 | ipv4_address: ${MYSQL_IP} 135 | rtpengine: 136 | build: ./rtpengine 137 | image: open5gs_rtpengine 138 | privileged: true 139 | container_name: rtpengine 140 | volumes: 141 | - ./rtpengine:/mnt/rtpengine 142 | environment: 143 | - RTPENGINE_IP=${RTPENGINE_IP} 144 | networks: 145 | default: 146 | ipv4_address: ${RTPENGINE_IP} 147 | pcscf: 148 | build: ./pcscf 149 | image: docker_open5gs_pcscf 150 | container_name: pcscf 151 | privileged: true 152 | volumes: 153 | - ./pcscf:/mnt/pcscf 154 | depends_on: 155 | - dns 156 | - mysql 157 | - pcrf 158 | - rtpengine 159 | environment: 160 | - MYSQL_IP=${MYSQL_IP} 161 | - PCSCF_IP=${PCSCF_IP} 162 | - RTPENGINE_IP=${RTPENGINE_IP} 163 | - PGW_IP=${PGW_IP} 164 | dns: ${DNS_IP} 165 | ports: 166 | - "5060:5060/tcp" 167 | - "5060:5060/udp" 168 | networks: 169 | default: 170 | ipv4_address: ${PCSCF_IP} 171 | icscf: 172 | build: ./icscf 173 | image: docker_open5gs_icscf 174 | container_name: icscf 175 | volumes: 176 | - ./icscf:/mnt/icscf 177 | depends_on: 178 | - dns 179 | - mysql 180 | environment: 181 | - MYSQL_IP=${MYSQL_IP} 182 | - ICSCF_IP=${ICSCF_IP} 183 | - FHOSS_IP=${FHOSS_IP} 184 | dns: ${DNS_IP} 185 | ports: 186 | - "4060:4060/tcp" 187 | - "4060:4060/udp" 188 | networks: 189 | default: 190 | ipv4_address: ${ICSCF_IP} 191 | scscf: 192 | build: ./scscf 193 | image: docker_open5gs_scscf 194 | container_name: scscf 195 | volumes: 196 | - ./scscf:/mnt/scscf 197 | depends_on: 198 | - dns 199 | - mysql 200 | environment: 201 | - MYSQL_IP=${MYSQL_IP} 202 | - SCSCF_IP=${SCSCF_IP} 203 | - FHOSS_IP=${FHOSS_IP} 204 | dns: ${DNS_IP} 205 | ports: 206 | - "6060:6060/tcp" 207 | - "6060:6060/udp" 208 | networks: 209 | default: 210 | ipv4_address: ${SCSCF_IP} 211 | fhoss: 212 | build: ./fhoss 213 | image: docker_open5gs_fhoss 214 | container_name: fhoss 215 | volumes: 216 | - ./fhoss:/mnt/fhoss 217 | depends_on: 218 | - dns 219 | - mysql 220 | environment: 221 | - MYSQL_IP=${MYSQL_IP} 222 | - FHOSS_IP=${FHOSS_IP} 223 | dns: ${DNS_IP} 224 | ports: 225 | - "8080:8080/tcp" 226 | networks: 227 | default: 228 | ipv4_address: ${FHOSS_IP} 229 | networks: 230 | default: 231 | ipam: 232 | config: 233 | - subnet: ${SUBNET} 234 | -------------------------------------------------------------------------------- /fhoss/.gitignore: -------------------------------------------------------------------------------- 1 | jdk-7u80-linux-x64.tar.gz 2 | apache-ant-1.9.14-bin.tar.gz 3 | -------------------------------------------------------------------------------- /fhoss/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | # Install updates and dependencies 4 | RUN apt-get update && \ 5 | apt-get -y install curl net-tools iputils-ping wget subversion 6 | 7 | WORKDIR /usr/local/src 8 | COPY jdk-checksum /usr/local/src 9 | COPY jdk-7u80-linux-x64.tar.gz /usr/local/src 10 | COPY apache-ant-1.9.14-bin.tar.gz /usr/local/src 11 | RUN apt-get -y install libdigest-sha-perl 12 | RUN shasum -c jdk-checksum 13 | RUN mkdir -p /usr/lib/jvm/ && \ 14 | tar zxf jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm/ && \ 15 | update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_80/bin/java 100 && \ 16 | update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_80/bin/javac 100 17 | 18 | WORKDIR /usr/local 19 | RUN tar zxf /usr/local/src/apache-ant-1.9.14-bin.tar.gz && \ 20 | echo ANT_HOME=/usr/local/ >> /etc/environment && \ 21 | ln -s /usr/local/apache-ant-1.9.14/bin/ant /usr/bin/ant 22 | 23 | RUN mkdir -p /opt/OpenIMSCore && \ 24 | cd /opt/OpenIMSCore && \ 25 | svn checkout svn://svn.code.sf.net/p/openimscore/code/FHoSS/trunk && \ 26 | mv trunk FHoSS 27 | 28 | WORKDIR /opt/OpenIMSCore/FHoSS 29 | ENV JAVA_HOME="/usr/lib/jvm/jdk1.7.0_80" 30 | ENV CLASSPATH="/usr/lib/jvm/jdk1.7.0_80/jre/lib/" 31 | ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" 32 | RUN ant compile deploy | tee ant_compile_deploy.txt 33 | 34 | ADD deploy /opt/OpenIMSCore/FHoSS/deploy/ 35 | ADD config /opt/OpenIMSCore/FHoSS/config/ 36 | ADD scripts /opt/OpenIMSCore/FHoSS/scripts/ 37 | COPY hss.sh / 38 | 39 | RUN apt-get install -y netcat 40 | 41 | EXPOSE 3868/udp 42 | EXPOSE 3868/tcp 43 | EXPOSE 3868/sctp 44 | EXPOSE 5868/udp 45 | EXPOSE 5868/tcp 46 | EXPOSE 5868/sctp 47 | EXPOSE 8080/tcp 48 | 49 | CMD /mnt/fhoss/fhoss_init.sh 50 | -------------------------------------------------------------------------------- /fhoss/config/DiameterPeerHSS.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fhoss/config/c3p0.properties: -------------------------------------------------------------------------------- 1 | c3p0.acquireRetryAttempts=60 2 | c3p0.acquireRetryDelay=1000 3 | c3p0.breakAfterAcquireFailure=false 4 | -------------------------------------------------------------------------------- /fhoss/config/configurator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Initialization & global vars 4 | # if you execute this script for the second time 5 | # you should change these variables to the latest 6 | # domain name and ip address 7 | DDOMAIN="open-ims\.test" 8 | DSDOMAIN="open-ims\\\.test" 9 | DEFAULTIP="127\.0\.0\.1" 10 | CONFFILES=`ls *.cfg *.xml *.sql *.properties 2>/dev/null` 11 | 12 | # Interaction 13 | printf "Domain Name:" 14 | read domainname 15 | printf "IP Adress:" 16 | read ip_address 17 | 18 | # input domain is to be slashed for cfg regexes 19 | slasheddomain=`echo $domainname | sed 's/\./\\\\\\\\\./g'` 20 | 21 | if [ $# != 0 ] 22 | then 23 | printf "changing: " 24 | for j in $* 25 | do 26 | sed -i -e "s/$DDOMAIN/$domainname/g" $j 27 | sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $j 28 | sed -i -e "s/$DEFAULTIP/$ip_address/g" $j 29 | printf "$j " 30 | done 31 | echo 32 | else 33 | printf "File to change [\"all\" for everything, \"exit\" to quit]:" 34 | # loop 35 | while read filename ; 36 | do 37 | if [ "$filename" = "exit" ] 38 | then 39 | printf "exitting...\n" 40 | break ; 41 | 42 | elif [ "$filename" = "all" ] 43 | then 44 | printf "changing: " 45 | for i in $CONFFILES 46 | do 47 | sed -i -e "s/$DDOMAIN/$domainname/g" $i 48 | sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $i 49 | sed -i -e "s/$DEFAULTIP/$ip_address/g" $i 50 | 51 | printf "$i " 52 | done 53 | echo 54 | break; 55 | 56 | elif [ -w $filename ] 57 | then 58 | printf "changing $filename \n" 59 | sed -i -e "s/$DDOMAIN/$domainname/g" $filename 60 | sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $filename 61 | sed -i -e "s/$DEFAULTIP/$ip_address/g" $filename 62 | 63 | else 64 | printf "cannot access file $filename. skipping... \n" 65 | fi 66 | printf "File to Change:" 67 | done 68 | fi 69 | -------------------------------------------------------------------------------- /fhoss/config/hibernate.properties: -------------------------------------------------------------------------------- 1 | ## MySQL 2 | 3 | # hibernate configuration 4 | hibernate.dialect=org.hibernate.dialect.MySQLDialect 5 | #hibernate.connection.driver_class=org.gjt.mm.mysql.Driver 6 | hibernate.connection.driver_class=com.mysql.jdbc.Driver 7 | hibernate.connection.url=jdbc:mysql://MYSQL_IP:3306/hss_db 8 | hibernate.connection.username=hss 9 | hibernate.connection.password=hss 10 | hibernate.connection.isolation=1 11 | 12 | # C3P0 configuration 13 | hibernate.c3p0.acquire_increment=1 14 | hibernate.c3p0.min_size=1 15 | hibernate.c3p0.max_size=30 16 | hibernate.c3p0.timeout=3600 17 | hibernate.c3p0.max_statements=0 18 | hibernate.c3p0.idle_test_period=1200 19 | -------------------------------------------------------------------------------- /fhoss/config/hss.properties: -------------------------------------------------------------------------------- 1 | # FOKUS HSS Properties file 2 | #------------------------------------------------------------------------------------------------------------------------------------ 3 | 4 | 5 | # host & port : specify the IP address and the port where Tomcat is listening, e.g. host=FHOSS_IP; port=8080; 6 | 7 | host=FHOSS_IP 8 | port=8080 9 | 10 | 11 | # Authentication properties 12 | #------------------------------------------------------------------------------------------------------------------------------------ 13 | 14 | # default operator and amf values 15 | #------------------------------------------------------------------------------------------------------------------------------------ 16 | # operator_id, as hex bytes, required length 32 byte, 17 | # e.g. 00000000000000000000000000000000 18 | operatorId=00000000000000000000000000000000 19 | # amf_id: Default amf id as hex bytes, required length 4 byte, e.g. 0000 20 | amfId=0000 21 | 22 | # configuration parameters relating to Milenage algorithm 23 | #------------------------------------------------------------------------------------------------------------------------------------ 24 | 25 | # Enable or disable the use of AK in the Milenage algorithm; if this flag is enabled, 26 | #then is mandatory to be enabled also on the client side 27 | USE_AK=true 28 | 29 | # IND_LEN property - contains the number of bits assigned for the Index; it is used in the generation process of new SQN values 30 | # We are using SQN values which are not time based, as is specified here C.1.1.2, C.1.2, C.2, C3.2 and C.3.4 of TS 33.102 31 | # (SQN = SEQ || IND) 32 | IND_LEN=5 33 | 34 | # delta value, assuring the protection against wrap around counter in the USIM 35 | delta=268435456 36 | 37 | # L - limit on the difference between SEQ_MS (Mobile Station) and SEQ_HE (HSS) 38 | L=32 39 | 40 | # Sh-Settings 41 | #----------------------------------------------------------------------------------------------------------------------------------- 42 | 43 | # Enable or disable IFC Notification mechanism. If you need this feature please enable it. However, be aware that this feature imply 44 | #important time for processing as more validation is required every time after an update (for entities as: IFC, TP, SPT, AS, SP_IFC), 45 | # and could affect the web console interface response-ness. 46 | iFC_NOTIF_ENABLED=false 47 | # interval to check in the db if there are any notifications to push over Sh 48 | SH_NOTIF_CHECK_INTERVAL=10 49 | 50 | # Cx-Settings 51 | # whether to automatically enable a PPR on each IMPU update. Probably not a good idea. 52 | AUTO_PPR_ENABLED=false 53 | # interval to check in the db if there are any events to push over Cx 54 | CX_EVENT_CHECK_INTERVAL=10 55 | 56 | # Expiry Time limit - indicates the subscriptions maximum lifetime allowed by the HSS 57 | expiry_time_lim=3600 58 | -------------------------------------------------------------------------------- /fhoss/config/log4j.properties: -------------------------------------------------------------------------------- 1 | # Set root category priority to INFO and its only appender to CONSOLE. 2 | #log4j.rootCategory=ERROR, MYCONSOLE 3 | log4j.rootLogger=WARN, MYCONSOLE, LOGFILE, LOGFILE2 4 | log4j.logger.de.fhg.fokus.diameter=INFO 5 | log4j.logger.de.fhg.fokus.hss=DEBUG 6 | 7 | # MYCONSOLE is set to be a ConsoleAppender using a PatternLayout. 8 | log4j.appender.MYCONSOLE=org.apache.log4j.ConsoleAppender 9 | log4j.appender.MYCONSOLE.Threshold=DEBUG 10 | log4j.appender.MYCONSOLE.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.MYCONSOLE.layout.ConversionPattern=%d %-5p %c - %M %m%n 12 | 13 | # LOGFILE is set to be a File appender using a PatternLayout. 14 | log4j.appender.LOGFILE=org.apache.log4j.FileAppender 15 | log4j.appender.LOGFILE.File=logs/hss.server.log 16 | log4j.appender.LOGFILE.Append=true 17 | log4j.appender.LOGFILE.Threshold=WARN 18 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout 19 | log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n 20 | 21 | # LOGFILE2 22 | log4j.appender.LOGFILE2=org.apache.log4j.DailyRollingFileAppender 23 | # Required! Specify here the path to the log file 24 | log4j.appender.LOGFILE2.File=logs/hss.activities.log 25 | log4j.appender.LOGFILE2.Append=true 26 | log4j.appender.LOGFILE2.Threshold=DEBUG 27 | log4j.appender.LOGFILE2.DatePattern='.'yyyy-MM-dd-HH 28 | log4j.appender.LOGFILE2.layout=org.apache.log4j.PatternLayout 29 | log4j.appender.LOGFILE2.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n 30 | -------------------------------------------------------------------------------- /fhoss/deploy/DiameterPeerHSS.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fhoss/deploy/hibernate.properties: -------------------------------------------------------------------------------- 1 | ## MySQL 2 | 3 | # hibernate configuration 4 | hibernate.dialect=org.hibernate.dialect.MySQLDialect 5 | #hibernate.connection.driver_class=org.gjt.mm.mysql.Driver 6 | hibernate.connection.driver_class=com.mysql.jdbc.Driver 7 | hibernate.connection.url=jdbc:mysql://MYSQL_IP:3306/hss_db 8 | hibernate.connection.username=hss 9 | hibernate.connection.password=hss 10 | hibernate.connection.isolation=1 11 | 12 | # C3P0 configuration 13 | hibernate.c3p0.acquire_increment=1 14 | hibernate.c3p0.min_size=1 15 | hibernate.c3p0.max_size=30 16 | hibernate.c3p0.timeout=3600 17 | hibernate.c3p0.max_statements=0 18 | hibernate.c3p0.idle_test_period=1200 19 | -------------------------------------------------------------------------------- /fhoss/deploy/webapps/hss.web.console/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HSS Management Console 5 | 6 | 7 | 8 | 9 | respFilter 10 | de.fhg.fokus.hss.web.servlet.ResponseFilter 11 | 12 | 13 | 14 | respFilter 15 | /pages/services/sp.jsp 16 | 17 | 18 | 19 | respFilter 20 | /pages/network/capability_set.jsp 21 | 22 | 23 | 24 | respFilter 25 | 26 | /pages/info/overview.jsp 27 | 28 | 29 | 30 | respFilter 31 | /pages/profiles/dStruct.jsp 32 | 33 | 34 | 35 | respFilter 36 | /pages/info/data.jsp 37 | 38 | 39 | 40 | action 41 | 42 | org.apache.struts.action.ActionServlet 43 | 44 | 45 | config 46 | /WEB-INF/struts-config.xml 47 | 48 | 49 | debug 50 | 2 51 | 52 | 53 | detail 54 | 2 55 | 56 | 2 57 | 58 | 59 | 60 | Log4jInit 61 | de.fhg.fokus.hss.Log4jInit 62 | 63 | 64 | log4j-init-file 65 | log4j.properties 66 | 67 | 68 | 1 69 | 70 | 71 | 72 | JUnitEETestServlet 73 | JUnitEE test runner 74 | org.junitee.servlet.JUnitEEServlet 75 | 76 | searchResources 77 | hss.core.test.jar 78 | 79 | 80 | 81 | 82 | 83 | action 84 | *.do 85 | 86 | 87 | 88 | JUnitEETestServlet 89 | /TestServlet/* 90 | 91 | 92 | 93 | index.jsp 94 | frameset.jsp 95 | 96 | 97 | 98 | 99 | 100 | 101 | /tags/struts-bean 102 | /WEB-INF/struts-bean.tld 103 | 104 | 105 | 106 | /tags/struts-html 107 | /WEB-INF/struts-html.tld 108 | 109 | 110 | 111 | /tags/struts-logic 112 | /WEB-INF/struts-logic.tld 113 | 114 | 115 | 116 | /tags/struts-nested 117 | /WEB-INF/struts-nested.tld 118 | 119 | 120 | 121 | /tags/struts-tiles 122 | /WEB-INF/struts-tiles.tld 123 | 124 | 125 | 126 | 127 | 128 | Link to the UserDatabase instance from which we request lists of 129 | defined role names. Typically, this will be connected to the global 130 | user database with a ResourceLink element in server.xml or the context 131 | configuration file for the Manager web application. 132 | 133 | users 134 | 135 | org.apache.catalina.UserDatabase 136 | 137 | 138 | 139 | 140 | 141 | 142 | hss.web.console 143 | * 144 | 145 | 146 | 147 | hss_user 148 | 149 | 150 | 151 | 152 | 153 | BASIC 154 | ims.mnc001.mcc001.3gppnetwork.org 155 | 156 | 157 | 158 | 159 | 160 | The role that is required to log into the HSS 161 | 162 | hss_user 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /fhoss/download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | wget https://files-cdn.liferay.com/mirrors/download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz 3 | wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.14-bin.tar.gz 4 | -------------------------------------------------------------------------------- /fhoss/fhoss_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while true; do 3 | echo 'Waiting for MySQL to start.' 4 | echo '' | nc -w 1 $MYSQL_IP 3306 && break 5 | sleep 1 6 | done 7 | 8 | cd /opt/OpenIMSCore/FHoSS 9 | sed -i 's|FHOSS_IP|'$FHOSS_IP'|g' ./config/hss.properties 10 | sed -i 's|MYSQL_IP|'$MYSQL_IP'|g' ./config/hibernate.properties 11 | sed -i 's|MYSQL_IP|'$MYSQL_IP'|g' ./deploy/hibernate.properties 12 | sed -i 's|FHOSS_IP|'$FHOSS_IP'|g' ./config/DiameterPeerHSS.xml 13 | sed -i 's|FHOSS_IP|'$FHOSS_IP'|g' ./deploy/DiameterPeerHSS.xml 14 | cp ./config/hss.properties ./deploy/hss.properties 15 | 16 | /hss.sh 17 | -------------------------------------------------------------------------------- /fhoss/hss.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -------------------------------------------------------------- 3 | # Include JAR Files 4 | # -------------------------------------------------------------- 5 | 6 | cd /opt/OpenIMSCore/FHoSS/deploy 7 | JAVA_HOME="/usr/lib/jvm/jdk1.7.0_80" 8 | CLASSPATH="/usr/lib/jvm/jdk1.7.0_80/jre/lib/" 9 | echo "Building Classpath" 10 | CLASSPATH=$CLASSPATH:log4j.properties:. 11 | for i in lib/*.jar; do CLASSPATH="$i":"$CLASSPATH"; done 12 | echo "Classpath is $CLASSPATH." 13 | 14 | # -------------------------------------------------------------- 15 | # Start-up 16 | # -------------------------------------------------------------- 17 | 18 | $JAVA_HOME/bin/java -cp $CLASSPATH de.fhg.fokus.hss.main.HSSContainer $1 $2 $3 $4 $5 $6 $7 $8 $9 19 | -------------------------------------------------------------------------------- /fhoss/jdk-checksum: -------------------------------------------------------------------------------- 1 | 21e5e18c3511def01590994e926a4350c0509f01 jdk-7u80-linux-x64.tar.gz 2 | d7dcfbb3089af750330f069a185389024773ac6d apache-ant-1.9.14-bin.tar.gz 3 | -------------------------------------------------------------------------------- /fhoss/scripts/configurator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Initialization & global vars 4 | # if you execute this script for the second time 5 | # you should change these variables to the latest 6 | # domain name and ip address 7 | DDOMAIN="open-ims\.test" 8 | DSDOMAIN="open-ims\\\.test" 9 | DEFAULTIP="127\.0\.0\.1" 10 | CONFFILES=`ls *.cfg *.xml *.sql *.properties 2>/dev/null` 11 | 12 | # Interaction 13 | printf "Domain Name:" 14 | read domainname 15 | printf "IP Adress:" 16 | read ip_address 17 | 18 | # input domain is to be slashed for cfg regexes 19 | slasheddomain=`echo $domainname | sed 's/\./\\\\\\\\\./g'` 20 | 21 | if [ $# != 0 ] 22 | then 23 | printf "changing: " 24 | for j in $* 25 | do 26 | sed -i -e "s/$DDOMAIN/$domainname/g" $j 27 | sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $j 28 | sed -i -e "s/$DEFAULTIP/$ip_address/g" $j 29 | printf "$j " 30 | done 31 | echo 32 | else 33 | printf "File to change [\"all\" for everything, \"exit\" to quit]:" 34 | # loop 35 | while read filename ; 36 | do 37 | if [ "$filename" = "exit" ] 38 | then 39 | printf "exitting...\n" 40 | break ; 41 | 42 | elif [ "$filename" = "all" ] 43 | then 44 | printf "changing: " 45 | for i in $CONFFILES 46 | do 47 | sed -i -e "s/$DDOMAIN/$domainname/g" $i 48 | sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $i 49 | sed -i -e "s/$DEFAULTIP/$ip_address/g" $i 50 | 51 | printf "$i " 52 | done 53 | echo 54 | break; 55 | 56 | elif [ -w $filename ] 57 | then 58 | printf "changing $filename \n" 59 | sed -i -e "s/$DDOMAIN/$domainname/g" $filename 60 | sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $filename 61 | sed -i -e "s/$DEFAULTIP/$ip_address/g" $filename 62 | 63 | else 64 | printf "cannot access file $filename. skipping... \n" 65 | fi 66 | printf "File to Change:" 67 | done 68 | fi 69 | -------------------------------------------------------------------------------- /fhoss/scripts/cpappend.cmd: -------------------------------------------------------------------------------- 1 | IF "%JARS%"=="" goto first 2 | set JARS=%JARS%;%1 3 | goto fertig 4 | :first 5 | set JARS=%1 6 | :fertig -------------------------------------------------------------------------------- /fhoss/scripts/dbdump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | 4 | FILE=hss_db.sql 5 | 6 | mysqldump hss_db -d -B --add-drop-table --add-drop-database >$FILE 7 | echo "# DB access rights" >>$FILE 8 | echo "grant delete,insert,select,update on hss_db.* to hss@localhost identified by 'hss';" >>$FILE 9 | 10 | FILE=userdata.sql 11 | mysqldump hss_db -t -B >$FILE 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /fhoss/scripts/hss_db_migrate_as_register.sql: -------------------------------------------------------------------------------- 1 | use hss_db; 2 | 3 | -- ---------------------------------------------------------------------------- 4 | -- We'll need to use IF to determine whether the database is already upgraded. 5 | -- MySQL only allows us to use IF from within stored procedures, so we'll 6 | -- create a very short-lived stored procedure. Before we do that, delete any 7 | -- existing procedure. 8 | -- ---------------------------------------------------------------------------- 9 | DROP PROCEDURE IF EXISTS upgrade_hss_database; 10 | 11 | -- ---------------------------------------------------------------------------- 12 | -- Define the stored procedure. Before doing this, we must redefine the 13 | -- delimiter so that the end of statements within the body of the stored 14 | -- procedure are not considered to be the end of the stored procedure as a 15 | -- whole. 16 | -- ---------------------------------------------------------------------------- 17 | DELIMITER $$ 18 | CREATE PROCEDURE upgrade_hss_database() 19 | BEGIN 20 | -- -------------------------------------------------------------------------- 21 | -- Add IncludeRegisterRequest/Response flags. 22 | -- -------------------------------------------------------------------------- 23 | IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='application_server' AND COLUMN_NAME='include_register_response') THEN 24 | ALTER TABLE application_server ADD COLUMN include_register_response TINYINT NOT NULL DEFAULT 0; 25 | END IF; 26 | 27 | IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='application_server' AND COLUMN_NAME='include_register_request') THEN 28 | ALTER TABLE application_server ADD COLUMN include_register_request TINYINT NOT NULL DEFAULT 0; 29 | END IF; 30 | 31 | END $$ 32 | DELIMITER ; 33 | 34 | -- ---------------------------------------------------------------------------- 35 | -- Call the upgrade procedure and then drop it from the database. 36 | -- ---------------------------------------------------------------------------- 37 | CALL upgrade_hss_database(); 38 | DROP PROCEDURE upgrade_hss_database; 39 | -------------------------------------------------------------------------------- /fhoss/scripts/hss_db_migrate_dsai.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.10 2 | -- 3 | -- Host: localhost Database: hss_db 4 | -- ------------------------------------------------------ 5 | -- Server version 5.0.21-log 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!40101 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Current Database: `hss_db` 20 | -- 21 | 22 | USE `hss_db`; 23 | 24 | -- 25 | -- Table structure for table `dsai` 26 | -- 27 | 28 | DROP TABLE IF EXISTS `dsai`; 29 | CREATE TABLE `dsai` ( 30 | `id` int(11) NOT NULL auto_increment, 31 | `dsai_tag` varchar(255) NOT NULL, 32 | PRIMARY KEY (`id`) 33 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='DSAI table'; 34 | 35 | -- 36 | -- Table structure for table `dsai_ifc` 37 | -- 38 | 39 | DROP TABLE IF EXISTS `dsai_ifc`; 40 | CREATE TABLE `dsai_ifc` ( 41 | `id` int(11) NOT NULL auto_increment, 42 | `id_dsai` int(11) NOT NULL default '0', 43 | `id_ifc` int(11) NOT NULL default '0', 44 | PRIMARY KEY (`id`), 45 | KEY `idx_id_dsai` (`id_dsai`), 46 | KEY `idx_id_ifc` (`id_ifc`) 47 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='DSAI - iFC Mappings'; 48 | 49 | -- 50 | -- Table structure for table `dsai_impu` 51 | -- 52 | 53 | DROP TABLE IF EXISTS `dsai_impu`; 54 | CREATE TABLE `dsai_impu` ( 55 | `id` int(11) NOT NULL auto_increment, 56 | `id_dsai` int(11) NOT NULL default '0', 57 | `id_impu` int(11) NOT NULL default '0', 58 | `dsai_value` int(11) NOT NULL default '0', 59 | PRIMARY KEY (`id`), 60 | KEY `idx_id_dsai` (`id_dsai`), 61 | KEY `idx_id_impu` (`id_impu`) 62 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='DSAI - IMPU/PSI Mappings'; 63 | 64 | -- 65 | -- Update expiration time in subscription old records 66 | -- 67 | 68 | UPDATE sh_subscription 69 | set expires = -1; 70 | 71 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 72 | 73 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 74 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 75 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 76 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 77 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 78 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 79 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 80 | 81 | # DB access rights 82 | grant delete,insert,select,update on hss_db.dsai to hss@localhost identified by 'hss'; 83 | grant delete,insert,select,update on hss_db.dsai_ifc to hss@localhost identified by 'hss'; 84 | grant delete,insert,select,update on hss_db.dsai_impu to hss@localhost identified by 'hss'; 85 | -------------------------------------------------------------------------------- /fhoss/scripts/startup.cmd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miaoski/docker_open5gs/be1de8e62a8d200bc47503e1b129a4c6425e608a/fhoss/scripts/startup.cmd -------------------------------------------------------------------------------- /fhoss/scripts/startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -------------------------------------------------------------- 3 | # Include JAR Files 4 | # -------------------------------------------------------------- 5 | 6 | echo "Building Classpath" 7 | CLASSPATH=$CLASSPATH:log4j.properties:. 8 | for i in lib/*.jar; do CLASSPATH="$i":"$CLASSPATH"; done 9 | echo "Classpath is $CLASSPATH." 10 | 11 | # -------------------------------------------------------------- 12 | # Start-up 13 | # -------------------------------------------------------------- 14 | 15 | $JAVA_HOME/bin/java -cp $CLASSPATH de.fhg.fokus.hss.main.HSSContainer $1 $2 $3 $4 $5 $6 $7 $8 $9 16 | -------------------------------------------------------------------------------- /fhoss/scripts/userdata.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.11 2 | -- 3 | -- Host: localhost Database: hss_db 4 | -- ------------------------------------------------------ 5 | -- Server version 5.0.67-0ubuntu6 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!40101 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Current Database: `hss_db` 20 | -- 21 | 22 | CREATE DATABASE /*!32312 IF NOT EXISTS*/ `hss_db` /*!40100 DEFAULT CHARACTER SET utf8 */; 23 | 24 | USE `hss_db`; 25 | 26 | -- 27 | -- Dumping data for table `aliases_repository_data` 28 | -- 29 | 30 | LOCK TABLES `aliases_repository_data` WRITE; 31 | /*!40000 ALTER TABLE `aliases_repository_data` DISABLE KEYS */; 32 | /*!40000 ALTER TABLE `aliases_repository_data` ENABLE KEYS */; 33 | UNLOCK TABLES; 34 | 35 | -- 36 | -- Dumping data for table `application_server` 37 | -- 38 | 39 | LOCK TABLES `application_server` WRITE; 40 | /*!40000 ALTER TABLE `application_server` DISABLE KEYS */; 41 | INSERT INTO `application_server` VALUES (1,'default_as','sip:FHOSS_IP:5065',0,'','presence.ims.mnc001.mcc001.3gppnetwork.org',1024,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); 42 | /*!40000 ALTER TABLE `application_server` ENABLE KEYS */; 43 | UNLOCK TABLES; 44 | 45 | -- 46 | -- Dumping data for table `capabilities_set` 47 | -- 48 | 49 | LOCK TABLES `capabilities_set` WRITE; 50 | /*!40000 ALTER TABLE `capabilities_set` DISABLE KEYS */; 51 | INSERT INTO `capabilities_set` VALUES (2,1,'cap_set1',1,0); 52 | /*!40000 ALTER TABLE `capabilities_set` ENABLE KEYS */; 53 | UNLOCK TABLES; 54 | 55 | -- 56 | -- Dumping data for table `capability` 57 | -- 58 | 59 | LOCK TABLES `capability` WRITE; 60 | /*!40000 ALTER TABLE `capability` DISABLE KEYS */; 61 | INSERT INTO `capability` VALUES (1,'cap1'),(2,'cap2'); 62 | /*!40000 ALTER TABLE `capability` ENABLE KEYS */; 63 | UNLOCK TABLES; 64 | 65 | -- 66 | -- Dumping data for table `charging_info` 67 | -- 68 | 69 | LOCK TABLES `charging_info` WRITE; 70 | /*!40000 ALTER TABLE `charging_info` DISABLE KEYS */; 71 | INSERT INTO `charging_info` VALUES (1,'default_charging_set','','','pri_ccf_address',''); 72 | /*!40000 ALTER TABLE `charging_info` ENABLE KEYS */; 73 | UNLOCK TABLES; 74 | 75 | -- 76 | -- Dumping data for table `cx_events` 77 | -- 78 | 79 | LOCK TABLES `cx_events` WRITE; 80 | /*!40000 ALTER TABLE `cx_events` DISABLE KEYS */; 81 | /*!40000 ALTER TABLE `cx_events` ENABLE KEYS */; 82 | UNLOCK TABLES; 83 | 84 | -- 85 | -- Dumping data for table `dsai` 86 | -- 87 | 88 | LOCK TABLES `dsai` WRITE; 89 | /*!40000 ALTER TABLE `dsai` DISABLE KEYS */; 90 | INSERT INTO `dsai` VALUES (1,'default_dsai'); 91 | /*!40000 ALTER TABLE `dsai` ENABLE KEYS */; 92 | UNLOCK TABLES; 93 | 94 | -- 95 | -- Dumping data for table `dsai_ifc` 96 | -- 97 | 98 | LOCK TABLES `dsai_ifc` WRITE; 99 | /*!40000 ALTER TABLE `dsai_ifc` DISABLE KEYS */; 100 | INSERT INTO `dsai_ifc` VALUES (1,1,1); 101 | /*!40000 ALTER TABLE `dsai_ifc` ENABLE KEYS */; 102 | UNLOCK TABLES; 103 | 104 | -- 105 | -- Dumping data for table `dsai_impu` 106 | -- 107 | 108 | LOCK TABLES `dsai_impu` WRITE; 109 | /*!40000 ALTER TABLE `dsai_impu` DISABLE KEYS */; 110 | INSERT INTO `dsai_impu` VALUES (1,1,1,0),(2,1,2,0); 111 | /*!40000 ALTER TABLE `dsai_impu` ENABLE KEYS */; 112 | UNLOCK TABLES; 113 | 114 | -- 115 | -- Dumping data for table `ifc` 116 | -- 117 | 118 | LOCK TABLES `ifc` WRITE; 119 | /*!40000 ALTER TABLE `ifc` DISABLE KEYS */; 120 | INSERT INTO `ifc` VALUES (1,'default_ifc',1,1,-1); 121 | /*!40000 ALTER TABLE `ifc` ENABLE KEYS */; 122 | UNLOCK TABLES; 123 | 124 | -- 125 | -- Dumping data for table `impi` 126 | -- 127 | 128 | LOCK TABLES `impi` WRITE; 129 | /*!40000 ALTER TABLE `impi` DISABLE KEYS */; 130 | INSERT INTO `impi` VALUES (4,1,'alice@ims.mnc001.mcc001.3gppnetwork.org','alice',127,1,'\0\0','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','000000000000','','',0,3600,1),(2,2,'bob@ims.mnc001.mcc001.3gppnetwork.org','bob',255,1,'\0\0','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','000000000000','','',0,3600,1); 131 | /*!40000 ALTER TABLE `impi` ENABLE KEYS */; 132 | UNLOCK TABLES; 133 | 134 | -- 135 | -- Dumping data for table `impi_impu` 136 | -- 137 | 138 | LOCK TABLES `impi_impu` WRITE; 139 | /*!40000 ALTER TABLE `impi_impu` DISABLE KEYS */; 140 | INSERT INTO `impi_impu` VALUES (4,4,1,0),(2,2,2,0); 141 | /*!40000 ALTER TABLE `impi_impu` ENABLE KEYS */; 142 | UNLOCK TABLES; 143 | 144 | -- 145 | -- Dumping data for table `impu` 146 | -- 147 | 148 | LOCK TABLES `impu` WRITE; 149 | /*!40000 ALTER TABLE `impu` DISABLE KEYS */; 150 | INSERT INTO `impu` VALUES (1,'sip:alice@ims.mnc001.mcc001.3gppnetwork.org',0,0,0,1,1,1,'','',0,1),(2,'sip:bob@ims.mnc001.mcc001.3gppnetwork.org',0,0,0,1,2,1,'','',0,1); 151 | /*!40000 ALTER TABLE `impu` ENABLE KEYS */; 152 | UNLOCK TABLES; 153 | 154 | -- 155 | -- Dumping data for table `impu_visited_network` 156 | -- 157 | 158 | LOCK TABLES `impu_visited_network` WRITE; 159 | /*!40000 ALTER TABLE `impu_visited_network` DISABLE KEYS */; 160 | INSERT INTO `impu_visited_network` VALUES (1,1,1),(2,2,1); 161 | /*!40000 ALTER TABLE `impu_visited_network` ENABLE KEYS */; 162 | UNLOCK TABLES; 163 | 164 | -- 165 | -- Dumping data for table `imsu` 166 | -- 167 | 168 | LOCK TABLES `imsu` WRITE; 169 | /*!40000 ALTER TABLE `imsu` DISABLE KEYS */; 170 | INSERT INTO `imsu` VALUES (1,'alice','','',1,1),(2,'bob','','',1,1); 171 | /*!40000 ALTER TABLE `imsu` ENABLE KEYS */; 172 | UNLOCK TABLES; 173 | 174 | -- 175 | -- Dumping data for table `preferred_scscf_set` 176 | -- 177 | 178 | LOCK TABLES `preferred_scscf_set` WRITE; 179 | /*!40000 ALTER TABLE `preferred_scscf_set` DISABLE KEYS */; 180 | INSERT INTO `preferred_scscf_set` VALUES (1,1,'scscf1','sip:scscf.ims.mnc001.mcc001.3gppnetwork.org:6060',0); 181 | /*!40000 ALTER TABLE `preferred_scscf_set` ENABLE KEYS */; 182 | UNLOCK TABLES; 183 | 184 | -- 185 | -- Dumping data for table `repository_data` 186 | -- 187 | 188 | LOCK TABLES `repository_data` WRITE; 189 | /*!40000 ALTER TABLE `repository_data` DISABLE KEYS */; 190 | /*!40000 ALTER TABLE `repository_data` ENABLE KEYS */; 191 | UNLOCK TABLES; 192 | 193 | -- 194 | -- Dumping data for table `sh_notification` 195 | -- 196 | 197 | LOCK TABLES `sh_notification` WRITE; 198 | /*!40000 ALTER TABLE `sh_notification` DISABLE KEYS */; 199 | /*!40000 ALTER TABLE `sh_notification` ENABLE KEYS */; 200 | UNLOCK TABLES; 201 | 202 | -- 203 | -- Dumping data for table `sh_subscription` 204 | -- 205 | 206 | LOCK TABLES `sh_subscription` WRITE; 207 | /*!40000 ALTER TABLE `sh_subscription` DISABLE KEYS */; 208 | /*!40000 ALTER TABLE `sh_subscription` ENABLE KEYS */; 209 | UNLOCK TABLES; 210 | 211 | -- 212 | -- Dumping data for table `shared_ifc_set` 213 | -- 214 | 215 | LOCK TABLES `shared_ifc_set` WRITE; 216 | /*!40000 ALTER TABLE `shared_ifc_set` DISABLE KEYS */; 217 | INSERT INTO `shared_ifc_set` VALUES (1,1,'default_shared_set',1,0); 218 | /*!40000 ALTER TABLE `shared_ifc_set` ENABLE KEYS */; 219 | UNLOCK TABLES; 220 | 221 | -- 222 | -- Dumping data for table `sp` 223 | -- 224 | 225 | LOCK TABLES `sp` WRITE; 226 | /*!40000 ALTER TABLE `sp` DISABLE KEYS */; 227 | INSERT INTO `sp` VALUES (1,'default_sp',0); 228 | /*!40000 ALTER TABLE `sp` ENABLE KEYS */; 229 | UNLOCK TABLES; 230 | 231 | -- 232 | -- Dumping data for table `sp_ifc` 233 | -- 234 | 235 | LOCK TABLES `sp_ifc` WRITE; 236 | /*!40000 ALTER TABLE `sp_ifc` DISABLE KEYS */; 237 | INSERT INTO `sp_ifc` VALUES (1,1,1,0); 238 | /*!40000 ALTER TABLE `sp_ifc` ENABLE KEYS */; 239 | UNLOCK TABLES; 240 | 241 | -- 242 | -- Dumping data for table `sp_shared_ifc_set` 243 | -- 244 | 245 | LOCK TABLES `sp_shared_ifc_set` WRITE; 246 | /*!40000 ALTER TABLE `sp_shared_ifc_set` DISABLE KEYS */; 247 | /*!40000 ALTER TABLE `sp_shared_ifc_set` ENABLE KEYS */; 248 | UNLOCK TABLES; 249 | 250 | -- 251 | -- Dumping data for table `spt` 252 | -- 253 | 254 | LOCK TABLES `spt` WRITE; 255 | /*!40000 ALTER TABLE `spt` DISABLE KEYS */; 256 | INSERT INTO `spt` VALUES (2,1,0,0,1,NULL,'PUBLISH',NULL,NULL,NULL,NULL,NULL,0),(5,1,0,0,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(7,1,0,1,1,NULL,'PUBLISH',NULL,NULL,NULL,NULL,NULL,0),(6,1,0,0,3,NULL,NULL,NULL,NULL,0,NULL,NULL,0),(8,1,0,1,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(9,1,0,1,3,NULL,NULL,NULL,NULL,3,NULL,NULL,0),(10,1,0,2,1,NULL,'SUBSCRIBE',NULL,NULL,NULL,NULL,NULL,0),(11,1,0,2,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(12,1,0,2,3,NULL,NULL,NULL,NULL,1,NULL,NULL,0),(13,1,0,3,1,NULL,'SUBSCRIBE',NULL,NULL,NULL,NULL,NULL,0),(14,1,0,3,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(15,1,0,3,3,NULL,NULL,NULL,NULL,2,NULL,NULL,0); 257 | /*!40000 ALTER TABLE `spt` ENABLE KEYS */; 258 | UNLOCK TABLES; 259 | 260 | -- 261 | -- Dumping data for table `tp` 262 | -- 263 | 264 | LOCK TABLES `tp` WRITE; 265 | /*!40000 ALTER TABLE `tp` DISABLE KEYS */; 266 | INSERT INTO `tp` VALUES (1,'default_tp',0); 267 | /*!40000 ALTER TABLE `tp` ENABLE KEYS */; 268 | UNLOCK TABLES; 269 | 270 | -- 271 | -- Dumping data for table `visited_network` 272 | -- 273 | 274 | LOCK TABLES `visited_network` WRITE; 275 | /*!40000 ALTER TABLE `visited_network` DISABLE KEYS */; 276 | INSERT INTO `visited_network` VALUES (1,'ims.mnc001.mcc001.3gppnetwork.org'); 277 | /*!40000 ALTER TABLE `visited_network` ENABLE KEYS */; 278 | UNLOCK TABLES; 279 | 280 | -- 281 | -- Dumping data for table `zh_uss` 282 | -- 283 | 284 | LOCK TABLES `zh_uss` WRITE; 285 | /*!40000 ALTER TABLE `zh_uss` DISABLE KEYS */; 286 | INSERT INTO `zh_uss` VALUES (4,1,0,0,NULL); 287 | /*!40000 ALTER TABLE `zh_uss` ENABLE KEYS */; 288 | UNLOCK TABLES; 289 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 290 | 291 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 292 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 293 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 294 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 295 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 296 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 297 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 298 | 299 | -- Dump completed on 2009-01-07 13:54:27 300 | -------------------------------------------------------------------------------- /hss/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM docker_open5gs 28 | 29 | # Expose port 3868 for Diameter queries 30 | EXPOSE 3868/udp 31 | EXPOSE 3868/tcp 32 | EXPOSE 3868/sctp 33 | EXPOSE 5868/udp 34 | EXPOSE 5868/tcp 35 | EXPOSE 5868/sctp 36 | 37 | # Expose port 3000 Web UI of HSS 38 | EXPOSE 3000/tcp 39 | 40 | CMD /mnt/hss/hss_init.sh && \ 41 | cd install/bin && sleep 5 && ./open5gs-hssd 42 | -------------------------------------------------------------------------------- /hss/hss.yaml: -------------------------------------------------------------------------------- 1 | db_uri: mongodb://MONGO_IP/open5gs 2 | 3 | logger: 4 | file: /open5gs/install/var/log/open5gs/hss.log 5 | 6 | parameter: 7 | no_ipv6: true 8 | prefer_ipv4: true 9 | 10 | hss: 11 | freeDiameter: 12 | identity: hss.epc.mnc001.mcc001.3gppnetwork.org 13 | realm: epc.mnc001.mcc001.3gppnetwork.org 14 | port: 3868 15 | sec_port: 5868 16 | listen_on: HSS_IP 17 | load_extension: 18 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx 19 | conf: 0x8888 20 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx 21 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx 22 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx 23 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx 24 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx 25 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx 26 | connect: 27 | - identity: mme.epc.mnc001.mcc001.3gppnetwork.org 28 | addr: MME_IP 29 | port: 3868 30 | -------------------------------------------------------------------------------- /hss/hss_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 2-Clause License 4 | 5 | # Copyright (c) 2019, Supreeth Herle 6 | # All rights reserved. 7 | 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | cd webui && npm run dev & 30 | export IP_ADDR=$(awk 'END{print $1}' /etc/hosts) 31 | 32 | cp /mnt/hss/hss.yaml install/etc/open5gs 33 | sed -i 's|HSS_IP|'$IP_ADDR'|g' install/etc/open5gs/hss.yaml 34 | sed -i 's|MME_IP|'$MME_IP'|g' install/etc/open5gs/hss.yaml 35 | sed -i 's|MONGO_IP|'$MONGO_IP'|g' install/etc/open5gs/hss.yaml 36 | 37 | -------------------------------------------------------------------------------- /icscf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM open5gs_kamailio 2 | 3 | ADD kamailio_icscf /etc/kamailio_icscf/ 4 | 5 | EXPOSE 4060/tcp 6 | EXPOSE 4060/udp 7 | EXPOSE 3869/tcp 8 | EXPOSE 3869/sctp 9 | 10 | COPY ./init.d/kamailio_icscf /etc/init.d/kamailio_icscf 11 | COPY ./default/kamailio_icscf /etc/default/kamailio_icscf 12 | 13 | CMD /mnt/icscf/icscf_init.sh 14 | -------------------------------------------------------------------------------- /icscf/default/kamailio_icscf: -------------------------------------------------------------------------------- 1 | # 2 | # Kamailio startup options 3 | # 4 | 5 | # Set to yes to enable kamailio, once configured properly. 6 | RUN_KAMAILIO=yes 7 | 8 | # User to run as 9 | #USER=kamailio 10 | 11 | # Group to run as 12 | #GROUP=kamailio 13 | 14 | # Amount of shared and private memory to allocate 15 | # for the running Kamailio server (in Mb) 16 | #SHM_MEMORY=64 17 | #PKG_MEMORY=8 18 | 19 | # Config file 20 | #CFGFILE=/etc/kamailio/kamailio.cfg 21 | 22 | # Enable the server to leave a core file when it crashes. 23 | # Set this to 'yes' to enable Kamailio to leave a core file when it crashes 24 | # or 'no' to disable this feature. This option is case sensitive and only 25 | # accepts 'yes' and 'no' and only in lowercase letters. 26 | # On some systems it is necessary to specify a directory for the core files 27 | # to get a dump. Look into the kamailio init file for an example configuration. 28 | #DUMP_CORE=yes 29 | -------------------------------------------------------------------------------- /icscf/icscf_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true; do 4 | echo 'Waiting for MySQL to start.' 5 | echo '' | nc -w 1 $MYSQL_IP 3306 && break 6 | sleep 1 7 | done 8 | 9 | while true; do 10 | echo 'Waiting for FHoSS to start.' 11 | echo '' | nc -w 1 $FHOSS_IP 3868 && break 12 | sleep 1 13 | done 14 | 15 | sed -i 's|ICSCF_IP|'$ICSCF_IP'|g' /etc/kamailio_icscf/kamailio_icscf.cfg 16 | sed -i 's|ICSCF_IP|'$ICSCF_IP'|g' /etc/kamailio_icscf/icscf.cfg 17 | sed -i 's|MYSQL_IP|'$MYSQL_IP'|g' /etc/kamailio_icscf/icscf.cfg 18 | sed -i 's|ICSCF_IP|'$ICSCF_IP'|g' /etc/kamailio_icscf/icscf.xml 19 | 20 | /etc/init.d/kamailio_icscf start 21 | -------------------------------------------------------------------------------- /icscf/init.d/kamailio_icscf: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | ### BEGIN INIT INFO 4 | # Provides: kamailio 5 | # Required-Start: $syslog $network $local_fs $remote_fs $time 6 | # Should-Start: $named slapd mysql postgresql snmpd radiusd 7 | # Should-Stop: $named slapd mysql postgresql snmpd radiusd 8 | # Required-Stop: $syslog $network $local_fs $remote_fs 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: Start the Kamailio SIP proxy server 12 | # Description: Start the Kamailio SIP proxy server 13 | ### END INIT INFO 14 | 15 | . /lib/lsb/init-functions 16 | 17 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 18 | DAEMON=/usr/local/sbin/kamailio 19 | NAME=`basename "$0"` 20 | DESC="Kamailio SIP Server" 21 | HOMEDIR=/var/run/$NAME 22 | PIDFILE=$HOMEDIR/$NAME.pid 23 | DEFAULTS=/etc/default/$NAME 24 | CFGFILE=/etc/kamailio_icscf/kamailio_icscf.cfg 25 | RUN_KAMAILIO=no 26 | USER=kamailio 27 | GROUP=kamailio 28 | # Amount of shared and private memory to allocate 29 | # for the running Kamailio server (in Mb) 30 | SHM_MEMORY=64 31 | PKG_MEMORY=8 32 | DUMP_CORE=no 33 | 34 | # Do not start kamailio if fork=no is set in the config file 35 | # otherwise the boot process will just stop 36 | check_fork () 37 | { 38 | if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then 39 | log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead" 40 | exit 0 41 | fi 42 | } 43 | 44 | check_kamailio_config () 45 | { 46 | # Check if kamailio configuration is valid before starting the server 47 | set +e 48 | out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null) 49 | retcode=$? 50 | set -e 51 | if [ "$retcode" != '0' ]; then 52 | log_failure_msg "Not starting $DESC: invalid configuration file!" 53 | log_failure_msg 54 | log_failure_msg "$out" 55 | log_failure_msg 56 | exit 1 57 | fi 58 | } 59 | 60 | create_radius_seqfile () 61 | { 62 | # Create a radius sequence file to be used by the radius client if 63 | # radius accounting is enabled. This is needed to avoid any issue 64 | # with the file not being writable if kamailio first starts as user 65 | # root because DUMP_CORE is enabled and creates this file as user 66 | # root and then later it switches back to user kamailio and cannot 67 | # write to the file. If the file exists before kamailio starts, it 68 | # won't change it's ownership and will be writable for both root 69 | # and kamailio, no matter what options are chosen at install time 70 | RADIUS_SEQ_FILE="$HOMEDIR/kamailio_radius.seq" 71 | if [ -d $HOMEDIR ]; then 72 | chown ${USER}:${GROUP} $HOMEDIR 73 | 74 | if [ ! -f $RADIUS_SEQ_FILE ]; then 75 | touch $RADIUS_SEQ_FILE 76 | fi 77 | 78 | chown ${USER}:${GROUP} $RADIUS_SEQ_FILE 79 | chmod 660 $RADIUS_SEQ_FILE 80 | fi 81 | } 82 | 83 | test -f $DAEMON || exit 0 84 | 85 | # Load startup options if available 86 | if [ -f $DEFAULTS ]; then 87 | . $DEFAULTS || true 88 | fi 89 | 90 | if [ "$RUN_KAMAILIO" != "yes" ]; then 91 | log_failure_msg "Kamailio not yet configured. Edit /etc/default/$NAME first." 92 | exit 0 93 | fi 94 | 95 | set -e 96 | 97 | SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`)) 98 | PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`)) 99 | [ -z "$USER" ] && USER=kamailio 100 | [ -z "$GROUP" ] && GROUP=kamailio 101 | [ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64 102 | [ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4 103 | 104 | if test "$DUMP_CORE" = "yes" ; then 105 | # set proper ulimit 106 | ulimit -c unlimited 107 | 108 | # directory for the core dump files 109 | # COREDIR=/home/corefiles 110 | # [ -d $COREDIR ] || mkdir $COREDIR 111 | # chmod 777 $COREDIR 112 | # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern 113 | fi 114 | 115 | # /var/run can be a tmpfs 116 | if [ ! -d $HOMEDIR ]; then 117 | mkdir -p $HOMEDIR 118 | chown ${USER}:${GROUP} $HOMEDIR 119 | fi 120 | 121 | OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP -DD -E -e" 122 | 123 | case "$1" in 124 | start|debug) 125 | check_kamailio_config 126 | create_radius_seqfile 127 | 128 | if [ "$1" != "debug" ]; then 129 | check_fork 130 | fi 131 | 132 | log_daemon_msg "Starting $DESC: $NAME" 133 | start-stop-daemon --start --quiet --pidfile $PIDFILE \ 134 | --exec $DAEMON -- $OPTIONS || log_failure_msg " already running" 135 | log_end_msg 0 136 | ;; 137 | stop) 138 | log_daemon_msg "Stopping $DESC: $NAME" 139 | start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \ 140 | --exec $DAEMON --retry 5 141 | log_end_msg 0 142 | ;; 143 | restart|force-reload) 144 | check_kamailio_config 145 | create_radius_seqfile 146 | 147 | $0 stop 148 | $0 start 149 | ;; 150 | status) 151 | log_daemon_msg "Status of $DESC: " 152 | 153 | status_of_proc -p"$PIDFILE" $NAME $NAME 154 | ;; 155 | *) 156 | N=/etc/init.d/$NAME 157 | echo "Usage: $N {start|stop|restart|force-reload|status|debug}" >&2 158 | exit 1 159 | ;; 160 | esac 161 | 162 | exit 0 163 | -------------------------------------------------------------------------------- /icscf/kamailio_icscf/README.md: -------------------------------------------------------------------------------- 1 | # Kamailio - Interrogating-CSCF Example Configuration File 2 | 3 | Project Website: 4 | 5 | * http://www.kamailio.org 6 | 7 | ## Database Structure 8 | 9 | The necessary Database files for the Interrogating-CSCF are included in this folder. 10 | 11 | -------------------------------------------------------------------------------- /icscf/kamailio_icscf/icscf.cfg: -------------------------------------------------------------------------------- 1 | # SIP / UDP 2 | listen=udp:ICSCF_IP:4060 3 | # listen=udp:ICSCF_IP:4060 advertise 172.24.15.30:4060 4 | # SIP / TCP 5 | listen=tcp:ICSCF_IP:4060 6 | # listen=tcp:ICSCF_IP:4060 advertise 172.24.15.30:4060 7 | # SIP / TCP/TLS 8 | #listen=tls:11.22.33.44:4061 9 | 10 | alias=ims.mnc001.mcc001.3gppnetwork.org 11 | 12 | #!define NETWORKNAME "ims.mnc001.mcc001.3gppnetwork.org" 13 | #!define HOSTNAME "icscf.ims.mnc001.mcc001.3gppnetwork.org" 14 | 15 | #!subst "/NETWORKNAME/ims.mnc001.mcc001.3gppnetwork.org/" 16 | 17 | #!define ENUM_SUFFIX "ims.mnc001.mcc001.3gppnetwork.org." 18 | 19 | # SIP-Address of capturing node, if not set, capturing is disabled. 20 | ##!define CAPTURE_NODE "sip:127.0.0.1:9060" 21 | 22 | # Connection URL for the database: 23 | #!define DB_URL "mysql://icscf:heslo@MYSQL_IP/icscf" 24 | ##!define DB_URL2 "con2=>mysql://icscf:heslo@127.0.0.1/icscf" 25 | 26 | # Allowed IPs for XML-RPC-Queries 27 | ##!define XMLRPC_WHITELIST_1 "127.0.0.1" 28 | ##!define XMLRPC_WHITELIST_2 "127.0.0.1" 29 | ##!define XMLRPC_WHITELIST_3 "127.0.0.1" 30 | 31 | # *** To run in debug mode: 32 | # - define WITH_DEBUG 33 | # 34 | # *** To enable TLS support execute: 35 | # - adjust CFGDIR/tls.cfg as needed 36 | # - define WITH_TLS 37 | # 38 | # *** To enable XMLRPC support execute: 39 | # - define WITH_XMLRPC 40 | # - adjust route[XMLRPC] for access policy 41 | # 42 | # *** To enable a Homer SIP-Capter-Node: 43 | # - define CAPTURE_NODE with a proper address 44 | # 45 | # *** To forwarding to PSTN for unknown users: 46 | # - define PEERING 47 | # 48 | # Enabled Features for this host: 49 | ##!define WITH_DEBUG 50 | #!define WITH_TCP 51 | ##!define WITH_TLS 52 | #!define WITH_XMLRPC 53 | ##!define PEERING 54 | ##!define FALLBACK_AUTH 55 | -------------------------------------------------------------------------------- /icscf/kamailio_icscf/icscf.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.4.13.1 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: localhost 6 | -- Generation Time: 17. Mrz 2016 um 17:36 7 | -- Server version: 5.5.47-0+deb7u1 8 | -- PHP Version: 5.4.45-0+deb7u2 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | -- 14 | -- Database: `icscf` 15 | -- 16 | 17 | -- -------------------------------------------------------- 18 | 19 | -- 20 | -- Tabellenstruktur für Tabelle `nds_trusted_domains` 21 | -- 22 | 23 | CREATE TABLE IF NOT EXISTS `nds_trusted_domains` ( 24 | `id` int(11) NOT NULL, 25 | `trusted_domain` varchar(83) NOT NULL DEFAULT '' 26 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 27 | 28 | -- -------------------------------------------------------- 29 | 30 | -- 31 | -- Tabellenstruktur für Tabelle `s_cscf` 32 | -- 33 | 34 | CREATE TABLE IF NOT EXISTS `s_cscf` ( 35 | `id` int(11) NOT NULL, 36 | `name` varchar(83) NOT NULL DEFAULT '', 37 | `s_cscf_uri` varchar(83) NOT NULL DEFAULT '' 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 39 | 40 | -- -------------------------------------------------------- 41 | 42 | -- 43 | -- Tabellenstruktur für Tabelle `s_cscf_capabilities` 44 | -- 45 | 46 | CREATE TABLE IF NOT EXISTS `s_cscf_capabilities` ( 47 | `id` int(11) NOT NULL, 48 | `id_s_cscf` int(11) NOT NULL DEFAULT '0', 49 | `capability` int(11) NOT NULL DEFAULT '0' 50 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 51 | 52 | -- 53 | -- Indexes for dumped tables 54 | -- 55 | 56 | -- 57 | -- Indexes for table `nds_trusted_domains` 58 | -- 59 | ALTER TABLE `nds_trusted_domains` 60 | ADD PRIMARY KEY (`id`); 61 | 62 | -- 63 | -- Indexes for table `s_cscf` 64 | -- 65 | ALTER TABLE `s_cscf` 66 | ADD PRIMARY KEY (`id`); 67 | 68 | -- 69 | -- Indexes for table `s_cscf_capabilities` 70 | -- 71 | ALTER TABLE `s_cscf_capabilities` 72 | ADD PRIMARY KEY (`id`), 73 | ADD KEY `idx_capability` (`capability`), 74 | ADD KEY `idx_id_s_cscf` (`id_s_cscf`); 75 | 76 | -- 77 | -- AUTO_INCREMENT for dumped tables 78 | -- 79 | 80 | -- 81 | -- AUTO_INCREMENT for table `nds_trusted_domains` 82 | -- 83 | ALTER TABLE `nds_trusted_domains` 84 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 85 | -- 86 | -- AUTO_INCREMENT for table `s_cscf` 87 | -- 88 | ALTER TABLE `s_cscf` 89 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 90 | -- 91 | -- AUTO_INCREMENT for table `s_cscf_capabilities` 92 | -- 93 | ALTER TABLE `s_cscf_capabilities` 94 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 95 | -------------------------------------------------------------------------------- /icscf/kamailio_icscf/icscf.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /kamailio_base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | # Install updates and dependencies 4 | RUN apt-get update && \ 5 | apt-get -y install python3-pip python3-setuptools python3-wheel \ 6 | build-essential flex bison git libsctp-dev libgnutls28-dev \ 7 | libgcrypt-dev libssl-dev libidn11-dev libbson-dev \ 8 | libyaml-dev vim ifupdown curl gnupg iptables net-tools \ 9 | iputils-ping 10 | 11 | # Dependencies of Kamailio 12 | ENV DEBIAN_FRONTEND=noninteractive 13 | RUN apt-get -y install libxml2-dev libmysqlclient-dev libmnl-dev \ 14 | mysql-server tcpdump screen ntp ntpdate dkms make \ 15 | libcurl4-openssl-dev libpcre3-dev bash-completion \ 16 | ipsec-tools libradcli-dev libradcli4 netcat 17 | 18 | RUN git clone https://github.com/herlesupreeth/kamailio && \ 19 | cd kamailio 20 | 21 | #RUN git clone https://github.com/kamailio/kamailio && \ 22 | # cd kamailio && \ 23 | # git checkout -b 5.3 origin/5.3 24 | 25 | COPY modules.lst /tmp/ 26 | 27 | # Compile kamailio 28 | WORKDIR /kamailio 29 | ENV RADCLI=1 30 | RUN make cfg && \ 31 | cp /tmp/modules.lst ./src/ && \ 32 | make -j4 Q=0 all | tee make_all.txt && \ 33 | make install | tee make_install.txt && \ 34 | ldconfig 35 | RUN adduser --quiet --system --group --disabled-password --shell /bin/false --gecos "Kamailio" --home /var/run/kamailio kamailio && \ 36 | chown kamailio:kamailio /var/run/kamailio 37 | -------------------------------------------------------------------------------- /kamailio_base/README.md: -------------------------------------------------------------------------------- 1 | Kamailio for VoLTE 2 | ================== 3 | Based on Supreeth's [Open5GS VoLTE Tutorial](https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/). 4 | 5 | April 15, 2020 6 | -------------- 7 | In order to use `destroy_ipsec_by_contact()`, this base image is switched to [herlesupreeth/kamailio](https://github.com/herlesupreeth/kamailio) commit 797692c. 8 | -------------------------------------------------------------------------------- /kamailio_base/modules.lst: -------------------------------------------------------------------------------- 1 | # this file is autogenerated by make modules-cfg 2 | 3 | # the list of sub-directories with modules 4 | modules_dirs:=modules 5 | 6 | # the list of module groups to compile 7 | cfg_group_include= 8 | 9 | # the list of extra modules to compile 10 | include_modules= cdp cdp_avp db_mysql dialplan ims_auth ims_charging ims_dialog ims_diameter_server ims_icscf ims_ipsec_pcscf ims_isc ims_ocs ims_qos ims_registrar_pcscf ims_registrar_scscf ims_usrloc_pcscf ims_usrloc_scscf outbound presence presence_conference presence_dialoginfo presence_mwi presence_profile presence_reginfo presence_xml pua pua_bla pua_dialoginfo pua_reginfo pua_rpc pua_usrloc pua_xmpp sctp tls utils xcap_client xcap_server xmlops xmlrpc 11 | 12 | # the list of static modules 13 | static_modules= 14 | 15 | # the list of modules to skip from compile list 16 | skip_modules= 17 | 18 | # the list of modules to exclude from compile list 19 | exclude_modules= acc_json acc_radius app_java app_lua app_lua_sr app_mono app_perl app_python app_python3 app_ruby auth_ephemeral auth_identity auth_radius cnxcc cplc crypto db2_ldap db_berkeley db_cassandra db_mongodb db_oracle db_perlvdb db_postgres db_redis db_sqlite db_unixodbc dnssec erlang evapi geoip geoip2 gzcompress h350 http_async_client http_client jansson janssonrpcc json jsonrpcc kafka kazoo lcr ldap log_systemd lost memcached misc_radius ndb_cassandra ndb_mongodb ndb_redis nsq osp peering phonenum pua_json rabbitmq regex rls rtp_media_server snmpstats systemdops topos_redis uuid websocket xhttp_pi xmpp $(skip_modules) 20 | 21 | modules_all= $(filter-out modules/CVS,$(wildcard modules/*)) 22 | modules_noinc= $(filter-out $(addprefix modules/, $(exclude_modules) $(static_modules)), $(modules_all)) 23 | modules= $(filter-out $(modules_noinc), $(addprefix modules/, $(include_modules) )) $(modules_noinc) 24 | modules_configured:=1 25 | -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miaoski/docker_open5gs/be1de8e62a8d200bc47503e1b129a4c6425e608a/log/.keep -------------------------------------------------------------------------------- /mme/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM docker_open5gs 28 | 29 | # Expose port 3868 for Diameter queries 30 | EXPOSE 3868/udp 31 | EXPOSE 3868/tcp 32 | EXPOSE 3868/sctp 33 | EXPOSE 5868/udp 34 | EXPOSE 5868/tcp 35 | EXPOSE 5868/sctp 36 | 37 | # Expose S1AP 38 | EXPOSE 36412/sctp 39 | 40 | # Expose S11 41 | EXPOSE 2123/udp 42 | 43 | CMD /mnt/mme/mme_init.sh && \ 44 | cd install/bin && ./open5gs-mmed 45 | -------------------------------------------------------------------------------- /mme/mme.yaml: -------------------------------------------------------------------------------- 1 | logger: 2 | file: /open5gs/install/var/log/open5gs/mme.log 3 | 4 | parameter: 5 | no_ipv6: true 6 | prefer_ipv4: true 7 | 8 | mme: 9 | freeDiameter: 10 | identity: mme.epc.mnc001.mcc001.3gppnetwork.org 11 | realm: epc.mnc001.mcc001.3gppnetwork.org 12 | port: 3868 13 | sec_port: 5868 14 | listen_on: MME_IP 15 | load_extension: 16 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx 17 | conf: 0x8888 18 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx 19 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx 20 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx 21 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx 22 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx 23 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx 24 | connect: 25 | - identity: hss.epc.mnc001.mcc001.3gppnetwork.org 26 | addr: HSS_IP 27 | port: 3868 28 | s1ap: 29 | dev: MME_IF 30 | gtpc: 31 | dev: MME_IF 32 | gummei: 33 | plmn_id: 34 | mcc: 001 35 | mnc: 01 36 | mme_gid: 2 37 | mme_code: 1 38 | tai: 39 | plmn_id: 40 | mcc: 001 41 | mnc: 01 42 | tac: 1 43 | security: 44 | integrity_order : [ EIA1, EIA2, EIA0 ] 45 | ciphering_order : [ EEA0, EEA1, EEA2 ] 46 | network_name: 47 | full: Open5GS 48 | 49 | sgw: 50 | gtpc: 51 | addr: SGW_IP 52 | 53 | pgw: 54 | gtpc: 55 | addr: 56 | - PGW_IP 57 | - ::1 58 | -------------------------------------------------------------------------------- /mme/mme_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 2-Clause License 4 | 5 | # Copyright (c) 2019, Supreeth Herle 6 | # All rights reserved. 7 | 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | export IP_ADDR=$(awk 'END{print $1}' /etc/hosts) 30 | export IF_NAME=$(ip r | awk '/default/ { print $5 }') 31 | 32 | cp /mnt/mme/mme.yaml install/etc/open5gs 33 | sed -i 's|MME_IP|'$IP_ADDR'|g' install/etc/open5gs/mme.yaml 34 | sed -i 's|MME_IF|'$IF_NAME'|g' install/etc/open5gs/mme.yaml 35 | sed -i 's|HSS_IP|'$HSS_IP'|g' install/etc/open5gs/mme.yaml 36 | sed -i 's|SGW_IP|'$SGW_IP'|g' install/etc/open5gs/mme.yaml 37 | sed -i 's|PGW_IP|'$PGW_IP'|g' install/etc/open5gs/mme.yaml 38 | 39 | -------------------------------------------------------------------------------- /mongo/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM docker_open5gs 28 | 29 | # Expose port 27017 for Mongodb queries 30 | EXPOSE 27017/udp 31 | EXPOSE 27017/tcp 32 | 33 | CMD /mnt/mongo/mongo_init.sh 34 | -------------------------------------------------------------------------------- /mongo/mongo_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 2-Clause License 4 | 5 | # Copyright (c) 2020, miaoski 6 | # All rights reserved. 7 | 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | mongod --smallfiles --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongodb.log --bind_ip 0.0.0.0 30 | -------------------------------------------------------------------------------- /mongodb/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miaoski/docker_open5gs/be1de8e62a8d200bc47503e1b129a4c6425e608a/mongodb/.keep -------------------------------------------------------------------------------- /mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM open5gs_kamailio 2 | 3 | EXPOSE 3306/tcp 4 | 5 | 6 | CMD bash /mnt/mysql/init_mysql.sh 7 | -------------------------------------------------------------------------------- /mysql/fhoss/init.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE hss_db; 2 | GRANT ALL PRIVILEGES ON hss_db.* TO 'hss'@'localhost' identified by 'hss'; 3 | GRANT ALL PRIVILEGES ON hss_db.* TO 'hss'@'%' identified by 'hss'; 4 | FLUSH PRIVILEGES; 5 | -------------------------------------------------------------------------------- /mysql/fhoss/userdata.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.11 2 | -- 3 | -- Host: localhost Database: hss_db 4 | -- ------------------------------------------------------ 5 | -- Server version 5.0.67-0ubuntu6 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!40101 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Current Database: `hss_db` 20 | -- 21 | 22 | CREATE DATABASE /*!32312 IF NOT EXISTS*/ `hss_db` /*!40100 DEFAULT CHARACTER SET utf8 */; 23 | 24 | USE `hss_db`; 25 | 26 | -- 27 | -- Dumping data for table `aliases_repository_data` 28 | -- 29 | 30 | LOCK TABLES `aliases_repository_data` WRITE; 31 | /*!40000 ALTER TABLE `aliases_repository_data` DISABLE KEYS */; 32 | /*!40000 ALTER TABLE `aliases_repository_data` ENABLE KEYS */; 33 | UNLOCK TABLES; 34 | 35 | -- 36 | -- Dumping data for table `application_server` 37 | -- 38 | 39 | LOCK TABLES `application_server` WRITE; 40 | /*!40000 ALTER TABLE `application_server` DISABLE KEYS */; 41 | INSERT INTO `application_server` VALUES (1,'default_as','sip:10.4.128.21:5065',0,'','presence.ims.mnc001.mcc001.3gppnetwork.org',1024,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); 42 | /*!40000 ALTER TABLE `application_server` ENABLE KEYS */; 43 | UNLOCK TABLES; 44 | 45 | -- 46 | -- Dumping data for table `capabilities_set` 47 | -- 48 | 49 | LOCK TABLES `capabilities_set` WRITE; 50 | /*!40000 ALTER TABLE `capabilities_set` DISABLE KEYS */; 51 | INSERT INTO `capabilities_set` VALUES (2,1,'cap_set1',1,0); 52 | /*!40000 ALTER TABLE `capabilities_set` ENABLE KEYS */; 53 | UNLOCK TABLES; 54 | 55 | -- 56 | -- Dumping data for table `capability` 57 | -- 58 | 59 | LOCK TABLES `capability` WRITE; 60 | /*!40000 ALTER TABLE `capability` DISABLE KEYS */; 61 | INSERT INTO `capability` VALUES (1,'cap1'),(2,'cap2'); 62 | /*!40000 ALTER TABLE `capability` ENABLE KEYS */; 63 | UNLOCK TABLES; 64 | 65 | -- 66 | -- Dumping data for table `charging_info` 67 | -- 68 | 69 | LOCK TABLES `charging_info` WRITE; 70 | /*!40000 ALTER TABLE `charging_info` DISABLE KEYS */; 71 | INSERT INTO `charging_info` VALUES (1,'default_charging_set','','','pri_ccf_address',''); 72 | /*!40000 ALTER TABLE `charging_info` ENABLE KEYS */; 73 | UNLOCK TABLES; 74 | 75 | -- 76 | -- Dumping data for table `cx_events` 77 | -- 78 | 79 | LOCK TABLES `cx_events` WRITE; 80 | /*!40000 ALTER TABLE `cx_events` DISABLE KEYS */; 81 | /*!40000 ALTER TABLE `cx_events` ENABLE KEYS */; 82 | UNLOCK TABLES; 83 | 84 | -- 85 | -- Dumping data for table `dsai` 86 | -- 87 | 88 | LOCK TABLES `dsai` WRITE; 89 | /*!40000 ALTER TABLE `dsai` DISABLE KEYS */; 90 | INSERT INTO `dsai` VALUES (1,'default_dsai'); 91 | /*!40000 ALTER TABLE `dsai` ENABLE KEYS */; 92 | UNLOCK TABLES; 93 | 94 | -- 95 | -- Dumping data for table `dsai_ifc` 96 | -- 97 | 98 | LOCK TABLES `dsai_ifc` WRITE; 99 | /*!40000 ALTER TABLE `dsai_ifc` DISABLE KEYS */; 100 | INSERT INTO `dsai_ifc` VALUES (1,1,1); 101 | /*!40000 ALTER TABLE `dsai_ifc` ENABLE KEYS */; 102 | UNLOCK TABLES; 103 | 104 | -- 105 | -- Dumping data for table `dsai_impu` 106 | -- 107 | 108 | LOCK TABLES `dsai_impu` WRITE; 109 | /*!40000 ALTER TABLE `dsai_impu` DISABLE KEYS */; 110 | INSERT INTO `dsai_impu` VALUES (1,1,1,0),(2,1,2,0); 111 | /*!40000 ALTER TABLE `dsai_impu` ENABLE KEYS */; 112 | UNLOCK TABLES; 113 | 114 | -- 115 | -- Dumping data for table `ifc` 116 | -- 117 | 118 | LOCK TABLES `ifc` WRITE; 119 | /*!40000 ALTER TABLE `ifc` DISABLE KEYS */; 120 | INSERT INTO `ifc` VALUES (1,'default_ifc',1,1,-1); 121 | /*!40000 ALTER TABLE `ifc` ENABLE KEYS */; 122 | UNLOCK TABLES; 123 | 124 | -- 125 | -- Dumping data for table `impi` 126 | -- 127 | 128 | LOCK TABLES `impi` WRITE; 129 | /*!40000 ALTER TABLE `impi` DISABLE KEYS */; 130 | INSERT INTO `impi` VALUES (4,1,'alice@ims.mnc001.mcc001.3gppnetwork.org','alice',127,1,'\0\0','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','000000000000','','',0,3600,1),(2,2,'bob@ims.mnc001.mcc001.3gppnetwork.org','bob',255,1,'\0\0','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','000000000000','','',0,3600,1); 131 | /*!40000 ALTER TABLE `impi` ENABLE KEYS */; 132 | UNLOCK TABLES; 133 | 134 | -- 135 | -- Dumping data for table `impi_impu` 136 | -- 137 | 138 | LOCK TABLES `impi_impu` WRITE; 139 | /*!40000 ALTER TABLE `impi_impu` DISABLE KEYS */; 140 | INSERT INTO `impi_impu` VALUES (4,4,1,0),(2,2,2,0); 141 | /*!40000 ALTER TABLE `impi_impu` ENABLE KEYS */; 142 | UNLOCK TABLES; 143 | 144 | -- 145 | -- Dumping data for table `impu` 146 | -- 147 | 148 | LOCK TABLES `impu` WRITE; 149 | /*!40000 ALTER TABLE `impu` DISABLE KEYS */; 150 | INSERT INTO `impu` VALUES (1,'sip:alice@ims.mnc001.mcc001.3gppnetwork.org',0,0,0,1,1,1,'','',0,1),(2,'sip:bob@ims.mnc001.mcc001.3gppnetwork.org',0,0,0,1,2,1,'','',0,1); 151 | /*!40000 ALTER TABLE `impu` ENABLE KEYS */; 152 | UNLOCK TABLES; 153 | 154 | -- 155 | -- Dumping data for table `impu_visited_network` 156 | -- 157 | 158 | LOCK TABLES `impu_visited_network` WRITE; 159 | /*!40000 ALTER TABLE `impu_visited_network` DISABLE KEYS */; 160 | INSERT INTO `impu_visited_network` VALUES (1,1,1),(2,2,1); 161 | /*!40000 ALTER TABLE `impu_visited_network` ENABLE KEYS */; 162 | UNLOCK TABLES; 163 | 164 | -- 165 | -- Dumping data for table `imsu` 166 | -- 167 | 168 | LOCK TABLES `imsu` WRITE; 169 | /*!40000 ALTER TABLE `imsu` DISABLE KEYS */; 170 | INSERT INTO `imsu` VALUES (1,'alice','','',1,1),(2,'bob','','',1,1); 171 | /*!40000 ALTER TABLE `imsu` ENABLE KEYS */; 172 | UNLOCK TABLES; 173 | 174 | -- 175 | -- Dumping data for table `preferred_scscf_set` 176 | -- 177 | 178 | LOCK TABLES `preferred_scscf_set` WRITE; 179 | /*!40000 ALTER TABLE `preferred_scscf_set` DISABLE KEYS */; 180 | INSERT INTO `preferred_scscf_set` VALUES (1,1,'scscf1','sip:scscf.ims.mnc001.mcc001.3gppnetwork.org:6060',0); 181 | /*!40000 ALTER TABLE `preferred_scscf_set` ENABLE KEYS */; 182 | UNLOCK TABLES; 183 | 184 | -- 185 | -- Dumping data for table `repository_data` 186 | -- 187 | 188 | LOCK TABLES `repository_data` WRITE; 189 | /*!40000 ALTER TABLE `repository_data` DISABLE KEYS */; 190 | /*!40000 ALTER TABLE `repository_data` ENABLE KEYS */; 191 | UNLOCK TABLES; 192 | 193 | -- 194 | -- Dumping data for table `sh_notification` 195 | -- 196 | 197 | LOCK TABLES `sh_notification` WRITE; 198 | /*!40000 ALTER TABLE `sh_notification` DISABLE KEYS */; 199 | /*!40000 ALTER TABLE `sh_notification` ENABLE KEYS */; 200 | UNLOCK TABLES; 201 | 202 | -- 203 | -- Dumping data for table `sh_subscription` 204 | -- 205 | 206 | LOCK TABLES `sh_subscription` WRITE; 207 | /*!40000 ALTER TABLE `sh_subscription` DISABLE KEYS */; 208 | /*!40000 ALTER TABLE `sh_subscription` ENABLE KEYS */; 209 | UNLOCK TABLES; 210 | 211 | -- 212 | -- Dumping data for table `shared_ifc_set` 213 | -- 214 | 215 | LOCK TABLES `shared_ifc_set` WRITE; 216 | /*!40000 ALTER TABLE `shared_ifc_set` DISABLE KEYS */; 217 | INSERT INTO `shared_ifc_set` VALUES (1,1,'default_shared_set',1,0); 218 | /*!40000 ALTER TABLE `shared_ifc_set` ENABLE KEYS */; 219 | UNLOCK TABLES; 220 | 221 | -- 222 | -- Dumping data for table `sp` 223 | -- 224 | 225 | LOCK TABLES `sp` WRITE; 226 | /*!40000 ALTER TABLE `sp` DISABLE KEYS */; 227 | INSERT INTO `sp` VALUES (1,'default_sp',0); 228 | /*!40000 ALTER TABLE `sp` ENABLE KEYS */; 229 | UNLOCK TABLES; 230 | 231 | -- 232 | -- Dumping data for table `sp_ifc` 233 | -- 234 | 235 | LOCK TABLES `sp_ifc` WRITE; 236 | /*!40000 ALTER TABLE `sp_ifc` DISABLE KEYS */; 237 | INSERT INTO `sp_ifc` VALUES (1,1,1,0); 238 | /*!40000 ALTER TABLE `sp_ifc` ENABLE KEYS */; 239 | UNLOCK TABLES; 240 | 241 | -- 242 | -- Dumping data for table `sp_shared_ifc_set` 243 | -- 244 | 245 | LOCK TABLES `sp_shared_ifc_set` WRITE; 246 | /*!40000 ALTER TABLE `sp_shared_ifc_set` DISABLE KEYS */; 247 | /*!40000 ALTER TABLE `sp_shared_ifc_set` ENABLE KEYS */; 248 | UNLOCK TABLES; 249 | 250 | -- 251 | -- Dumping data for table `spt` 252 | -- 253 | 254 | LOCK TABLES `spt` WRITE; 255 | /*!40000 ALTER TABLE `spt` DISABLE KEYS */; 256 | INSERT INTO `spt` VALUES (2,1,0,0,1,NULL,'PUBLISH',NULL,NULL,NULL,NULL,NULL,0),(5,1,0,0,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(7,1,0,1,1,NULL,'PUBLISH',NULL,NULL,NULL,NULL,NULL,0),(6,1,0,0,3,NULL,NULL,NULL,NULL,0,NULL,NULL,0),(8,1,0,1,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(9,1,0,1,3,NULL,NULL,NULL,NULL,3,NULL,NULL,0),(10,1,0,2,1,NULL,'SUBSCRIBE',NULL,NULL,NULL,NULL,NULL,0),(11,1,0,2,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(12,1,0,2,3,NULL,NULL,NULL,NULL,1,NULL,NULL,0),(13,1,0,3,1,NULL,'SUBSCRIBE',NULL,NULL,NULL,NULL,NULL,0),(14,1,0,3,2,NULL,NULL,'Event','.*presence.*',NULL,NULL,NULL,0),(15,1,0,3,3,NULL,NULL,NULL,NULL,2,NULL,NULL,0); 257 | /*!40000 ALTER TABLE `spt` ENABLE KEYS */; 258 | UNLOCK TABLES; 259 | 260 | -- 261 | -- Dumping data for table `tp` 262 | -- 263 | 264 | LOCK TABLES `tp` WRITE; 265 | /*!40000 ALTER TABLE `tp` DISABLE KEYS */; 266 | INSERT INTO `tp` VALUES (1,'default_tp',0); 267 | /*!40000 ALTER TABLE `tp` ENABLE KEYS */; 268 | UNLOCK TABLES; 269 | 270 | -- 271 | -- Dumping data for table `visited_network` 272 | -- 273 | 274 | LOCK TABLES `visited_network` WRITE; 275 | /*!40000 ALTER TABLE `visited_network` DISABLE KEYS */; 276 | INSERT INTO `visited_network` VALUES (1,'ims.mnc001.mcc001.3gppnetwork.org'); 277 | /*!40000 ALTER TABLE `visited_network` ENABLE KEYS */; 278 | UNLOCK TABLES; 279 | 280 | -- 281 | -- Dumping data for table `zh_uss` 282 | -- 283 | 284 | LOCK TABLES `zh_uss` WRITE; 285 | /*!40000 ALTER TABLE `zh_uss` DISABLE KEYS */; 286 | INSERT INTO `zh_uss` VALUES (4,1,0,0,NULL); 287 | /*!40000 ALTER TABLE `zh_uss` ENABLE KEYS */; 288 | UNLOCK TABLES; 289 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 290 | 291 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 292 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 293 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 294 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 295 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 296 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 297 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 298 | 299 | -- Dump completed on 2009-01-07 13:54:27 300 | -------------------------------------------------------------------------------- /mysql/init.sql: -------------------------------------------------------------------------------- 1 | GRANT ALL PRIVILEGES ON pcscf.* TO pcscf@localhost identified by 'heslo'; 2 | GRANT ALL PRIVILEGES ON scscf.* TO scscf@localhost identified by 'heslo'; 3 | GRANT ALL PRIVILEGES ON icscf.* TO icscf@localhost identified by 'heslo'; 4 | GRANT ALL PRIVILEGES ON icscf.* TO provisioning@localhost identified by 'provi'; 5 | GRANT ALL PRIVILEGES ON pcscf.* TO 'pcscf'@'%' identified by 'heslo'; 6 | GRANT ALL PRIVILEGES ON scscf.* TO 'scscf'@'%' identified by 'heslo'; 7 | GRANT ALL PRIVILEGES ON icscf.* TO 'icscf'@'%' identified by 'heslo'; 8 | GRANT ALL PRIVILEGES ON icscf.* TO 'provisioning'@'%' identified by 'provi'; 9 | FLUSH PRIVILEGES; 10 | 11 | use icscf; 12 | INSERT INTO nds_trusted_domains VALUES (1,'ims.mnc001.mcc001.3gppnetwork.org'); 13 | INSERT INTO s_cscf VALUES (1,'First and only S-CSCF','sip:scscf.ims.mnc001.mcc001.3gppnetwork.org:6060'); 14 | INSERT INTO s_cscf_capabilities VALUES (1,1,0),(2,1,1); 15 | -------------------------------------------------------------------------------- /mysql/init_mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | cp /mnt/mysql/mysqld.cnf /etc/mysql/mysql.conf.d/ 3 | 4 | rm -f /var/run/mysqld/mysqld.sock 5 | chown -R mysql:mysql /var/lib/mysql 6 | 7 | if [ ! -e /var/lib/mysql/ibdata1 ]; then 8 | echo 'Initialize MySQL DB' 9 | mysqld --initialize-insecure 10 | fi 11 | 12 | while true; do 13 | echo 'Waiting for MySQL to start.' 14 | /etc/init.d/mysql restart 15 | echo 'quit' | mysql --connect-timeout=1 && break 16 | done 17 | 18 | 19 | if [ ! -d /var/lib/mysql/pcscf ]; then 20 | echo 'Creating database for P-CSCF' 21 | mysqladmin -u root create pcscf 22 | mysql -u root pcscf < /kamailio/utils/kamctl/mysql/standard-create.sql 23 | mysql -u root pcscf < /kamailio/utils/kamctl/mysql/presence-create.sql 24 | mysql -u root pcscf < /kamailio/utils/kamctl/mysql/ims_usrloc_pcscf-create.sql 25 | mysql -u root pcscf < /kamailio/utils/kamctl/mysql/ims_dialog-create.sql 26 | fi 27 | 28 | if [ ! -d /var/lib/mysql/icscf ]; then 29 | echo 'Creating database for I-CSCF' 30 | mysqladmin -u root create icscf 31 | mysql -u root icscf < /kamailio/misc/examples/ims/icscf/icscf.sql 32 | fi 33 | 34 | if [ ! -d /var/lib/mysql/scscf ]; then 35 | echo 'Creating database for S-CSCF' 36 | mysqladmin -u root create scscf 37 | mysql -u root scscf < /kamailio/utils/kamctl/mysql/standard-create.sql 38 | mysql -u root scscf < /kamailio/utils/kamctl/mysql/presence-create.sql 39 | mysql -u root scscf < /kamailio/utils/kamctl/mysql/ims_usrloc_scscf-create.sql 40 | mysql -u root scscf < /kamailio/utils/kamctl/mysql/ims_dialog-create.sql 41 | mysql -u root scscf < /kamailio/utils/kamctl/mysql/ims_charging-create.sql 42 | fi 43 | 44 | if [ ! -d /var/lib/mysql/hss_db ]; then 45 | echo 'Creating database for FHoSS' 46 | mysql -u root < /mnt/mysql/fhoss/init.sql 47 | mysql -u root hss_db < /mnt/mysql/fhoss/hss_db.sql 48 | mysql -u root hss_db < /mnt/mysql/fhoss/userdata.sql 49 | fi 50 | 51 | 52 | if [ ! -f /var/lib/mysql/kamailio.sem ]; then 53 | echo 'Grant privileges.' 54 | mysql -u root < /mnt/mysql/init.sql 55 | :> /var/lib/mysql/kamailio.sem 56 | fi 57 | 58 | chown -R mysql:mysql /var/lib/mysql 59 | echo 'MySQL is running.' 60 | while true; do 61 | sleep 1 62 | done 63 | -------------------------------------------------------------------------------- /mysql/mysqld.cnf: -------------------------------------------------------------------------------- 1 | # 2 | # The MySQL database server configuration file. 3 | # 4 | # You can copy this to one of: 5 | # - "/etc/mysql/my.cnf" to set global options, 6 | # - "~/.my.cnf" to set user-specific options. 7 | # 8 | # One can use all long options that the program supports. 9 | # Run program with --help to get a list of available options and with 10 | # --print-defaults to see which it would actually understand and use. 11 | # 12 | # For explanations see 13 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 14 | 15 | # This will be passed to all mysql clients 16 | # It has been reported that passwords should be enclosed with ticks/quotes 17 | # escpecially if they contain "#" chars... 18 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 19 | 20 | # Here is entries for some specific programs 21 | # The following values assume you have at least 32M ram 22 | 23 | [mysqld_safe] 24 | socket = /var/run/mysqld/mysqld.sock 25 | nice = 0 26 | 27 | [mysqld] 28 | # 29 | # * Basic Settings 30 | # 31 | user = mysql 32 | pid-file = /var/run/mysqld/mysqld.pid 33 | socket = /var/run/mysqld/mysqld.sock 34 | port = 3306 35 | basedir = /usr 36 | datadir = /var/lib/mysql 37 | tmpdir = /tmp 38 | lc-messages-dir = /usr/share/mysql 39 | skip-external-locking 40 | # 41 | # Instead of skip-networking the default is now to listen only on 42 | # localhost which is more compatible and is not less secure. 43 | bind-address = 0.0.0.0 44 | # 45 | # * Fine Tuning 46 | # 47 | key_buffer_size = 16M 48 | max_allowed_packet = 16M 49 | thread_stack = 192K 50 | thread_cache_size = 8 51 | # This replaces the startup script and checks MyISAM tables if needed 52 | # the first time they are touched 53 | myisam-recover-options = BACKUP 54 | #max_connections = 100 55 | #table_open_cache = 64 56 | #thread_concurrency = 10 57 | # 58 | # * Query Cache Configuration 59 | # 60 | query_cache_limit = 1M 61 | query_cache_size = 16M 62 | # 63 | # * Logging and Replication 64 | # 65 | # Both location gets rotated by the cronjob. 66 | # Be aware that this log type is a performance killer. 67 | # As of 5.1 you can enable the log at runtime! 68 | #general_log_file = /var/log/mysql/mysql.log 69 | #general_log = 1 70 | # 71 | # Error log - should be very few entries. 72 | # 73 | log_error = /var/log/mysql/error.log 74 | # 75 | # Here you can see queries with especially long duration 76 | #slow_query_log = 1 77 | #slow_query_log_file = /var/log/mysql/mysql-slow.log 78 | #long_query_time = 2 79 | #log-queries-not-using-indexes 80 | # 81 | # The following can be used as easy to replay backup logs or for replication. 82 | # note: if you are setting up a replication slave, see README.Debian about 83 | # other settings you may need to change. 84 | #server-id = 1 85 | #log_bin = /var/log/mysql/mysql-bin.log 86 | expire_logs_days = 10 87 | max_binlog_size = 100M 88 | #binlog_do_db = include_database_name 89 | #binlog_ignore_db = include_database_name 90 | # 91 | # * InnoDB 92 | # 93 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 94 | # Read the manual for more InnoDB related options. There are many! 95 | # 96 | # * Security Features 97 | # 98 | # Read the manual, too, if you want chroot! 99 | # chroot = /var/lib/mysql/ 100 | # 101 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 102 | # 103 | # ssl-ca=/etc/mysql/cacert.pem 104 | # ssl-cert=/etc/mysql/server-cert.pem 105 | # ssl-key=/etc/mysql/server-key.pem 106 | -------------------------------------------------------------------------------- /network-topology.dot: -------------------------------------------------------------------------------- 1 | digraph open5gs_network { 2 | graph [label="Open5GS Network Topology"]; 3 | rankdir=LR; 4 | 5 | eNB [label="eNB\n172.18.0.7"]; 6 | 7 | subgraph CN { 8 | bgcolor="green"; 9 | label="Open5GS"; 10 | HSS [label="HSS\n172.18.0.2"]; 11 | MME [label="MME\n172.18.0.3"]; 12 | PCRF [label="PCRF\n172.18.0.6"]; 13 | PGW [label="PGW\n172.18.0.5"]; 14 | SGW [label="SGW\n172.18.0.4"]; 15 | } 16 | subgraph IMS { 17 | bgcolor="blue"; 18 | label="Kamailio IMS"; 19 | PCSCF [label="P-CSCF\n172.18.0.12"]; 20 | ICSCF [label="I-CSCF\n172.18.0.13"]; 21 | SCSCF [label="S-CSCF\n172.18.0.14"]; 22 | FHoSS [label="FHoSS\n172.18.0.15"]; 23 | RTP [label="RTPEngine\n172.18.0.18"]; 24 | } 25 | 26 | MONGO [label="MongoDB"]; 27 | 28 | // dashed: for diameter 29 | // solid: for TCP & UDP 30 | 31 | HSS -> MME [label="S6a\n(3868/SCTP)" style="dashed" color="blue"]; 32 | MME -> HSS [label="S6a\n(3868/SCTP)" style="dashed" color="blue"]; 33 | HSS -> MONGO [label="(27017/TCP)" dir=both]; 34 | MME -> SGW [label="S11\n(2123/UDP)" color="red"]; 35 | MME -> SGSAP [label="(29118/SCTP)"]; 36 | SGSAP -> MME [label="(29118/SCTP)"]; 37 | PCRF -> PGW [label="S7\n(3868/SCTP)" style="dashed" color="blue"]; 38 | PCRF -> PCSCF [label="Rx\n(3871/SCTP)" style="dashed" color="blue"]; 39 | PGW -> PCRF [label="S7\n(3868/SCTP)" style="dashed" color="blue"]; 40 | PGW -> PCSCF [label="SGi\n(3871/SCTP)" style="dashed" color="blue"]; 41 | PGW -> SGW [label="S5U\n(2152/UDP)" color="green"]; 42 | SGW -> PGW [label="S5C\n(2123/UDP)" color="red"]; 43 | PGW -> SGW [label="S5C\n(2123/UDP)" color="red"]; 44 | SGW -> PGW [label="S5U\n(2152/UDP)" color="green"]; 45 | SGW -> eNB [label="S1U\n(2152/UDP)" color="green"]; 46 | SGW -> MME [label="S11\n(2123/UDP)" color="red"]; 47 | eNB -> MME [label="S1AP\n(36412/SCTP)" color="red"]; 48 | eNB -> SGW [label="S1U\n(2152/UDP)" color="green"]; 49 | MME -> eNB [label="S1C\n(2123/UDP)" color="red"]; 50 | 51 | PCSCF -> PCRF [label="Rx\n(3868/SCTP)" style="dashed" color="blue"]; 52 | PCSCF -> FHoSS [label="(3868/SCTP)" style="dashed" color="blue"]; 53 | PCSCF -> RTP [label="RTP (2223/UDP)" color="green"]; 54 | ICSCF -> FHoSS [label="(3868/SCTP)" style="dashed" color="blue"]; 55 | SCSCF -> FHoSS [label="(3868/SCTP)" style="dashed" color="blue"]; 56 | FHoSS -> ICSCF [label="(3869/SCTP)" style="dashed" color="blue"]; 57 | FHoSS -> SCSCF [label="(3870/SCTP)" style="dashed" color="blue"]; 58 | } 59 | -------------------------------------------------------------------------------- /network-topology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miaoski/docker_open5gs/be1de8e62a8d200bc47503e1b129a4c6425e608a/network-topology.png -------------------------------------------------------------------------------- /pcrf/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM docker_open5gs 28 | 29 | # Expose port 3868 for Diameter queries 30 | EXPOSE 3868/udp 31 | EXPOSE 3868/tcp 32 | EXPOSE 3868/sctp 33 | EXPOSE 5868/udp 34 | EXPOSE 5868/tcp 35 | EXPOSE 5868/sctp 36 | 37 | CMD /mnt/pcrf/pcrf_init.sh && sleep 10 && \ 38 | cd install/bin && ./open5gs-pcrfd -------------------------------------------------------------------------------- /pcrf/pcrf.yaml: -------------------------------------------------------------------------------- 1 | db_uri: mongodb://MONGO_IP/open5gs 2 | 3 | logger: 4 | file: /open5gs/install/var/log/open5gs/pcrf.log 5 | level: DEBUG 6 | 7 | parameter: 8 | no_ipv6: true 9 | prefer_ipv4: true 10 | 11 | pcrf: 12 | freeDiameter: 13 | identity: pcrf.epc.mnc001.mcc001.3gppnetwork.org 14 | realm: epc.mnc001.mcc001.3gppnetwork.org 15 | port: 3868 16 | sec_port: 5868 17 | listen_on: PCRF_IP 18 | load_extension: 19 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx 20 | conf: 0x8888 21 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx 22 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx 23 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx 24 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx 25 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx 26 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx 27 | connect: 28 | - identity: pgw.epc.mnc001.mcc001.3gppnetwork.org 29 | addr: PGW_IP 30 | port: 3868 31 | - identity: pcscf.ims.mnc001.mcc001.3gppnetwork.org 32 | addr: PCSCF_IP 33 | port: 3871 34 | -------------------------------------------------------------------------------- /pcrf/pcrf_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 2-Clause License 4 | 5 | # Copyright (c) 2019, Supreeth Herle 6 | # All rights reserved. 7 | 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | export IP_ADDR=$(awk 'END{print $1}' /etc/hosts) 30 | 31 | cp /mnt/pcrf/pcrf.yaml install/etc/open5gs 32 | sed -i 's|MONGO_IP|'$MONGO_IP'|g' install/etc/open5gs/pcrf.yaml 33 | sed -i 's|NAME|'$NAME'|g' install/etc/open5gs/pcrf.yaml 34 | sed -i 's|REALM|'$REALM'|g' install/etc/open5gs/pcrf.yaml 35 | sed -i 's|PCRF_IP|'$IP_ADDR'|g' install/etc/open5gs/pcrf.yaml 36 | sed -i 's|PGW_IP|'$PGW_IP'|g' install/etc/open5gs/pcrf.yaml 37 | sed -i 's|PCSCF_IP|'$PCSCF_IP'|g' install/etc/open5gs/pcrf.yaml 38 | -------------------------------------------------------------------------------- /pcscf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM open5gs_kamailio 2 | 3 | ADD kamailio_pcscf /etc/kamailio_pcscf/ 4 | 5 | # ims_ipsec_pcscf listens to ports 5060-5064 6 | EXPOSE 5060/tcp 7 | EXPOSE 5060/udp 8 | EXPOSE 5062/tcp 9 | EXPOSE 5062/udp 10 | EXPOSE 5063/tcp 11 | EXPOSE 5063/udp 12 | 13 | # ipsec client/server 14 | EXPOSE 5100-5109/tcp 15 | EXPOSE 5100-5109/udp 16 | EXPOSE 6100-6109/tcp 17 | EXPOSE 6100-6109/udp 18 | 19 | # Diameter 20 | EXPOSE 3871/tcp 21 | EXPOSE 3871/sctp 22 | 23 | COPY ./init.d/kamailio_pcscf /etc/init.d/kamailio_pcscf 24 | COPY ./default/kamailio_pcscf /etc/default/kamailio_pcscf 25 | 26 | CMD /mnt/pcscf/pcscf_init.sh 27 | -------------------------------------------------------------------------------- /pcscf/default/kamailio_pcscf: -------------------------------------------------------------------------------- 1 | # 2 | # Kamailio startup options 3 | # 4 | 5 | # Set to yes to enable kamailio, once configured properly. 6 | RUN_KAMAILIO=yes 7 | 8 | # User to run as 9 | #USER=kamailio 10 | 11 | # Group to run as 12 | #GROUP=kamailio 13 | 14 | # Amount of shared and private memory to allocate 15 | # for the running Kamailio server (in Mb) 16 | #SHM_MEMORY=64 17 | #PKG_MEMORY=8 18 | 19 | # Config file 20 | #CFGFILE=/etc/kamailio/kamailio.cfg 21 | 22 | # Enable the server to leave a core file when it crashes. 23 | # Set this to 'yes' to enable Kamailio to leave a core file when it crashes 24 | # or 'no' to disable this feature. This option is case sensitive and only 25 | # accepts 'yes' and 'no' and only in lowercase letters. 26 | # On some systems it is necessary to specify a directory for the core files 27 | # to get a dump. Look into the kamailio init file for an example configuration. 28 | #DUMP_CORE=yes 29 | -------------------------------------------------------------------------------- /pcscf/init.d/kamailio_pcscf: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | ### BEGIN INIT INFO 4 | # Provides: kamailio 5 | # Required-Start: $syslog $network $local_fs $remote_fs $time 6 | # Should-Start: $named slapd mysql postgresql snmpd radiusd 7 | # Should-Stop: $named slapd mysql postgresql snmpd radiusd 8 | # Required-Stop: $syslog $network $local_fs $remote_fs 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: Start the Kamailio SIP proxy server 12 | # Description: Start the Kamailio SIP proxy server 13 | ### END INIT INFO 14 | 15 | . /lib/lsb/init-functions 16 | 17 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 18 | DAEMON=/usr/local/sbin/kamailio 19 | NAME=`basename "$0"` 20 | DESC="Kamailio SIP Server" 21 | HOMEDIR=/var/run/$NAME 22 | PIDFILE=$HOMEDIR/$NAME.pid 23 | DEFAULTS=/etc/default/$NAME 24 | CFGFILE=/etc/kamailio_pcscf/kamailio_pcscf.cfg 25 | RUN_KAMAILIO=no 26 | USER=root 27 | GROUP=root 28 | # Amount of shared and private memory to allocate 29 | # for the running Kamailio server (in Mb) 30 | SHM_MEMORY=64 31 | PKG_MEMORY=8 32 | DUMP_CORE=no 33 | 34 | # Do not start kamailio if fork=no is set in the config file 35 | # otherwise the boot process will just stop 36 | check_fork () 37 | { 38 | if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then 39 | log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead" 40 | exit 0 41 | fi 42 | } 43 | 44 | check_kamailio_config () 45 | { 46 | # Check if kamailio configuration is valid before starting the server 47 | set +e 48 | out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null) 49 | retcode=$? 50 | set -e 51 | if [ "$retcode" != '0' ]; then 52 | log_failure_msg "Not starting $DESC: invalid configuration file!" 53 | log_failure_msg 54 | log_failure_msg "$out" 55 | log_failure_msg 56 | exit 1 57 | fi 58 | } 59 | 60 | create_radius_seqfile () 61 | { 62 | # Create a radius sequence file to be used by the radius client if 63 | # radius accounting is enabled. This is needed to avoid any issue 64 | # with the file not being writable if kamailio first starts as user 65 | # root because DUMP_CORE is enabled and creates this file as user 66 | # root and then later it switches back to user kamailio and cannot 67 | # write to the file. If the file exists before kamailio starts, it 68 | # won't change it's ownership and will be writable for both root 69 | # and kamailio, no matter what options are chosen at install time 70 | RADIUS_SEQ_FILE="$HOMEDIR/kamailio_radius.seq" 71 | if [ -d $HOMEDIR ]; then 72 | chown ${USER}:${GROUP} $HOMEDIR 73 | 74 | if [ ! -f $RADIUS_SEQ_FILE ]; then 75 | touch $RADIUS_SEQ_FILE 76 | fi 77 | 78 | chown ${USER}:${GROUP} $RADIUS_SEQ_FILE 79 | chmod 660 $RADIUS_SEQ_FILE 80 | fi 81 | } 82 | 83 | test -f $DAEMON || exit 0 84 | 85 | # Load startup options if available 86 | if [ -f $DEFAULTS ]; then 87 | . $DEFAULTS || true 88 | fi 89 | 90 | if [ "$RUN_KAMAILIO" != "yes" ]; then 91 | log_failure_msg "Kamailio not yet configured. Edit /etc/default/$NAME first." 92 | exit 0 93 | fi 94 | 95 | set -e 96 | 97 | SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`)) 98 | PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`)) 99 | [ -z "$USER" ] && USER=kamailio 100 | [ -z "$GROUP" ] && GROUP=kamailio 101 | [ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64 102 | [ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4 103 | 104 | if test "$DUMP_CORE" = "yes" ; then 105 | # set proper ulimit 106 | ulimit -c unlimited 107 | 108 | # directory for the core dump files 109 | # COREDIR=/home/corefiles 110 | # [ -d $COREDIR ] || mkdir $COREDIR 111 | # chmod 777 $COREDIR 112 | # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern 113 | fi 114 | 115 | # /var/run can be a tmpfs 116 | if [ ! -d $HOMEDIR ]; then 117 | mkdir -p $HOMEDIR 118 | chown ${USER}:${GROUP} $HOMEDIR 119 | fi 120 | 121 | OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP -DD -E -e" 122 | 123 | case "$1" in 124 | start|debug) 125 | check_kamailio_config 126 | create_radius_seqfile 127 | 128 | if [ "$1" != "debug" ]; then 129 | check_fork 130 | fi 131 | 132 | log_daemon_msg "Starting $DESC: $NAME" 133 | start-stop-daemon --start --quiet --pidfile $PIDFILE \ 134 | --exec $DAEMON -- $OPTIONS || log_failure_msg " already running" 135 | log_end_msg 0 136 | ;; 137 | stop) 138 | log_daemon_msg "Stopping $DESC: $NAME" 139 | start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \ 140 | --exec $DAEMON --retry 5 141 | log_end_msg 0 142 | ;; 143 | restart|force-reload) 144 | check_kamailio_config 145 | create_radius_seqfile 146 | 147 | $0 stop 148 | $0 start 149 | ;; 150 | status) 151 | log_daemon_msg "Status of $DESC: " 152 | 153 | status_of_proc -p"$PIDFILE" $NAME $NAME 154 | ;; 155 | *) 156 | N=/etc/init.d/$NAME 157 | echo "Usage: $N {start|stop|restart|force-reload|status|debug}" >&2 158 | exit 1 159 | ;; 160 | esac 161 | 162 | exit 0 163 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/README.md: -------------------------------------------------------------------------------- 1 | # Kamailio - Proxy-CSCF Example Configuration File 2 | 3 | Project Website: 4 | 5 | * http://www.kamailio.org 6 | 7 | ## Database Structure 8 | 9 | The necessary Database files for the Proxy-CSCF can be found in the utils/kamctl/mysql/ folder. 10 | 11 | The following tables (or files) are required: 12 | 13 | * ims_dialog-create.sql 14 | * ims_usrloc_pcscf-create.sql 15 | * presence-create.sql 16 | * standard-create.sql 17 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/dispatcher.list: -------------------------------------------------------------------------------- 1 | # SBC's 2 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/pcscf.cfg: -------------------------------------------------------------------------------- 1 | # IP-Adress for incoming SIP-Traffic, in the following format: 2 | 3 | # SIP / UDP 4 | listen=udp:PCSCF_IP:5060 5 | # Uncomment the below line only when UE is behind double NAT (e.g. VoIP calling over WiFi/ CN behind a NAT) 6 | #listen=udp:PCSCF_IP:5060 advertise 172.24.15.30:5060 7 | # SIP / TCP 8 | listen=tcp:PCSCF_IP:5060 9 | # Uncomment the below line only when UE is behind double NAT (e.g. VoIP calling over WiFi/ CN behind a NAT) 10 | #listen=tcp:PCSCF_IP:5060 advertise 172.24.15.30:5060 11 | # SIP / TCP/TLS 12 | #listen=tls:11.22.33.44:5061 13 | 14 | # IPSEC / UDP 15 | #!define IPSEC_LISTEN_ADDR "PCSCF_IP" 16 | #!define IPSEC_CLIENT_PORT 5100 17 | #!define IPSEC_SERVER_PORT 6100 18 | 19 | # IP used in Rx_AAR_Register - IP of this P-CSCF, to be used in the flow for the AF-signaling 20 | #!define RX_AF_SIGNALING_IP "PCSCF_IP" 21 | # Uncomment the below line only when UE is behind double NAT (e.g. VoIP calling over WiFi/ CN behind a NAT) 22 | ##!define RX_AF_SIGNALING_IP "172.24.15.30" 23 | 24 | alias=pcscf.ims.mnc001.mcc001.3gppnetwork.org 25 | 26 | #!define MY_WS_PORT 80 27 | #!define MY_WSS_PORT 443 28 | 29 | #!define PCSCF_URL "sip:pcscf.ims.mnc001.mcc001.3gppnetwork.org:5060" 30 | 31 | #!define TCP_PROCESSES 8 32 | 33 | #!subst "/NETWORKNAME/ims.mnc001.mcc001.3gppnetwork.org/" 34 | #!subst "/HOSTNAME/pcscf.ims.mnc001.mcc001.3gppnetwork.org/" 35 | #!subst "/PCRF_REALM/epc.mnc001.mcc001.3gppnetwork.org/" 36 | 37 | # SIP-Address of capturing node, if not set, capturing is disabled. 38 | ##!define CAPTURE_NODE "sip:127.0.0.1:9060" 39 | 40 | # Allowed IPs for XML-RPC-Queries 41 | ##!define XMLRPC_WHITELIST_1 "127.0.0.1" 42 | ##!define XMLRPC_WHITELIST_2 "127.0.0.1" 43 | ##!define XMLRPC_WHITELIST_3 "127.0.0.1" 44 | 45 | # Databases: 46 | #!define DB_URL "mysql://pcscf:heslo@MYSQL_IP/pcscf" 47 | ##!define DB_URL2 "con2=>mysql://pcscf:heslo@127.0.0.1/pcscf" 48 | 49 | #!define SQLOPS_DBURL "pcscf=>mysql://pcscf:heslo@MYSQL_IP/pcscf" 50 | 51 | #! Optional: Server-URL for Websocket-Requests 52 | ##!define WEBSOCKET_WEBSERVER "phone.ng-voice.com" 53 | 54 | ##!define TRF_FUNCTION "trf.ims.mnc001.mcc001.3gppnetwork.org" 55 | 56 | # 57 | # Several features can be enabled using '#!define WITH_FEATURE' directives: 58 | # 59 | # *** To run in debug mode: 60 | # - define WITH_DEBUG 61 | # 62 | # *** To enable nat traversal execute: 63 | # - define WITH_NAT 64 | # - define the connection to the RTP-Proxy: RTPPROXY_ADDRESS 65 | # 66 | # *** To force alls calls through the RTP-Proxy 67 | # - this will automagically enable NAT-Traversal 68 | # - define FORCE_RTPRELAY 69 | # 70 | # *** To enable IPv4/IPv6 Translation (RTPProxy) 71 | # - this will automagically enable NAT-Traversal 72 | # - define WITH_RTPIPV4 73 | # 74 | # *** To enable TCP support execute: 75 | # - define WITH_TCP 76 | # 77 | # *** To enable TLS support execute: 78 | # - adjust CFGDIR/tls.cfg as needed 79 | # - define WITH_TLS 80 | # - this will automagically enable TCP 81 | # 82 | # *** To enable XMLRPC support execute: 83 | # - define WITH_XMLRPC 84 | # - this will automagically enable TCP 85 | # 86 | # *** To enable anti-flood detection execute: 87 | # - adjust pike and htable=>ipban settings as needed (default is 88 | # block if more than 16 requests in 2 seconds and ban for 300 seconds) 89 | # - define WITH_ANTIFLOOD 90 | # 91 | # *** To enable the Rx-Interface: 92 | # - Configure Rx-Diameter-Interface in pcscf.xml 93 | # - define WITH_RX 94 | # 95 | # *** To enable a Homer SIP-Capter-Node: 96 | # - define CAPTURE_NODE with a proper address 97 | # 98 | # *** To enable support for the SEMS-SBC 99 | # - define WITH_SBC 100 | # - configure dispatcher-list with a set of SBC's 101 | 102 | # 103 | # Enabled Features for this host: 104 | ##!define WITH_DEBUG 105 | #!define WITH_NAT 106 | #!define WITH_NATPING 107 | #!define FORCE_RTPRELAY 108 | ##!define WITH_TLS 109 | ##!define WITH_XMLRPC 110 | ##!define WITH_IPBLOCK 111 | ##!define WITH_ANTIFLOOD 112 | #!define WITH_RX 113 | #!define WITH_RX_REG 114 | #!define WITH_RX_CALL 115 | #!define WITH_TCP 116 | ##!define WITH_RTPIPV4 117 | ##!define WITH_SBC 118 | ##!define WITH_SBC_CALL 119 | ##!define WITH_REGINFO 120 | ##!define WITH_RTPPING 121 | ##!define WITH_WEBSOCKET 122 | #!define WITH_IPSEC 123 | #!define WITH_IMS_HDR_CACHE 124 | #!define WITH_PING_UDP 125 | #!define WITH_PING_TCP 126 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/pcscf.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/route/mo.cfg: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Originating, Intial Requests 3 | ###################################################################### 4 | route[MO] 5 | { 6 | # Strip Transport from RURI: 7 | $ru = $(ru{re.subst,/;transport=[A-Za-z]*//g}); 8 | xnotice("PCSCF MO: \n Destination URI: $du\n Request URI: $ru\n"); 9 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 10 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 11 | xnotice("Contact header: $ct\n"); 12 | 13 | # Process route headers, if any: 14 | loose_route(); 15 | if (!pcscf_is_registered("location")) { 16 | send_reply("403","Forbidden - You must register first with a S-CSCF"); 17 | exit; 18 | } 19 | 20 | # We do not trust the user, let's remove the P-Asserted-Identity, if any: 21 | remove_hf("P-Asserted-Identity"); 22 | remove_hf("P-Preferred-Identity"); 23 | 24 | # Add P-Charging-Vector 25 | sip_p_charging_vector("g"); 26 | 27 | if (is_present_hf("P-Preferred-Identity") && pcscf_assert_identity("location", "$hdr(P-Preferred-Identity)")) { 28 | append_hf("P-Asserted-Identity: $hdr(P-Preferred-Identity)\r\n"); 29 | } else if (is_present_hf("P-Asserted-Identity") && pcscf_assert_identity("location", "$hdr(P-Asserted-Identity)")) { 30 | append_hf("P-Asserted-Identity: $hdr(P-Asserted-Identity)\r\n"); 31 | } else if (pcscf_assert_identity("location", "$(fu{tobody.uri})")) { 32 | append_hf("P-Asserted-Identity: <$(fu{tobody.uri})>\r\n"); 33 | } else { 34 | append_hf("P-Asserted-Identity: <$pcscf_asserted_identity>\r\n"); 35 | } 36 | 37 | if (!pcscf_follows_service_routes("location")){ 38 | #Variant 1 - deny access to the network 39 | #send_reply("400","Bad Request - Not following indicated service routes"); 40 | #break; 41 | 42 | #Variant 2 - enforce routes and let the dialog continue 43 | pcscf_force_service_routes("location"); 44 | } 45 | 46 | # add IBCF/THIG route here if required 47 | # Check for "sec-agree" in the Require header: 48 | if (is_present_hf("Require") && $hdr(Require) =~ ".*sec-agree.*") { 49 | # Remove the old Require-Header: 50 | remove_hf("Require"); 51 | # Replace ", sec-agree" with "" 52 | $var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi}); 53 | if ($(var(new_hdr){s.len}) > 0) { 54 | append_hf("Require: $var(new_hdr)\r\n"); 55 | } 56 | } 57 | 58 | # Check for "sec-agree" in the Proxy-Require header: 59 | if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~ ".*sec-agree.*") { 60 | # Remove the old Proxy-Require-Header: 61 | remove_hf("Proxy-Require"); 62 | # Replace ", sec-agree" with "" 63 | $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi}); 64 | if ($(var(new_hdr){s.len}) > 0) { 65 | append_hf("Proxy-Require: $var(new_hdr)\r\n"); 66 | } 67 | } 68 | remove_hf("Security-Verify"); 69 | 70 | #!ifdef TRF_FUNCTION 71 | $var(trf) = TRF_FUNCTION; 72 | # Check for "sec-agree" in the Proxy-Require header: 73 | if (is_present_hf("Feature-Caps")) { 74 | # Remove the old Proxy-Require-Header: 75 | remove_hf("Feature-Caps"); 76 | append_hf("Feature-Caps: $hdr(Feature-Caps);+g.3gpp.trf=\"\"\r\n"); 77 | } else { 78 | append_hf("Feature-Caps: *;+g.3gpp.trf=\"\"\r\n"); 79 | } 80 | #!endif 81 | # Add a visited Network-ID-Header: 82 | if (is_present_hf("P-Visited-Network-ID")) { 83 | $var(new_hdr) = "NETWORKNAME, "+$hdr(P-Visited-Network-ID); 84 | append_hf("P-Visited-Network-ID: $var(new_hdr)\r\n"); 85 | } else { 86 | append_hf("P-Visited-Network-ID: NETWORKNAME\r\n"); 87 | } 88 | set_dlg_profile("orig"); 89 | t_on_reply("MO_reply"); 90 | } 91 | 92 | ###################################################################### 93 | # Replies to Originating Initial Requests 94 | ###################################################################### 95 | onreply_route[MO_reply] { 96 | xnotice("PCSCF MO_reply: \n Destination URI: $du\n Request URI: $ru\n"); 97 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 98 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 99 | xnotice("Contact header: $ct\n"); 100 | if (is_present_hf("C-Params")) { 101 | remove_hf("Contact"); 102 | remove_hf("C-Params"); 103 | append_hf("Contact: $ct;$hdr(C-Params)\r\n"); 104 | } 105 | ##!ifdef WITH_IPSEC 106 | #if ($sht(ipsec_clients=>$(T_req($ct){nameaddr.uri})) != $null) { 107 | #ipsec_forward("location"); 108 | #} 109 | ##!endif 110 | # In case of 1xx and 2xx do NAT 111 | if(status=~"[12][0-9][0-9]") 112 | route(NATMANAGE); 113 | #!ifdef WITH_RX 114 | if (t_check_status("183|200") && has_body("application/sdp")){ 115 | xlog("L_DBG", "IMS: Received 183/200 inside orig_initial_reply\n"); 116 | 117 | if (t_is_retr_async_reply()) { 118 | xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n"); 119 | drop(); 120 | } 121 | 122 | xlog("L_DBG","Diameter: Orig authorizing media via Rx\n"); 123 | $avp(FTAG_CUSTOM_AVP)=$ft; 124 | $avp(TTAG_CUSTOM_AVP)=$tt; 125 | $avp(CALLID_CUSTOM_AVP)=$ci; 126 | 127 | if (Rx_AAR("MO_aar_reply","orig","",-1) == 0) { 128 | exit; 129 | } 130 | } 131 | } 132 | 133 | route[MO_aar_reply] 134 | { 135 | #this is async so to know status we have to check the reply avp 136 | switch ($avp(s:aar_return_code)) { 137 | case 1: 138 | xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n"); 139 | break; 140 | default: 141 | xlog("L_ERR", "IMS: AAR failed Orig\n"); 142 | xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)"); 143 | xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)"); 144 | xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)"); 145 | #comment this if you want to allow even if Rx fails 146 | if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){ 147 | dlg_terminate("all", "Sorry no QoS available"); 148 | exit; 149 | } 150 | } 151 | #!endif 152 | } 153 | 154 | 155 | ###################################################################### 156 | # In-Dialog-Mo-Requests 157 | ###################################################################### 158 | route[MO_indialog] { 159 | xnotice("PCSCF MO_indialog: \n Destination URI: $du\n Request URI: $ru\n"); 160 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 161 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 162 | xnotice("Contact header: $ct\n"); 163 | setflag(FLT_MOBILE_ORIG); 164 | t_on_reply("MO_indialog_reply"); 165 | } 166 | 167 | onreply_route[MO_indialog_reply] { 168 | xnotice("PCSCF MO_indialog_reply: \n Destination URI: $du\n Request URI: $ru\n"); 169 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 170 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 171 | xnotice("Contact header: $ct\n"); 172 | # In case of 1xx and 2xx do NAT 173 | if(status=~"[12][0-9][0-9]") 174 | route(NATMANAGE); 175 | 176 | #!ifdef WITH_RX 177 | if(t_check_status("200") && is_method("INVITE")) { 178 | if (t_is_retr_async_reply()) { 179 | xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n"); 180 | drop(); 181 | } 182 | 183 | xlog("L_DBG", "IMS: ORIG_SUBSEQUENT reply. This is a 200 OK to a re-INVITE\n"); 184 | xlog("L_DBG","Diameter: Orig authorizing media via Rx\n"); 185 | $avp(FTAG_CUSTOM_AVP)=$ft; 186 | $avp(TTAG_CUSTOM_AVP)=$tt; 187 | $avp(CALLID_CUSTOM_AVP)=$ci; 188 | 189 | if (Rx_AAR("MO_indialog_aar_reply","orig","",-1) == 0) { 190 | exit; 191 | } 192 | } 193 | } 194 | 195 | route[MO_indialog_aar_reply] 196 | { 197 | #this is async so to know status we have to check the reply avp 198 | switch ($avp(s:aar_return_code)) { 199 | case 1: 200 | xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n"); 201 | break; 202 | default: 203 | xlog("L_ERR", "IMS: AAR failed Orig\n"); 204 | xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)"); 205 | xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)"); 206 | xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)"); 207 | #comment this if you want to allow even if Rx fails 208 | if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){ 209 | dlg_terminate("all", "Sorry no QoS available"); 210 | exit; 211 | } 212 | } 213 | #!endif 214 | } 215 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/route/mt.cfg: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Terminating, Initial requests 3 | ###################################################################### 4 | route[MT] { 5 | xnotice("PCSCF MT: \n Destination URI: $du\n Request URI: $ru\n"); 6 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 7 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 8 | xnotice("Contact header: $ct\n"); 9 | set_dlg_profile("term"); 10 | #!ifdef WITH_IPSEC 11 | ipsec_forward("location"); 12 | #!endif 13 | t_on_reply("MT_reply"); 14 | } 15 | 16 | ###################################################################### 17 | # Replies to Originating Initial Requests 18 | ###################################################################### 19 | onreply_route[MT_reply] { 20 | xnotice("PCSCF MT_reply: \n Destination URI: $du\n Request URI: $ru\n"); 21 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 22 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 23 | xnotice("Contact header: $ct\n"); 24 | if (!strempty($(ct{tobody.params}))) { 25 | append_hf("C-Params: $(ct{tobody.params})\r\n"); 26 | } 27 | 28 | # In case of 1xx and 2xx do NAT 29 | if(status=~"[12][0-9][0-9]") 30 | route(NATMANAGE); 31 | #!ifdef WITH_RX 32 | if (t_check_status("183|200") && has_body("application/sdp")){ 33 | xnotice("PCSCF MT_reply: \n Destination URI: $du\n Request URI: $ru\n"); 34 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 35 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 36 | xnotice("Contact header: $ct\n"); 37 | xlog("L_DBG", "IMS: Received 183 inside term_initial_reply\n"); 38 | 39 | xlog("L_DBG", "About to test if this is a retransmitted reply which is still currently suspended\n"); 40 | if (t_is_retr_async_reply()) { 41 | xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n"); 42 | drop(); 43 | } 44 | 45 | xlog("L_DBG","Diameter: Term authorizing media via Rx\n"); 46 | $avp(FTAG_CUSTOM_AVP)=$ft; 47 | $avp(TTAG_CUSTOM_AVP)=$tt; 48 | $avp(CALLID_CUSTOM_AVP)=$ci; 49 | 50 | if (Rx_AAR("MT_aar_reply","term","",-1) == 0) { 51 | exit; 52 | } 53 | } 54 | } 55 | 56 | route[MT_aar_reply] 57 | { 58 | xlog("L_DBG", "IMS: TERM_SESSION_AAR_REPLY\n"); 59 | 60 | #this is async so to know status we have to check the reply avp 61 | switch ($avp(s:aar_return_code)) { 62 | case 1: 63 | xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n"); 64 | break; 65 | default: 66 | xlog("L_ERR", "IMS: AAR failed Orig\n"); 67 | xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)"); 68 | xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)"); 69 | xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)"); 70 | #comment this if you want to allow even if Rx fails 71 | if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){ 72 | dlg_terminate("all", "Sorry no QoS available"); 73 | exit; 74 | } 75 | } 76 | #!endif 77 | } 78 | 79 | 80 | ###################################################################### 81 | # In-Dialog-MT-Requests 82 | ###################################################################### 83 | route[MT_indialog] { 84 | xnotice("PCSCF MT_indialog: \n Destination URI: $du\n Request URI: $ru\n"); 85 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 86 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 87 | xnotice("Contact header: $ct\n"); 88 | #resetflag(FLT_MOBILE_ORIG); 89 | t_on_reply("MT_indialog_reply"); 90 | } 91 | 92 | onreply_route[MT_indialog_reply] { 93 | xnotice("PCSCF MT_indialog_reply: \n Destination URI: $du\n Request URI: $ru\n"); 94 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 95 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 96 | xnotice("Contact header: $ct\n"); 97 | # In case of 1xx and 2xx do NAT 98 | if(status=~"[12][0-9][0-9]") 99 | route(NATMANAGE); 100 | 101 | #!ifdef WITH_RX 102 | if(t_check_status("200") && is_method("INVITE")) { 103 | if (t_is_retr_async_reply()) { 104 | xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n"); 105 | drop(); 106 | } 107 | 108 | xlog("L_DBG", "IMS: TERM_SUBSEQUENT reply. This is a 200 OK to a re-INVITE\n"); 109 | xlog("L_DBG","Diameter: Term authorizing media via Rx\n"); 110 | $avp(FTAG_CUSTOM_AVP)=$ft; 111 | $avp(TTAG_CUSTOM_AVP)=$tt; 112 | $avp(CALLID_CUSTOM_AVP)=$ci; 113 | 114 | if (Rx_AAR("MT_indialog_aar_reply","term","",-1) == 0) { 115 | exit; 116 | } 117 | } 118 | } 119 | 120 | route[MT_indialog_aar_reply] 121 | { 122 | #this is async so to know status we have to check the reply avp 123 | switch ($avp(s:aar_return_code)) { 124 | case 1: 125 | xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n"); 126 | break; 127 | default: 128 | xlog("L_ERR", "IMS: AAR failed Orig\n"); 129 | xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)"); 130 | xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)"); 131 | xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)"); 132 | #comment this if you want to allow even if Rx fails 133 | if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){ 134 | dlg_terminate("all", "Sorry no QoS available"); 135 | exit; 136 | } 137 | } 138 | #!endif 139 | } 140 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/route/register.cfg: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Route for handling Registrations: 3 | ###################################################################### 4 | route[REGISTER] { 5 | # Provide some statistics 6 | if ($sht(a=>$ci::start_time) == $null || $sht(a=>$ci::start_time) == 0) { 7 | $sht(a=>$ci::start_time) = $TV(Sn); 8 | } 9 | xnotice("PCSCF REGISTER: \n Destination URI: $du\n Request URI: $ru\n"); 10 | xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n"); 11 | xnotice("Received IP and Port: ($Ri:$Rp)\n"); 12 | xnotice("Contact header: $ct\n"); 13 | 14 | # Strip Transport from RURI: 15 | $ru = $(ru{re.subst,/;transport=[A-Za-z]*//g}); 16 | 17 | if (is_present_hf("Contact")) { 18 | pcscf_save_pending("location"); 19 | } else { 20 | send_reply("403", "No contact header"); 21 | exit; 22 | } 23 | 24 | $sht(ipsec_clients=>$(ct{nameaddr.uri})) = $null; 25 | if ($hdr(Security-Client) =~ ".*ipsec-3gpp.*") { 26 | $sht(ipsec_clients=>$(ct{nameaddr.uri})) = 1; 27 | } 28 | 29 | # Strip additional Tags from RURI: 30 | if ($rU == $null) 31 | $ru = "sip:"+$rd; 32 | else 33 | $ru = "sip:"+$rU+"@"+$rd; 34 | 35 | #!ifdef WITH_RX 36 | xlog("L_DBG","Subscribing to signalling bearer status\n"); 37 | 38 | Rx_AAR_Register("REG_AAR_REPLY", "location"); 39 | switch ($retcode) { 40 | case -1: 41 | # There was an error sending the AAR-Request: 42 | xlog("L_ERR", "Diameter: AAR failed on subscription to signalling\n"); 43 | send_reply("403", "Can't register to QoS for signalling"); 44 | exit; 45 | break; 46 | case 0: 47 | # We are waiting for an async reply, just exit here. 48 | exit; 49 | break; 50 | case 1: 51 | # We did not need to send AAR, so just continue as normal 52 | route(REGISTER_CONTINUE); 53 | break; 54 | } 55 | exit; 56 | } 57 | 58 | route[REG_AAR_REPLY] { 59 | switch ($avp(s:aar_return_code)) { 60 | case 1: 61 | xlog("L_DBG", "Diameter: AAR success on subscription to signalling\n"); 62 | break; 63 | default: 64 | xlog("L_ERR", "Diameter: AAR failed on subscription to signalling\n"); 65 | send_reply("403", "Can't register to QoS for signalling"); 66 | exit; 67 | } 68 | # Proceed with Registering: 69 | route(REGISTER_CONTINUE); 70 | } 71 | 72 | route[REGISTER_CONTINUE] { 73 | #!endif 74 | append_hf("Path: \r\n"); 75 | 76 | remove_hf("Supported"); 77 | append_hf("Supported: path\r\n"); 78 | remove_hf("Require"); 79 | append_hf("Require: path\r\n"); 80 | 81 | # Add a visited Network-ID-Header: 82 | if (is_present_hf("P-Visited-Network-ID")) { 83 | $var(new_hdr) = "NETWORKNAME, "+$hdr(P-Visited-Network-ID); 84 | append_hf("P-Visited-Network-ID: $var(new_hdr)\r\n"); 85 | } else { 86 | append_hf("P-Visited-Network-ID: NETWORKNAME\r\n"); 87 | } 88 | #!ifdef WITH_SBC 89 | #!ifndef WITH_SBC_CALL 90 | t_on_failure("SBC_failure"); 91 | # Choose an SBC to send the call to: 92 | if (!ds_select_dst(DISPATCHER_LIST_SBC, "4")) { 93 | send_reply("503", "Service Unavailable (SBC failure)"); 94 | exit; 95 | } 96 | #!else 97 | t_on_failure("REGISTER_failure"); 98 | #!endif 99 | #!else 100 | t_on_failure("REGISTER_failure"); 101 | #!endif 102 | t_on_reply("REGISTER_reply"); 103 | # Forward request: 104 | route(RELAY); 105 | exit; 106 | } 107 | 108 | # Replies for REGISTER requests: 109 | ###################################################################### 110 | onreply_route[REGISTER_reply] 111 | { 112 | #!ifdef WITH_IMS_HDR_CACHE 113 | if (is_present_hf("Service-Route")) { 114 | $sht(serviceroutes=>$ci) = $hdr(Service-Route); 115 | } else { 116 | if ($sht(serviceroutes=>$ci) != $null) { 117 | append_hf("Service-Route: $sht(serviceroutes=>$ci)\r\n"); 118 | msg_apply_changes(); 119 | } 120 | } 121 | if (is_present_hf("P-Associated-URI")) { 122 | $sht(associateduris=>$ci) = $hdr(P-Associated-URI); 123 | } else { 124 | if ($sht(associateduris=>$ci) != $null) { 125 | append_hf("P-Associated-URI: $sht(associateduris=>$ci)\r\n"); 126 | msg_apply_changes(); 127 | } 128 | } 129 | #!endif 130 | 131 | if (t_check_status("200")) { 132 | #!ifdef WITH_IPBLOCK 133 | $sht(failedauth=>$T_req($si)) = $null; 134 | #!endif 135 | pcscf_save("location"); 136 | #!ifdef WITH_NATPING 137 | #!ifdef WITH_PING_UDP 138 | #if ($T_req($pr) == "udp") { 139 | if ($pr == "udp") { 140 | sht_lock("natping=>natpinglock"); 141 | $var(ouri) = "sip:"+$T_req($si)+":"+$T_req($sp); 142 | $sht(natping=>$var(ouri)) = $(T_req($ct){nameaddr.uri}); 143 | sht_unlock("natping=>natpinglock"); 144 | } 145 | #!endif 146 | #!ifdef WITH_PING_TCP 147 | #if ($T_req($pr) == "tcp") { 148 | if ($pr == "tcp") { 149 | sht_lock("natping=>natpinglock"); 150 | $var(ouri) = "sip:"+$T_req($si)+":"+$T_req($sp)+";transport=tcp"; 151 | $sht(natping=>$var(ouri)) = $(T_req($ct){nameaddr.uri}); 152 | sht_unlock("natping=>natpinglock"); 153 | } 154 | #!endif 155 | #!ifdef WITH_PING_TLS 156 | #if ($T_req($pr) == "tls") { 157 | if ($pr == "tls") { 158 | sht_lock("natping=>natpinglock"); 159 | $var(ouri) = "sip:"+$T_req($si)+":"+$T_req($sp)+";transport=tls"; 160 | $sht(natping=>$var(ouri)) = $(T_req($ct){nameaddr.uri}); 161 | sht_unlock("natping=>natpinglock"); 162 | } 163 | #!endif 164 | #!endif 165 | #update stats for register reply on success 166 | $var(start_secs) = $(sht(a=>$ci::start_time){s.select,0,.}); 167 | $var(start_usecs) = $(sht(a=>$ci::start_time){s.select,1,.}); 168 | $var(diff_secs) = $TV(s) - $var(start_secs); 169 | $var(diff_usecs) = $TV(u) - $var(start_usecs); 170 | $var(diff_ms) = $var(diff_secs)*1000 + ($var(diff_usecs)/1000); 171 | $sht(a=>$ci::start_time)=0; 172 | $var(stat_add) = "+" + $var(diff_ms); 173 | xlog("L_DBG", "REGISTER SUCCESS[$ci] took $var(stat_add)ms\n"); 174 | update_stat("register_success", "+1"); 175 | update_stat("register_time", "$var(stat_add)"); 176 | #!ifdef WITH_IPSEC 177 | #if ($sht(ipsec_clients=>$(T_req($ct){nameaddr.uri})) != $null) { 178 | ipsec_forward("location"); 179 | #} 180 | } 181 | else { 182 | if (t_check_status("401")) { 183 | #if ($sht(ipsec_clients=>$(T_req($ct){nameaddr.uri})) != $null) { 184 | ipsec_create("location"); 185 | #} 186 | } 187 | #!endif 188 | } 189 | exit; 190 | } 191 | 192 | # Negative replies to REGISTER requests: 193 | ###################################################################### 194 | failure_route[REGISTER_failure] 195 | { 196 | #!ifdef WITH_IPBLOCK 197 | if (t_check_status("403|[5-6][0-9][0-9]")) { 198 | if ($sht(failedauth=>$si) != $null) 199 | $sht(failedauth=>$si) = $sht(failedauth=>$si) + 1; 200 | else 201 | $sht(failedauth=>$si) = 1; 202 | if ($sht(failedauth=>$si) > 10) { 203 | xlog("L_ALERT","ALERT: blocking $rm from $fu (IP:$si:$sp), more than 5 failed auth requests!\n"); 204 | xlog("Blocking traffic from $si\n"); 205 | $sht(ipban=>$si) = 1; 206 | } 207 | update_stat("register_failed", "+1"); 208 | } 209 | #!endif 210 | if (t_check_status("408")) { 211 | send_reply("504","Server Time-Out"); 212 | update_stat("register_failed", "+1"); 213 | exit; 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/route/rtp.cfg: -------------------------------------------------------------------------------- 1 | # RTPProxy control 2 | route[ENC_SRTP] { 3 | add_rr_param(";rm=1"); 4 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=force SRTP AVP"; 5 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 6 | } 7 | 8 | route[DEC_SRTP] { 9 | add_rr_param(";rm=2"); 10 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 11 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=force SRTP AVP"; 12 | } 13 | 14 | route[ENC_WS_RTP] { 15 | add_rr_param(";rm=3"); 16 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=force RTP AVPF"; 17 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 18 | } 19 | 20 | route[DEC_WS_RTP] { 21 | add_rr_param(";rm=4"); 22 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 23 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=force RTP AVPF"; 24 | } 25 | 26 | route[ENC_WSS_RTP] { 27 | add_rr_param(";rm=5"); 28 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=force SRTP AVPF DTLS=passive"; 29 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 30 | } 31 | 32 | route[DEC_WSS_RTP] { 33 | add_rr_param(";rm=6"); 34 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 35 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=force SRTP AVPF DTLS=passive"; 36 | } 37 | 38 | route[ENC_RTP] { 39 | add_rr_param(";rm=7"); 40 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=force RTP AVP"; 41 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 42 | } 43 | 44 | route[DEC_RTP] { 45 | add_rr_param(";rm=8"); 46 | $avp(rtpproxy_offer_flags) = "replace-origin replace-session-connection ICE=remove RTP AVP"; 47 | $avp(rtpproxy_answer_flags) = "replace-origin replace-session-connection ICE=force RTP AVP"; 48 | } 49 | 50 | # RTPProxy control 51 | route[NATMANAGE] { 52 | #!ifdef WITH_DEBUG 53 | if (is_request()) 54 | xlog("REQUEST: $rm $ru ($si:$sp, $ci)\n"); 55 | else 56 | xlog("REPLY: $rs $rr ($rm, $si:$sp, $ci)\n"); 57 | 58 | if (is_direction("downstream")) 59 | xlog(" downstream\n"); 60 | else 61 | xlog(" upstream\n"); 62 | 63 | xlog(" Offer: $avp(rtpproxy_offer_flags)\n"); 64 | xlog(" Answer: $avp(rtpproxy_answer_flags)\n"); 65 | if (isflagset(FLT_MOBILE_ORIG)) { 66 | xlog(" mo\n"); 67 | } else { 68 | xlog(" mt\n"); 69 | } 70 | #!endif 71 | if ((is_reply() && ($T_req($tt) != $null)) || (is_request() && has_totag())) { 72 | xlog("L_DBG", "Request had ToTag."); 73 | #if((is_request() && !check_route_param("rm=")) || (is_reply() && !isflagset(FLT_RTP))) { 74 | if(!check_route_param("rm=") && !isflagset(FLT_RTP)) { 75 | xlog("L_DBG", "No RM Param\n"); 76 | return; 77 | } 78 | if (is_request()) { 79 | if (isflagset(FLT_MOBILE_ORIG) && is_direction("downstream")) { 80 | xlog("L_DBG", "1) add_contact_alias();"); 81 | add_contact_alias(); 82 | } else if (!isflagset(FLT_MOBILE_ORIG) && is_direction("upstream")) { 83 | xlog("L_DBG", "2) add_contact_alias();"); 84 | add_contact_alias(); 85 | } 86 | } else { 87 | if (!isflagset(FLT_MOBILE_ORIG) && is_direction("downstream")) { 88 | xlog("L_DBG", "1) ADD_contact_alias();"); 89 | add_contact_alias(); 90 | } else if (isflagset(FLT_MOBILE_ORIG) && is_direction("downstream")) { 91 | xlog("L_DBG", "2) ADD_contact_alias();"); 92 | add_contact_alias(); 93 | } 94 | } 95 | } else { 96 | if (is_reply() && !isflagset(FLT_MOBILE_ORIG)) { 97 | xlog("L_DBG", "3) ADD_contact_alias();"); 98 | add_contact_alias(); 99 | } 100 | } 101 | 102 | if (isflagset(FLT_MOBILE_ORIG)) { 103 | $avp(setid) = 1; 104 | $avp(extra_id) = "mo"; 105 | } else { 106 | $avp(setid) = 1; 107 | # $avp(setid) = 2; 108 | $avp(extra_id) = "mt"; 109 | } 110 | 111 | if(!t_is_set("onreply_route")) t_on_reply("NAT_REPLY"); 112 | if(!t_is_set("failure_route")) t_on_failure("NATMANAGE"); 113 | 114 | if (is_method("BYE") || t_is_failure_route()) { 115 | rtpengine_manage(); 116 | return; 117 | } 118 | 119 | setflag(FLT_RTP); 120 | 121 | if (!has_body("application/sdp")) 122 | return; 123 | 124 | #!ifdef REMOVE_BITALIGNED_AMR 125 | route(REMOVE_BITALIGNED); 126 | #!endif 127 | 128 | #!ifndef FORCE_RTPRELAY 129 | if (!isflagset(FLT_NAT) || !check_route_param("rm=")) 130 | return; 131 | #!endif 132 | 133 | if ((is_reply() && ($T_req($tt) != $null)) || (is_request() && has_totag())) { 134 | # In-Dialog requests 135 | # Requests originating from MO or MT 136 | if ((is_request() && isflagset(FLT_MOBILE_ORIG) && is_direction("downstream")) || (is_request() && !isflagset(FLT_MOBILE_ORIG) && is_direction("upstream"))) { 137 | rtpengine_manage(); 138 | } else if ((is_reply() && !isflagset(FLT_MOBILE_ORIG) && is_direction("upstream")) || (is_reply() && isflagset(FLT_MOBILE_ORIG) && is_direction("downstream"))) { 139 | rtpengine_manage(); 140 | } 141 | } else { 142 | # Initial Requests 143 | if ($avp(rtpproxy_offer_flags) == $null) 144 | return; 145 | if ($avp(rtpproxy_answer_flags) == $null) 146 | return; 147 | 148 | if (is_request() && isflagset(FLT_MOBILE_ORIG)) { 149 | rtpengine_manage($avp(rtpproxy_offer_flags)); 150 | } else if (is_reply() && !isflagset(FLT_MOBILE_ORIG)) { 151 | rtpengine_manage($avp(rtpproxy_answer_flags)); 152 | } 153 | } 154 | } 155 | 156 | # manage incoming replies 157 | onreply_route[NAT_REPLY] { 158 | # In case of 1xx and 2xx do NAT 159 | if(status=~"[12][0-9][0-9]") 160 | route(NATMANAGE); 161 | } 162 | 163 | route[REMOVE_BITALIGNED] { 164 | if (sdp_get_line_startswith("$avp(mline)", "m=")) { 165 | # xlog("m-line: $avp(mline)\n"); 166 | sdp_get("$avp(sdp)"); 167 | # xlog("\n$avp(sdp)\n"); 168 | $var(x) = -1; 169 | $var(remove) = ""; 170 | $var(codec) = $(avp(mline){s.select,$var(x), }); 171 | # xlog("$$var(codec) => $var(codec)\n"); 172 | while ($(var(codec){s.int}) > 0) { 173 | # xlog("$var(x)) $$var(codec) => $var(codec)\n"); 174 | $var(s) = "a=fmtp:"+$var(codec); 175 | # xlog("$$var(s) => $var(s)\n"); 176 | $var(fmtp) = $(avp(sdp){line.sw,$var(s)}); 177 | # xlog("$$var(fmtp) => $var(fmtp)\n"); 178 | if ($var(fmtp) =~ "a=fmtp:"+$var(codec)+" mode-change-capability.*") { 179 | # xlog("Match: $var(codec)\n"); 180 | if ($var(remove) == "") { 181 | $var(remove) = $var(codec); 182 | } else { 183 | $var(remove) = $var(remove)+","+$var(codec); 184 | } 185 | } 186 | $var(codec) = $(avp(mline){s.select,$var(x), }); 187 | $var(x) = $var(x) - 1; 188 | } 189 | # xlog("$$var(remove) => $var(remove)\n"); 190 | if ($var(remove) != "") { 191 | sdp_remove_codecs_by_id($var(remove), "audio"); 192 | msg_apply_changes(); 193 | } 194 | } 195 | } 196 | 197 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/route/websocket.cfg: -------------------------------------------------------------------------------- 1 | event_route[xhttp:request] { 2 | set_reply_close(); 3 | set_reply_no_connect(); 4 | 5 | #!ifdef WITH_XMLRPC 6 | if ($hu =~ "^/RPC") { 7 | route(XMLRPC); 8 | exit; 9 | } 10 | #!endif 11 | 12 | if ($Rp != MY_WS_PORT 13 | #!ifdef WITH_TLS 14 | && $Rp != MY_WSS_PORT 15 | #!endif 16 | ) { 17 | xlog("L_WARN", "HTTP request received on $Rp\n"); 18 | xhttp_reply("403", "Forbidden - HTTP request received on $Rp", "", ""); 19 | exit; 20 | } 21 | 22 | if ($hdr(Upgrade)=~"websocket" 23 | && in_list("Upgrade", $hdr(Connection), ",") 24 | && $rm=~"GET") { 25 | 26 | # Validate Host - make sure the client is using the correct 27 | # alias for WebSockets 28 | if ($hdr(Host) == $null || !is_myself("sip:" + $hdr(Host))) { 29 | xlog("L_WARN", "Bad host $hdr(Host)\n"); 30 | xhttp_reply("403", "Forbidden - invalid host", "", ""); 31 | exit; 32 | } 33 | 34 | #!ifdef WEBSOCKET_WEBSERVER 35 | # Validate Origin - make sure the client is from the authorised website 36 | if ($hdr(Origin) != "http://"+WEBSOCKET_WEBSERVER 37 | #!ifdef WITH_TLS 38 | && $hdr(Origin) != "https://"+WEBSOCKET_WEBSERVER 39 | #!endif 40 | ) { 41 | xlog("L_WARN", "Unauthorised client $hdr(Origin)\n"); 42 | xhttp_reply("403", "Forbidden - invalid website", "", ""); 43 | exit; 44 | } 45 | #!endif 46 | 47 | # ws_handle_handshake() exits (no further configuration file 48 | # processing of the request) when complete. 49 | if (ws_handle_handshake()) { 50 | # Optional... cache some information about the 51 | # successful connection 52 | exit; 53 | } 54 | } 55 | 56 | # xhttp_reply("200", "OK", "text/html", "Wrong URL $hu"); 57 | xhttp_reply("404", "Not Found", "", ""); 58 | } 59 | 60 | event_route[websocket:closed] { 61 | xlog("L_DBG", "WebSocket connection from $si:$sp has closed\n"); 62 | } 63 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/route/xmlrpc.cfg: -------------------------------------------------------------------------------- 1 | # XMLRPC routing 2 | route[XMLRPC] { 3 | # allow XMLRPC from localhost 4 | if ((method=="POST" || method=="GET") 5 | #!ifdef XMLRPC_WHITELIST_1 6 | && ((src_ip == XMLRPC_WHITELIST_1) 7 | #!ifdef XMLRPC_WHITELIST_2 8 | || (src_ip == XMLRPC_WHITELIST_2) 9 | #!endif 10 | #!ifdef XMLRPC_WHITELIST_3 11 | || (src_ip == XMLRPC_WHITELIST_3) 12 | #!endif 13 | ) 14 | #!endif 15 | ) { 16 | # close connection only for xmlrpclib user agents (there is a bug in 17 | # xmlrpclib: it waits for EOF before interpreting the response). 18 | if ($hdr(User-Agent) =~ "xmlrpclib") 19 | set_reply_close(); 20 | set_reply_no_connect(); 21 | dispatch_rpc(); 22 | exit; 23 | } 24 | send_reply("403", "Forbidden"); 25 | exit; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/methodmap.conf: -------------------------------------------------------------------------------- 1 | OPTIONS=>refuse_with_200 2 | REGISTER=>register 3 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/mo.sbcprofile.conf: -------------------------------------------------------------------------------- 1 | # transparent SBC profile 2 | # 3 | # This implements a transparent B2BUA - all possible options are commented 4 | 5 | # defaults: transparent 6 | #RURI=$r 7 | #From=$f 8 | #To=sip:$rU@ims.voiceblue.com 9 | 10 | #Call-ID 11 | #Call-ID=$ci-ngv 12 | 13 | ## routing 14 | # outbound proxy: 15 | outbound_proxy=sip:mo@$si:$sp 16 | # force outbound proxy (in-dialog requests)? 17 | #force_outbound_proxy=yes 18 | # destination IP[:port] for outgoing requests 19 | next_hop_ip=$si 20 | next_hop_port=$sp 21 | # use next_hop for replies, too? 22 | #next_hop_for_replies=yes 23 | # outbound interface to use (interface ID) 24 | #outbound_interface=extern 25 | 26 | ## RTP relay 27 | # enable RTP relaying (bridging): 28 | enable_rtprelay=no 29 | # force symmetric RTP (start with passive mode): 30 | #rtprelay_force_symmetric_rtp=yes 31 | # use symmetric RTP indication from P-MsgFlags flag 2 32 | #rtprelay_msgflags_symmetric_rtp=yes 33 | 34 | ## filters: 35 | header_filter=whitelist 36 | header_list=Diversion,P-Asserted-Identity,Privacy,Allow,Event,Expires,Accept,User-Agent,Subscription-State,P-Access-Network-Info,P-Route,C-Params,Feature-Caps 37 | #header_filter=blacklist 38 | #header_list= 39 | #header_list=P-App-Param,P-App-Name 40 | message_filter=blacklist 41 | message_list=SUBSCRIBE 42 | sdp_filter=whitelist 43 | #sdpfilter_list=g722,pcma,pcmu,gsm,amr,h264,telephone-event 44 | sdpfilter_list=g722,pcma,pcmu,gsm,amr,amr-wb,amr-wb/16000,h264,telephone-event 45 | codec_preference=g722,amr-wb,amr-wb/16000,pcmu,pcma,gsm,amr 46 | sdp_anonymize=yes 47 | #sdp_anonymize=no 48 | # Filter A-Lines: 49 | sdp_alines_filter=blacklist 50 | sdp_alinesfilter_list=crypto,nortpproxy 51 | 52 | ## Transcoding 53 | enable_transcoder=on_missing_compatible 54 | #enable_transcoder=always 55 | transcoder_codecs=amr,pcma,pcmu 56 | #transcoder_codecs=amr-wb/16000,amr-wb,g722,amr,pcma,pcmu 57 | prefer_existing_codecs=yes 58 | # Minimum G711! 59 | callee_codeccaps=pcma,pcmu 60 | 61 | ## reply translations 62 | # translate some 6xx class replies to 4xx class: 63 | #reply_translations="603=>488 Not acceptable here|600=>406 Not Acceptable" 64 | 65 | # From the mobile network 66 | enable_aleg_session_timer=no 67 | aleg_session_expires=120 68 | aleg_minimum_timer=90 69 | aleg_maximum_timer=180 70 | 71 | # From our network 72 | enable_session_timer=no 73 | session_expires=120 74 | minimum_timer=90 75 | maximum_timer=7200 76 | 77 | #session_refresh_method=UPDATE_FALLBACK_INVITE 78 | #accept_501_reply=yes 79 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/monitoring.conf: -------------------------------------------------------------------------------- 1 | 2 | #run_garbage_collector=[yes | no] 3 | # 4 | # run garbage collection on expired session info? 5 | # Default: no 6 | # 7 | run_garbage_collector = yes 8 | 9 | #garbage_collector_interval=10 10 | # 11 | # run garbage collection every n seconds 12 | # Default: 10 13 | # 14 | #garbage_collector_interval = 20 15 | 16 | # retain_samples_s=10 17 | # 18 | # retain "sample" type values for n seconds 19 | # 20 | #retain_samples_s=20 21 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/mt.sbcprofile.conf: -------------------------------------------------------------------------------- 1 | # transparent SBC profile 2 | # 3 | # This implements a transparent B2BUA - all possible options are commented 4 | 5 | # defaults: transparent 6 | #RURI=$r 7 | #From=$f 8 | #To=sip:$rU@$td 9 | 10 | #Call-ID 11 | #Call-ID=$ci_leg2 12 | 13 | ## routing 14 | # outbound proxy: 15 | outbound_proxy=sip:mt@$si:$sp 16 | # force outbound proxy (in-dialog requests)? 17 | #force_outbound_proxy=yes 18 | # destination IP[:port] for outgoing requests 19 | #next_hop_ip=$si 20 | #next_hop_port=$sp 21 | # use next_hop for replies, too? 22 | #next_hop_for_replies=yes 23 | # outbound interface to use (interface ID) 24 | #outbound_interface=extern 25 | 26 | ## RTP relay 27 | # enable RTP relaying (bridging): 28 | enable_rtprelay=no 29 | # force symmetric RTP (start with passive mode): 30 | #rtprelay_force_symmetric_rtp=yes 31 | # use symmetric RTP indication from P-MsgFlags flag 2 32 | #rtprelay_msgflags_symmetric_rtp=yes 33 | 34 | ## filters: 35 | header_filter=whitelist 36 | header_list=Diversion,P-Asserted-Identity,Privacy,P-Route,P-NAT,P-Source,Allow,Event,Expires,Accept,User-Agent,Subscription-State,P-Route,C-Params 37 | #header_filter=blacklist 38 | #header_list= 39 | #header_list=P-App-Param,P-App-Name 40 | #message_filter=blacklist 41 | #message_list=OPTIONS 42 | sdp_filter=whitelist 43 | sdpfilter_list=g722,pcma,pcmu,gsm,amr-wb,amr-wb/16000,amr,h264,telephone-event 44 | sdp_anonymize=yes 45 | # Filter A-Lines: 46 | sdp_alines_filter=blacklist 47 | sdp_alinesfilter_list=crypto,nortpproxy 48 | 49 | ## Transcoding 50 | enable_transcoder=on_missing_compatible 51 | transcoder_codecs=pcma,pcmu,amr 52 | prefer_existing_codecs=yes 53 | callee_codeccaps=amr 54 | 55 | ## reply translations 56 | # translate some 6xx class replies to 4xx class: 57 | #reply_translations="603=>488 Not acceptable here|600=>406 Not Acceptable" 58 | 59 | ## session timer: 60 | 61 | # From our network 62 | enable_aleg_session_timer=no 63 | aleg_session_expires=120 64 | aleg_minimum_timer=90 65 | aleg_maximum_timer=7200 66 | 67 | # From the mobile network 68 | enable_session_timer=no 69 | session_expires=120 70 | minimum_timer=90 71 | maximum_timer=180 72 | 73 | #session_refresh_method=UPDATE_FALLBACK_INVITE 74 | #accept_501_reply=yes 75 | 76 | ## Registration Caching 77 | enable_reg_caching=no 78 | min_reg_expires=7200 79 | max_ua_expires=120 80 | 81 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/nocache.sbcprofile.conf: -------------------------------------------------------------------------------- 1 | # transparent SBC profile 2 | # 3 | # This implements a transparent B2BUA - all possible options are commented 4 | 5 | # defaults: transparent 6 | 7 | ## routing 8 | # outbound proxy: 9 | outbound_proxy=sip:$si:$sp 10 | # force outbound proxy (in-dialog requests)? 11 | #force_outbound_proxy=yes 12 | # destination IP[:port] for outgoing requests 13 | #next_hop_ip=$si 14 | #next_hop_port=$sp 15 | # use next_hop for replies, too? 16 | #next_hop_for_replies=yes 17 | # outbound interface to use (interface ID) 18 | #outbound_interface=extern 19 | 20 | ## filters: 21 | #header_filter=whitelist 22 | #header_list=Diversion,P-Asserted-Identity,Privacy,P-Route,P-Destination,P-Source 23 | #header_filter=blacklist 24 | #header_list= 25 | #header_list=P-App-Param,P-App-Name 26 | #message_filter=blacklist 27 | #message_list=OPTIONS 28 | sdp_filter=whitelist 29 | sdpfilter_list=g722,pcma,pcmu,isac,ilbc,gsm,telephone-event 30 | sdp_anonymize=yes 31 | # Filter A-Lines: 32 | sdp_alines_filter=blacklist 33 | sdp_alinesfilter_list=crypto,nortpproxy 34 | 35 | ## Registration Caching 36 | enable_reg_caching=no 37 | min_reg_expires=60 38 | max_ua_expires=60 39 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/refuse.sbcprofile.conf: -------------------------------------------------------------------------------- 1 | refuse_with="403 Forbidden" 2 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/refuse_with_200.sbcprofile.conf: -------------------------------------------------------------------------------- 1 | refuse_with="200 OK" 2 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/register.sbcprofile.conf: -------------------------------------------------------------------------------- 1 | # transparent SBC profile 2 | # 3 | # This implements a transparent B2BUA - all possible options are commented 4 | 5 | # defaults: transparent 6 | 7 | ## routing 8 | # outbound proxy: 9 | #outbound_proxy=sip:$si:$sp 10 | # force outbound proxy (in-dialog requests)? 11 | #force_outbound_proxy=yes 12 | # destination IP[:port] for outgoing requests 13 | #next_hop_ip=$si 14 | #next_hop_port=$sp 15 | # use next_hop for replies, too? 16 | #next_hop_for_replies=yes 17 | # outbound interface to use (interface ID) 18 | #outbound_interface=extern 19 | 20 | ## filters: 21 | #header_filter=whitelist 22 | #header_list=P-Visited-Network-ID 23 | 24 | ## Registration Caching 25 | enable_reg_caching=yes 26 | min_reg_expires=120 27 | #min_reg_expires=57600 28 | max_ua_expires=120 29 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/rurimap.conf: -------------------------------------------------------------------------------- 1 | ims.voiceblue.com=>mo 2 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/sbc.conf: -------------------------------------------------------------------------------- 1 | 2 | # profiles - comma-separated list of call profiles to load 3 | # 4 | # .sbcprofile.conf is loaded from module config 5 | # path (the path where this file resides) 6 | profiles=mo,mt,register 7 | 8 | # active call profile - comma separated list, first non-empty is used 9 | # 10 | # o active_profile= always use 11 | # 12 | # o active_profile=$(ruri.user) use user part of INVITE Request URI 13 | # 14 | # o active_profile=$(paramhdr) use "profile" option in P-App-Param header 15 | # 16 | # o any replacement pattern 17 | # 18 | active_profile=$H(SBC),register 19 | 20 | # regex_maps - comma-separated list of regex maps to load at startup, for $M() 21 | # 22 | # regex=>value maps for which names are given here are loaded from 23 | # this path, e.g. src_ipmap.conf, ruri_map.conf, usermap.conf 24 | # 25 | #regex_maps=src_ipmap 26 | 27 | ## RFC4028 Session Timer 28 | # default configuration - can be overridden by call profiles 29 | 30 | # - enables the session timer ([yes,no]; default: no) 31 | # 32 | #enable_session_timer=yes 33 | 34 | # - set the "Session-Expires" parameter for the session timer. 35 | # 36 | #session_expires=120 37 | 38 | # - set the "Min-SE" parameter for the session timer. 39 | # 40 | #minimum_timer=90 41 | 42 | # session refresh (Session Timer, RFC4028) method 43 | # 44 | # INVITE - use re-INVITE 45 | # UPDATE - use UPDATE 46 | # UPDATE_FALLBACK_INVITE - use UPDATE if indicated in Allow, re-INVITE otherwise 47 | # 48 | # Default: UPDATE_FALLBACK_INVITE 49 | # 50 | #session_refresh_method=UPDATE 51 | 52 | # accept_501_reply - accept 501 reply as successful refresh? [yes|no] 53 | # 54 | # Default: yes 55 | # 56 | #accept_501_reply=no 57 | 58 | # handle OPTIONS messages in the core? (with limits etc) 59 | # Default: no 60 | core_options_handling=yes 61 | 62 | 63 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/stats.conf: -------------------------------------------------------------------------------- 1 | # IP of the monitoring interface: 2 | monit_udp_ip=127.0.0.1 3 | 4 | # port the statistics server should listen to: 5 | monit_udp_port=5040 6 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/sems/etc/xmlrpc2di.conf: -------------------------------------------------------------------------------- 1 | # server_ip : IP to bind XMLRPC server to 2 | # leave empty for ANY interface 3 | server_ip=127.0.0.1 4 | 5 | # port to bind XMLRPC server to 6 | xmlrpc_port=8090 7 | 8 | # run multi-threaded server? 9 | # Default: yes 10 | # 11 | # multithreaded = yes 12 | 13 | # threads to run - this many requests can be processed in parallel 14 | # Default: 5 15 | # 16 | # threads=5 17 | 18 | # export all DI functions with the function call 'di'? 19 | # defaults to: yes 20 | # export_di=yes 21 | 22 | # 23 | # these DI interfaces are searched for functions to 24 | # export under their proper function names 25 | # defaults to: none 26 | # direct_export=di_dial;registrar_client 27 | direct_export=sbc 28 | 29 | # run the XMLRPC server at all (default: yes) 30 | # 31 | # run_server=yes 32 | 33 | # timeout for client requests, in milliseconds (0 to disable) 34 | # 35 | # server_timeout=500 36 | 37 | # print parameters of XMLRPC server calls into debug log [yes|no] 38 | # debug_server_params=yes 39 | # 40 | # print result of XMLRPC server calls into debug log [yes|no] 41 | # debug_server_result=yes 42 | # 43 | -------------------------------------------------------------------------------- /pcscf/kamailio_pcscf/tls.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # TLS Configuration File 3 | # 4 | 5 | # This is the default server domain, settings 6 | # in this domain will be used for all incoming 7 | # connections that do not match any other server 8 | # domain in this configuration file. 9 | # 10 | [server:default] 11 | method = SSLv23 12 | verify_certificate = no 13 | require_certificate = no 14 | private_key = /etc/kamailio/kamailio-selfsigned.key 15 | certificate = /etc/kamailio/kamailio-selfsigned.pem 16 | -------------------------------------------------------------------------------- /pcscf/pcscf_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true; do 4 | echo 'Waiting for MySQL to start.' 5 | echo '' | nc -w 1 $MYSQL_IP 3306 && break 6 | sleep 1 7 | done 8 | 9 | sed -i 's|PCSCF_IP|'$PCSCF_IP'|g' /etc/kamailio_pcscf/kamailio_pcscf.cfg 10 | sed -i 's|RTPENGINE_IP|'$RTPENGINE_IP'|g' /etc/kamailio_pcscf/kamailio_pcscf.cfg 11 | sed -i 's|PCSCF_IP|'$PCSCF_IP'|g' /etc/kamailio_pcscf/pcscf.cfg 12 | sed -i 's|MYSQL_IP|'$MYSQL_IP'|g' /etc/kamailio_pcscf/pcscf.cfg 13 | sed -i 's|PCSCF_IP|'$PCSCF_IP'|g' /etc/kamailio_pcscf/pcscf.xml 14 | 15 | ip r a 192.168.101.0/24 via $PGW_IP 16 | 17 | /etc/init.d/kamailio_pcscf start 18 | -------------------------------------------------------------------------------- /pgw/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM docker_open5gs 28 | 29 | # Expose port 3868 for Diameter queries 30 | EXPOSE 3868/udp 31 | EXPOSE 3868/tcp 32 | EXPOSE 3868/sctp 33 | EXPOSE 5868/udp 34 | EXPOSE 5868/tcp 35 | EXPOSE 5868/sctp 36 | 37 | # Expose port 2152 38 | EXPOSE 2152/udp 39 | 40 | # Expose port 2123 41 | EXPOSE 2123/udp 42 | 43 | CMD /mnt/pgw/pgw_init.sh && \ 44 | cd install/bin && ./open5gs-pgwd -------------------------------------------------------------------------------- /pgw/pgw.yaml: -------------------------------------------------------------------------------- 1 | logger: 2 | file: /open5gs/install/var/log/open5gs/pgw.log 3 | 4 | parameter: 5 | no_ipv6: true 6 | prefer_ipv4: true 7 | 8 | pgw: 9 | freeDiameter: 10 | identity: pgw.epc.mnc001.mcc001.3gppnetwork.org 11 | realm: epc.mnc001.mcc001.3gppnetwork.org 12 | port: 3868 13 | sec_port: 5868 14 | listen_on: PGW_IP 15 | load_extension: 16 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx 17 | conf: 0x8888 18 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx 19 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx 20 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx 21 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx 22 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx 23 | - module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx 24 | connect: 25 | - identity: pcrf.epc.mnc001.mcc001.3gppnetwork.org 26 | addr: PCRF_IP 27 | port: 3868 28 | gtpc: 29 | dev: PGW_IF 30 | gtpu: 31 | dev: PGW_IF 32 | ue_pool: 33 | - addr: 192.168.100.1/24 34 | dev: ogstun 35 | - addr: fd84:6aea:c36e:2b69::/64 36 | dev: ogstun 37 | apn: internet 38 | - addr: 192.168.101.1/24 39 | apn: ims 40 | dev: ogstun2 41 | - addr: fd1f:76f3:da9b:0101::/64 42 | apn: ims 43 | dev: ogstun2 44 | dns: 45 | - DNS_IP 46 | - DNS_IP 47 | p-cscf: 48 | - PCSCF_IP 49 | -------------------------------------------------------------------------------- /pgw/pgw_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LC_ALL=C.UTF-8 4 | export LANG=C.UTF-8 5 | export IP_ADDR=$(awk 'END{print $1}' /etc/hosts) 6 | export IF_NAME=$(ip r | awk '/default/ { print $5 }') 7 | 8 | # python3 /mnt/pgw/tun_if.py --tun_ifname ogstun --ipv4_range 192.168.100.0/24 --ipv6_range fd84:6aea:c36e:2b69::/64 9 | # python3 /mnt/pgw/tun_if.py --tun_ifname ogstun2 --ipv4_range 192.168.101.0/24 --ipv6_range fd1f:76f3:da9b:0101::/64 10 | 11 | ip tuntap add name ogstun mode tun 12 | ip addr add 192.168.100.1/24 dev ogstun 13 | ip addr add fd84:6aea:c36e:2b69:0000:0000:0000:0001/64 dev ogstun 14 | ip link set ogstun mtu 1400 15 | ip link set ogstun up 16 | iptables -t nat -A POSTROUTING -s 192.168.100.0/24 ! -o ogstun -j MASQUERADE 17 | ip6tables -t nat -A POSTROUTING -s fd84:6aea:c36e:2b69::/64 ! -o ogstun -j MASQUERADE 18 | iptables -A INPUT -i ogstun -j ACCEPT 19 | ip6tables -A INPUT -i ogstun -j ACCEPT 20 | 21 | ip tuntap add name ogstun2 mode tun 22 | ip addr add 192.168.101.1/24 dev ogstun2 23 | ip addr add fd1f:76f3:da9b:0101:0000:0000:0000:0001/64 dev ogstun2 24 | ip link set ogstun2 mtu 1400 25 | ip link set ogstun2 up 26 | iptables -A INPUT -i ogstun2 -j ACCEPT 27 | ip6tables -A INPUT -i ogstun2 -j ACCEPT 28 | 29 | cp /mnt/pgw/pgw.yaml install/etc/open5gs 30 | sed -i 's|PGW_IP|'$IP_ADDR'|g' install/etc/open5gs/pgw.yaml 31 | sed -i 's|PGW_IF|'$IF_NAME'|g' install/etc/open5gs/pgw.yaml 32 | sed -i 's|PCRF_IP|'$PCRF_IP'|g' install/etc/open5gs/pgw.yaml 33 | sed -i 's|DNS_IP|'$DNS_IP'|g' install/etc/open5gs/pgw.yaml 34 | sed -i 's|PCSCF_IP|'$PCSCF_IP'|g' install/etc/open5gs/pgw.yaml 35 | -------------------------------------------------------------------------------- /pgw/tun_if.py: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | import click 28 | import subprocess 29 | import ipaddress 30 | 31 | """ 32 | Usage in command line: 33 | e.g: 34 | $ python3 tun_if.py --tun_ifname ogstun --ipv4_range 192.168.100.0/24 --ipv6_range fd84:6aea:c36e:2b69::/64 35 | """ 36 | 37 | def validate_ip_net(ctx, param, value): 38 | try: 39 | ip_net = ipaddress.ip_network(value) 40 | return ip_net 41 | except ValueError: 42 | raise click.BadParameter('Value does not represent a valid IPv4/IPv6 range') 43 | 44 | @click.command() 45 | @click.option('--tun_ifname', 46 | required=True, 47 | help='TUN interface name e.g. ogstun') 48 | @click.option('--ipv4_range', 49 | required=True, 50 | callback=validate_ip_net, 51 | help='UE IPv4 Address range in CIDR format e.g. 192.168.100.0/24') 52 | @click.option('--ipv6_range', 53 | required=True, 54 | callback=validate_ip_net, 55 | help='UE IPv6 Address range in CIDR format e.g. fd84:6aea:c36e:2b69::/64') 56 | def start(tun_ifname, 57 | ipv4_range, 58 | ipv6_range): 59 | 60 | # Get the first IP address in the IP range and netmask prefix length 61 | first_ipv4_addr = next(ipv4_range.hosts(), None) 62 | if not first_ipv4_addr: 63 | raise ValueError('Invalid UE IPv4 range. Only one IP given') 64 | else: 65 | first_ipv4_addr = first_ipv4_addr.exploded 66 | first_ipv6_addr = next(ipv6_range.hosts(), None) 67 | if not first_ipv6_addr: 68 | raise ValueError('Invalid UE IPv6 range. Only one IP given') 69 | else: 70 | first_ipv6_addr = first_ipv6_addr.exploded 71 | 72 | ipv4_netmask_prefix = ipv4_range.prefixlen 73 | ipv6_netmask_prefix = ipv6_range.prefixlen 74 | 75 | # Setup the TUN interface, set IP address and setup IPtables 76 | # if ls /sys/class/net | grep "ogstun" ; then ip link delete ogstun; fi 77 | execute_bash_cmd('ip tuntap add name ' + tun_ifname + ' mode tun') 78 | execute_bash_cmd('ip addr add ' + first_ipv4_addr + '/' + str(ipv4_netmask_prefix) + ' dev ' + tun_ifname) 79 | execute_bash_cmd('ip addr add ' + first_ipv6_addr + '/' + str(ipv6_netmask_prefix) + ' dev ' + tun_ifname) 80 | execute_bash_cmd('ip link set ' + tun_ifname + ' mtu 1400') 81 | execute_bash_cmd('ip link set ' + tun_ifname + ' up') 82 | execute_bash_cmd('if ! iptables-save | grep -- \"-A POSTROUTING -s ' + ipv4_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE\" ; then ' + 83 | 'iptables -t nat -A POSTROUTING -s ' + ipv4_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE; fi') 84 | execute_bash_cmd('if ! ip6tables-save | grep -- \"-A POSTROUTING -s ' + ipv6_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE\" ; then ' + 85 | 'ip6tables -t nat -A POSTROUTING -s ' + ipv6_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE; fi') 86 | execute_bash_cmd('if ! iptables-save | grep -- \"-A INPUT -i ' + tun_ifname + ' -j ACCEPT\" ; then ' + 87 | 'iptables -A INPUT -i ' + tun_ifname + ' -j ACCEPT; fi') 88 | execute_bash_cmd('if ! ip6tables-save | grep -- \"-A INPUT -i ' + tun_ifname + ' -j ACCEPT\" ; then ' + 89 | 'ip6tables -A INPUT -i ' + tun_ifname + ' -j ACCEPT; fi') 90 | 91 | def execute_bash_cmd(bash_cmd): 92 | print("Executing: /bin/bash -c " + bash_cmd) 93 | #return subprocess.run(bash_cmd, stdout=subprocess.PIPE, shell=True) 94 | 95 | if __name__ == '__main__': 96 | start() 97 | -------------------------------------------------------------------------------- /rtpengine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y debhelper default-libmysqlclient-dev gperf iptables-dev libavcodec-dev \ 5 | git libavfilter-dev libavformat-dev libavutil-dev libbencode-perl libcrypt-openssl-rsa-perl \ 6 | libcrypt-rijndael-perl libdigest-crc-perl libdigest-hmac-perl libevent-dev libhiredis-dev \ 7 | libio-multiplex-perl libio-socket-inet6-perl libiptc-dev libjson-glib-dev libnet-interface-perl \ 8 | libpcap0.8-dev libsocket6-perl libspandsp-dev libswresample-dev libsystemd-dev \ 9 | libxmlrpc-core-c3-dev markdown dkms module-assistant keyutils libnfsidmap2 libtirpc1 \ 10 | nfs-common rpcbind netcat iptables 11 | 12 | ENV DEB_BUILD_PROFILES="pkg.ngcp-rtpengine.nobcg729" 13 | RUN apt-get install -y dpkg-dev libcurl4-openssl-dev 14 | 15 | RUN git clone https://github.com/sipwise/rtpengine && \ 16 | cd rtpengine && \ 17 | git checkout mr7.4.1 18 | 19 | WORKDIR /rtpengine 20 | RUN dpkg-checkbuilddeps && \ 21 | dpkg-buildpackage -uc -us 22 | 23 | # ngcp-rtpengine-utils depends on netcat 24 | RUN cd .. && \ 25 | dpkg -i *.deb 26 | 27 | ENV DEBIAN_FRONTEND=noninteractive 28 | RUN apt-get install -y linux-headers-$(uname -r) linux-image-$(uname -r) && \ 29 | module-assistant update && \ 30 | module-assistant auto-install ngcp-rtpengine-kernel-source 31 | 32 | EXPOSE 2223/udp 33 | 34 | CMD /mnt/rtpengine/rtpengine_init.sh 35 | -------------------------------------------------------------------------------- /rtpengine/rtpengine-recording.conf: -------------------------------------------------------------------------------- 1 | [rtpengine-recording] 2 | 3 | table = 0 4 | 5 | ### number of worker threads (default 8) 6 | # num-threads = 16 7 | 8 | ### where to forward to (unix socket) 9 | # forward-to = /var/run/rtpengine/sock 10 | 11 | ### where to store recordings: file (default), db, both 12 | # output-storage = db 13 | 14 | ### format of stored recordings: wav (default), mp3 15 | # output-format = mp3 16 | 17 | ### directory containing rtpengine metadata files 18 | # spool-dir = /var/spool/rtpengine 19 | 20 | ### where to store media files to 21 | # output-dir = /var/lib/rtpengine-recording 22 | 23 | ### resample all output audio 24 | # resample-to = 8000 25 | 26 | ### bits per second for MP3 encoding 27 | # mp3_bitrate = 24000 28 | 29 | ### mix participating sources into a single output 30 | # output-mixed = true 31 | 32 | ### create one output file for each source 33 | # output-single = true 34 | 35 | ### mysql configuration for db storage 36 | # mysql-host = localhost 37 | # mysql-port = 3306 38 | # mysql-user = rtpengine 39 | # mysql-pass = secret 40 | # mysql-db = rtpengine 41 | -------------------------------------------------------------------------------- /rtpengine/rtpengine.conf: -------------------------------------------------------------------------------- 1 | [rtpengine] 2 | 3 | table = 0 4 | # no-fallback = false 5 | ### for userspace forwarding only: 6 | # table = -1 7 | 8 | ### a single interface: 9 | # interface = RTPENGINE_IP 10 | ### separate multiple interfaces with semicolons: 11 | # interface = internal/12.23.34.45;external/23.34.45.54 12 | ### for different advertised address: 13 | # interface = 12.23.34.45!23.34.45.56 14 | 15 | 16 | 17 | # listen-ng = RTPENGINE_IP:2223 18 | # listen-tcp = 25060 19 | # listen-udp = 12222 20 | 21 | timeout = 60 22 | silent-timeout = 3600 23 | tos = 184 24 | #control-tos = 184 25 | # delete-delay = 30 26 | # final-timeout = 10800 27 | 28 | foreground = true 29 | # pidfile = /run/ngcp-rtpengine-daemon.pid 30 | # num-threads = 16 31 | 32 | port-min = 30000 33 | port-max = 40000 34 | # max-sessions = 5000 35 | 36 | # recording-dir = /var/spool/rtpengine 37 | # recording-method = proc 38 | # recording-format = raw 39 | 40 | # redis = 127.0.0.1:6379/5 41 | # redis-write = password@12.23.34.45:6379/42 42 | # redis-num-threads = 8 43 | # no-redis-required = false 44 | # redis-expires = 86400 45 | # redis-allowed-errors = -1 46 | # redis-disable-time = 10 47 | # redis-cmd-timeout = 0 48 | # redis-connect-timeout = 1000 49 | 50 | # b2b-url = http://127.0.0.1:8090/ 51 | # xmlrpc-format = 0 52 | 53 | log-level = 6 54 | log-stderr = true 55 | # log-facility = daemon 56 | # log-facility-cdr = local0 57 | # log-facility-rtcp = local1 58 | 59 | # graphite = 127.0.0.1:9006 60 | # graphite-interval = 60 61 | # graphite-prefix = foobar. 62 | 63 | # homer = 123.234.345.456:65432 64 | # homer-protocol = udp 65 | # homer-id = 2001 66 | 67 | # sip-source = false 68 | # dtls-passive = false 69 | 70 | [rtpengine-testing] 71 | table = -1 72 | interface = 10.15.20.121 73 | listen-ng = 2223 74 | foreground = true 75 | log-stderr = true 76 | log-level = 7 77 | -------------------------------------------------------------------------------- /rtpengine/rtpengine_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p /var/spool/rtpengine 4 | cp /mnt/rtpengine/*.conf /etc/rtpengine/ 5 | modprobe xt_RTPENGINE 6 | /usr/sbin/ngcp-rtpengine-iptables-setup start 7 | /usr/sbin/rtpengine-recording -E --no-log-timestamps --pidfile /ngcp-rtpengine-recording-daemon.pid --config-file /etc/rtpengine/rtpengine-recording.conf 8 | /usr/sbin/rtpengine -f -E --no-log-timestamps --pidfile ngcp-rtpengine-daemon.pid --config-file /etc/rtpengine/rtpengine.conf --table 0 --interface=$RTPENGINE_IP --listen-ng=$RTPENGINE_IP:2223 9 | -------------------------------------------------------------------------------- /rtpproxy/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker_open5gs 2 | 3 | RUN apt-get install -y rtpproxy 4 | 5 | EXPOSE 7722/udp 6 | EXPOSE 2223/UDP 7 | 8 | COPY rtpproxy /etc/default/ 9 | ENV CONTROL_SOCK=udp:0.0.0.0:7722 10 | CMD /usr/bin/rtpproxy -f -l 0.0.0.0 -d DBUG:LOG_LOCAL0 -u rtpproxy 11 | -------------------------------------------------------------------------------- /rtpproxy/rtpproxy: -------------------------------------------------------------------------------- 1 | # Defaults for rtpproxy 2 | 3 | # The control socket. 4 | #CONTROL_SOCK="unix:/var/run/rtpproxy/rtpproxy.sock" 5 | # To listen on an UDP socket, uncomment this line: 6 | CONTROL_SOCK=udp:0.0.0.0:7722 7 | 8 | # Additional options that are passed to the daemon. 9 | EXTRA_OPTS="-l 0.0.0.0 -d DBUG:LOG_LOCAL0" 10 | -------------------------------------------------------------------------------- /scscf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM open5gs_kamailio 2 | 3 | ADD kamailio_scscf /etc/kamailio_scscf/ 4 | 5 | EXPOSE 6060/tcp 6 | EXPOSE 6060/udp 7 | EXPOSE 3870/tcp 8 | EXPOSE 3870/sctp 9 | 10 | COPY ./init.d/kamailio_scscf /etc/init.d/kamailio_scscf 11 | COPY ./default/kamailio_scscf /etc/default/kamailio_scscf 12 | 13 | CMD /mnt/scscf/scscf_init.sh 14 | -------------------------------------------------------------------------------- /scscf/default/kamailio_scscf: -------------------------------------------------------------------------------- 1 | # 2 | # Kamailio startup options 3 | # 4 | 5 | # Set to yes to enable kamailio, once configured properly. 6 | RUN_KAMAILIO=yes 7 | 8 | # User to run as 9 | #USER=kamailio 10 | 11 | # Group to run as 12 | #GROUP=kamailio 13 | 14 | # Amount of shared and private memory to allocate 15 | # for the running Kamailio server (in Mb) 16 | #SHM_MEMORY=64 17 | #PKG_MEMORY=8 18 | 19 | # Config file 20 | #CFGFILE=/etc/kamailio/kamailio.cfg 21 | 22 | # Enable the server to leave a core file when it crashes. 23 | # Set this to 'yes' to enable Kamailio to leave a core file when it crashes 24 | # or 'no' to disable this feature. This option is case sensitive and only 25 | # accepts 'yes' and 'no' and only in lowercase letters. 26 | # On some systems it is necessary to specify a directory for the core files 27 | # to get a dump. Look into the kamailio init file for an example configuration. 28 | #DUMP_CORE=yes 29 | -------------------------------------------------------------------------------- /scscf/init.d/kamailio_scscf: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | ### BEGIN INIT INFO 4 | # Provides: kamailio 5 | # Required-Start: $syslog $network $local_fs $remote_fs $time 6 | # Should-Start: $named slapd mysql postgresql snmpd radiusd 7 | # Should-Stop: $named slapd mysql postgresql snmpd radiusd 8 | # Required-Stop: $syslog $network $local_fs $remote_fs 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: Start the Kamailio SIP proxy server 12 | # Description: Start the Kamailio SIP proxy server 13 | ### END INIT INFO 14 | 15 | . /lib/lsb/init-functions 16 | 17 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 18 | DAEMON=/usr/local/sbin/kamailio 19 | NAME=`basename "$0"` 20 | DESC="Kamailio SIP Server" 21 | HOMEDIR=/var/run/$NAME 22 | PIDFILE=$HOMEDIR/$NAME.pid 23 | DEFAULTS=/etc/default/$NAME 24 | CFGFILE=/etc/kamailio_scscf/kamailio_scscf.cfg 25 | RUN_KAMAILIO=no 26 | USER=kamailio 27 | GROUP=kamailio 28 | # Amount of shared and private memory to allocate 29 | # for the running Kamailio server (in Mb) 30 | SHM_MEMORY=64 31 | PKG_MEMORY=8 32 | DUMP_CORE=no 33 | 34 | # Do not start kamailio if fork=no is set in the config file 35 | # otherwise the boot process will just stop 36 | check_fork () 37 | { 38 | if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then 39 | log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead" 40 | exit 0 41 | fi 42 | } 43 | 44 | check_kamailio_config () 45 | { 46 | # Check if kamailio configuration is valid before starting the server 47 | set +e 48 | out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null) 49 | retcode=$? 50 | set -e 51 | if [ "$retcode" != '0' ]; then 52 | log_failure_msg "Not starting $DESC: invalid configuration file!" 53 | log_failure_msg 54 | log_failure_msg "$out" 55 | log_failure_msg 56 | exit 1 57 | fi 58 | } 59 | 60 | create_radius_seqfile () 61 | { 62 | # Create a radius sequence file to be used by the radius client if 63 | # radius accounting is enabled. This is needed to avoid any issue 64 | # with the file not being writable if kamailio first starts as user 65 | # root because DUMP_CORE is enabled and creates this file as user 66 | # root and then later it switches back to user kamailio and cannot 67 | # write to the file. If the file exists before kamailio starts, it 68 | # won't change it's ownership and will be writable for both root 69 | # and kamailio, no matter what options are chosen at install time 70 | RADIUS_SEQ_FILE="$HOMEDIR/kamailio_radius.seq" 71 | if [ -d $HOMEDIR ]; then 72 | chown ${USER}:${GROUP} $HOMEDIR 73 | 74 | if [ ! -f $RADIUS_SEQ_FILE ]; then 75 | touch $RADIUS_SEQ_FILE 76 | fi 77 | 78 | chown ${USER}:${GROUP} $RADIUS_SEQ_FILE 79 | chmod 660 $RADIUS_SEQ_FILE 80 | fi 81 | } 82 | 83 | test -f $DAEMON || exit 0 84 | 85 | # Load startup options if available 86 | if [ -f $DEFAULTS ]; then 87 | . $DEFAULTS || true 88 | fi 89 | 90 | if [ "$RUN_KAMAILIO" != "yes" ]; then 91 | log_failure_msg "Kamailio not yet configured. Edit /etc/default/$NAME first." 92 | exit 0 93 | fi 94 | 95 | set -e 96 | 97 | SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`)) 98 | PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`)) 99 | [ -z "$USER" ] && USER=kamailio 100 | [ -z "$GROUP" ] && GROUP=kamailio 101 | [ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64 102 | [ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4 103 | 104 | if test "$DUMP_CORE" = "yes" ; then 105 | # set proper ulimit 106 | ulimit -c unlimited 107 | 108 | # directory for the core dump files 109 | # COREDIR=/home/corefiles 110 | # [ -d $COREDIR ] || mkdir $COREDIR 111 | # chmod 777 $COREDIR 112 | # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern 113 | fi 114 | 115 | # /var/run can be a tmpfs 116 | if [ ! -d $HOMEDIR ]; then 117 | mkdir -p $HOMEDIR 118 | chown ${USER}:${GROUP} $HOMEDIR 119 | fi 120 | 121 | OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP -DD -E -e" 122 | 123 | case "$1" in 124 | start|debug) 125 | check_kamailio_config 126 | create_radius_seqfile 127 | 128 | if [ "$1" != "debug" ]; then 129 | check_fork 130 | fi 131 | 132 | log_daemon_msg "Starting $DESC: $NAME" 133 | start-stop-daemon --start --quiet --pidfile $PIDFILE \ 134 | --exec $DAEMON -- $OPTIONS || log_failure_msg " already running" 135 | log_end_msg 0 136 | ;; 137 | stop) 138 | log_daemon_msg "Stopping $DESC: $NAME" 139 | start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \ 140 | --exec $DAEMON --retry 5 141 | log_end_msg 0 142 | ;; 143 | restart|force-reload) 144 | check_kamailio_config 145 | create_radius_seqfile 146 | 147 | $0 stop 148 | $0 start 149 | ;; 150 | status) 151 | log_daemon_msg "Status of $DESC: " 152 | 153 | status_of_proc -p"$PIDFILE" $NAME $NAME 154 | ;; 155 | *) 156 | N=/etc/init.d/$NAME 157 | echo "Usage: $N {start|stop|restart|force-reload|status|debug}" >&2 158 | exit 1 159 | ;; 160 | esac 161 | 162 | exit 0 163 | -------------------------------------------------------------------------------- /scscf/kamailio_scscf/README.md: -------------------------------------------------------------------------------- 1 | # Kamailio - Serving-CSCF Example Configuration File 2 | 3 | Project Website: 4 | 5 | * http://www.kamailio.org 6 | 7 | ## Database Structure 8 | 9 | The necessary Database files for the Serving-CSCF can be found in the utils/kamctl/mysql/ folder. 10 | 11 | The following tables (or files) are required: 12 | 13 | * ims_charging_create.sql 14 | * ims_dialog-create.sql 15 | * ms_usrloc_scscf-create.sql 16 | * presence-create.sql 17 | * standard-create.sql 18 | -------------------------------------------------------------------------------- /scscf/kamailio_scscf/dispatcher.list: -------------------------------------------------------------------------------- 1 | # ng-voice Interconnect 2 | -------------------------------------------------------------------------------- /scscf/kamailio_scscf/scscf.cfg: -------------------------------------------------------------------------------- 1 | # SIP / UDP 2 | listen=udp:SCSCF_IP:6060 3 | #listen=udp:10.45.0.1:6060 advertise 172.24.15.30:6060 4 | # SIP / TCP 5 | listen=tcp:SCSCF_IP:6060 6 | #listen=tcp:10.45.0.1:6060 advertise 172.24.15.30:6060 7 | # SIP / TCP/TLS 8 | #listen=tls:11.22.33.44:6061 9 | 10 | #!define NETWORKNAME "ims.mnc001.mcc001.3gppnetwork.org" 11 | #!define NETWORKNAME_ESC "ims\.mnc001\.mcc001\.3gppnetwork\.org" 12 | #!define HOSTNAME "scscf.ims.mnc001.mcc001.3gppnetwork.org" 13 | #!define HOSTNAME_ESC "scscf\.ims\.mnc001\.mcc001\.3gppnetwork\.org" 14 | #!define URI "sip:scscf.ims.mnc001.mcc001.3gppnetwork.org:6060" 15 | 16 | #!subst "/NETWORKNAME/ims.mnc001.mcc001.3gppnetwork.org/" 17 | 18 | alias=scscf.ims.mnc001.mcc001.3gppnetwork.org 19 | 20 | # ENUM-Server to query: 21 | #!define ENUM_SUFFIX "ims.mnc001.mcc001.3gppnetwork.org." 22 | 23 | # SIP-Address of capturing node, if not set, capturing is disabled. 24 | ##!define CAPTURE_NODE "sip:127.0.0.1:9060" 25 | 26 | # Connection URL for the database: 27 | # For use with a single database: 28 | #!define DB_URL "mysql://scscf:heslo@MYSQL_IP/scscf" 29 | 30 | # For use with DB_Cluster: con1 (primary), con2 (backup) 31 | ##!define DB_URL "con1=>mysql://scscf:heslo@127.0.0.1/scscf" 32 | ##!define DB_URL2 "con2=>mysql://scscf:heslo@127.0.0.1/scscf" 33 | 34 | # Select Authorization Algorhithm: 35 | ##!define REG_AUTH_DEFAULT_ALG "AKAv1-MD5" 36 | ##!define REG_AUTH_DEFAULT_ALG "AKAv2-MD5" 37 | ##!define REG_AUTH_DEFAULT_ALG "MD5" 38 | ##!define REG_AUTH_DEFAULT_ALG "CableLabs-Digest" 39 | ##!define REG_AUTH_DEFAULT_ALG "3GPP-Digest" 40 | ##!define REG_AUTH_DEFAULT_ALG "TISPAN-HTTP_DIGEST_MD5" 41 | # Let the HSS decide 42 | #!define REG_AUTH_DEFAULT_ALG "HSS-Selected" 43 | 44 | # Number of TCP Processes 45 | #!define TCP_PROCESSES 3 46 | 47 | ##!define RO_FORCED_PEER "32260@3gpp.org" 48 | #!define RO_DESTINATION "hssocs.voiceblue.com" 49 | #!define RO_ROOT "32260@3gpp.org" 50 | #!define RO_EXT "ext" 51 | #!define RO_MNC "01" 52 | #!define RO_MCC "001" 53 | #(see https://en.wikipedia.org/wiki/Mobile_country_code_(MCC)) 54 | #!define RO_RELEASE "8" 55 | # See http://tools.ietf.org/html/rfc4006#section-4.1.2 for the definition of the Service-Context 56 | 57 | ##!define XMLRPC_WHITELIST_1 "127.0.0.1" 58 | ##!define XMLRPC_WHITELIST_2 "127.0.0.1" 59 | ##!define XMLRPC_WHITELIST_3 "127.0.0.1" 60 | 61 | # Several features can be enabled using '#!define WITH_FEATURE' directives: 62 | # 63 | # *** To run in debug mode: 64 | # - define WITH_DEBUG 65 | # 66 | # *** To enable TCP support execute: 67 | # - define WITH_TCP 68 | # 69 | # *** To enable XMLRPC support execute: 70 | # - define WITH_XMLRPC 71 | # - this will automagically enable TCP 72 | # 73 | # *** To enable the Ro-Interface: 74 | # - Configure Ro-Diameter-Interface in scscf.xml 75 | # - define WITH_RO 76 | # 77 | # *** To enable a Homer SIP-Capter-Node: 78 | # - define CAPTURE_NODE with a proper address 79 | # 80 | # Enabled Features for this host: 81 | ##!define WITH_DEBUG 82 | #!define WITH_TCP 83 | ##!define WITH_XMLRPC 84 | ##!define WITH_RO 85 | ##!define WITH_RO_TERM 86 | #!define WITH_AUTH 87 | -------------------------------------------------------------------------------- /scscf/kamailio_scscf/scscf.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /scscf/scscf_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true; do 4 | echo 'Waiting for MySQL to start.' 5 | echo '' | nc -w 1 $MYSQL_IP 3306 && break 6 | sleep 1 7 | done 8 | 9 | while true; do 10 | echo 'Waiting for FHoSS to start.' 11 | echo '' | nc -w 1 $FHOSS_IP 3868 && break 12 | sleep 1 13 | done 14 | 15 | 16 | sed -i 's|SCSCF_IP|'$SCSCF_IP'|g' /etc/kamailio_scscf/kamailio_scscf.cfg 17 | sed -i 's|SCSCF_IP|'$SCSCF_IP'|g' /etc/kamailio_scscf/scscf.cfg 18 | sed -i 's|MYSQL_IP|'$MYSQL_IP'|g' /etc/kamailio_scscf/scscf.cfg 19 | sed -i 's|SCSCF_IP|'$SCSCF_IP'|g' /etc/kamailio_scscf/scscf.xml 20 | 21 | /etc/init.d/kamailio_scscf start 22 | -------------------------------------------------------------------------------- /sgw/Dockerfile: -------------------------------------------------------------------------------- 1 | # BSD 2-Clause License 2 | 3 | # Copyright (c) 2019, Supreeth Herle 4 | # All rights reserved. 5 | 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | 9 | # 1. Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | FROM docker_open5gs 28 | 29 | # Expose port 2152 30 | EXPOSE 2152/udp 31 | 32 | # Expose port 2123 33 | EXPOSE 2123/udp 34 | 35 | CMD /mnt/sgw/sgw_init.sh && \ 36 | cd install/bin && ./open5gs-sgwd -------------------------------------------------------------------------------- /sgw/sgw.yaml: -------------------------------------------------------------------------------- 1 | logger: 2 | file: /open5gs/install/var/log/open5gs/sgw.log 3 | 4 | parameter: 5 | no_ipv6: true 6 | 7 | sgw: 8 | gtpc: 9 | dev: SGW_IF 10 | gtpu: 11 | dev: SGW_IF 12 | -------------------------------------------------------------------------------- /sgw/sgw_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 2-Clause License 4 | 5 | # Copyright (c) 2019, Supreeth Herle 6 | # All rights reserved. 7 | 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | export IF_NAME=$(ip r | awk '/default/ { print $5 }') 30 | 31 | cp /mnt/sgw/sgw.yaml install/etc/open5gs 32 | sed -i 's|SGW_IF|'$IF_NAME'|g' install/etc/open5gs/sgw.yaml 33 | 34 | 35 | -------------------------------------------------------------------------------- /srsenb.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | srsenb: 4 | build: ./srslte 5 | image: open5gs_srslte 6 | container_name: srsenb 7 | privileged: true 8 | volumes: 9 | - /dev/bus/usb:/dev/bus/usb 10 | - ./srslte:/mnt/srsenb 11 | environment: 12 | - MME_IP=${MME_IP} 13 | - ENB_IP=${ENB_IP} 14 | - DL_EARFCN=${DL_EARFCN} 15 | - TX_GAIN=${TX_GAIN} 16 | - RX_GAIN=${RX_GAIN} 17 | networks: 18 | default: 19 | ipv4_address: ${ENB_IP} 20 | networks: 21 | default: 22 | external: 23 | name: docker_open5gs_default 24 | -------------------------------------------------------------------------------- /srslte/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | # Install updates and dependencies 4 | RUN apt-get update && \ 5 | apt-get -y install cmake libfftw3-dev libmbedtls-dev libboost-program-options-dev libconfig++-dev libsctp-dev 6 | RUN apt-get -y install git 7 | 8 | # Install Ettus USRP (UHD) 9 | RUN apt-get -y install libuhd-dev libuhd003.010.003 uhd-host --no-install-recommends && \ 10 | /usr/bin/uhd_images_downloader 11 | 12 | # Get srsLTE and compile 13 | RUN git clone https://github.com/srsLTE/srsLTE.git && \ 14 | cd srsLTE && \ 15 | git checkout tags/release_19_12 16 | 17 | WORKDIR /srsLTE 18 | 19 | RUN mkdir build && \ 20 | mkdir /etc/srslte && \ 21 | cd build && \ 22 | cmake ../ && \ 23 | make -j4 && \ 24 | make install && \ 25 | ldconfig 26 | 27 | COPY conf/*.conf /srsLTE/ 28 | 29 | EXPOSE 2152/udp 30 | EXPOSE 2123/udp 31 | 32 | CMD /mnt/srsenb/srsenb_init.sh && \ 33 | /usr/local/bin/srsenb 34 | -------------------------------------------------------------------------------- /srslte/conf/drb.conf: -------------------------------------------------------------------------------- 1 | // All times are in ms. Use -1 for infinity, where available 2 | 3 | qci_config = ( 4 | 5 | { 6 | qci=1; 7 | pdcp_config = { 8 | discard_timer = 100; 9 | pdcp_sn_size = 12; 10 | } 11 | rlc_config = { 12 | ul_um = { 13 | sn_field_length = 10; 14 | }; 15 | dl_um = { 16 | sn_field_length = 10; 17 | t_reordering = 50; 18 | }; 19 | }; 20 | logical_channel_config = { 21 | priority = 6; 22 | prioritized_bit_rate = -1; 23 | bucket_size_duration = 100; 24 | log_chan_group = 1; 25 | }; 26 | }, 27 | { 28 | qci=5; 29 | pdcp_config = { 30 | discard_timer = -1; 31 | status_report_required = true; 32 | } 33 | rlc_config = { 34 | ul_am = { 35 | t_poll_retx = 80; 36 | poll_pdu = 128; 37 | poll_byte = 125; 38 | max_retx_thresh = 4; 39 | }; 40 | dl_am = { 41 | t_reordering = 80; 42 | t_status_prohibit = 60; 43 | }; 44 | }; 45 | logical_channel_config = { 46 | priority = 13; 47 | prioritized_bit_rate = -1; 48 | bucket_size_duration = 100; 49 | log_chan_group = 2; 50 | }; 51 | }, 52 | { 53 | qci=7; 54 | pdcp_config = { 55 | discard_timer = 100; 56 | pdcp_sn_size = 12; 57 | } 58 | rlc_config = { 59 | ul_um = { 60 | sn_field_length = 10; 61 | }; 62 | dl_um = { 63 | sn_field_length = 10; 64 | t_reordering = 45; 65 | }; 66 | }; 67 | logical_channel_config = { 68 | priority = 13; 69 | prioritized_bit_rate = -1; 70 | bucket_size_duration = 100; 71 | log_chan_group = 2; 72 | }; 73 | }, 74 | { 75 | qci=9; 76 | pdcp_config = { 77 | discard_timer = -1; 78 | status_report_required = true; 79 | } 80 | rlc_config = { 81 | ul_am = { 82 | t_poll_retx = 120; 83 | poll_pdu = 64; 84 | poll_byte = 750; 85 | max_retx_thresh = 16; 86 | }; 87 | dl_am = { 88 | t_reordering = 50; 89 | t_status_prohibit = 50; 90 | }; 91 | }; 92 | logical_channel_config = { 93 | priority = 11; 94 | prioritized_bit_rate = -1; 95 | bucket_size_duration = 100; 96 | log_chan_group = 3; 97 | }; 98 | } 99 | 100 | ); 101 | -------------------------------------------------------------------------------- /srslte/conf/enb.conf: -------------------------------------------------------------------------------- 1 | ##################################################################### 2 | # srsENB configuration file 3 | ##################################################################### 4 | 5 | ##################################################################### 6 | # eNB configuration 7 | # 8 | # enb_id: 20-bit eNB identifier. 9 | # cell_id: 8-bit cell identifier. 10 | # tac: 16-bit Tracking Area Code. 11 | # mcc: Mobile Country Code 12 | # mnc: Mobile Network Code 13 | # mme_addr: IP address of MME for S1 connnection 14 | # gtp_bind_addr: Local IP address to bind for GTP connection 15 | # s1c_bind_addr: Local IP address to bind for S1AP connection 16 | # n_prb: Number of Physical Resource Blocks (6,15,25,50,75,100) 17 | # tm: Transmission mode 1-4 (TM1 default) 18 | # nof_ports: Number of Tx ports (1 port default, set to 2 for TM2/3/4) 19 | # 20 | ##################################################################### 21 | [enb] 22 | enb_id = 0x19B 23 | cell_id = 0x01 24 | phy_cell_id = 1 25 | tac = 1 26 | mcc = 001 27 | mnc = 01 28 | mme_addr = MME_IP # S1AP, should match S1AP setting in mme.yaml 29 | gtp_bind_addr = ENB_IP 30 | s1c_bind_addr = ENB_IP 31 | # s1c_bind_addr = 127.0.0.2 32 | n_prb = 50 33 | #tm = 4 34 | #nof_ports = 2 35 | 36 | ##################################################################### 37 | # eNB configuration files 38 | # 39 | # sib_config: SIB1, SIB2 and SIB3 configuration file 40 | # note: when enabling mbms, use the sib.conf.mbsfn configuration file which includes SIB13 41 | # rr_config: Radio Resources configuration file 42 | # drb_config: DRB configuration file 43 | ##################################################################### 44 | [enb_files] 45 | sib_config = /etc/srslte/sib.conf 46 | rr_config = /etc/srslte/rr.conf 47 | drb_config = /etc/srslte/drb.conf 48 | 49 | ##################################################################### 50 | # RF configuration 51 | # 52 | # dl_earfcn: EARFCN code for DL 53 | # tx_gain: Transmit gain (dB). 54 | # rx_gain: Optional receive gain (dB). If disabled, AGC if enabled 55 | # 56 | # Optional parameters: 57 | # dl_freq: Override DL frequency corresponding to dl_earfcn 58 | # ul_freq: Override UL frequency corresponding to dl_earfcn (must be set if dl_freq is set) 59 | # device_name: Device driver family. Supported options: "auto" (uses first found), "UHD" or "bladeRF" 60 | # device_args: Arguments for the device driver. Options are "auto" or any string. 61 | # Default for UHD: "recv_frame_size=9232,send_frame_size=9232" 62 | # Default for bladeRF: "" 63 | # #time_adv_nsamples: Transmission time advance (in number of samples) to compensate for RF delay 64 | # from antenna to timestamp insertion. 65 | # Default "auto". B210 USRP: 100 samples, bladeRF: 27. 66 | # burst_preamble_us: Preamble length to transmit before start of burst. 67 | # Default "auto". B210 USRP: 400 us, bladeRF: 0 us. 68 | ##################################################################### 69 | [rf] # 2460 works for Samsung Galaxy S5 70 | dl_earfcn = DL_EARFCN # LTE band 5 71 | # dl_earfcn = 3100 # LTE band 7 72 | # dl_earfcn = 300 # LTE band 1 73 | # dl_earfcn = 3625 # LTE band 8 74 | # dl_earfcn = 9435 # LTE band 28 75 | tx_gain = TX_GAIN 76 | rx_gain = RX_GAIN 77 | # device_name = bladeRF 78 | device_name = UHD 79 | device_args = num_recv_frames=64,num_send_frames=64,clock=external 80 | 81 | # device_args = type=usrp2,addr=192.168.10.2 82 | 83 | #device_name = auto 84 | 85 | # For best performance in 2x2 MIMO and >= 15 MHz use the following device_args settings: 86 | # USRP B210: num_recv_frames=64,num_send_frames=64 87 | 88 | # For best performance when BW<5 MHz (25 PRB), use the following device_args settings: 89 | # USRP B210: send_frame_size=512,recv_frame_size=512 90 | 91 | #device_args = auto 92 | #time_adv_nsamples = auto 93 | #burst_preamble_us = auto 94 | 95 | 96 | ##################################################################### 97 | # MAC-layer packet capture configuration 98 | # 99 | # Packets are captured to file in the compact format decoded by 100 | # the Wireshark mac-lte-framed dissector and with DLT 147. 101 | # To use the dissector, edit the preferences for DLT_USER to 102 | # add an entry with DLT=147, Payload Protocol=mac-lte-framed. 103 | # For more information see: https://wiki.wireshark.org/MAC-LTE 104 | # 105 | # Please note that this setting will by default only capture MAC 106 | # frames on dedicated channels, and not SIB. You have to build with 107 | # WRITE_SIB_PCAP enabled in srsenb/src/stack/mac/mac.cc if you want 108 | # SIB to be part of the MAC pcap file. 109 | # 110 | # enable: Enable MAC layer packet captures (true/false) 111 | # filename: File path to use for packet captures 112 | ##################################################################### 113 | [pcap] 114 | enable = false 115 | filename = /tmp/enb.pcap 116 | 117 | ##################################################################### 118 | # Log configuration 119 | # 120 | # Log levels can be set for individual layers. "all_level" sets log 121 | # level for all layers unless otherwise configured. 122 | # Format: e.g. phy_level = info 123 | # 124 | # In the same way, packet hex dumps can be limited for each level. 125 | # "all_hex_limit" sets the hex limit for all layers unless otherwise 126 | # configured. 127 | # Format: e.g. phy_hex_limit = 32 128 | # 129 | # Logging layers: rf, phy, mac, rlc, pdcp, rrc, nas, gtpu, usim, all 130 | # Logging levels: debug, info, warning, error, none 131 | # 132 | # filename: File path to use for log output. Can be set to stdout 133 | # to print logs to standard output 134 | # file_max_size: Maximum file size (in kilobytes). When passed, multiple files are created. 135 | # If set to negative, a single log file will be created. 136 | ##################################################################### 137 | [log] 138 | all_level = info 139 | all_hex_limit = 32 140 | filename = /tmp/enb.log 141 | file_max_size = -1 142 | 143 | [gui] 144 | enable = false 145 | 146 | ##################################################################### 147 | # Scheduler configuration options 148 | # 149 | # pdsch_mcs: Optional fixed PDSCH MCS (ignores reported CQIs if specified) 150 | # pdsch_max_mcs: Optional PDSCH MCS limit 151 | # pusch_mcs: Optional fixed PUSCH MCS (ignores reported CQIs if specified) 152 | # pusch_max_mcs: Optional PUSCH MCS limit 153 | # #nof_ctrl_symbols: Number of control symbols 154 | # 155 | ##################################################################### 156 | [scheduler] 157 | #pdsch_mcs = -1 158 | #pdsch_max_mcs = -1 159 | #pusch_mcs = -1 160 | pusch_max_mcs = 16 161 | nof_ctrl_symbols = 3 162 | 163 | ##################################################################### 164 | # eMBMS configuration options 165 | # 166 | # enable: Enable MBMS transmission in the eNB 167 | # m1u_multiaddr: Multicast addres the M1-U socket will register to 168 | # m1u_if_addr: Address of the inteferface the M1-U interface will listen for multicast packets. 169 | # 170 | ##################################################################### 171 | #enable = false 172 | #m1u_multiaddr = 239.255.0.1 173 | #m1u_if_addr = 127.0.1.201 174 | 175 | ##################################################################### 176 | # Expert configuration options 177 | # 178 | # pusch_max_its: Maximum number of turbo decoder iterations (Default 4) 179 | # pusch_8bit_decoder: Use 8-bit for LLR representation and turbo decoder trellis computation (Experimental) 180 | # nof_phy_threads: Selects the number of PHY threads (maximum 4, minimum 1, default 2) 181 | # metrics_period_secs: Sets the period at which metrics are requested from the eNB. 182 | # metrics_csv_enable: Write eNB metrics to CSV file. 183 | # metrics_csv_filename: File path to use for CSV metrics. 184 | # pregenerate_signals: Pregenerate uplink signals after attach. Improves CPU performance. 185 | # tx_amplitude: Transmit amplitude factor (set 0-1 to reduce PAPR) 186 | # link_failure_nof_err: Number of PUSCH failures after which a radio-link failure is triggered. 187 | # a link failure is when SNR<0 and CRC=KO 188 | # max_prach_offset_us: Maximum allowed RACH offset (in us) 189 | # eea_pref_list: Ordered preference list for the selection of encryption algorithm (EEA) (default: EEA0, EEA2, EEA1). 190 | # eia_pref_list: Ordered preference list for the selection of integrity algorithm (EIA) (default: EIA2, EIA1, EIA0). 191 | # 192 | ##################################################################### 193 | [expert] 194 | #pusch_max_its = 8 # These are half iterations 195 | #pusch_8bit_decoder = false 196 | #nof_phy_threads = 3 197 | #metrics_period_secs = 1 198 | #metrics_csv_enable = false 199 | #metrics_csv_filename = /tmp/enb_metrics.csv 200 | #pregenerate_signals = false 201 | #tx_amplitude = 0.6 202 | #link_failure_nof_err = 50 203 | #rrc_inactivity_timer = 60000 204 | #max_prach_offset_us = 30 205 | #eea_pref_list = EEA0, EEA2, EEA1 206 | #eia_pref_list = EIA2, EIA1, EIA0 207 | -------------------------------------------------------------------------------- /srslte/conf/rr.conf: -------------------------------------------------------------------------------- 1 | mac_cnfg = 2 | { 3 | phr_cnfg = 4 | { 5 | dl_pathloss_change = "dB3"; // Valid: 1, 3, 6 or INFINITY 6 | periodic_phr_timer = 50; 7 | prohibit_phr_timer = 0; 8 | }; 9 | ulsch_cnfg = 10 | { 11 | max_harq_tx = 4; 12 | periodic_bsr_timer = 20; // in ms 13 | retx_bsr_timer = 320; // in ms 14 | }; 15 | 16 | time_alignment_timer = -1; // -1 is infinity 17 | }; 18 | 19 | phy_cnfg = 20 | { 21 | phich_cnfg = 22 | { 23 | duration = "Normal"; 24 | resources = "1/6"; 25 | }; 26 | 27 | pusch_cnfg_ded = 28 | { 29 | beta_offset_ack_idx = 6; 30 | beta_offset_ri_idx = 6; 31 | beta_offset_cqi_idx = 6; 32 | }; 33 | 34 | // PUCCH-SR resources are scheduled on time-frequeny domain first, then multiplexed in the same resource. 35 | sched_request_cnfg = 36 | { 37 | dsr_trans_max = 64; 38 | period = 20; // in ms 39 | subframe = [1]; // vector of subframe indices allowed for SR transmissions 40 | nof_prb = 2; // number of PRBs on each extreme used for SR (total prb is twice this number) 41 | }; 42 | cqi_report_cnfg = 43 | { 44 | mode = "periodic"; 45 | simultaneousAckCQI = true; 46 | period = 40; // in ms 47 | subframe = [0]; 48 | nof_prb = 2; 49 | m_ri = 8; // RI period in CQI period 50 | }; 51 | }; 52 | -------------------------------------------------------------------------------- /srslte/conf/sib.conf: -------------------------------------------------------------------------------- 1 | sib1 = 2 | { 3 | intra_freq_reselection = "Allowed"; 4 | q_rx_lev_min = -65; 5 | //p_max = 3; 6 | cell_barred = "NotBarred" 7 | si_window_length = 20; 8 | sched_info = 9 | ( 10 | { 11 | si_periodicity = 16; 12 | si_mapping_info = []; // comma-separated array of SIB-indexes (from 3 to 13). 13 | // Leave empty or commented to just scheduler sib2 14 | } 15 | ); 16 | system_info_value_tag = 0; 17 | }; 18 | 19 | sib2 = 20 | { 21 | rr_config_common_sib = 22 | { 23 | rach_cnfg = 24 | { 25 | num_ra_preambles = 52; 26 | preamble_init_rx_target_pwr = -104; 27 | pwr_ramping_step = 6; // in dB 28 | preamble_trans_max = 10; 29 | ra_resp_win_size = 10; // in ms 30 | mac_con_res_timer = 64; // in ms 31 | max_harq_msg3_tx = 4; 32 | }; 33 | bcch_cnfg = 34 | { 35 | modification_period_coeff = 16; // in ms 36 | }; 37 | pcch_cnfg = 38 | { 39 | default_paging_cycle = 32; // in rf 40 | nB = "1"; 41 | }; 42 | prach_cnfg = 43 | { 44 | root_sequence_index = 128; 45 | prach_cnfg_info = 46 | { 47 | high_speed_flag = false; 48 | prach_config_index = 3; 49 | prach_freq_offset = 2; 50 | zero_correlation_zone_config = 5; 51 | }; 52 | }; 53 | pdsch_cnfg = 54 | { 55 | /* Warning: Currently disabled and forced to p_b=1 for TM2/3/4 and p_b=0 for TM1 56 | */ 57 | p_b = 1; 58 | rs_power = 0; 59 | }; 60 | pusch_cnfg = 61 | { 62 | n_sb = 1; 63 | hopping_mode = "inter-subframe"; 64 | pusch_hopping_offset = 2; 65 | enable_64_qam = false; // 64QAM PUSCH is not currently enabled 66 | ul_rs = 67 | { 68 | cyclic_shift = 0; 69 | group_assignment_pusch = 0; 70 | group_hopping_enabled = false; 71 | sequence_hopping_enabled = false; 72 | }; 73 | }; 74 | pucch_cnfg = 75 | { 76 | delta_pucch_shift = 2; 77 | n_rb_cqi = 2; 78 | n_cs_an = 0; 79 | n1_pucch_an = 12; 80 | }; 81 | ul_pwr_ctrl = 82 | { 83 | p0_nominal_pusch = -85; 84 | alpha = 0.7; 85 | p0_nominal_pucch = -107; 86 | delta_flist_pucch = 87 | { 88 | format_1 = 0; 89 | format_1b = 3; 90 | format_2 = 1; 91 | format_2a = 2; 92 | format_2b = 2; 93 | }; 94 | delta_preamble_msg3 = 6; 95 | }; 96 | ul_cp_length = "len1"; 97 | }; 98 | 99 | ue_timers_and_constants = 100 | { 101 | t300 = 2000; // in ms 102 | t301 = 100; // in ms 103 | t310 = 1000; // in ms 104 | n310 = 1; 105 | t311 = 1000; // in ms 106 | n311 = 1; 107 | }; 108 | 109 | freqInfo = 110 | { 111 | ul_carrier_freq_present = true; 112 | ul_bw_present = true; 113 | additional_spectrum_emission = 1; 114 | }; 115 | 116 | time_alignment_timer = "INFINITY"; // use "sf500", "sf750", etc. 117 | }; 118 | 119 | -------------------------------------------------------------------------------- /srslte/srsenb_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p /etc/srslte 4 | cp /mnt/srsenb/conf/*.conf /etc/srslte/ 5 | 6 | sed -i 's|MME_IP|'$MME_IP'|g' /etc/srslte/enb.conf 7 | sed -i 's|ENB_IP|'$ENB_IP'|g' /etc/srslte/enb.conf 8 | sed -i 's|DL_EARFCN|'$DL_EARFCN'|g' /etc/srslte/enb.conf 9 | sed -i 's|TX_GAIN|'$TX_GAIN'|g' /etc/srslte/enb.conf 10 | sed -i 's|RX_GAIN|'$RX_GAIN'|g' /etc/srslte/enb.conf 11 | -------------------------------------------------------------------------------- /test-dns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -a 3 | . .env 4 | set +a 5 | 6 | host hss.epc.mnc001.mcc001.3gppnetwork.org. $DNS_IP 7 | host mme.epc.mnc001.mcc001.3gppnetwork.org. $DNS_IP 8 | host pcrf.epc.mnc001.mcc001.3gppnetwork.org. $DNS_IP 9 | host ims.mnc001.mcc001.3gppnetwork.org. $DNS_IP 10 | host pcscf.ims.mnc001.mcc001.3gppnetwork.org. $DNS_IP 11 | host -t SRV _sip._udp.pcscf.ims.mnc001.mcc001.3gppnetwork.org $DNS_IP 12 | host -t SRV _sip._tcp.scscf.ims.mnc001.mcc001.3gppnetwork.org $DNS_IP 13 | --------------------------------------------------------------------------------