Harald Welte has submitted this change and it was merged.

Change subject: Permit any Sender MSISDN when sending SMS from VTY
......................................................................


Permit any Sender MSISDN when sending SMS from VTY

In the old days, OsmoNITB couldn't process any SMS that wasn't between
two subscribers on the same NITB.

We've long re-worked the internals in order to process SMS with
arbitrary sender MSISDN (e.g. from SMPP). However, the VTY command
"subscriber ... sms" was never updated, it seems.

Change-Id: I62b17e0a67989484415f0df2c8cb4ff1f94dbf2b
Closes: OS#3151
---
M include/osmocom/msc/gsm_04_11.h
M src/libmsc/gsm_04_11.c
M src/libmsc/msc_vty.c
M tests/msc_vlr/msc_vlr_tests.c
4 files changed, 32 insertions(+), 26 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/msc/gsm_04_11.h b/include/osmocom/msc/gsm_04_11.h
index 3305e3e..e3ff4ba 100644
--- a/include/osmocom/msc/gsm_04_11.h
+++ b/include/osmocom/msc/gsm_04_11.h
@@ -34,7 +34,7 @@
 struct gsm_sms *sms_alloc(void);
 void sms_free(struct gsm_sms *sms);
 struct gsm_sms *sms_from_text(struct vlr_subscr *receiver,
-                             struct vlr_subscr *sender,
+                             const char *sender_msisdn,
                              int dcs, const char *text);
 
 void _gsm411_sms_trans_free(struct gsm_trans *trans);
diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index aa60490..077c8d8 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -82,7 +82,7 @@
 }
 
 struct gsm_sms *sms_from_text(struct vlr_subscr *receiver,
-                             struct vlr_subscr *sender,
+                             const char *sender_msisdn,
                               int dcs, const char *text)
 {
        struct gsm_sms *sms = sms_alloc();
@@ -93,7 +93,7 @@
        sms->receiver = vlr_subscr_get(receiver);
        OSMO_STRLCPY_ARRAY(sms->text, text);
 
-       OSMO_STRLCPY_ARRAY(sms->src.addr, sender->msisdn);
+       OSMO_STRLCPY_ARRAY(sms->src.addr, sender_msisdn);
        sms->reply_path_req = 0;
        sms->status_rep_req = 0;
        sms->ud_hdr_ind = 0;
diff --git a/src/libmsc/msc_vty.c b/src/libmsc/msc_vty.c
index 33613e9..84d4d14 100644
--- a/src/libmsc/msc_vty.c
+++ b/src/libmsc/msc_vty.c
@@ -705,13 +705,13 @@
 }
 
 static int _send_sms_str(struct vlr_subscr *receiver,
-                        struct vlr_subscr *sender,
+                        const char *sender_msisdn,
                         char *str, uint8_t tp_pid)
 {
        struct gsm_network *net = receiver->vlr->user_ctx;
        struct gsm_sms *sms;
 
-       sms = sms_from_text(receiver, sender, 0, str);
+       sms = sms_from_text(receiver, sender_msisdn, 0, str);
        sms->protocol_id = tp_pid;
 
        /* store in database for the queue */
@@ -813,7 +813,7 @@
        SUBSCR_HELP "SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS 
Text\n")
 {
        struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
-       struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]);
+       const char *sender_msisdn;
        char *str;
        int rc;
 
@@ -824,21 +824,24 @@
                goto err;
        }
 
-       if (!sender) {
-               vty_out(vty, "%% No sender found for %s %s%s",
-                       argv[2], argv[3], VTY_NEWLINE);
-               rc = CMD_WARNING;
-               goto err;
+       if (!strcmp(argv[2], "msisdn"))
+               sender_msisdn = argv[3];
+       else {
+               struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], 
argv[3]);
+               if (!sender) {
+                       vty_out(vty, "%% No sender found for %s %s%s", argv[2], 
argv[3], VTY_NEWLINE);
+                       rc = CMD_WARNING;
+                       goto err;
+               }
+               sender_msisdn = sender->msisdn;
+               vlr_subscr_put(sender);
        }
 
        str = argv_concat(argv, argc, 4);
-       rc = _send_sms_str(vsub, sender, str, 0);
+       rc = _send_sms_str(vsub, sender_msisdn, str, 0);
        talloc_free(str);
 
 err:
-       if (sender)
-               vlr_subscr_put(sender);
-
        if (vsub)
                vlr_subscr_put(vsub);
 
@@ -852,7 +855,7 @@
        SUBSCR_HELP "Silent SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual 
SMS Text\n")
 {
        struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
-       struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]);
+       const char *sender_msisdn;
        char *str;
        int rc;
 
@@ -863,21 +866,24 @@
                goto err;
        }
 
-       if (!sender) {
-               vty_out(vty, "%% No sender found for %s %s%s",
-                       argv[2], argv[3], VTY_NEWLINE);
-               rc = CMD_WARNING;
-               goto err;
+       if (!strcmp(argv[2], "msisdn")) {
+               sender_msisdn = argv[3];
+       } else {
+               struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], 
argv[3]);
+               if (!sender) {
+                       vty_out(vty, "%% No sender found for %s %s%s", argv[2], 
argv[3], VTY_NEWLINE);
+                       rc = CMD_WARNING;
+                       goto err;
+               }
+               sender_msisdn = sender->msisdn;
+               vlr_subscr_put(sender);
        }
 
        str = argv_concat(argv, argc, 4);
-       rc = _send_sms_str(vsub, sender, str, 64);
+       rc = _send_sms_str(vsub, sender_msisdn, str, 64);
        talloc_free(str);
 
 err:
-       if (sender)
-               vlr_subscr_put(sender);
-
        if (vsub)
                vlr_subscr_put(vsub);
 
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index 7c54057..45ab5e1 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -294,7 +294,7 @@
              struct vlr_subscr *sender,
              char *str)
 {
-       struct gsm_sms *sms = sms_from_text(receiver, sender, 0, str);
+       struct gsm_sms *sms = sms_from_text(receiver, sender->msisdn, 0, str);
        gsm411_send_sms_subscr(receiver, sms);
 }
 

-- 
To view, visit https://gerrit.osmocom.org/7694
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I62b17e0a67989484415f0df2c8cb4ff1f94dbf2b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to