From d84ca6c68f852ef1f78c56243cff774d2c2e9b4a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joanne=20Hug=C3=A9?= <joanne.huge@nexedi.com>
Date: Wed, 2 Oct 2024 15:34:53 +0200
Subject: [PATCH] software/ors: support external MBMSGW

---
 software/ors-amarisoft/buildout.hash.cfg          |  2 +-
 software/ors-amarisoft/config/enb.jinja2.cfg      | 10 ++++++++++
 .../ors-amarisoft/instance-enb-input-schema.json  | 15 +++++++++++++++
 .../instance-ors-enb-input-schema.json            |  3 +++
 .../instance-ors-gnb-input-schema.json            |  3 +++
 software/ors-amarisoft/test/test.py               |  6 ++++--
 6 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/software/ors-amarisoft/buildout.hash.cfg b/software/ors-amarisoft/buildout.hash.cfg
index 7667d75d2..42517e932 100644
--- a/software/ors-amarisoft/buildout.hash.cfg
+++ b/software/ors-amarisoft/buildout.hash.cfg
@@ -88,7 +88,7 @@ md5sum = dd50b4e4780830ddbde28b84af118f18
 
 [enb.jinja2.cfg]
 filename = config/enb.jinja2.cfg
-md5sum = fd4bb1115aa650b7c1daa3e904ab93b1
+md5sum = 2c49e14af6869387880d5e8e1c0ede64
 
 [drb_lte.jinja2.cfg]
 filename = config/drb_lte.jinja2.cfg
diff --git a/software/ors-amarisoft/config/enb.jinja2.cfg b/software/ors-amarisoft/config/enb.jinja2.cfg
index fa9a2a51e..8e8bec277 100644
--- a/software/ors-amarisoft/config/enb.jinja2.cfg
+++ b/software/ors-amarisoft/config/enb.jinja2.cfg
@@ -155,12 +155,19 @@
   com_addr: "{{ slapparameter_dict.com_addr }}:{{ slapparameter_dict.com_ws_port }}",
   {%- endif %}
 
+{%- if slapparameter_dict.get('mbmsgw_addr', '') %}
+  mbmsgw_addr: "{{ slapparameter_dict.mbmsgw_addr }}",
+{%- endif %}
+
 {%  if do_lte %}
   // LTE core network
   mme_list: [
 {%-   for _, mme in slapparameter_dict.mme_list |dictsort %}
     {
       mme_addr: "{{ mme['mme_addr'] }}",
+{%-     if mme.get('s1ap_bind_addr', '') %}
+      s1ap_bind_addr: "{{ mme['s1ap_bind_addr'] }}",
+{%-     endif %}
     },
 {%-   endfor %}
   ],
@@ -172,6 +179,9 @@
 {%-   for _, amf in slapparameter_dict.amf_list |dictsort %}
     {
       amf_addr: "{{ amf['amf_addr'] }}",
+{%-     if amf.get('ngap_bind_addr', '') %}
+      ngap_bind_addr: "{{ amf['ngap_bind_addr'] }}",
+{%-     endif %}
     },
 {%-   endfor %}
   ],
diff --git a/software/ors-amarisoft/instance-enb-input-schema.json b/software/ors-amarisoft/instance-enb-input-schema.json
index 6bba2e52d..854063656 100644
--- a/software/ors-amarisoft/instance-enb-input-schema.json
+++ b/software/ors-amarisoft/instance-enb-input-schema.json
@@ -20,6 +20,11 @@
       "type": "string",
       "default": "127.0.1.1"
     },
+    "mbmsgw_addr": {
+      "title": "SGW Address",
+      "description": "Set the IP address (and optional port) of the MBMS Gateway for the M2 connection. The default port is 36443.",
+      "type": "string"
+    },
     "mme_list": {
       "title": "MME list",
       "description": "List of MME to which the eNodeB is connected. (must be set if there are LTE cells)",
@@ -30,6 +35,11 @@
               "title": "MME Address",
               "description": "IP address (and optional port) of S1AP SCTP connection to the MME. The default port is 36412.",
               "type": "string"
+            },
+            "s1ap_bind_addr": {
+              "title": "S1AP Bind Address",
+              "description": "Optional String. IP address and optional port on which the S1AP SCTP connection is bound.",
+              "type": "string"
             }
           },
           "type": "object"
@@ -87,6 +97,11 @@
               "title": "AMF Address",
               "description": "IP address (and optional port) of NGAP SCTP connection to the AMF. The default port is 38412.",
               "type": "string"
+            },
+            "ngap_bind_addr": {
+              "title": "NGAP Bind Address",
+              "description": "Optional string. IP address and optional port on which the NGAP SCTP connection is bound.",
+              "type": "string"
             }
           },
           "type": "object"
diff --git a/software/ors-amarisoft/instance-ors-enb-input-schema.json b/software/ors-amarisoft/instance-ors-enb-input-schema.json
index 0346c4201..da0536ede 100644
--- a/software/ors-amarisoft/instance-ors-enb-input-schema.json
+++ b/software/ors-amarisoft/instance-ors-enb-input-schema.json
@@ -73,6 +73,9 @@
       "$ref": "instance-enb-input-schema.json#/properties/gtp_addr",
       "default": "127.0.1.1"
     },
+    "mbmsgw_addr": {
+      "$ref": "instance-enb-input-schema.json#/properties/mbmsgw_addr"
+    },
     "mme_list": {
       "$ref": "instance-enb-input-schema.json#/properties/mme_list",
       "default": {
diff --git a/software/ors-amarisoft/instance-ors-gnb-input-schema.json b/software/ors-amarisoft/instance-ors-gnb-input-schema.json
index 606ba1478..e5307aa39 100644
--- a/software/ors-amarisoft/instance-ors-gnb-input-schema.json
+++ b/software/ors-amarisoft/instance-ors-gnb-input-schema.json
@@ -54,6 +54,9 @@
       "$ref": "instance-enb-input-schema.json#/properties/gtp_addr",
       "default": "127.0.1.1"
     },
+    "mbmsgw_addr": {
+      "$ref": "instance-enb-input-schema.json#/properties/mbmsgw_addr"
+    },
     "amf_list": {
       "$ref": "instance-enb-input-schema.json#/properties/amf_list",
       "default": {
diff --git a/software/ors-amarisoft/test/test.py b/software/ors-amarisoft/test/test.py
index 3bb955351..1ddbdc623 100644
--- a/software/ors-amarisoft/test/test.py
+++ b/software/ors-amarisoft/test/test.py
@@ -314,12 +314,14 @@ class ENBTestCase4(RFTestCase4):
         'enb_id':       '0x17',
         'gnb_id':       '0x23',
         'gnb_id_bits':  30,
+        'mbmsgw_addr':  '1.4.3.2',
+        'gtp_addr':  '4.2.3.1',
         'mme_list':     {
-            '1': {'mme_addr': '1.2.3.4'},
+            '1': {'mme_addr': '1.2.3.4', 's1ap_bind_addr': '2.1.3.4'},
             '2': {'mme_addr': '[abcd:5::1]:78'},
         },
         'amf_list':     {
-            '1': {'amf_addr': '4.3.2.1:77'},
+            '1': {'amf_addr': '4.3.2.1:77', 'ngap_bind_addr': '2.1.3.4'},
             '2': {'amf_addr': 'dcba:5::1'},
         },
         'plmn_list':    {
-- 
2.30.9