lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

May 2022

  • 2 participants
  • 1343 discussions
Change in osmo-msc[master]: smpp: Parse and use SMPP-provided validity period
by laforge 17 May '22

17 May '22
Attention is currently required from: laforge. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-msc/+/28136 to look at the new patch set (#4). Change subject: smpp: Parse and use SMPP-provided validity period ...................................................................... smpp: Parse and use SMPP-provided validity period Before this patch, we always ignored any SMPP-provided validity period and used '0' which is now, and means it expires immediately. As SMPP allows for validity_period of NULL, use 7 days as SMSC default in such situations. Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Closes: OS#5567 --- M configure.ac M src/libmsc/smpp_openbsc.c M src/libmsc/smpp_smsc.h M src/libmsc/smpp_utils.c M tests/smpp/smpp_test.c M tests/smpp/smpp_test.ok 6 files changed, 165 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/36/28136/4 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28136 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Gerrit-Change-Number: 28136 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-msc[master]: sms: Make default SMS validity period configurable via VTY
by laforge 17 May '22

17 May '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/28137 ) Change subject: sms: Make default SMS validity period configurable via VTY ...................................................................... sms: Make default SMS validity period configurable via VTY Change-Id: Ie2c81c1d5795dd9aaf07b9766013f20b01abc762 --- M include/osmocom/msc/sms_queue.h M src/libmsc/smpp_openbsc.c M src/libmsc/sms_queue.c M src/libmsc/smsc_vty.c 4 files changed, 17 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/37/28137/1 diff --git a/include/osmocom/msc/sms_queue.h b/include/osmocom/msc/sms_queue.h index ccc56ab..c3a6cfb 100644 --- a/include/osmocom/msc/sms_queue.h +++ b/include/osmocom/msc/sms_queue.h @@ -13,6 +13,7 @@ int max_pending; /* maximum number of gsm_sms_pending in RAM */ bool delete_delivered; /* delete delivered SMS from DB? */ bool delete_expired; /* delete expired SMS from DB? */ + unsigned int default_validity_mins; /* default validity period in minutes */ }; struct sms_queue_config *sms_queue_cfg_alloc(void *ctx); diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c index 4ce6c27..64d4f1e 100644 --- a/src/libmsc/smpp_openbsc.c +++ b/src/libmsc/smpp_openbsc.c @@ -263,7 +263,7 @@ t_validity_absolute = smpp_parse_time_format((const char *) submit->validity_period, &t_now); if (!t_validity_absolute) - sms->validity_minutes = 7 * 24 * 60; /* default: 7 days */ + sms->validity_minutes = net->sms_queue_cfg->default_validity_mins; else sms->validity_minutes = (t_validity_absolute - t_now) / 60; diff --git a/src/libmsc/sms_queue.c b/src/libmsc/sms_queue.c index 7d1860f..24811c5 100644 --- a/src/libmsc/sms_queue.c +++ b/src/libmsc/sms_queue.c @@ -474,6 +474,7 @@ sqcfg->max_fail = 1; sqcfg->delete_delivered = true; sqcfg->delete_expired = true; + sqcfg->default_validity_mins = 7 * 24 * 60; /* 7 days */ sqcfg->db_file_path = talloc_strdup(ctx, SMS_DEFAULT_DB_FILE_PATH); return sqcfg; diff --git a/src/libmsc/smsc_vty.c b/src/libmsc/smsc_vty.c index b2d191a..547b7d5 100644 --- a/src/libmsc/smsc_vty.c +++ b/src/libmsc/smsc_vty.c @@ -98,6 +98,17 @@ return CMD_SUCCESS; } +DEFUN(cfg_sms_def_val_per, cfg_sms_def_val_per_cmd, + "validity-period default <1-5256000>", + "Configure validity period for SMS\n" + "Default SMS validity period in minutes\n" + "Default SMS validity period in minutes\n") +{ + smqcfg->default_validity_mins = atoi(argv[0]); + return CMD_SUCCESS; +} + + /*********************************************************************** * View / Enable Node ***********************************************************************/ @@ -166,6 +177,8 @@ vty_out(vty, " database delete-delivered %u%s", smqcfg->delete_delivered, VTY_NEWLINE); vty_out(vty, " database delete-expired %u%s", smqcfg->delete_expired, VTY_NEWLINE); + vty_out(vty, " validity-period default %u%s", smqcfg->default_validity_mins, VTY_NEWLINE); + return 0; } @@ -183,6 +196,7 @@ install_element(SMSC_NODE, &cfg_sms_queue_fail_cmd); install_element(SMSC_NODE, &cfg_sms_db_del_delivered_cmd); install_element(SMSC_NODE, &cfg_sms_db_del_expired_cmd); + install_element(SMSC_NODE, &cfg_sms_def_val_per_cmd); /* enable node */ install_element(ENABLE_NODE, &smsqueue_trigger_cmd); -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28137 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Ie2c81c1d5795dd9aaf07b9766013f20b01abc762 Gerrit-Change-Number: 28137 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: sms: Introduce VTY-configurable minimum SMS validity period
by laforge 17 May '22

17 May '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/28138 ) Change subject: sms: Introduce VTY-configurable minimum SMS validity period ...................................................................... sms: Introduce VTY-configurable minimum SMS validity period This is meant as a safeguard against users or user equipment which doesn't set a reasonable validity period. Using this setting, the SMSC administrator can set a minimum SMS validity period. Any SMS submitted with lower validity period will be extended to that minimum. Change-Id: I192528a6f9059d158fa12876a247d61bd7edaec8 Related: OS#5567 --- M include/osmocom/msc/sms_queue.h M src/libmsc/gsm_04_11.c M src/libmsc/smpp_openbsc.c M src/libmsc/sms_queue.c M src/libmsc/smsc_vty.c M tests/test_nodes.vty 6 files changed, 25 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/38/28138/1 diff --git a/include/osmocom/msc/sms_queue.h b/include/osmocom/msc/sms_queue.h index c3a6cfb..a6e6aeb 100644 --- a/include/osmocom/msc/sms_queue.h +++ b/include/osmocom/msc/sms_queue.h @@ -13,6 +13,7 @@ int max_pending; /* maximum number of gsm_sms_pending in RAM */ bool delete_delivered; /* delete delivered SMS from DB? */ bool delete_expired; /* delete expired SMS from DB? */ + unsigned int minimum_validity_mins; /* minimum validity period in minutes */ unsigned int default_validity_mins; /* default validity period in minutes */ }; diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c index 722973e..743e272 100644 --- a/src/libmsc/gsm_04_11.c +++ b/src/libmsc/gsm_04_11.c @@ -626,6 +626,12 @@ osmo_hexdump(gsms->user_data, gsms->user_data_len)); gsms->validity_minutes = gsm340_validity_period(sms_vpf, sms_vp); + if (gsms->validity_minutes < net->sms_queue_cfg->minimum_validity_mins) { + LOG_TRANS(trans, LOGL_INFO, "Overriding user-provided validity period (%lu) " + "with minimum SMSC validity period (%u) minutes\n", gsms->validity_minutes, + net->sms_queue_cfg->minimum_validity_mins); + gsms->validity_minutes = net->sms_queue_cfg->minimum_validity_mins; + } rc = sms_route_mt_sms(trans, gsms); diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c index 64d4f1e..91666a9 100644 --- a/src/libmsc/smpp_openbsc.c +++ b/src/libmsc/smpp_openbsc.c @@ -267,6 +267,13 @@ else sms->validity_minutes = (t_validity_absolute - t_now) / 60; + if (sms->validity_minutes < net->sms_queue_cfg->minimum_validity_mins) { + LOGP(DLSMS, LOGL_INFO, "SMS to %s: Overriding ESME-provided validity period (%lu) " + "with minimum SMSC validity period (%u) minutes\n", submit->destination_addr, + sms->validity_minutes, net->sms_queue_cfg->minimum_validity_mins); + sms->validity_minutes = net->sms_queue_cfg->minimum_validity_mins; + } + *psms = sms; return ESME_ROK; } diff --git a/src/libmsc/sms_queue.c b/src/libmsc/sms_queue.c index 24811c5..9f18f4f 100644 --- a/src/libmsc/sms_queue.c +++ b/src/libmsc/sms_queue.c @@ -475,6 +475,7 @@ sqcfg->delete_delivered = true; sqcfg->delete_expired = true; sqcfg->default_validity_mins = 7 * 24 * 60; /* 7 days */ + sqcfg->minimum_validity_mins = 1; sqcfg->db_file_path = talloc_strdup(ctx, SMS_DEFAULT_DB_FILE_PATH); return sqcfg; diff --git a/src/libmsc/smsc_vty.c b/src/libmsc/smsc_vty.c index 547b7d5..e99b236 100644 --- a/src/libmsc/smsc_vty.c +++ b/src/libmsc/smsc_vty.c @@ -99,12 +99,16 @@ } DEFUN(cfg_sms_def_val_per, cfg_sms_def_val_per_cmd, - "validity-period default <1-5256000>", + "validity-period (minimum|default) <1-5256000>", "Configure validity period for SMS\n" + "Minimum SMS validity period in minutes\n" "Default SMS validity period in minutes\n" - "Default SMS validity period in minutes\n") + "Validity period in minutes\n") { - smqcfg->default_validity_mins = atoi(argv[0]); + if (!strcmp(argv[0], "minimum")) + smqcfg->minimum_validity_mins = atoi(argv[1]); + else + smqcfg->default_validity_mins = atoi(argv[1]); return CMD_SUCCESS; } @@ -177,6 +181,7 @@ vty_out(vty, " database delete-delivered %u%s", smqcfg->delete_delivered, VTY_NEWLINE); vty_out(vty, " database delete-expired %u%s", smqcfg->delete_expired, VTY_NEWLINE); + vty_out(vty, " validity-period minimum %u%s", smqcfg->minimum_validity_mins, VTY_NEWLINE); vty_out(vty, " validity-period default %u%s", smqcfg->default_validity_mins, VTY_NEWLINE); return 0; diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty index ac3ff16..8ffb2bd 100644 --- a/tests/test_nodes.vty +++ b/tests/test_nodes.vty @@ -183,6 +183,8 @@ queue max-failure 1 database delete-delivered 1 database delete-expired 1 + validity-period minimum 1 + validity-period default 10080 end OsmoMSC# configure terminal -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28138 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I192528a6f9059d158fa12876a247d61bd7edaec8 Gerrit-Change-Number: 28138 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: db: Switch from 'synchronous = FULL' to 'synchronous = NORMAL'
by fixeria 17 May '22

17 May '22
Attention is currently required from: laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/28130 ) Change subject: db: Switch from 'synchronous = FULL' to 'synchronous = NORMAL' ...................................................................... Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28130 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Ie782f0fe90e7204c4d55cdb3948b728c348367d1 Gerrit-Change-Number: 28130 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Tue, 17 May 2022 17:03:30 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in osmo-msc[master]: switch from libdbi to lbsqlite3
by fixeria 17 May '22

