├── .debian.packages ├── .github └── workflows │ └── docker-image.yml ├── .gitignore ├── LICENSE ├── README.md ├── docker-compose.yml ├── docs ├── config.md ├── getting-started.md ├── icscf.md ├── pcscf.md └── scscf.md ├── icscf ├── .gitignore ├── freeDiameter.conf.m4 ├── icscf.dictionary └── opensips.cfg ├── pcscf ├── .gitignore ├── db │ ├── dispatcher │ └── version ├── entrypoint.sh ├── freeDiameter.conf.m4 ├── opensips.cfg └── pcscf.dictionary ├── scscf ├── .gitignore ├── entrypoint.sh ├── freeDiameter.conf.m4 ├── opensips.cfg ├── scscf.dictionary └── substenv.sh └── substenv.sh /.debian.packages: -------------------------------------------------------------------------------- 1 | m4 2 | iproute2 3 | gettext-base 4 | default-mysql-client 5 | opensips-xml-module 6 | opensips-json-module 7 | opensips-auth-modules 8 | opensips-http-modules 9 | opensips-ipsec-module 10 | opensips-mysql-module 11 | opensips-mysql-dbschema 12 | opensips-diameter-module 13 | opensips-dialplan-module 14 | opensips-presence-modules 15 | -------------------------------------------------------------------------------- /.github/workflows/docker-image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Build OpenSIPS SoftSwitch IMS Image 3 | 4 | on: 5 | workflow_dispatch: 6 | push: 7 | paths: 8 | - .debian.packages 9 | 10 | jobs: 11 | 12 | publish: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - name: Get the required packages 20 | id: fetch_packages 21 | run: echo "MODULES=$(cat .debian.packages | tr '\n' ' ')" > $GITHUB_OUTPUT 22 | 23 | - name: Publish OpenSIPS SoftSwitch IMS Docker image 24 | uses: OpenSIPS/docker-opensips/.github/actions/docker-opensips-publish@main 25 | with: 26 | version: 3.6 27 | tag: ims-ce 28 | cli: false 29 | build: nightly 30 | modules: ${{ steps.fetch_packages.outputs.MODULES }} 31 | docker-username: ${{ secrets.DOCKER_USERNAME }} 32 | docker-token: ${{ secrets.DOCKER_TOKEN }} 33 | 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | freeDiameter.conf 2 | .*\.swp 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenSIPS IMS - Community Edition 2 | 3 | This project provides a fully working IMS (IP Multimedia Subsystem) CSCF (Call 4 | Session Control Function) component compliant with the 3GPP specifications for 5 | IMS and VoLTE integration. 6 | 7 | Currently, the project includes the following essential IMS CSCF sub-components: 8 | 9 | * [P-CSCF](docs/pcscf.md) (Proxy CSCF): Acts as the entry point for SIP 10 | signaling, providing initial security, routing, and NAT traversal 11 | functionalities. 12 | * [I-CSCF](docs/icscf.md) (Interrogating CSCF): Manages SIP signaling for 13 | session control and ensures secure interactions between home and external 14 | networks. 15 | * [S-CSCF](docs/scscf.md) (Serving CSCF): Handles session management, including 16 | registration, authentication, and routing for end-user SIP sessions. 17 | 18 | Each sub-component adheres to the IMS standards outlined in TS 124 228, 19 | ensuring compatibility and enabling seamless integration as a replacement in an 20 | existing (non OpenSIPS-based) IMS setup. 21 | 22 | The project is designed to seamlessly integrate and provide the IMS 23 | functionality within the Dockerized Open5GS 4G core network, incorporating all 24 | the essential CSCF (Call Session Control Function) Docker components for a 25 | fully integrated solution. 26 | 27 | ## Getting Started 28 | 29 | The IP Multimedia Subsystem (IMS) must operate on top of an existing core 30 | network, such as a 4G Evolved Packet Core (EPC) or a 5G Core (5GC). A 31 | straightforward method to set up such a network is by using the 32 | [Docker Open5GS](https://github.com/herlesupreeth/docker_open5gs) 33 | project, which offers a Dockerized container solution for running a 4G/5G 34 | network. 35 | 36 | Follow the [Getting Started](docs/getting-started.md) tutorial to set up IMS 37 | within the Docker Open5GS environment. 38 | 39 | ## Configuration 40 | 41 | Each component's script can be customized using various environment variables. 42 | The [Configuration](docs/config.md) page provides a comprehensive list of all 43 | the adjustable variables. 44 | 45 | Detailed information about the configuration and tuning of each sub-component 46 | can be found on its dedicated page. 47 | 48 | ## Documentation 49 | 50 | Documentation pages contain the following topics: 51 | 52 | * [P-CSCF](docs/pcscf.md) - information about P-CSCF sub-component 53 | * [I-CSCF](docs/icscf.md) - information about I-CSCF sub-component 54 | * [S-CSCF](docs/scscf.md) - information about S-CSCF sub-component 55 | * [Getting Started](docs/getting-started.md) - show how you can setup OpenSIPS 56 | IMS Community Edition in the Docker Open5GS environment 57 | * [Configuration](docs/config.md) - detailed information about configuration 58 | 59 | 60 | ## Contribute 61 | 62 | This project is Community driven, therefore any contribution is welcome. Feel 63 | free to open a pull request for any fix/feature you find useful. 64 | 65 | ## License 66 | 67 | 68 | [License-GPLv3]: https://www.gnu.org/licenses/gpl-3.0.en.html "GNU GPLv3" 69 | [Logo-CC_BY]: https://i.creativecommons.org/l/by/4.0/88x31.png "Creative Common Logo" 70 | [License-CC_BY]: https://creativecommons.org/licenses/by/4.0/legalcode "Creative Common License" 71 | 72 | The `OpenSIPS IMS Community Edition` source code is licensed under the [GNU General Public License v3.0][License-GPLv3] 73 | 74 | All documentation files (i.e. `.md` extension) are licensed under the [Creative Common License 4.0][License-CC_BY] 75 | 76 | ![Creative Common Logo][Logo-CC_BY] 77 | 78 | © 2024 - SIP Point Consulting SRL 79 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | mongo: 3 | image: mongo:6.0 4 | container_name: mongo 5 | command: --bind_ip 0.0.0.0 6 | env_file: 7 | - .env 8 | volumes: 9 | - mongodbdata:/data/db 10 | - mongodbdata:/data/configdb 11 | - /etc/timezone:/etc/timezone:ro 12 | - /etc/localtime:/etc/localtime:ro 13 | expose: 14 | - "27017/udp" 15 | - "27017/tcp" 16 | networks: 17 | default: 18 | ipv4_address: ${MONGO_IP} 19 | webui: 20 | image: docker_open5gs 21 | container_name: webui 22 | depends_on: 23 | - mongo 24 | env_file: 25 | - .env 26 | environment: 27 | - COMPONENT_NAME=webui 28 | volumes: 29 | - ./webui:/mnt/webui 30 | - /etc/timezone:/etc/timezone:ro 31 | - /etc/localtime:/etc/localtime:ro 32 | expose: 33 | - "9999/tcp" 34 | ports: 35 | - "9999:9999/tcp" 36 | networks: 37 | default: 38 | ipv4_address: ${WEBUI_IP} 39 | hss: 40 | image: docker_open5gs 41 | container_name: hss 42 | env_file: 43 | - .env 44 | environment: 45 | - COMPONENT_NAME=hss-1 46 | volumes: 47 | - ./hss:/mnt/hss 48 | - ./log:/open5gs/install/var/log/open5gs 49 | - /etc/timezone:/etc/timezone:ro 50 | - /etc/localtime:/etc/localtime:ro 51 | depends_on: 52 | - mongo 53 | expose: 54 | - "3868/udp" 55 | - "3868/tcp" 56 | - "3868/sctp" 57 | - "5868/udp" 58 | - "5868/tcp" 59 | - "5868/sctp" 60 | networks: 61 | default: 62 | ipv4_address: ${HSS_IP} 63 | sgwc: 64 | image: docker_open5gs 65 | depends_on: 66 | - smf 67 | - upf 68 | container_name: sgwc 69 | env_file: 70 | - .env 71 | environment: 72 | - COMPONENT_NAME=sgwc-1 73 | volumes: 74 | - ./sgwc:/mnt/sgwc 75 | - ./log:/open5gs/install/var/log/open5gs 76 | - /etc/timezone:/etc/timezone:ro 77 | - /etc/localtime:/etc/localtime:ro 78 | expose: 79 | - "2123/udp" 80 | - "8805/udp" 81 | networks: 82 | default: 83 | ipv4_address: ${SGWC_IP} 84 | sgwu: 85 | image: docker_open5gs 86 | depends_on: 87 | - smf 88 | - upf 89 | container_name: sgwu 90 | env_file: 91 | - .env 92 | environment: 93 | - COMPONENT_NAME=sgwu-1 94 | volumes: 95 | - ./sgwu:/mnt/sgwu 96 | - ./log:/open5gs/install/var/log/open5gs 97 | - /etc/timezone:/etc/timezone:ro 98 | - /etc/localtime:/etc/localtime:ro 99 | expose: 100 | - "8805/udp" 101 | - "2152/udp" 102 | ports: 103 | - "2152:2152/udp" 104 | networks: 105 | default: 106 | ipv4_address: ${SGWU_IP} 107 | smf: 108 | image: docker_open5gs 109 | container_name: smf 110 | env_file: 111 | - .env 112 | environment: 113 | - COMPONENT_NAME=smf-1 114 | - DEPLOY_MODE=4G 115 | volumes: 116 | - ./smf:/mnt/smf 117 | - ./log:/open5gs/install/var/log/open5gs 118 | - /etc/timezone:/etc/timezone:ro 119 | - /etc/localtime:/etc/localtime:ro 120 | expose: 121 | - "3868/udp" 122 | - "3868/tcp" 123 | - "3868/sctp" 124 | - "5868/udp" 125 | - "5868/tcp" 126 | - "5868/sctp" 127 | - "8805/udp" 128 | - "2123/udp" 129 | - "7777/tcp" 130 | - "9091/tcp" 131 | networks: 132 | default: 133 | ipv4_address: ${SMF_IP} 134 | upf: 135 | image: docker_open5gs 136 | depends_on: 137 | - smf 138 | container_name: upf 139 | env_file: 140 | - .env 141 | environment: 142 | - COMPONENT_NAME=upf-1 143 | volumes: 144 | - ./upf:/mnt/upf 145 | - ./log:/open5gs/install/var/log/open5gs 146 | - /etc/timezone:/etc/timezone:ro 147 | - /etc/localtime:/etc/localtime:ro 148 | expose: 149 | - "2152/udp" 150 | - "8805/udp" 151 | - "9091/tcp" 152 | cap_add: 153 | - NET_ADMIN 154 | privileged: true 155 | sysctls: 156 | - net.ipv4.ip_forward=1 157 | networks: 158 | default: 159 | ipv4_address: ${UPF_IP} 160 | mme: 161 | image: docker_open5gs 162 | depends_on: 163 | - hss 164 | - sgwc 165 | - sgwu 166 | - smf 167 | - upf 168 | - osmomsc 169 | container_name: mme 170 | env_file: 171 | - .env 172 | environment: 173 | - COMPONENT_NAME=mme-1 174 | volumes: 175 | - ./mme:/mnt/mme 176 | - ./log:/open5gs/install/var/log/open5gs 177 | - /etc/timezone:/etc/timezone:ro 178 | - /etc/localtime:/etc/localtime:ro 179 | expose: 180 | - "3868/udp" 181 | - "3868/tcp" 182 | - "3868/sctp" 183 | - "5868/udp" 184 | - "5868/tcp" 185 | - "5868/sctp" 186 | - "36412/sctp" 187 | - "2123/udp" 188 | - "9091/tcp" 189 | ports: 190 | - "36412:36412/sctp" 191 | networks: 192 | default: 193 | ipv4_address: ${MME_IP} 194 | pcrf: 195 | image: docker_open5gs 196 | container_name: pcrf 197 | env_file: 198 | - .env 199 | environment: 200 | - COMPONENT_NAME=pcrf-1 201 | depends_on: 202 | - mongo 203 | volumes: 204 | - ./pcrf:/mnt/pcrf 205 | - ./log:/open5gs/install/var/log/open5gs 206 | - /etc/timezone:/etc/timezone:ro 207 | - /etc/localtime:/etc/localtime:ro 208 | expose: 209 | - "3868/udp" 210 | - "3868/tcp" 211 | - "3868/sctp" 212 | - "5868/udp" 213 | - "5868/tcp" 214 | - "5868/sctp" 215 | networks: 216 | default: 217 | ipv4_address: ${PCRF_IP} 218 | dns: 219 | build: ./dns 220 | image: docker_dns 221 | container_name: dns 222 | env_file: 223 | - .env 224 | volumes: 225 | - ./dns:/mnt/dns 226 | - /etc/timezone:/etc/timezone:ro 227 | - /etc/localtime:/etc/localtime:ro 228 | expose: 229 | - "53/udp" 230 | networks: 231 | default: 232 | ipv4_address: ${DNS_IP} 233 | rtpengine: 234 | build: ./rtpengine 235 | image: docker_rtpengine 236 | container_name: rtpengine 237 | privileged: true 238 | env_file: 239 | - .env 240 | volumes: 241 | - ./rtpengine:/mnt/rtpengine 242 | - /etc/timezone:/etc/timezone:ro 243 | - /etc/localtime:/etc/localtime:ro 244 | cap_add: 245 | - NET_ADMIN 246 | environment: 247 | - TABLE=0 248 | - INTERFACE=${RTPENGINE_IP} 249 | - LISTEN_NG=${RTPENGINE_IP}:2223 250 | - PIDFILE=/run/ngcp-rtpengine-daemon.pid 251 | - PORT_MAX=50000 252 | - PORT_MIN=49000 253 | - NO_FALLBACK=no 254 | - TOS=184 255 | expose: 256 | - "2223/udp" 257 | - "49000-50000/udp" 258 | networks: 259 | default: 260 | ipv4_address: ${RTPENGINE_IP} 261 | mysql: 262 | build: ./mysql 263 | image: docker_mysql 264 | container_name: mysql 265 | env_file: 266 | - .env 267 | volumes: 268 | - dbdata:/var/lib/mysql 269 | - /etc/timezone:/etc/timezone:ro 270 | - /etc/localtime:/etc/localtime:ro 271 | expose: 272 | - "3306/tcp" 273 | networks: 274 | default: 275 | ipv4_address: ${MYSQL_IP} 276 | pyhss: 277 | build: ./pyhss 278 | image: docker_pyhss 279 | container_name: pyhss 280 | dns: ${DNS_IP} 281 | volumes: 282 | - ./pyhss:/mnt/pyhss 283 | - ./pyhss/logs:/pyhss/log/ 284 | - /etc/timezone:/etc/timezone:ro 285 | - /etc/localtime:/etc/localtime:ro 286 | env_file: 287 | - .env 288 | depends_on: 289 | - dns 290 | - mysql 291 | expose: 292 | - "3868/udp" 293 | - "3868/tcp" 294 | - "8080/tcp" 295 | ports: 296 | - "8080:8080/tcp" 297 | networks: 298 | default: 299 | ipv4_address: ${PYHSS_IP} 300 | icscf: 301 | image: opensips/opensips:ims-ce 302 | container_name: icscf 303 | dns: ${DNS_IP} 304 | volumes: 305 | - ./opensips-ims-ce/icscf:/etc/opensips 306 | - ./opensips-ims-ce/substenv.sh:/etc/opensips/substenv.sh 307 | - /etc/timezone:/etc/timezone:ro 308 | - /etc/localtime:/etc/localtime:ro 309 | command: 310 | - -p /etc/opensips/substenv.sh 311 | env_file: 312 | - .env 313 | environment: 314 | - COMPONENT_NAME=icscf-1 315 | depends_on: 316 | - dns 317 | - mysql 318 | - pyhss 319 | expose: 320 | - "3869/udp" 321 | - "3869/tcp" 322 | - "4060/udp" 323 | - "4060/tcp" 324 | networks: 325 | default: 326 | ipv4_address: ${ICSCF_IP} 327 | scscf: 328 | image: opensips/opensips:ims-ce 329 | container_name: scscf 330 | dns: ${DNS_IP} 331 | volumes: 332 | - ./opensips-ims-ce/scscf:/etc/opensips 333 | - ./opensips-ims-ce/substenv.sh:/etc/opensips/substenv.sh 334 | - /etc/timezone:/etc/timezone:ro 335 | - /etc/localtime:/etc/localtime:ro 336 | entrypoint: /etc/opensips/entrypoint.sh 337 | command: 338 | - -p /etc/opensips/substenv.sh 339 | env_file: 340 | - .env 341 | environment: 342 | - COMPONENT_NAME=scscf-1 343 | depends_on: 344 | - dns 345 | - mysql 346 | - pyhss 347 | expose: 348 | - "3870/udp" 349 | - "3870/tcp" 350 | - "6060/udp" 351 | - "6060/tcp" 352 | networks: 353 | default: 354 | ipv4_address: ${SCSCF_IP} 355 | pcscf: 356 | image: opensips/opensips:ims-ce 357 | container_name: pcscf 358 | dns: ${DNS_IP} 359 | privileged: true 360 | cap_add: 361 | - NET_ADMIN 362 | volumes: 363 | - ./opensips-ims-ce/pcscf:/etc/opensips 364 | - ./opensips-ims-ce/substenv.sh:/etc/opensips/substenv.sh 365 | - /etc/timezone:/etc/timezone:ro 366 | - /etc/localtime:/etc/localtime:ro 367 | entrypoint: /etc/opensips/entrypoint.sh 368 | command: 369 | - -p /etc/opensips/substenv.sh 370 | env_file: 371 | - .env 372 | environment: 373 | - COMPONENT_NAME=pcscf-1 374 | depends_on: 375 | - dns 376 | - mysql 377 | - rtpengine 378 | - icscf 379 | - scscf 380 | expose: 381 | - "3871/udp" 382 | - "3871/tcp" 383 | - "5060/tcp" 384 | - "5060/udp" 385 | - "5100/tcp" 386 | - "5100/udp" 387 | - "6100/tcp" 388 | - "6100/udp" 389 | networks: 390 | default: 391 | ipv4_address: ${PCSCF_IP} 392 | smsc: 393 | image: docker_kamailio 394 | container_name: smsc 395 | dns: ${DNS_IP} 396 | volumes: 397 | - ./smsc:/mnt/smsc 398 | - /etc/timezone:/etc/timezone:ro 399 | - /etc/localtime:/etc/localtime:ro 400 | env_file: 401 | - .env 402 | environment: 403 | - COMPONENT_NAME=smsc-1 404 | depends_on: 405 | - dns 406 | - mysql 407 | expose: 408 | - "7090/udp" 409 | - "7090/tcp" 410 | networks: 411 | default: 412 | ipv4_address: ${SMSC_IP} 413 | osmomsc: 414 | build: ./osmomsc 415 | image: docker_osmomsc 416 | container_name: osmomsc 417 | volumes: 418 | - ./osmomsc:/mnt/osmomsc 419 | - /etc/timezone:/etc/timezone:ro 420 | - /etc/localtime:/etc/localtime:ro 421 | env_file: 422 | - .env 423 | environment: 424 | - COMPONENT_NAME=osmomsc-1 425 | depends_on: 426 | - osmohlr 427 | expose: 428 | - "29118/sctp" 429 | - "2775/tcp" 430 | networks: 431 | default: 432 | ipv4_address: ${OSMOMSC_IP} 433 | osmohlr: 434 | build: ./osmohlr 435 | image: docker_osmohlr 436 | container_name: osmohlr 437 | volumes: 438 | - ./osmohlr:/mnt/osmohlr 439 | - /etc/timezone:/etc/timezone:ro 440 | - /etc/localtime:/etc/localtime:ro 441 | env_file: 442 | - .env 443 | environment: 444 | - COMPONENT_NAME=osmohlr-1 445 | expose: 446 | - "4222/tcp" 447 | networks: 448 | default: 449 | ipv4_address: ${OSMOHLR_IP} 450 | metrics: 451 | build: ./metrics 452 | image: docker_metrics 453 | container_name: metrics 454 | env_file: 455 | - .env 456 | volumes: 457 | - ./metrics:/mnt/metrics 458 | - /etc/timezone:/etc/timezone:ro 459 | - /etc/localtime:/etc/localtime:ro 460 | expose: 461 | - "9090/tcp" 462 | ports: 463 | - "9090:9090/tcp" 464 | networks: 465 | default: 466 | ipv4_address: ${METRICS_IP} 467 | grafana: 468 | image: grafana/grafana:11.3.0 469 | container_name: grafana 470 | env_file: 471 | - .env 472 | volumes: 473 | - grafana_data:/var/lib/grafana 474 | - ./grafana/:/etc/grafana/provisioning/ 475 | - ./grafana:/mnt/grafana 476 | - /etc/timezone:/etc/timezone:ro 477 | - /etc/localtime:/etc/localtime:ro 478 | environment: 479 | - GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME} 480 | - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} 481 | #- GF_INSTALL_PLUGINS=${GRAFANA_INSTALL_PLUGINS} 482 | - GF_PATHS_PROVISIONING=/etc/grafana/provisioning 483 | - GF_PATHS_DATA=/var/lib/grafana 484 | - METRICS_IP=${METRICS_IP} 485 | expose: 486 | - "3000/tcp" 487 | ports: 488 | - "3000:3000/tcp" 489 | networks: 490 | default: 491 | ipv4_address: ${GRAFANA_IP} 492 | networks: 493 | default: 494 | ipam: 495 | config: 496 | - subnet: ${TEST_NETWORK} 497 | volumes: 498 | grafana_data: 499 | name: grafana_data 500 | mongodbdata: {} 501 | dbdata: {} 502 | -------------------------------------------------------------------------------- /docs/config.md: -------------------------------------------------------------------------------- 1 | # OpenSIPS IMS - Community Edition - Configuration 2 | 3 | 4 | The OpenSIPS IMS Community Edition scripts can be configured using environment 5 | variables. These variables are utilized by the OpenSIPS pre-processing script 6 | (via the `-p` parameter) at startup, so they must be exported in the 7 | environment where each component is running. 8 | 9 | _Note_: Docker Open5GS already includes all these variables in the 10 | [`.env`](https://github.com/herlesupreeth/docker_open5gs/blob/master/.env) 11 | file, so you don't necessarily need to explicitely tune them unless really 12 | needed. 13 | 14 | ## Environment Variables 15 | 16 | The following environemnt variables are being used: 17 | 18 | | Environment Variable | Components | Description | Default | 19 | |----------------------|------------|--------------------------------|---------| 20 | | `MCC` | P/I/S | Mobile Country Code | `001` | 21 | | `MNC` | P/I/S | Mobile Network Code | `01` | 22 | | `DOMAIN` | P/I/S | Root Domain handled | `mnc${MNC}.mcc${MCC}.3gppnetwork.org` | 23 | | `IMS_DOMAIN` | P/I/S | IMS Domain handled | `ims.${DOMAIN}` | 24 | | `EPC_DOMAIN` | P/I/S | EPC Domain | `epc.${DOMAIN}` | 25 | | `PCSCF_BIND_PORT` | P | Diameter port used by P-CSCF | `3871` | 26 | | `PCSCF_IP` | P | IP of the P-CSCF | `172.22.0.21` | 27 | | `ICSCF_BIND_PORT` | I | Diameter port used by I-CSCF | `3869` | 28 | | `ICSCF_IP` | I | IP of the I-CSCF | `172.22.0.19` | 29 | | `SCSCF_BIND_PORT` | S | Diameter port used by S-CSCF | `3870` | 30 | | `SCSCF_IP` | S | IP of the S-CSCF | `172.22.0.20` | 31 | | `MYSQL_IP` | S | Used by S-CSCF to store information about dialplan | `172.22.0.17` | 32 | | `RTPENGINE_IP` | P | Used to communicate with RTPEngine | `172.22.0.16` | 33 | | `PYHSS_BIND_PORT` | I/S | Diameter port the HSS is listening on | `3875`| 34 | | `PCRF_BIND_PORT` | P | Diameter port the HSS is listening on | `3873`| 35 | | `UPF_IP` | P | Used by P-CSCF to route traffic back through UPF | `172.22.0.8` | 36 | 37 | 38 | * The components field contains one of the initials of the CSCF sub-component. 39 | 40 | 41 | 42 | 43 | ** The default variables are mainly provided by the Docker Open5GS project - 44 | in case you are using a different setup, make sure you set them accordingly. 45 | 46 | -------------------------------------------------------------------------------- /docs/getting-started.md: -------------------------------------------------------------------------------- 1 | # OpenSIPS IMS - Community Edition - Getting Started 2 | 3 | This page provides a guide on setting up the OpenSIPS IMS Community Edition 4 | within the [Docker Open5GS](https://github.com/herlesupreeth/docker_open5gs) 5 | Core network. This is the simplest way to get the OpenSIPS IMS running. 6 | 7 | ## Setup Docker Open5GS 8 | 9 | This section describes how to set up the Core Network. 10 | 11 | 1. Clone the [Docker Open5GS](https://github.com/herlesupreeth/docker_open5gs) 12 | repository: 13 | ``` 14 | git clone https://github.com/herlesupreeth/docker_open5gs.git 15 | cd docker_open5gs 16 | ``` 17 | 18 | 2. Clone the [OpenSIPS IMS](https://github.com/OpenSIPS/opensips-ims-ce) 19 | repository: 20 | ``` 21 | git clone https://github.com/OpenSIPS/opensips-ims-ce.git 22 | ``` 23 | 24 | 3. Adjust the environment variables according to your setup/networking layout 25 | by editting the `.env` file, as described 26 | [here](https://github.com/herlesupreeth/docker_open5gs?tab=readme-ov-file#network-and-deployment-configuration). 27 | Pay attention to the `DOCKER_HOST_IP` and `SGWU_ADVERTISE_IP` variables, which 28 | should be set to the value of your host. Make sure you follow the Docker 29 | Open5GS tutorial for more complex setups. 30 | 31 | 4. Build the Docker images as described 32 | [here](https://github.com/herlesupreeth/docker_open5gs?tab=readme-ov-file#build-docker-images-from-source) 33 | or get the pre-built ones as instructed 34 | [here](https://github.com/herlesupreeth/docker_open5gs?tab=readme-ov-file#get-pre-built-docker-images). 35 | OpenSIPS images are already available in 36 | [Docker Hub](https://hub.docker.com/r/opensips/opensips), all you need to do is 37 | to pull the `opensips/opensips:ims-ce` image: 38 | ``` 39 | docker pull opensips/opensips:ims-ce 40 | ``` 41 | 42 | 5. Deploy the Core Network along with the OpenSIPS IMS CSCF components: 43 | ``` 44 | cp opensips-ims-ce/docker-compose.yml 4g-volte-deploy-opensips.yaml 45 | docker compose -f 4g-volte-deploy-opensips.yaml up -d 46 | ``` 47 | 48 | At this point, all the necessary components should be up and running. 49 | 50 | ## Setup SIM information 51 | 52 | To register phones in the core network, you need to program their SIMs and 53 | provision the information in the platform. 54 | 55 | 1. Program your SIM cards(USIM) to use the configured network. You can follow 56 | [this](https://open5gs.org/open5gs/docs/tutorial/01-your-first-lte/#usim-setup) tutorial. 57 | 58 | 2. Provision the SIMs in the Open5GS HSS (Home Subscriber Server). Follow 59 | [these](https://github.com/herlesupreeth/docker_open5gs?tab=readme-ov-file#provisioning-of-sim-information) 60 | steps to do that. 61 | 62 | 3. Provision the SIMs in the IMS HSS (pyHSS). Follow 63 | [these](https://github.com/herlesupreeth/docker_open5gs?tab=readme-ov-file#provisioning-of-sim-information-in-pyhss-is-as-follows) 64 | steps for that. 65 | 66 | ## Configure Dialplan (optional) 67 | 68 | The S-CSCF considers every dialled number as being a user and handles it 69 | accordingly. However, you can also add custom rules for handling different 70 | other services or applications. For example, to add a dialplan rule that sends 71 | all the calls dialling `*99` to the voicemail box, you can follow these steps: 72 | ``` 73 | # login in mysql scscf database 74 | docker exec -it mysql mysql scscf 75 | # insert the dialplan rule, with the associated type 76 | insert into dialplan (dpid, match_op, match_exp, repl_exp) values (1, 1, "^\*99$", "SERVICE"); 77 | ``` 78 | * voicemail handling is currently not handled. 79 | 80 | Of course, you can set multiple rules, according to your dialplan. Once 81 | everything is set up, we need to reload OpenSIPS's dialplan cache. 82 | 83 | More information about the dialplan provisioning can be found in the 84 | [S-CSCF configuration](scscf.md#configuration) section. 85 | 86 | ``` 87 | docker exec -it scscf opensips-mi dp_reload 88 | ``` 89 | 90 | ## Testing 91 | 92 | At this stage, you should be able to register your phones, equipped with the 93 | SIMs provisioned earlier, to the Open5GS core network. If the configuration has 94 | been completed successfully, the VoLTE icon should appear on all devices, and 95 | it should be possible to initiate a call between two UEs by dialing their 96 | respective MSISDNs. 97 | 98 | ## References 99 | 100 | * [Open5GS project](https://open5gs.org) 101 | * [Docker Open5GS project](https://github.com/herlesupreeth/docker_open5gs) 102 | * More information about testing and troubleshooting can be found 103 | [here](https://open5gs.org/open5gs/docs/tutorial/03-VoLTE-dockerized/) 104 | -------------------------------------------------------------------------------- /docs/icscf.md: -------------------------------------------------------------------------------- 1 | # OpenSIPS IMS - Community Edition - I-CSCF 2 | 3 | The Interrogating - Call Session Control Function (I-CSCF) handles SIP 4 | signaling for session control and facilitates secure interactions between the 5 | home network and external networks. 6 | 7 | The I-CSCF receives messages from the P-CSCF and determines the assigned S-CSCF 8 | for a particular user by querying the HSS. 9 | 10 | ## Interfaces 11 | 12 | The I-CSCF implements the following interfaces: 13 | 14 | * `Mw` - (defined in 3GPP TS 24.229) describes the SIP messages exchanged 15 | internally between the CSCF sub-components - in particular, the I-CSCF uses 16 | the SIP `Mw` interface to communicate with P-CSCF and S-CSCF. 17 | * `Cx` - (defined in 3GPP TS 29.228) - Diameter interface between the I-CSCF 18 | and the IMS HSS. Supported Diameter commands are: 19 | * `UAR` - User-Authorization-Request sent to HSS in order to request the 20 | authorization of the registration of a multimedia user alocate resources 21 | * `UAA` - User-Authorization-Answer received from HSS containing the S-CSCF 22 | instance that should handle the multimedia user 23 | 24 | ## Configuration 25 | 26 | The I-CSCF can be configured through the environment variables defined 27 | [here](config.md#environment-variables). 28 | -------------------------------------------------------------------------------- /docs/pcscf.md: -------------------------------------------------------------------------------- 1 | # OpenSIPS IMS - Community Edition - P-CSCF 2 | 3 | The Proxy - Call Session Control Function (P-CSCF) serves as the initial point 4 | of contact for user equipment in a mobile network. All SIP traffic to and from 5 | the user equipment (UE) is routed through the P-CSCF. 6 | 7 | When a UE registers with the network, it establishes an IPSec tunnel to the 8 | P-CSCF in accordance with the 3GPP TS 33.203 specifications (3G Security: 9 | Access Security for IP-based Services). All SIP communication between the UE 10 | and the network is securely transmitted through this tunnel, ensuring 11 | confidentiality and integrity. 12 | 13 | On the core network side, the P-CSCF interacts with the home network's I-CSCF 14 | instance to handle call signaling and coordinates with the PCRF to allocate the 15 | necessary resources for the call. 16 | 17 | ## Interfaces 18 | 19 | The P-CSCF implements the following interfaces: 20 | 21 | * `Gm` - (defined in 3GPP TS 24.229) describes the SIP messages that need to 22 | be exchanged in order to enables connectivity between the UE/PGW and the IMS 23 | network (P-CSCF) for registration, authentication, encryption, and session 24 | control. It contains information about the IPSec tunnel establishement and 25 | IMS AKA authentication. 26 | * `Mw` - (defined in 3GPP TS 24.229) describes the SIP messages exchanged 27 | internally between the CSCF sub-components - in the P-CSCF case, the 28 | interaction between P-CSCF and I-CSCF is done over the `Mw` interface. 29 | * `Rx` - (defined in 3GPP TS 29.211) - Diameter interface between the P-CSCF 30 | and PCRF used to allocate resources for a UE. Supported Diameter commands are: 31 | * `AAR` - Authentication and authorization request, sent by the P-CSCF to 32 | alocate resources for registration/calls 33 | * `AAA` - Answer from PCRF of the resources allocation request 34 | * `STR` - Session-Termination-Request sent to release resources allocations 35 | * `ASR` - Abort-Session-Request received from the PCRF when the UE 36 | disconnects from the network 37 | 38 | ## Configuration 39 | 40 | The P-CSCF can be configured through the environment variables defined 41 | [here](config.md#environment-variables). 42 | -------------------------------------------------------------------------------- /docs/scscf.md: -------------------------------------------------------------------------------- 1 | # OpenSIPS IMS - Community Edition - S-CSCF 2 | 3 | The Serving Call Session Control Function (S-CSCF) handles the UE registrations, 4 | manages users authentication, SIP sessions routing and external service integration. 5 | 6 | The S-CSCF interacts with I-CSCF for registrations and server assignement, and with 7 | P-CSCF and AS (application servers) for calls routing. 8 | 9 | ## Interfaces 10 | 11 | The S-CSCF implements the following interfaces: 12 | 13 | * `Mw` - (defined in 3GPP TS 24.229) describes the SIP messages exchanged 14 | between the S-CSCF and I-CSCF, as well as with different AS (application servers). 15 | * `Cx` - (defined in 3GPP TS 29.228) - Diameter interface between the S-CSCF 16 | and the IMS HSS. Supported Diameter commands are: 17 | * `MAR` - Multimedia-Auth-Request sent by the S-CSCF to request security information 18 | for a particular user. 19 | * `MAA` - Multimedia-Auth-Answer containing information used for digest/AKA authentication 20 | 21 | ## Configuration 22 | 23 | The S-CSCF can be configured through the environment variables defined 24 | [here](config.md#environment-variables). 25 | 26 | By default, the S-CSCF considers each number dialled as being a USER, and 27 | handles it accordingly. Optionally, you can provision custom dialplan rules 28 | that the S-CSCF can handle differently. These rules must have be provisioned in 29 | the MySQL `scscf` database `dialplan`. The required fields in the database are: 30 | 31 | * `dpid` - dialplan ID, needs to be set to `1` 32 | * `match_op` - matching operator - `0` if a string match is used, `1` if regex 33 | * `match_exp` - the regular expression used to match the dialled number 34 | * `repl_exp` - the way the dialled number should be handled. Currently supported values: 35 | * `USER`: if the dialplan is a user, the call is routed back to a user, if registered 36 | * `SERVICE`: the call is sent to an internal service - currently not handled 37 | * `APPLICATION`: the call is sent to an `Application Server` - currently not handled 38 | -------------------------------------------------------------------------------- /icscf/.gitignore: -------------------------------------------------------------------------------- 1 | /substenv.sh 2 | -------------------------------------------------------------------------------- /icscf/freeDiameter.conf.m4: -------------------------------------------------------------------------------- 1 | Identity = "icscf.${IMS_DOMAIN}"; 2 | Realm = "${IMS_DOMAIN}"; 3 | Port = ${ICSCF_BIND_PORT}; 4 | SecPort = 0; 5 | No_SCTP; 6 | NoRelay; 7 | 8 | ConnectPeer = "hss.${IMS_DOMAIN}" { 9 | No_TLS; 10 | port = ${PYHSS_BIND_PORT}; 11 | }; 12 | -------------------------------------------------------------------------------- /icscf/icscf.dictionary: -------------------------------------------------------------------------------- 1 | VENDOR 10415 TGPP 2 | 3 | ATTRIBUTE Visited-Network-Identifier 600 string 10415 4 | ATTRIBUTE Public-Identity 601 string 10415 5 | ATTRIBUTE Server-Name 602 string 10415 6 | 7 | APPLICATION-AUTH 16777216/10415 3GPP Cx 8 | 9 | REQUEST 300 User-Authorization Request 10 | { 11 | Session-Id | REQUIRED | 1 12 | Origin-Host | REQUIRED | 1 13 | Origin-Realm | REQUIRED | 1 14 | Destination-Realm | REQUIRED | 1 15 | Vendor-Specific-Application-Id | REQUIRED | 1 16 | Auth-Session-State | REQUIRED | 1 17 | User-Name | REQUIRED | 1 18 | Public-Identity | REQUIRED | 1 19 | Visited-Network-Identifier | REQUIRED | 1 20 | } 21 | 22 | ANSWER 300 User-Authorization Answer 23 | { 24 | Session-Id | REQUIRED | 1 25 | Origin-Host | REQUIRED | 1 26 | Origin-Realm | REQUIRED | 1 27 | Destination-Host | OPTIONAL | 1 28 | Destination-Realm | OPTIONAL | 1 29 | Vendor-Specific-Application-Id | REQUIRED | 1 30 | Auth-Session-State | REQUIRED | 1 31 | Experimental-Result | REQUIRED | 1 32 | } 33 | -------------------------------------------------------------------------------- /icscf/opensips.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # OpenSIPS residential configuration script 3 | # by OpenSIPS Solutions 4 | # 5 | # This script was generated via "make menuconfig", from 6 | # the "Residential" scenario. 7 | # You can enable / disable more features / functionalities by 8 | # re-generating the scenario with different options.# 9 | # 10 | # Please refer to the Core CookBook at: 11 | # https://opensips.org/Resources/DocsCookbooks 12 | # for a explanation of possible statements, functions and parameters. 13 | # 14 | 15 | 16 | ####### Global Parameters ######### 17 | 18 | /* uncomment the following lines to enable debugging */ 19 | #debug_mode=yes 20 | 21 | log_level=3 22 | xlog_level=3 23 | log_stderror=yes 24 | log_stdout=yes 25 | log_facility=LOG_LOCAL0 26 | 27 | udp_workers=4 28 | 29 | /* uncomment the next line to enable the auto temporary blacklisting of 30 | not available destinations (default disabled) */ 31 | #disable_dns_blacklist=no 32 | 33 | /* uncomment the next line to enable IPv6 lookup after IPv4 dns 34 | lookup failures (default disabled) */ 35 | #dns_try_ipv6=yes 36 | 37 | 38 | socket=udp:${ICSCF_IP}:4060 39 | socket=tcp:${ICSCF_IP}:4060 40 | 41 | #set module path 42 | mpath="/usr/lib/x86_64-linux-gnu/opensips/modules" 43 | 44 | ####### Modules Section ######## 45 | ####### http module ###### 46 | loadmodule "httpd.so" 47 | 48 | modparam("httpd", "ip", "${ICSCF_IP}") 49 | modparam("httpd", "port", 8080) 50 | 51 | 52 | #### SIGNALING module 53 | loadmodule "signaling.so" 54 | 55 | #### StateLess module 56 | loadmodule "sl.so" 57 | 58 | #### Transaction Module 59 | loadmodule "tm.so" 60 | modparam("tm", "fr_timeout", 5) 61 | modparam("tm", "fr_inv_timeout", 30) 62 | modparam("tm", "restart_fr_on_each_reply", 0) 63 | modparam("tm", "onreply_avp_mode", 1) 64 | 65 | #### Record Route Module 66 | loadmodule "rr.so" 67 | /* do not append from tag to the RR (no need for this script) */ 68 | modparam("rr", "append_fromtag", 0) 69 | 70 | #### MAX ForWarD module 71 | loadmodule "maxfwd.so" 72 | 73 | #### SIP MSG OPerationS module 74 | loadmodule "sipmsgops.so" 75 | 76 | #### FIFO Management Interface 77 | loadmodule "mi_fifo.so" 78 | modparam("mi_fifo", "fifo_name", "/run/opensips/opensips_fifo") 79 | modparam("mi_fifo", "fifo_mode", 0666) 80 | 81 | #### USeR LOCation module 82 | loadmodule "usrloc.so" 83 | modparam("usrloc", "nat_bflag", "NAT") 84 | modparam("usrloc", "working_mode_preset", "single-instance-no-db") 85 | 86 | #### REGISTRAR module 87 | loadmodule "registrar.so" 88 | modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT") 89 | /* uncomment the next line not to allow more than 10 contacts per AOR */ 90 | #modparam("registrar", "max_contacts", 10) 91 | 92 | #### ACCounting module 93 | loadmodule "acc.so" 94 | /* what special events should be accounted ? */ 95 | modparam("acc", "early_media", 0) 96 | modparam("acc", "report_cancels", 0) 97 | /* by default we do not adjust the direct of the sequential requests. 98 | if you enable this parameter, be sure to enable "append_fromtag" 99 | in "rr" module */ 100 | modparam("acc", "detect_direction", 0) 101 | 102 | loadmodule "proto_udp.so" 103 | loadmodule "proto_tcp.so" 104 | 105 | #### aaa_diameter module 106 | loadmodule "aaa_diameter.so" 107 | modparam("aaa_diameter", "fd_log_level", 1) # max amount of logging, quite annoying 108 | modparam("aaa_diameter", "realm", "${IMS_DOMAIN}") 109 | modparam("aaa_diameter", "peer_identity", "hss") 110 | modparam("aaa_diameter", "aaa_url", 111 | "diameter:/etc/opensips/freeDiameter.conf;extra-avps-file:/etc/opensips/icscf.dictionary") 112 | 113 | #### JSON module 114 | loadmodule "json.so" 115 | 116 | 117 | 118 | ####### Routing Logic ######## 119 | 120 | # main request routing logic 121 | 122 | route{ 123 | xlog("L_INFO", "[$ci] Start route time [$Tf] method ($rm) r-uri ($ru) \n"); 124 | 125 | if (!mf_process_maxfwd_header(10)) { 126 | send_reply(483,"Too Many Hops"); 127 | exit; 128 | } 129 | 130 | if (has_totag()) { 131 | 132 | # handle hop-by-hop ACK (no routing required) 133 | if ( is_method("ACK") && t_check_trans() ) { 134 | t_relay(); 135 | exit; 136 | } 137 | 138 | # sequential request within a dialog should 139 | # take the path determined by record-routing 140 | if ( !loose_route() ) { 141 | # we do record-routing for all our traffic, so we should not 142 | # receive any sequential requests without Route hdr. 143 | send_reply(404,"Not here"); 144 | exit; 145 | } 146 | 147 | if (is_method("BYE")) { 148 | # do accounting even if the transaction fails 149 | do_accounting("log","failed"); 150 | } 151 | 152 | # route it out to whatever destination was set by loose_route() 153 | # in $du (destination URI). 154 | route(relay); 155 | exit; 156 | } 157 | 158 | # CANCEL processing 159 | if (is_method("CANCEL")) { 160 | if (t_check_trans()) 161 | t_relay(); 162 | exit; 163 | } 164 | 165 | # absorb retransmissions, but do not create transaction 166 | t_check_trans(); 167 | 168 | if (is_method("REGISTER")) { 169 | xlog("L_INFO", "[$ci] Received REGISTER for $tu - doing UAR\n"); 170 | 171 | $var(payload) = "[ 172 | { \"Session-Id\": \"icscf.${IMS_DOMAIN};"+$Ts+"."+$Tsm+";"+$pp+"\" }, 173 | { \"Origin-Host\": \"icscf.${IMS_DOMAIN}\" }, 174 | { \"Origin-Realm\": \"${IMS_DOMAIN}\" }, 175 | { \"Destination-Realm\": \"${IMS_DOMAIN}\" }, 176 | { \"Vendor-Specific-Application-Id\": [{\"Vendor-Id\": 10415}, 177 | {\"Auth-Application-Id\": 16777216}]}, 178 | { \"Auth-Session-State\": 1 }, 179 | { \"User-Name\": \""+$fU+"@"+$fd+"\" }, 180 | { \"Public-Identity\": \""+$fu+"\" }, 181 | { \"Visited-Network-Identifier\": \"${IMS_DOMAIN}\" } 182 | ]"; 183 | 184 | $var(rc) = dm_send_request(16777216, 300, $var(payload), $var(rpl_avps)); 185 | xlog("[$ci] UAA rc: $var(rc), UAA AVPs: $var(rpl_avps)\n"); 186 | 187 | $var(server_name) = NULL; 188 | $json(rpl_avps) := $var(rpl_avps); 189 | for ($var(item) in $(json(rpl_avps)[*])) { 190 | $json(item) := $var(item); 191 | for ($var(key) in $(json(item.keys)[*])) { 192 | if ($var(key) == "Server-Name") { 193 | $var(server_name) = $json(item/$var(key)); 194 | break; 195 | } 196 | } 197 | if ($var(server_name) != NULL) 198 | break; 199 | } 200 | 201 | if ($var(server_name) == NULL) { 202 | xlog("L_ERR", "[$ci] No server available!\n"); 203 | send_reply(503,"Not available"); 204 | exit; 205 | } 206 | 207 | # relay to S-CSCF 208 | xlog("L_INFO", "[$ci] using S-CSCF $var(server_name)\n"); 209 | $ru = $var(server_name); 210 | 211 | route(relay); 212 | exit; 213 | } 214 | 215 | send_reply(503,"Not Implemented"); 216 | exit; 217 | } 218 | 219 | 220 | route[relay] { 221 | if (!t_relay()) { 222 | send_reply(500,"Internal Error"); 223 | } 224 | exit; 225 | } 226 | -------------------------------------------------------------------------------- /pcscf/.gitignore: -------------------------------------------------------------------------------- 1 | /substenv.sh 2 | -------------------------------------------------------------------------------- /pcscf/db/dispatcher: -------------------------------------------------------------------------------- 1 | id(int,auto) setid(int) destination(string) socket(string,null) state(int) probe_mode(int) weight(string) priority(int) attrs(string) description(string) 2 | 1:1:sip\:172.22.0.41\:5060:null:0:1:1:1:'carrier':'icscf' 3 | -------------------------------------------------------------------------------- /pcscf/db/version: -------------------------------------------------------------------------------- 1 | table_name(string) table_version(int) 2 | dispatcher:9 3 | -------------------------------------------------------------------------------- /pcscf/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 2-Clause License 4 | 5 | # Copyright (c) 2020, 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 | ip route add ${UE_IPV4_IMS} via ${UPF_IP} 30 | 31 | while ! mysqladmin ping -h ${MYSQL_IP} --silent; do 32 | sleep 5; 33 | done 34 | 35 | # Sleep until permissions are set 36 | sleep 10; 37 | 38 | # Create PCSCF database, populate tables and grant privileges 39 | if [[ -z "`mysql -u root -h ${MYSQL_IP} -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='pcscf'" 2>&1`" ]]; 40 | then 41 | mysql -u root -h ${MYSQL_IP} -e "create database pcscf;" 42 | mysql -u root -h ${MYSQL_IP} pcscf < /usr/share/opensips/mysql/standard-create.sql 43 | mysql -u root -h ${MYSQL_IP} pcscf < /usr/share/opensips/mysql/presence-create.sql 44 | PCSCF_USER_EXISTS=`mysql -u root -h ${MYSQL_IP} -s -N -e "SELECT EXISTS(SELECT 1 FROM mysql.user WHERE User = 'pcscf' AND Host = '%')"` 45 | if [[ "$PCSCF_USER_EXISTS" == 0 ]] 46 | then 47 | mysql -u root -h ${MYSQL_IP} -e "CREATE USER 'pcscf'@'%' IDENTIFIED WITH mysql_native_password BY 'heslo'"; 48 | mysql -u root -h ${MYSQL_IP} -e "CREATE USER 'pcscf'@'$PCSCF_IP' IDENTIFIED WITH mysql_native_password BY 'heslo'"; 49 | mysql -u root -h ${MYSQL_IP} -e "GRANT ALL ON pcscf.* TO 'pcscf'@'%'"; 50 | mysql -u root -h ${MYSQL_IP} -e "GRANT ALL ON pcscf.* TO 'pcscf'@'$PCSCF_IP'"; 51 | mysql -u root -h ${MYSQL_IP} -e "FLUSH PRIVILEGES;" 52 | fi 53 | fi 54 | 55 | exec /usr/sbin/opensips -F $@ 56 | -------------------------------------------------------------------------------- /pcscf/freeDiameter.conf.m4: -------------------------------------------------------------------------------- 1 | Identity = "pcscf.${IMS_DOMAIN}"; 2 | Realm = "${IMS_DOMAIN}"; 3 | Port = ${PCSCF_BIND_PORT}; 4 | SecPort = 0; 5 | No_SCTP; 6 | NoRelay; 7 | 8 | ConnectPeer = "pcrf.${EPC_DOMAIN}" { 9 | No_TLS; 10 | port = ${PCRF_BIND_PORT}; 11 | }; 12 | -------------------------------------------------------------------------------- /pcscf/opensips.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # OpenSIPS residential configuration script 3 | # by OpenSIPS Solutions 4 | # 5 | # This script was generated via "make menuconfig", from 6 | # the "Residential" scenario. 7 | # You can enable / disable more features / functionalities by 8 | # re-generating the scenario with different options.# 9 | # 10 | # Please refer to the Core CookBook at: 11 | # https://opensips.org/Resources/DocsCookbooks 12 | # for a explanation of possible statements, functions and parameters. 13 | # 14 | 15 | 16 | ####### Global Parameters ######### 17 | 18 | /* uncomment the following lines to enable debugging */ 19 | #debug_mode=yes 20 | 21 | log_level=6 22 | xlog_level=3 23 | #mem_log=6 24 | log_stderror=yes 25 | log_stdout=yes 26 | log_facility=LOG_LOCAL0 27 | 28 | udp_workers=4 29 | 30 | /* uncomment the next line to enable the auto temporary blacklisting of 31 | not available destinations (default disabled) */ 32 | #disable_dns_blacklist=no 33 | 34 | /* uncomment the next line to enable IPv6 lookup after IPv4 dns 35 | lookup failures (default disabled) */ 36 | #dns_try_ipv6=yes 37 | 38 | dns=no 39 | 40 | socket=udp:${PCSCF_IP}:5060 41 | socket=tcp:${PCSCF_IP}:5060 42 | socket=ipsec:${PCSCF_IP}:6100,5100 43 | 44 | alias="pcscf.${IMS_DOMAIN}" 45 | 46 | 47 | #set module path 48 | mpath="/usr/lib/x86_64-linux-gnu/opensips/modules" 49 | 50 | ####### Modules Section ######## 51 | 52 | #### MYSQL module 53 | loadmodule "db_mysql.so" 54 | 55 | #### SIGNALING module 56 | loadmodule "signaling.so" 57 | 58 | #### StateLess module 59 | loadmodule "sl.so" 60 | 61 | #### Transaction Module 62 | loadmodule "tm.so" 63 | modparam("tm", "fr_timeout", 5) 64 | modparam("tm", "fr_inv_timeout", 30) 65 | modparam("tm", "restart_fr_on_each_reply", 0) 66 | modparam("tm", "onreply_avp_mode", 1) 67 | 68 | #### Record Route Module 69 | loadmodule "rr.so" 70 | /* do not append from tag to the RR (no need for this script) */ 71 | modparam("rr", "append_fromtag", 0) 72 | 73 | #### MAX ForWarD module 74 | loadmodule "maxfwd.so" 75 | 76 | #### NATHELPER module 77 | loadmodule "nathelper.so" 78 | 79 | #### SIP MSG OPerationS module 80 | loadmodule "sipmsgops.so" 81 | 82 | #### FIFO Management Interface 83 | loadmodule "mi_fifo.so" 84 | modparam("mi_fifo", "fifo_name", "/run/opensips/opensips_fifo") 85 | modparam("mi_fifo", "fifo_mode", 0666) 86 | 87 | #### USeR LOCation module 88 | loadmodule "usrloc.so" 89 | modparam("usrloc", "nat_bflag", "NAT") 90 | modparam("usrloc", "mi_dump_kv_store", 1) 91 | modparam("usrloc", "working_mode_preset", "single-instance-no-db") 92 | 93 | #### REGISTRAR module 94 | loadmodule "registrar.so" 95 | modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT") 96 | /* uncomment the next line not to allow more than 10 contacts per AOR */ 97 | #modparam("registrar", "max_contacts", 10) 98 | 99 | #### ACCounting module 100 | loadmodule "acc.so" 101 | /* what special events should be accounted ? */ 102 | modparam("acc", "early_media", 0) 103 | modparam("acc", "report_cancels", 0) 104 | /* by default we do not adjust the direct of the sequential requests. 105 | if you enable this parameter, be sure to enable "append_fromtag" 106 | in "rr" module */ 107 | modparam("acc", "detect_direction", 0) 108 | 109 | #### proto_udp module 110 | loadmodule "dispatcher.so" 111 | 112 | loadmodule "proto_udp.so" 113 | loadmodule "proto_tcp.so" 114 | loadmodule "proto_ipsec.so" 115 | loadmodule "dialog.so" 116 | 117 | #### dbtext module 118 | loadmodule "db_text.so" 119 | modparam("dispatcher", "db_url", "text:///etc/opensips/db") 120 | 121 | #### aaa_diameter module 122 | loadmodule "aaa_diameter.so" 123 | modparam("aaa_diameter", "fd_log_level", 0) # max amount of logging, quite annoying 124 | modparam("aaa_diameter", "realm", "${IMS_DOMAIN}") 125 | modparam("aaa_diameter", "peer_identity", "hss") 126 | modparam("aaa_diameter", "aaa_url", 127 | "diameter:/etc/opensips/freeDiameter.conf;extra-avps-file:/etc/opensips/pcscf.dictionary") 128 | 129 | modparam("proto_ipsec", "min_spi", 10000) 130 | modparam("proto_ipsec", "max_spi", 10100) 131 | #modparam("proto_ipsec", "allowed_algorithms", "hmac-sha-1-96=null") 132 | 133 | #### RTPENGINE module 134 | loadmodule "rtpengine.so" 135 | modparam("rtpengine", "rtpengine_sock", "udp:$${RTPENGINE_IP}:2223") 136 | 137 | 138 | loadmodule "event_route.so" 139 | loadmodule "json.so" 140 | 141 | #### PRESENCE modules 142 | loadmodule "presence.so" 143 | loadmodule "presence_reginfo.so" 144 | loadmodule "pua.so" 145 | modparam("pua|presence","db_url", "mysql://pcscf:heslo@${MYSQL_IP}/pcscf") 146 | 147 | loadmodule "pua_reginfo.so" 148 | 149 | modparam("pua_reginfo", "ul_domain", "location") 150 | modparam("pua_reginfo", "ul_identities_key", "identities") 151 | modparam("pua_reginfo", "default_domain", "${IMS_DOMAIN}") 152 | modparam("pua_reginfo", "server_address", "sip:reginfo@pcscf.${IMS_DOMAIN}") 153 | 154 | 155 | 156 | ####### Routing Logic ######## 157 | 158 | # main request routing logic 159 | 160 | route{ 161 | xlog("L_INFO", "[$ci] Start route time [$Tf] method ($rm) r-uri ($ru) \n"); 162 | set_via_handling("force-rport"); 163 | 164 | if (!mf_process_maxfwd_header(10)) { 165 | send_reply(483,"Too Many Hops"); 166 | exit; 167 | } 168 | 169 | if (has_totag()) { 170 | 171 | # handle hop-by-hop ACK (no routing required) 172 | if ( is_method("ACK") && t_check_trans() ) { 173 | t_relay(); 174 | exit; 175 | } 176 | 177 | # sequential request within a dialog should 178 | # take the path determined by record-routing 179 | if ( !loose_route() ) { 180 | # we do record-routing for all our traffic, so we should not 181 | # receive any sequential requests without Route hdr. 182 | send_reply(404,"Not here"); 183 | exit; 184 | } 185 | 186 | if (is_method("BYE")) { 187 | # do accounting even if the transaction fails 188 | do_accounting("log","failed"); 189 | route(session_termination); 190 | } 191 | 192 | if (is_method("UPDATE")) { 193 | if ($si != "${SCSCF_IP}") 194 | rtpengine_offer("replace-origin"); 195 | else 196 | t_on_reply("rtpengine_answer"); 197 | } 198 | 199 | if (is_method("SUBSCRIBE|NOTIFY") && is_myself($rd)) { 200 | route(handle_presence); 201 | exit; 202 | } 203 | 204 | # route it out to whatever destination was set by loose_route() 205 | # in $du (destination URI). 206 | route(relay); 207 | exit; 208 | } 209 | 210 | # CANCEL processing 211 | if (is_method("CANCEL")) { 212 | if (t_check_trans()) 213 | t_relay(); 214 | exit; 215 | } 216 | 217 | # absorb retransmissions, but do not create transaction 218 | t_check_trans(); 219 | 220 | if (is_method("REGISTER")) { 221 | xlog("L_INFO", "[$ci] Received REGISTER for $tu - relaying to I-CSCF\n"); 222 | append_hf("Path: \r\n"); 223 | 224 | if ($hdr(Security-Client)) { 225 | setflag("SEC_AGREE"); 226 | append_hf("P-Visited-Network-ID: ${IMS_DOMAIN}\r\n"); 227 | } 228 | 229 | t_on_reply("register_reply"); 230 | route(relay); 231 | exit; 232 | } else if (is_method("SUBSCRIBE|PUBLISH")) { 233 | xlog("L_INFO", "[$ci] Received $rm for $tu - handling\n"); 234 | route(handle_presence); 235 | exit; 236 | } else if (is_method("INVITE")) { 237 | if (loose_route()) { 238 | xlog("L_INFO", "[$ci] Received INVITE for $tu - relaying to S-CSCF ($ru/$du)\n"); 239 | remove_hf("Security-Verify"); 240 | if (list_hdr_has_option("Require", "sec-agree")) 241 | list_hdr_remove_option("Require", "sec-agree"); 242 | if (list_hdr_has_option("Proxy-Require", "sec-agree")) 243 | list_hdr_remove_option("Proxy-Require", "sec-agree"); 244 | append_hf("P-Visited-Network-ID: ${IMS_DOMAIN}\r\n"); 245 | $socket_out = "tcp:${PCSCF_IP}:5060"; 246 | $avp(si) = $si; 247 | rtpengine_offer("replace-origin"); 248 | } else { 249 | xlog("L_INFO", "[$ci] Received INVITE for $tu - looking up from S-CSCF ($ru/$du/$tu)\n"); 250 | $rU = $(tU{s.select,0,;}); 251 | if (!lookup("location")) { 252 | xlog("L_ERR", "[$ci] user $rU not found\n"); 253 | t_reply(404, "Not here"); 254 | exit; 255 | } 256 | } 257 | route(extract_ip_port); 258 | $avp(ip) = $var(ip); 259 | $avp(port) = $var(port); 260 | $avp(rtcp) = $var(rtcp); 261 | $avp(stream) = $(rb{sdp.stream,0}); 262 | t_on_reply("invite_reply"); 263 | if (!record_route()) { 264 | xlog("L_ERR", "[$ci] Cannot do record_route()\n"); 265 | t_reply(503, "Internal Error"); 266 | exit; 267 | } 268 | if (!create_dialog()) { 269 | xlog("L_ERR", "[$ci] Cannot create_dialog()\n"); 270 | t_reply(503, "Internal Error"); 271 | exit; 272 | } 273 | 274 | if (!t_relay()) { 275 | xlog("L_ERR", "[$ci] Cannot relay to $ru/$du\n"); 276 | t_reply(503, "Internal Error"); 277 | exit; 278 | } 279 | exit; 280 | } 281 | 282 | send_reply(405,"Method Not Allowed"); 283 | exit; 284 | } 285 | 286 | 287 | route[relay] { 288 | if (!t_relay()) { 289 | send_reply(500,"Internal Error"); 290 | } 291 | exit; 292 | } 293 | 294 | onreply_route[register_reply] { 295 | xlog("L_INFO","[$ci] Received REGISTER reply $rs from $si for $tu\n"); 296 | if ($T_reply_code == 401) { 297 | if (!isflagset("SEC_AGREE") || ipsec_create()) 298 | route(dm_send_aar, "control"); 299 | } else if ($T_reply_code == 200) { 300 | for ($var(item) in $(hdr(P-Associated-URI)[*])) { 301 | $var(uri_len) = $(var(item){s.len}) - 2; 302 | $var(uri) = $(var(item){s.substr, 1, $var(uri_len)}); 303 | if (!save("location", "no-reply, path-off", $var(uri))) { 304 | xlog("L_ERR", "[$ci] could not save aor [$var(uri)]\n"); 305 | } else { 306 | ul_add_key("location", "$tU@$td", "identities", "$var(uri)"); 307 | } 308 | } 309 | reginfo_update("$tU@$td"); 310 | } 311 | } 312 | 313 | onreply_route[invite_reply] { 314 | 315 | if (!has_body_part("application/sdp")) { 316 | xlog("L_INFO","[$ci] Received INVITE reply $rs from $si for $tu - without SDP\n"); 317 | return; 318 | } else if (isflagset("INVITE_AAA")) { 319 | xlog("L_INFO","[$ci] Received INVITE reply $rs from $si for $tu - AAA done\n"); 320 | return; 321 | } 322 | xlog("L_INFO","[$ci] Received INVITE reply $rs from $si for $tu - doing AAR\n"); 323 | route(extract_ip_port); 324 | if ($avp(si) == NULL) { 325 | rtpengine_answer("replace-origin"); 326 | $avp(si) = $si; 327 | $var(tmp_ip) = $avp(ip); 328 | $var(tmp_port) = $avp(port); 329 | $avp(ip) := $var(ip); 330 | $avp(port) := $var(port); 331 | $var(ip) = $var(tmp_ip); 332 | $var(port) = $var(tmp_port); 333 | } 334 | route(dm_send_aar, "audio"); 335 | setflag("INVITE_AAA"); 336 | } 337 | 338 | onreply_route[rtpengine_answer] { 339 | if (!has_body_part("application/sdp")) 340 | return; 341 | rtpengine_answer("replace-origin"); 342 | } 343 | 344 | 345 | route[dm_send_aar] { 346 | 347 | switch ($param(1)) { 348 | 349 | case "control": 350 | if ($ipsec(ip) != NULL) { 351 | $var(src_ip) = $ipsec_ue(ip); 352 | $var(src_port) = $ipsec_ue(port-c); 353 | $var(dst_ip) = $ipsec(ip); 354 | $var(dst_port) = $ipsec(port-s); 355 | $var(sess_port) = $ipsec_ue(port-s); 356 | } else { 357 | $var(src_ip) = $si; 358 | $var(src_port) = $sp; 359 | $var(dst_ip) = $socket_in(ip); 360 | $var(dst_port) = $socket_in(port); 361 | $var(sess_port) = $sp; 362 | } 363 | $var(media_component) = "[{\"Media-Component-Number\": 1}, 364 | {\"Media-Sub-Component\": [{\"Flow-Number\": 1}, 365 | {\"Flow-Description\": \"permit in ip from "+$var(src_ip)+" "+$var(src_port)+" to "+$var(dst_ip)+" "+$var(dst_port)+"\"}, 366 | {\"Flow-Description\": \"permit out ip from "+$var(dst_ip)+" "+$var(dst_port)+" to "+$var(src_ip)+" "+$var(src_port)+"\"}, 367 | {\"Flow-Usage\": 2}]}, 368 | {\"Media-Type\": 4}, 369 | {\"Codec-Data\": \"uplink\noffer\n\"}, 370 | {\"Codec-Data\": \"downlink\nanswer\n\"}, 371 | {\"Flow-Status\": 2}]"; 372 | $avp(si) = $var(src_ip); 373 | $var(session_id) = $var(src_ip) + ";" + $var(sess_port) + ";pcscf.${IMS_DOMAIN};"+$Ts+"."+$Tsm+";"+$pp; 374 | break; 375 | case "audio": 376 | $var(session_id) = "pcscf.${IMS_DOMAIN};"+$Ts+"."+$Tsm+";"+$pp; 377 | $var(media_component) = "[{\"Media-Component-Number\": 1}, 378 | {\"Media-Sub-Component\": [{\"Flow-Number\": 1}, 379 | {\"Flow-Description\": \"permit in 17 from "+$avp(ip)+" "+$avp(port)+" to "+$var(ip)+" "+$var(port)+"\"}, 380 | {\"Flow-Description\": \"permit out 17 from "+$var(ip)+" "+$var(port)+" to "+$avp(ip)+" "+$avp(port)+"\"}, 381 | {\"Flow-Description\": \"permit in 17 from "+$avp(ip)+" "+$avp(rtcp)+" to "+$var(ip)+" "+$var(rtcp)+"\"}, 382 | {\"Flow-Description\": \"permit out 17 from "+$var(ip)+" "+$var(rtcp)+" to "+$avp(ip)+" "+$avp(rtcp)+"\"}, 383 | {\"Flow-Usage\": 0}]}, 384 | {\"Media-Type\": 0}, 385 | {\"Max-Requested-Bandwidth-DL\": 41000}, 386 | {\"Max-Requested-Bandwidth-UL\": 41000}, 387 | {\"Codec-Data\": \"uplink\noffer\n"+$avp(stream)+"\"}, 388 | {\"Codec-Data\": \"downlink\nanswer\n"+$(rb{sdp.stream,0})+"\"}, 389 | {\"Flow-Status\": 2}]"; 390 | $dlg_val(session_id) = $var(session_id); 391 | break; 392 | } 393 | $var(payload) = "[ 394 | { \"Session-Id\": \""+$var(session_id)+"\" }, 395 | { \"Auth-Application-Id\": 16777236 }, 396 | { \"Origin-Host\": \"pcscf.${IMS_DOMAIN}\" }, 397 | { \"Origin-Realm\": \"${IMS_DOMAIN}\" }, 398 | { \"Destination-Realm\": \"${EPC_DOMAIN}\" }, 399 | { \"Vendor-Specific-Application-Id\": [{\"Vendor-Id\": 10415}, 400 | {\"Auth-Application-Id\": 16777236}]}, 401 | { \"AF-Application-Identifier\": \"IMS Services\" }, 402 | { \"Authorization-Lifetime\": 3600 }, 403 | { \"Subscription-ID\": [{\"Subscription-Id-Type\": 2}, 404 | {\"Subscription-Id-Data\": \""+$fu+"\"}]}, 405 | { \"Reservation-Priority\": 0 }, 406 | { \"Media-Component-Description\": "+$var(media_component)+"}, 407 | { \"Frame-IP-Address\": \""+$avp(si)+"\" }, 408 | { \"Specific-Action\": 1 }, 409 | { \"Specific-Action\": 2 }, 410 | { \"Specific-Action\": 3 }, 411 | { \"Specific-Action\": 4 }, 412 | { \"Specific-Action\": 5 }, 413 | { \"Specific-Action\": 6 }, 414 | { \"Specific-Action\": 12 }, 415 | { \"Auth-Grace-Period\": 0 }, 416 | { \"Session-Timeout\": 3600 } 417 | ]"; 418 | 419 | $var(rc) = dm_send_request(16777236, 265, $var(payload), $var(rpl_avps)); 420 | xlog("[$ci] AAA rc: $var(rc), AAA AVPs: $var(rpl_avps)\n"); 421 | } 422 | 423 | route[session_termination] { 424 | if ($si != "${SCSCF_IP}") 425 | rtpengine_delete(); 426 | 427 | xlog("L_INFO","[$ci] Received BYE from $si for $tu - doing STR\n"); 428 | 429 | $var(payload) = "[ 430 | { \"Session-Id\": \""+$dlg_val(session_id)+"\" }, 431 | { \"Auth-Application-Id\": 16777236 }, 432 | { \"Origin-Host\": \"pcscf.${IMS_DOMAIN}\" }, 433 | { \"Origin-Realm\": \"${IMS_DOMAIN}\" }, 434 | { \"Destination-Realm\": \"${EPC_DOMAIN}\" }, 435 | { \"Vendor-Specific-Application-Id\": [{\"Vendor-Id\": 10415}, 436 | {\"Auth-Application-Id\": 16777236}]}, 437 | { \"AF-Application-Identifier\": \"IMS Services\" }, 438 | { \"Termination-Cause\": 1 } 439 | ]"; 440 | 441 | $var(rc) = dm_send_request(16777236, 275, $var(payload), $var(rpl_avps)); 442 | xlog("[$ci] STA rc: $var(rc), STA AVPs: $var(rpl_avps)\n"); 443 | } 444 | 445 | route[extract_ip_port] { 446 | $var(ip) = $(rb{sdp.line,c}{s.select,2, }); 447 | $var(port) = $(rb{sdp.line,m}{s.select,1, }); 448 | $var(rtcp) = $(var(port){s.int}) + 1; 449 | } 450 | 451 | event_route[E_DM_REQUEST] { 452 | if ($param(app_id) == 16777236 && $param(cmd_code) == 274) { 453 | $var(ip) = $(param(sess_id){s.select,0,;}); 454 | $var(port) = $(param(sess_id){s.select,1,;}{s.int}); 455 | xlog("[diameter] removing $var(ip):$var(port) contact\n"); 456 | remove_ip_port($var(ip), $var(port), "location"); 457 | $var(payload) = "[ 458 | { \"Vendor-Specific-Application-Id\": [{\"Vendor-Id\": 10415}, 459 | {\"Auth-Application-Id\": 16777236}]}, 460 | { \"Result-Code\": 2001 }, 461 | { \"Auth-Session-State\": 0 }, 462 | { \"Origin-Host\": \"pcscf.${IMS_DOMAIN}\" }, 463 | { \"Origin-Realm\": \"${IMS_DOMAIN}\" } 464 | ]"; 465 | dm_send_answer($var(payload)); 466 | 467 | } 468 | } 469 | 470 | route[handle_presence] { 471 | if (!t_newtran()){ 472 | sl_reply_error(); 473 | exit; 474 | } 475 | if ($hdr(Event) != "reg") { 476 | xlog("L_ERR", "[$ci] Unhandled event $hdr(Event)\n"); 477 | send_reply(489, "Bad Event"); 478 | exit; 479 | } 480 | 481 | if (is_method("PUBLISH")) 482 | handle_publish(); 483 | if (is_method("SUBSCRIBE")) 484 | handle_subscribe(); 485 | } 486 | -------------------------------------------------------------------------------- /pcscf/pcscf.dictionary: -------------------------------------------------------------------------------- 1 | VENDOR 10415 TGPP 2 | VENDOR 13019 ETSI 3 | 4 | ATTRIBUTE Abort-Cause 500 unsigned32 10415 5 | ATTRIBUTE AF-Application-Identifier 504 string 10415 6 | ATTRIBUTE Flow-Description 507 string 10415 7 | ATTRIBUTE Flow-Number 509 unsigned32 10415 8 | ATTRIBUTE Flow-Status 511 unsigned32 10415 9 | ATTRIBUTE Flow-Usage 512 unsigned32 10415 10 | ATTRIBUTE Specific-Action 513 unsigned32 10415 11 | ATTRIBUTE Max-Requested-Bandwidth-DL 515 unsigned32 10415 12 | ATTRIBUTE Max-Requested-Bandwidth-UL 516 unsigned32 10415 13 | ATTRIBUTE Media-Component-Number 518 unsigned32 10415 14 | ATTRIBUTE Media-Type 520 unsigned32 10415 15 | ATTRIBUTE Codec-Data 524 string 10415 16 | ATTRIBUTE Media-Sub-Component 519 grouped 10415 17 | { 18 | Flow-Number | REQUIRED | 1 19 | Flow-Usage | REQUIRED | 1 20 | Flow-Description | REQUIRED | 9 21 | } 22 | 23 | ATTRIBUTE Media-Component-Description 517 grouped 10415 24 | { 25 | Media-Component-Number | REQUIRED | 1 26 | Media-Sub-Component | REQUIRED | 1 27 | Media-Type | REQUIRED | 1 28 | Max-Requested-Bandwidth-DL | REQUIRED | 1 29 | Max-Requested-Bandwidth-UL | REQUIRED | 1 30 | Flow-Status | REQUIRED | 1 31 | } 32 | ATTRIBUTE IP-CAN-Type 1027 unsigned32 10415 33 | ATTRIBUTE RAT-Type 1032 unsigned32 10415 34 | 35 | ATTRIBUTE Subscription-Id-Type 450 unsigned32 36 | ATTRIBUTE Subscription-Id-Data 444 string 37 | ATTRIBUTE Subscription-ID 443 grouped 38 | { 39 | Subscription-Id-Type | REQUIRED | 1 40 | Subscription-Id-Data | REQUIRED | 1 41 | } 42 | ATTRIBUTE Frame-IP-Address 8 ip 43 | ATTRIBUTE Reservation-Priority 458 unsigned32 13019 44 | 45 | APPLICATION-AUTH 16777236/10415 3GPP Rx 46 | 47 | REQUEST 265 AA Request 48 | { 49 | Session-Id | REQUIRED | 1 50 | Auth-Application-Id | REQUIRED | 1 51 | Origin-Host | REQUIRED | 1 52 | Origin-Realm | REQUIRED | 1 53 | Destination-Realm | REQUIRED | 1 54 | AF-Application-Identifier | REQUIRED | 1 55 | Authorization-Lifetime | REQUIRED | 1 56 | Subscription-ID | REQUIRED | 1 57 | Specific-Action | REQUIRED | 9 58 | Frame-IP-Address | REQUIRED | 1 59 | Reservation-Priority | REQUIRED | 1 60 | Session-Timeout | OPTIONAL | 1 61 | Auth-Grace-Period | OPTIONAL | 1 62 | } 63 | # Vendor-Specific-Application-Id | REQUIRED | 1 64 | # Media-Component-Description | REQUIRED | 1 65 | 66 | ANSWER 265 AA Answer 67 | { 68 | Session-Id | REQUIRED | 1 69 | Auth-Application-Id | REQUIRED | 1 70 | Origin-Host | REQUIRED | 1 71 | Origin-Realm | REQUIRED | 1 72 | Destination-Host | OPTIONAL | 1 73 | Destination-Realm | OPTIONAL | 1 74 | Result-Code | OPTIONAL | 1 75 | Experimental-Result | OPTIONAL | 1 76 | IP-CAN-Type | OPTIONAL | 1 77 | RAT-Type | OPTIONAL | 1 78 | } 79 | -------------------------------------------------------------------------------- /scscf/.gitignore: -------------------------------------------------------------------------------- 1 | /substenv.sh 2 | -------------------------------------------------------------------------------- /scscf/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 2-Clause License 4 | 5 | # Copyright (c) 2020, 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 | while ! mysqladmin ping -h ${MYSQL_IP} --silent; do 30 | sleep 5; 31 | done 32 | 33 | # Sleep until permissions are set 34 | sleep 10; 35 | 36 | # Create SCSCF database, populate tables and grant privileges 37 | if [[ -z "`mysql -u root -h ${MYSQL_IP} -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='scscf'" 2>&1`" ]]; 38 | then 39 | mysql -u root -h ${MYSQL_IP} -e "create database scscf;" 40 | mysql -u root -h ${MYSQL_IP} scscf < /usr/share/opensips/mysql/standard-create.sql 41 | mysql -u root -h ${MYSQL_IP} scscf < /usr/share/opensips/mysql/dialplan-create.sql 42 | SCSCF_USER_EXISTS=`mysql -u root -h ${MYSQL_IP} -s -N -e "SELECT EXISTS(SELECT 1 FROM mysql.user WHERE User = 'scscf' AND Host = '%')"` 43 | if [[ "$SCSCF_USER_EXISTS" == 0 ]] 44 | then 45 | mysql -u root -h ${MYSQL_IP} -e "CREATE USER 'scscf'@'%' IDENTIFIED WITH mysql_native_password BY 'heslo'"; 46 | mysql -u root -h ${MYSQL_IP} -e "CREATE USER 'scscf'@'$SCSCF_IP' IDENTIFIED WITH mysql_native_password BY 'heslo'"; 47 | mysql -u root -h ${MYSQL_IP} -e "GRANT ALL ON scscf.* TO 'scscf'@'%'"; 48 | mysql -u root -h ${MYSQL_IP} -e "GRANT ALL ON scscf.* TO 'scscf'@'$SCSCF_IP'"; 49 | mysql -u root -h ${MYSQL_IP} -e "FLUSH PRIVILEGES;" 50 | fi 51 | fi 52 | 53 | exec /usr/sbin/opensips -F $@ 54 | -------------------------------------------------------------------------------- /scscf/freeDiameter.conf.m4: -------------------------------------------------------------------------------- 1 | Identity = "scscf.${IMS_DOMAIN}"; 2 | Realm = "${IMS_DOMAIN}"; 3 | Port = ${SCSCF_BIND_PORT}; 4 | SecPort = 0; 5 | No_SCTP; 6 | NoRelay; 7 | 8 | ConnectPeer = "hss.${IMS_DOMAIN}" { 9 | No_TLS; 10 | port = ${PYHSS_BIND_PORT}; 11 | }; 12 | -------------------------------------------------------------------------------- /scscf/opensips.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # OpenSIPS residential configuration script 3 | # by OpenSIPS Solutions 4 | # 5 | # This script was generated via "make menuconfig", from 6 | # the "Residential" scenario. 7 | # You can enable / disable more features / functionalities by 8 | # re-generating the scenario with different options.# 9 | # 10 | # Please refer to the Core CookBook at: 11 | # https://opensips.org/Resources/DocsCookbooks 12 | # for a explanation of possible statements, functions and parameters. 13 | # 14 | 15 | 16 | ####### Global Parameters ######### 17 | 18 | /* uncomment the following lines to enable debugging */ 19 | #debug_mode=yes 20 | 21 | log_level=3 22 | xlog_level=3 23 | log_stderror=yes 24 | log_stdout=yes 25 | xlog_buf_size=16384 26 | log_facility=LOG_LOCAL0 27 | 28 | udp_workers=4 29 | 30 | /* uncomment the next line to enable the auto temporary blacklisting of 31 | not available destinations (default disabled) */ 32 | #disable_dns_blacklist=no 33 | 34 | /* uncomment the next line to enable IPv6 lookup after IPv4 dns 35 | lookup failures (default disabled) */ 36 | #dns_try_ipv6=yes 37 | 38 | 39 | socket=udp:${SCSCF_IP}:6060 40 | socket=tcp:${SCSCF_IP}:6060 41 | 42 | alias="scscf.${IMS_DOMAIN}" 43 | 44 | #set module path 45 | mpath="/usr/lib/x86_64-linux-gnu/opensips/modules" 46 | 47 | ####### Modules Section ######## 48 | 49 | #### MYSQL module 50 | loadmodule "db_mysql.so" 51 | 52 | #### SIGNALING module 53 | loadmodule "signaling.so" 54 | 55 | #### StateLess module 56 | loadmodule "sl.so" 57 | 58 | #### Transaction Module 59 | loadmodule "tm.so" 60 | modparam("tm", "fr_timeout", 5) 61 | modparam("tm", "fr_inv_timeout", 30) 62 | modparam("tm", "restart_fr_on_each_reply", 0) 63 | modparam("tm", "onreply_avp_mode", 1) 64 | 65 | #### Record Route Module 66 | loadmodule "rr.so" 67 | /* do not append from tag to the RR (no need for this script) */ 68 | modparam("rr", "append_fromtag", 0) 69 | 70 | #### MAX ForWarD module 71 | loadmodule "maxfwd.so" 72 | 73 | #### SIP MSG OPerationS module 74 | loadmodule "sipmsgops.so" 75 | 76 | #### FIFO Management Interface 77 | loadmodule "mi_fifo.so" 78 | modparam("mi_fifo", "fifo_name", "/run/opensips/opensips_fifo") 79 | modparam("mi_fifo", "fifo_mode", 0666) 80 | 81 | #### USeR LOCation module 82 | loadmodule "usrloc.so" 83 | modparam("usrloc", "nat_bflag", "NAT") 84 | modparam("usrloc", "working_mode_preset", "single-instance-no-db") 85 | 86 | #### REGISTRAR module 87 | loadmodule "registrar.so" 88 | modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT") 89 | modparam("registrar", "attr_avp", "$avp(attr)") 90 | /* uncomment the next line not to allow more than 10 contacts per AOR */ 91 | #modparam("registrar", "max_contacts", 10) 92 | 93 | #### ACCounting module 94 | loadmodule "acc.so" 95 | /* what special events should be accounted ? */ 96 | modparam("acc", "early_media", 0) 97 | modparam("acc", "report_cancels", 0) 98 | /* by default we do not adjust the direct of the sequential requests. 99 | if you enable this parameter, be sure to enable "append_fromtag" 100 | in "rr" module */ 101 | modparam("acc", "detect_direction", 0) 102 | 103 | loadmodule "proto_udp.so" 104 | loadmodule "proto_tcp.so" 105 | 106 | #### aaa_diameter module 107 | loadmodule "aaa_diameter.so" 108 | modparam("aaa_diameter", "fd_log_level", 1) # max amount of logging, quite annoying 109 | modparam("aaa_diameter", "realm", "${IMS_DOMAIN}") 110 | modparam("aaa_diameter", "peer_identity", "hss") 111 | modparam("aaa_diameter", "aaa_url", 112 | "diameter:/etc/opensips/freeDiameter.conf;extra-avps-file:/etc/opensips/scscf.dictionary") 113 | loadmodule "auth_aka.so" 114 | modparam("auth_aka", "default_av_mgm", "diameter") 115 | modparam("auth_aka", "default_qop", "auth,auth-int") 116 | loadmodule "aka_av_diameter.so" 117 | modparam("aka_av_diameter", "realm", 118 | "scscf.${IMS_DOMAIN}") 119 | modparam("aka_av_diameter", "aaa_url", 120 | "diameter:/etc/opensips/freeDiameter.conf;extra-avps-file:/etc/opensips/scscf.dictionary") 121 | 122 | #### dialplan module 123 | loadmodule "dialplan.so" 124 | modparam("dialplan","db_url", "mysql://scscf:heslo@${MYSQL_IP}/scscf") 125 | 126 | 127 | #### auth module 128 | loadmodule "auth.so" 129 | 130 | #### JSON module 131 | loadmodule "json.so" 132 | 133 | #### XML module 134 | loadmodule "xml.so" 135 | 136 | 137 | 138 | ####### Routing Logic ######## 139 | 140 | # main request routing logic 141 | 142 | route{ 143 | xlog("L_INFO", "[$ci] Start route time [$Tf] method ($rm) r-uri ($ru) \n"); 144 | 145 | if (!mf_process_maxfwd_header(10)) { 146 | send_reply(483,"Too Many Hops"); 147 | exit; 148 | } 149 | 150 | if (has_totag()) { 151 | 152 | # handle hop-by-hop ACK (no routing required) 153 | if ( is_method("ACK") && t_check_trans() ) { 154 | t_relay(); 155 | exit; 156 | } 157 | 158 | # sequential request within a dialog should 159 | # take the path determined by record-routing 160 | if ( !loose_route() ) { 161 | # we do record-routing for all our traffic, so we should not 162 | # receive any sequential requests without Route hdr. 163 | send_reply(404,"Not here"); 164 | exit; 165 | } 166 | 167 | if (is_method("BYE")) { 168 | # do accounting even if the transaction fails 169 | do_accounting("log","failed"); 170 | } 171 | 172 | # route it out to whatever destination was set by loose_route() 173 | # in $du (destination URI). 174 | route(relay); 175 | exit; 176 | } 177 | 178 | # CANCEL processing 179 | if (is_method("CANCEL")) { 180 | if (t_check_trans()) 181 | t_relay(); 182 | exit; 183 | } 184 | 185 | # absorb retransmissions, but do not create transaction 186 | t_check_trans(); 187 | 188 | if (is_method("REGISTER")) { 189 | xlog("L_INFO", "[$ci] Received REGISTER for $tu - doing authorization\n"); 190 | if (!aka_www_authorize()) { 191 | if (!async(aka_www_challenge(), aka_resume_mar)) 192 | t_reply(500, "Internal Error"); 193 | exit; 194 | } 195 | xlog("L_INFO", "[$ci] Received REGISTER for $tu - authorized, doing SAR\n"); 196 | $var(payload) = "[ 197 | { \"Session-Id\": \"scscf.${IMS_DOMAIN};"+$Ts+"."+$Tsm+";"+$pp+"\" }, 198 | { \"Origin-Host\": \"scscf.${IMS_DOMAIN}\" }, 199 | { \"Origin-Realm\": \"${IMS_DOMAIN}\" }, 200 | { \"Destination-Realm\": \"${IMS_DOMAIN}\" }, 201 | { \"Vendor-Specific-Application-Id\": [{\"Vendor-Id\": 10415}, 202 | {\"Auth-Application-Id\": 16777216}]}, 203 | { \"Auth-Session-State\": 1 }, 204 | { \"User-Name\": \""+$fU+"@"+$fd+"\" }, 205 | { \"Public-Identity\": \""+$fu+"\" }, 206 | { \"Server-Assignment-Type\": 1 }, 207 | { \"User-Data-Already-Available\": 0}, 208 | { \"Server-Name\": \"sip:scscf.${IMS_DOMAIN}:6060\" } 209 | ]"; 210 | 211 | if (!async(dm_send_request(16777216, 301, $var(payload), $var(rpl_avps)), aka_resume_sar)) { 212 | t_reply(500, "Internal Error"); 213 | exit; 214 | } 215 | exit; 216 | } else if (is_method("INVITE")) { 217 | 218 | xlog("L_INFO", "[$ci] Received INVITE for $tu/$ru - checking dialplan\n"); 219 | loose_route(); # consume preloaded routes 220 | if (!record_route()) { 221 | xlog("L_ERR", "[$ci] Cannot do record_route()\n"); 222 | t_reply(503, "Internal Error"); 223 | exit; 224 | } 225 | if ($ru =~ "^tel:") { 226 | $var(tel_user) = $rU; 227 | $var(tel_domain) = $(ru{uri.param,phone-context}); 228 | $ru = "sip:" + $var(tel_user) + "@" + $var(tel_domain); 229 | } else { 230 | $rU = $(rU{s.select,0,;}); 231 | } 232 | if (!dp_translate(1, $rU, $var(dialplan))) { 233 | $var(dialplan) = "USER"; 234 | xlog("L_DBG", "[$ci] unknown dialplan - considering $var(dialplan)\n"); 235 | } 236 | xlog("L_INFO", "[$ci] Dial $rU is a $var(dialplan) dialplan\n"); 237 | switch ($var(dialplan)) { 238 | case "USER": 239 | xlog("L_INFO", "[$ci] lookup user $rU/$(oU{s.select,0,;})\n"); 240 | if (!lookup("location")) { 241 | xlog("L_ERR", "[$ci] Received INVITE for $tu/$ru not registered - sending to service\n"); 242 | t_reply(404, "User not found"); 243 | exit; 244 | } 245 | break; 246 | case "SERVICE": 247 | # TODO: handle service 248 | case "APPLICATION": 249 | # TODO: handle application server 250 | default: 251 | xlog("L_ERR", "[$ci] unknown $var(dialplan) dialplan\n"); 252 | t_reply(503, "Unknown dialplan"); 253 | exit; 254 | } 255 | if (!t_relay()) { 256 | xlog("L_ERR", "[$ci] Cannot relay to $ru\n"); 257 | t_reply(503, "Internal Error"); 258 | } 259 | exit; 260 | } 261 | 262 | send_reply(503,"Not Implemented"); 263 | exit; 264 | } 265 | 266 | 267 | route[relay] { 268 | if (!t_relay()) { 269 | send_reply(500,"Internal Error"); 270 | } 271 | exit; 272 | } 273 | 274 | route[aka_resume_mar] { 275 | xlog("L_DBG", "[$ci] MAA rc: $rc\n"); 276 | } 277 | 278 | route[aka_resume_sar] { 279 | xlog("[$ci] SAA rc: $var(rc), SAA AVPs: $var(rpl_avps)\n"); 280 | $avp(attr) = $ct.fields(params); 281 | append_to_reply("Service-Route: \r\n"); 282 | $json(rpl_avps) := $var(rpl_avps); 283 | for ($var(item) in $(json(rpl_avps)[*])) { 284 | $json(item) := $var(item); 285 | for ($var(key) in $(json(item.keys)[*])) { 286 | if ($var(key) == "Cx-User-Data") { 287 | $xml(data) := $json(item/$var(key)); 288 | $xml(profile) := $xml(data/IMSSubscription/ServiceProfile); 289 | $var(idx) = 0; 290 | while ($xml(profile/ServiceProfile/PublicIdentity[$var(idx)]) != NULL) { 291 | append_to_reply("P-Associated-URI: <$xml(profile/ServiceProfile/PublicIdentity[$var(idx)]/Identity.val)>\r\n"); 292 | $var(uri) = $xml(profile/ServiceProfile/PublicIdentity[$var(idx)]/Identity.val); 293 | if ($var(uri) == $tu) { 294 | # Save AoR for IMPU in format sip:IMSI@IMS_DOMAIN and send 200 response. 295 | if (!save("location", "path-lazy")) { 296 | t_reply(503, "Internal Error"); 297 | exit; 298 | } 299 | } else { 300 | # Save AoR for IMPU in other formats and dont send response. 301 | if (!save("location", "no-reply, path-lazy", $var(uri))) { 302 | t_reply(503, "Internal Error"); 303 | exit; 304 | } 305 | } 306 | $var(idx) = $var(idx) + 1; 307 | } 308 | } 309 | } 310 | } 311 | } 312 | -------------------------------------------------------------------------------- /scscf/scscf.dictionary: -------------------------------------------------------------------------------- 1 | VENDOR 10415 TGPP 2 | 3 | ATTRIBUTE Visited-Network-Identifier 600 string 10415 4 | ATTRIBUTE Public-Identity 601 string 10415 5 | ATTRIBUTE Server-Name 602 string 10415 6 | ATTRIBUTE Mandatory-Capability 604 unsigned32 10415 7 | ATTRIBUTE Optional-Capability 605 unsigned32 10415 8 | ATTRIBUTE Cx-User-Data 606 string 10415 9 | ATTRIBUTE 3GPP-SIP-Number-Auth-Items 607 unsigned32 10415 10 | ATTRIBUTE 3GPP-SIP-Authentication-Scheme 608 utf8string 10415 11 | ATTRIBUTE 3GPP-SIP-Authenticate 609 hexstring 10415 12 | ATTRIBUTE 3GPP-SIP-Authorization 610 hexstring 10415 13 | ATTRIBUTE 3GPP-SIP-Authentication-Context 611 string 10415 14 | ATTRIBUTE 3GPP-SIP-Item-Number 613 unsigned32 10415 15 | ATTRIBUTE Server-Assignment-Type 614 unsigned32 10415 16 | ATTRIBUTE User-Data-Already-Available 624 unsigned32 10415 17 | ATTRIBUTE Confidentiality-Key 625 hexstring 10415 18 | ATTRIBUTE Integrity-Key 626 hexstring 10415 19 | 20 | ATTRIBUTE Primary-Event-Charging-Function-Name 619 string 10415 21 | ATTRIBUTE Secondary-Event-Charging-Function-Name 620 string 10415 22 | ATTRIBUTE Primary-Charging-Collection-Function-Name 621 string 10415 23 | ATTRIBUTE Secondary-Charging-Collection-Function-Name 622 string 10415 24 | 25 | ATTRIBUTE 3GPP-SIP-Auth-Data-Item 612 grouped 10415 26 | { 27 | 3GPP-SIP-Item-Number | OPTIONAL | 1 28 | 3GPP-SIP-Authentication-Scheme | OPTIONAL | 1 29 | 3GPP-SIP-Authenticate | OPTIONAL | 1 30 | 3GPP-SIP-Authorization | OPTIONAL | 1 31 | 3GPP-SIP-Authentication-Context | OPTIONAL | 1 32 | Confidentiality-Key | OPTIONAL | 1 33 | Integrity-Key | OPTIONAL | 1 34 | } 35 | 36 | ATTRIBUTE Charging-Information 618 grouped 10415 37 | { 38 | Primary-Event-Charging-Function-Name | OPTIONAL | 1 39 | Secondary-Event-Charging-Function-Name | OPTIONAL | 1 40 | Primary-Charging-Collection-Function-Name | OPTIONAL | 1 41 | Secondary-Charging-Collection-Function-Name | OPTIONAL | 1 42 | } 43 | 44 | 45 | APPLICATION-AUTH 16777216/10415 3GPP Cx 46 | 47 | REQUEST 301 Server-Assignment Request 48 | { 49 | Session-Id | REQUIRED | 1 50 | Origin-Host | REQUIRED | 1 51 | Origin-Realm | REQUIRED | 1 52 | Destination-Realm | REQUIRED | 1 53 | Vendor-Specific-Application-Id | REQUIRED | 1 54 | Auth-Session-State | REQUIRED | 1 55 | Public-Identity | REQUIRED | 1 56 | Server-Name | REQUIRED | 1 57 | User-Name | REQUIRED | 1 58 | Server-Assignment-Type | REQUIRED | 1 59 | User-Data-Already-Available | REQUIRED | 1 60 | } 61 | 62 | ANSWER 301 Server-Assignment Answer 63 | { 64 | Session-Id | REQUIRED | 1 65 | Origin-Host | REQUIRED | 1 66 | Origin-Realm | REQUIRED | 1 67 | Destination-Host | OPTIONAL | 1 68 | Destination-Realm | OPTIONAL | 1 69 | Vendor-Specific-Application-Id | REQUIRED | 1 70 | Auth-Session-State | REQUIRED | 1 71 | User-Name | REQUIRED | 1 72 | Cx-User-Data | REQUIRED | 1 73 | Charging-Information | OPTIONAL | 1 74 | Result-Code | REQUIRED | 1 75 | } 76 | 77 | REQUEST 303 Multimedia-Auth Request 78 | { 79 | Session-Id | REQUIRED | 1 80 | Origin-Host | REQUIRED | 1 81 | Origin-Realm | REQUIRED | 1 82 | Destination-Realm | REQUIRED | 1 83 | Vendor-Specific-Application-Id | REQUIRED | 1 84 | Auth-Session-State | REQUIRED | 1 85 | Public-Identity | REQUIRED | 1 86 | 3GPP-SIP-Number-Auth-Items | REQUIRED | 1 87 | 3GPP-SIP-Auth-Data-Item | REQUIRED | 1 88 | Server-Name | REQUIRED | 1 89 | } 90 | 91 | ANSWER 303 Multimedia-Auth Answer 92 | { 93 | Session-Id | REQUIRED | 1 94 | Origin-Host | REQUIRED | 1 95 | Origin-Realm | REQUIRED | 1 96 | Destination-Host | OPTIONAL | 1 97 | Destination-Realm | OPTIONAL | 1 98 | Vendor-Specific-Application-Id | REQUIRED | 1 99 | Auth-Session-State | REQUIRED | 1 100 | Public-Identity | REQUIRED | 1 101 | 3GPP-SIP-Number-Auth-Items | REQUIRED | 1 102 | 3GPP-SIP-Auth-Data-Item | REQUIRED | 1 103 | User-Name | REQUIRED | 1 104 | Result-Code | REQUIRED | 1 105 | } 106 | -------------------------------------------------------------------------------- /scscf/substenv.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenSIPS/opensips-ims-ce/c6fdc130dd92cb09b4d125cce2e1d547df34dca6/scscf/substenv.sh -------------------------------------------------------------------------------- /substenv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test -z "${DOMAIN}" && test ${#MNC} == 3 && \ 4 | DOMAIN="mnc${MNC}.mcc${MCC}.3gppnetwork.org" || \ 5 | DOMAIN="mnc0${MNC}.mcc${MCC}.3gppnetwork.org" 6 | IMS_DOMAIN=${IMS_DOMAIN:-ims.${DOMAIN}} 7 | EPC_DOMAIN=${EPC_DOMAIN:-epc.${DOMAIN}} 8 | export EPC_DOMAIN IMS_DOMAIN 9 | ENV="$(printf '${%s} ' $(env | cut -d'=' -f1))" 10 | DIAMETER_FILE=/etc/opensips/freeDiameter.conf.m4 11 | test -f "${DIAMETER_FILE}" && cat "${DIAMETER_FILE}" | \ 12 | envsubst "${ENV}" > ${DIAMETER_FILE%.*} 13 | envsubst "${ENV}" 14 | 15 | --------------------------------------------------------------------------------