17 May '22
Attention is currently required from: neels, laforge, keith. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/28114 ) Change subject: switch from libdbi to lbsqlite3 ...................................................................... Patch Set 10: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28114 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Ia334904289f92d014e7bd16b02b3b5817c12c790 Gerrit-Change-Number: 28114 Gerrit-PatchSet: 10 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: keith <keith(a)rhizomatica.org> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: keith <keith(a)rhizomatica.org> Gerrit-Comment-Date: Tue, 17 May 2022 17:02:30 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in osmo-msc[master]: smpp: Parse and use SMPP-provided validity period
by laforge 17 May '22

17 May '22
Attention is currently required from: laforge. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-msc/+/28136 to look at the new patch set (#3). Change subject: smpp: Parse and use SMPP-provided validity period ...................................................................... smpp: Parse and use SMPP-provided validity period Before this patch, we always ignored any SMPP-provided validity period and used '0' which is now, and means it expires immediately. As SMPP allows for validity_period of NULL, use 7 days as SMSC default in such situations. Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Closes: OS#5567 --- M configure.ac M src/libmsc/smpp_openbsc.c M src/libmsc/smpp_smsc.h M src/libmsc/smpp_utils.c M tests/smpp/smpp_test.c M tests/smpp/smpp_test.ok 6 files changed, 155 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/36/28136/3 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28136 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Gerrit-Change-Number: 28136 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-msc[master]: smpp: Parse and use SMPP-provided validity period
by laforge 17 May '22

17 May '22
Attention is currently required from: laforge. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-msc/+/28136 to look at the new patch set (#2). Change subject: smpp: Parse and use SMPP-provided validity period ...................................................................... smpp: Parse and use SMPP-provided validity period Before this patch, we always ignored any SMPP-provided validity period and used '0' which is now, and means it expires immediately. As SMPP allows for validity_period of NULL, use 7 days as SMSC default in such situations. Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Closes: OS#5567 --- M configure.ac M src/libmsc/smpp_openbsc.c M src/libmsc/smpp_smsc.h M src/libmsc/smpp_utils.c M tests/smpp/smpp_test.c M tests/smpp/smpp_test.ok 6 files changed, 155 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/36/28136/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28136 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Gerrit-Change-Number: 28136 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-msc[master]: sms_queue: Use local variable rather than 9x pointer de-ref in function
by laforge 17 May '22

17 May '22
Attention is currently required from: keith. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/28134 ) Change subject: sms_queue: Use local variable rather than 9x pointer de-ref in function ...................................................................... Patch Set 1: (1 comment) Patchset: PS1: > I guess pointer dereferencing can be considered reasonably expensive then? :-) the compiler should optimize those away, but it also just adds a lot of churn to the code and we try to avoid that. If you use something 9 times in a function, I would say a local variable is worth. -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28134 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Idf6eb9ec6603a0643033396ed9227e4319724145 Gerrit-Change-Number: 28134 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: keith <keith(a)rhizomatica.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: keith <keith(a)rhizomatica.org> Gerrit-Comment-Date: Tue, 17 May 2022 16:30:29 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: keith <keith(a)rhizomatica.org> Gerrit-MessageType: comment
1 0
0 0
Change in osmo-msc[master]: smpp: Parse and use SMPP-provided validity period
by laforge 17 May '22

17 May '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/28136 ) Change subject: smpp: Parse and use SMPP-provided validity period ...................................................................... smpp: Parse and use SMPP-provided validity period Before this patch, we always ignored any SMPP-provided validity period and used '0' which is now, and means it expires immediately. As SMPP allows for validity_period of NULL, use 7 days as SMSC default in such situations. Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Closes: OS#5567 --- M src/libmsc/smpp_openbsc.c M src/libmsc/smpp_smsc.h M src/libmsc/smpp_utils.c M tests/smpp/smpp_test.c M tests/smpp/smpp_test.ok 5 files changed, 139 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/36/28136/1 diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c index 54cd75b..4ce6c27 100644 --- a/src/libmsc/smpp_openbsc.c +++ b/src/libmsc/smpp_openbsc.c @@ -1,6 +1,6 @@ /* OpenBSC SMPP 3.4 interface, SMSC-side implementation */ -/* (C) 2012-2013 by Harald Welte <laforge(a)gnumonks.org> +/* (C) 2012-2022 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -24,6 +24,7 @@ #include <string.h> #include <stdint.h> #include <errno.h> +#include <time.h> #include <smpp34.h> #include <smpp34_structs.h> @@ -122,6 +123,8 @@ static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net, const struct submit_sm_t *submit) { + time_t t_now = time(NULL); + time_t t_validity_absolute; const uint8_t *sms_msg = NULL; unsigned int sms_msg_len = 0; struct vlr_subscr *dest; @@ -258,6 +261,12 @@ sms->user_data_len = sms_msg_len; } + t_validity_absolute = smpp_parse_time_format((const char *) submit->validity_period, &t_now); + if (!t_validity_absolute) + sms->validity_minutes = 7 * 24 * 60; /* default: 7 days */ + else + sms->validity_minutes = (t_validity_absolute - t_now) / 60; + *psms = sms; return ESME_ROK; } diff --git a/src/libmsc/smpp_smsc.h b/src/libmsc/smpp_smsc.h index 4c0d701..257589e 100644 --- a/src/libmsc/smpp_smsc.h +++ b/src/libmsc/smpp_smsc.h @@ -158,6 +158,7 @@ int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode); +time_t smpp_parse_time_format(const char *vp, time_t *t_now); struct gsm_sms; diff --git a/src/libmsc/smpp_utils.c b/src/libmsc/smpp_utils.c index 7fffdd2..f894cfb 100644 --- a/src/libmsc/smpp_utils.c +++ b/src/libmsc/smpp_utils.c @@ -1,5 +1,5 @@ -/* (C) 2012-2013 by Harald Welte <laforge(a)gnumonks.org> +/* (C) 2012-2022 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -17,6 +17,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <time.h> +#include <osmocom/msc/smpp.h> #include "smpp_smsc.h" #include <osmocom/core/logging.h> @@ -59,3 +61,92 @@ return 0; } + +/* convert a 'struct tm' holding relative time to an absolute one by adding it to t_now */ +static void relative2absolute(struct tm *tm, time_t t_now) +{ + struct tm tm_now; + + localtime_r(&t_now, &tm_now); + + tm->tm_year += tm_now.tm_year; + tm->tm_mon += tm_now.tm_mon; + tm->tm_mday += tm_now.tm_mday; + tm->tm_hour += tm_now.tm_hour; + tm->tm_min += tm_now.tm_min; + tm->tm_sec += tm_now.tm_sec; +} + +/*! Parse a SMPP time format as defined in SMPP v3.4 7.1.1. + * \param[in] vp string containing the time as encoded in SMPP v3.4 + * \param[in] t_now pointer to a time value for 'now'. Can be NULL, then we call time() ourselves. + * \returns time_t value in seconds since the epoch of the absolute decoded time */ +time_t smpp_parse_time_format(const char *vp, time_t *t_now) +{ + unsigned int year, month, day, hour, minute, second, tenth, gmt_off_quarter; + char plus_minus_relative; + int gmt_off_minutes; + const char *orig_tz; + struct tm tm; + time_t ret; + int rc; + + memset(&tm, 0, sizeof(tm)); + + if (vp[0] == '\0') + return 0; + + /* YYMMDDhhmmsstnnp (where p can be -, + or R) */ + rc = sscanf(vp, "%2u%2u%2u%2u%2u%2u%1u%2u%c", &year, &month, &day, &hour, &minute, + &second, &tenth, &gmt_off_quarter, &plus_minus_relative); + if (rc != 9) + return (time_t) -1; + + tm.tm_year = year; + /* month handling differs between absolute/relative below... */ + tm.tm_mday = day; + tm.tm_hour = hour; + tm.tm_min = minute; + tm.tm_sec = second; + tm.tm_isdst = 0; + + orig_tz = getenv("TZ"); + + switch (plus_minus_relative) { + case '+': /* time is in quarter hours advanced compared to UTC */ + if (year < 70) + tm.tm_year += 100; + tm.tm_mon = month - 1; + gmt_off_minutes = 15 * gmt_off_quarter; + tm.tm_min -= gmt_off_minutes; + setenv("TZ", "UTC", 1); + ret = mktime(&tm); + if (orig_tz) + setenv("TZ", orig_tz, 1); + break; + case '-': /* time is in quarter hours retared compared to UTC */ + if (year < 70) + tm.tm_year += 100; + tm.tm_mon = month - 1; + gmt_off_minutes = 15 * gmt_off_quarter; + tm.tm_min += gmt_off_minutes; + setenv("TZ", "UTC", 1); + ret = mktime(&tm); + if (orig_tz) + setenv("TZ", orig_tz, 1); + break; + case 'R': + /* relative time */ + tm.tm_mon = month; + if (t_now) + relative2absolute(&tm, *t_now); + else + relative2absolute(&tm, time(NULL)); + ret = mktime(&tm); + break; + default: + return (time_t) -1; + } + + return ret; +} diff --git a/tests/smpp/smpp_test.c b/tests/smpp/smpp_test.c index d86da54..d656f6e 100644 --- a/tests/smpp/smpp_test.c +++ b/tests/smpp/smpp_test.c @@ -1,5 +1,6 @@ /* * (C) 2013 by Holger Hans Peter Freyther + * (C) 2022 by Harald Welte <laforge(a)osmocom.org> * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -62,6 +63,31 @@ } } +static const char *smpp_time_tests[] = { + "\0", + "220517175524000+", + "220517175524000-", + "220517175524004+", /* 1 hour advanced compared to GMT */ + "220517175524004-", /* 1 hour retarded compared to GMT */ + "000000010000000R", /* 1 hour */ + "000001000000000R", /* 1 day */ +}; + +static void test_smpp_parse_time_format(void) +{ + time_t t_now = 1652745600; /* 2022-05-17 00:00:00 */ + + printf("Testing SMPP time format parser\n"); + + for (unsigned int i = 0; i < ARRAY_SIZE(smpp_time_tests); i++) { + time_t t = smpp_parse_time_format(smpp_time_tests[i], &t_now); + char buf[32]; + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", gmtime(&t)); + printf("'%s': %ld == %s\n", smpp_time_tests[i], t, buf); + } + +} + static const struct log_info_cat smpp_mirror_default_categories[] = { [DSMPP] = { .name = "DSMPP", @@ -85,5 +111,7 @@ log_set_print_category_hex(osmo_stderr_target, 0); test_coding_scheme(); + test_smpp_parse_time_format(); + return EXIT_SUCCESS; } diff --git a/tests/smpp/smpp_test.ok b/tests/smpp/smpp_test.ok index fd44804..feb75a6 100644 --- a/tests/smpp/smpp_test.ok +++ b/tests/smpp/smpp_test.ok @@ -1 +1,9 @@ Testing coding scheme support +Testing SMPP time format parser +'': 0 == 1970-01-01 00:00:00 +'220517175524000+': 1652810124 == 2022-05-17 17:55:24 +'220517175524000-': 1652810124 == 2022-05-17 17:55:24 +'220517175524004+': 1652806524 == 2022-05-17 16:55:24 +'220517175524004-': 1652813724 == 2022-05-17 18:55:24 +'000000010000000R': 1652749200 == 2022-05-17 01:00:00 +'000001000000000R': 1652832000 == 2022-05-18 00:00:00 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28136 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Iad9f2697f045ed3bc0eb74c3a9730861f82e6c48 Gerrit-Change-Number: 28136 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-msc[master]: sms_queue: Make deletion of messages from DB VTY-configurable
by keith 17 May '22

17 May '22
Attention is currently required from: laforge. keith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/28135 ) Change subject: sms_queue: Make deletion of messages from DB VTY-configurable ...................................................................... Patch Set 1: (1 comment) File src/libmsc/smsc_vty.c: https://gerrit.osmocom.org/c/osmo-msc/+/28135/comment/6743f006_dbef9152 PS1, Line 82: "database delete-delivered (0|1)", > I was thinking to make an sms node and move max-pending, max-failure here, which can currently only […] Ugh.. OK you did that.. I think I'll give up trying to do computers until i'm over this head-cold. -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/28135 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: Id6174875d5c01c40d987077651b27ae1acbcaa93 Gerrit-Change-Number: 28135 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: keith <keith(a)rhizomatica.org> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Tue, 17 May 2022 14:27:30 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: keith <keith(a)rhizomatica.org> Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • ...
  • 135
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.