Projects
osmocom:nightly
osmo-msc
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 44
View file
osmo-msc.spec
Changed
@@ -18,14 +18,14 @@ %define with_iu 1 Name: osmo-msc -Requires: osmocom-nightly = 202208060002 -Version: 1.9.0.14.3948f.202208060002 +Requires: osmocom-nightly = 202208070002 +Version: 1.9.0.16.62977.202208070002 Release: 0 Summary: Osmocom's MSC for 2G and 3G circuit-switched mobile networks License: AGPL-3.0-or-later AND GPL-2.0-only Group: Productivity/Telephony/Servers URL: https://osmocom.org/projects/osmomsc -Source: osmo-msc_1.9.0.14.3948f.202208060002.tar.xz +Source: osmo-msc_1.9.0.16.62977.202208070002.tar.xz Source1: rpmlintrc BuildRequires: autoconf BuildRequires: automake
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/include/osmocom/msc/smpp.h
Deleted
@@ -1,4 +0,0 @@ -#pragma once - -int smpp_openbsc_alloc_init(void *ctx); -int smpp_openbsc_start(struct gsm_network *net);
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/libmsc/smpp_openbsc.c
Deleted
@@ -1,865 +0,0 @@ -/* OpenBSC SMPP 3.4 interface, SMSC-side implementation */ - -/* (C) 2012-2022 by Harald Welte <laforge@gnumonks.org> - * - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <stdint.h> -#include <errno.h> -#include <time.h> - -#include <smpp34.h> -#include <smpp34_structs.h> -#include <smpp34_params.h> -#include <smpp34_heap.h> - -#include <osmocom/core/utils.h> -#include <osmocom/core/msgb.h> -#include <osmocom/core/logging.h> -#include <osmocom/core/talloc.h> -#include <osmocom/gsm/protocol/gsm_04_11.h> -#include <osmocom/gsm/protocol/smpp34_osmocom.h> - -#include <osmocom/msc/gsm_subscriber.h> -#include <osmocom/msc/debug.h> -#include <osmocom/msc/db.h> -#include <osmocom/msc/gsm_04_11.h> -#include <osmocom/msc/gsm_data.h> -#include <osmocom/msc/signal.h> -#include <osmocom/msc/transaction.h> -#include <osmocom/msc/gsm_subscriber.h> -#include <osmocom/msc/vlr.h> -#include <osmocom/msc/msc_a.h> - -#include "smpp_smsc.h" - -#define VSUB_USE_SMPP "SMPP" -#define VSUB_USE_SMPP_CMD "SMPP-cmd" - -/* talloc integration for libsmpp34 */ - -static struct smsc *g_smsc; - -static void *smpp34_talloc_malloc(size_t sz) -{ - return talloc_size(g_smsc, sz); -} - -static void *smpp34_talloc_realloc(void *ptr, size_t sz) -{ - return talloc_realloc_size(g_smsc, ptr, sz); -} - -static void smpp34_talloc_free(void *ptr) -{ - talloc_free(ptr); -} - -static const struct smpp34_memory_functions smpp34_talloc = { - .malloc_fun = smpp34_talloc_malloc, - .realloc_fun = smpp34_talloc_realloc, - .free_fun = smpp34_talloc_free, -}; - -/*! \brief find vlr_subscr for a given SMPP NPI/TON/Address */ -static struct vlr_subscr *subscr_by_dst(struct gsm_network *net, - uint8_t npi, uint8_t ton, - const char *addr) -{ - struct vlr_subscr *vsub = NULL; - - switch (npi) { - case NPI_Land_Mobile_E212: - vsub = vlr_subscr_find_by_imsi(net->vlr, addr, VSUB_USE_SMPP); - break; - case NPI_ISDN_E163_E164: - case NPI_Private: - vsub = vlr_subscr_find_by_msisdn(net->vlr, addr, VSUB_USE_SMPP); - break; - default: - LOGP(DSMPP, LOGL_NOTICE, "Unsupported NPI: %u\n", npi); - break; - } - - log_set_context(LOG_CTX_VLR_SUBSCR, vsub); - return vsub; -} - -static int smpp34_submit_tlv_msg_payload(const struct tlv_t *t, - const struct submit_sm_t *submit, - const uint8_t **sms_msg, - unsigned int *sms_msg_len) -{ - if (submit->sm_length) { - LOGP(DLSMS, LOGL_ERROR, - "SMPP cannot have payload in TLV _and_ in the header\n"); - return -1; - } - *sms_msg = t->value.octet; - *sms_msg_len = t->length; - - return 0; -} - -/*! \brief convert from submit_sm_t to gsm_sms */ -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; - uint16_t msg_ref = 0; - struct gsm_sms *sms; - struct tlv_t *t; - int mode; - int can_store_sms = ((submit->esm_class & SMPP34_MSG_MODE_MASK) != 2); /* != forward mode */ - - dest = subscr_by_dst(net, submit->dest_addr_npi, - submit->dest_addr_ton, - (const char *)submit->destination_addr); - if (!dest && !can_store_sms) { - LOGP(DLSMS, LOGL_NOTICE, "SMPP SUBMIT-SM for unknown subscriber: " - "%s (NPI=%u)\n", submit->destination_addr, - submit->dest_addr_npi); - return ESME_RINVDSTADR; - } - - smpp34_tlv_for_each(t, submit->tlv) { - switch (t->tag) { - case TLVID_message_payload: - if (smpp34_submit_tlv_msg_payload(t, submit, &sms_msg, - &sms_msg_len) < 0) { - if (dest) - vlr_subscr_put(dest, VSUB_USE_SMPP); - return ESME_ROPTPARNOTALLWD; - } - break; - case TLVID_user_message_reference: - msg_ref = t->value.val16; - break; - default: - break; - } - } - - if (!sms_msg) { - if (submit->sm_length > 0 && submit->sm_length < 255) { - sms_msg = submit->short_message; - sms_msg_len = submit->sm_length; - } else { - LOGP(DLSMS, LOGL_ERROR, - "SMPP neither message payload nor valid sm_length.\n"); - if (dest) - vlr_subscr_put(dest, VSUB_USE_SMPP); - return ESME_RINVPARLEN; - } - } - - sms = sms_alloc(); - sms->source = SMS_SOURCE_SMPP; - sms->smpp.sequence_nr = submit->sequence_number; - sms->status_rep_req = submit->registered_delivery; - sms->msg_ref = msg_ref; - - /* fill in the destination address */ - sms->receiver = dest; - if (dest) { - /* Replace use count from above subscr_by_dst (VSUB_USE_SMPP) by the sms->receiver use count - * (VSUB_USE_SMS_RECEIVER) */ - vlr_subscr_get(sms->receiver, VSUB_USE_SMS_RECEIVER); - vlr_subscr_put(dest, VSUB_USE_SMPP); - } - sms->dst.ton = submit->dest_addr_ton; - sms->dst.npi = submit->dest_addr_npi; - if (dest) - OSMO_STRLCPY_ARRAY(sms->dst.addr, dest->msisdn); - else - OSMO_STRLCPY_ARRAY(sms->dst.addr, - (const char *)submit->destination_addr); -
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/libmsc/smpp_smsc.c
Deleted
@@ -1,1050 +0,0 @@ -/* SMPP 3.4 interface, SMSC-side implementation */ -/* (C) 2012 by Harald Welte <laforge@gnumonks.org> - * - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <stdint.h> -#include <errno.h> -#include <limits.h> - -#include <sys/socket.h> -#include <netinet/in.h> - -#include <smpp34.h> -#include <smpp34_structs.h> -#include <smpp34_params.h> - -#include <osmocom/core/utils.h> -#include <osmocom/core/socket.h> -#include <osmocom/core/msgb.h> -#include <osmocom/core/logging.h> -#include <osmocom/core/write_queue.h> -#include <osmocom/core/talloc.h> -#include <osmocom/gsm/protocol/gsm_04_11.h> - -#include "smpp_smsc.h" - -#include <osmocom/msc/debug.h> -#include <osmocom/msc/gsm_data.h> - -/*! \brief Ugly wrapper. libsmpp34 should do this itself! */ -#define SMPP34_UNPACK(rc, type, str, data, len) \ - memset(str, 0, sizeof(*str)); \ - rc = smpp34_unpack(type, str, data, len) - -enum emse_bind { - ESME_BIND_RX = 0x01, - ESME_BIND_TX = 0x02, -}; - -const struct value_string smpp_status_strs = { - { ESME_ROK, "No Error" }, - { ESME_RINVMSGLEN, "Message Length is invalid" }, - { ESME_RINVCMDLEN, "Command Length is invalid" }, - { ESME_RINVCMDID, "Invalid Command ID" }, - { ESME_RINVBNDSTS, "Incorrect BIND Status for given command" }, - { ESME_RALYBND, "ESME Already in Bound State" }, - { ESME_RINVPRTFLG, "Invalid Priority Flag" }, - { ESME_RINVREGDLVFLG, "Invalid Registered Delivery Flag" }, - { ESME_RSYSERR, "System Error" }, - { ESME_RINVSRCADR, "Invalid Source Address" }, - { ESME_RINVDSTADR, "Invalid Destination Address" }, - { ESME_RINVMSGID, "Message ID is invalid" }, - { ESME_RBINDFAIL, "Bind failed" }, - { ESME_RINVPASWD, "Invalid Password" }, - { ESME_RINVSYSID, "Invalid System ID" }, - { ESME_RCANCELFAIL, "Cancel SM Failed" }, - { ESME_RREPLACEFAIL, "Replace SM Failed" }, - { ESME_RMSGQFUL, "Message Queue Full" }, - { ESME_RINVSERTYP, "Invalid Service Type" }, - { ESME_RINVNUMDESTS, "Invalid number of destinations" }, - { ESME_RINVDLNAME, "Invalid Distribution List name" }, - { ESME_RINVDESTFLAG, "Destination flag is invalid" }, - { ESME_RINVSUBREP, "Invalid submit with replace request" }, - { ESME_RINVESMCLASS, "Invalid esm_class field data" }, - { ESME_RCNTSUBDL, "Cannot Submit to Distribution List" }, - { ESME_RSUBMITFAIL, "submit_sm or submit_multi failed" }, - { ESME_RINVSRCTON, "Invalid Source address TON" }, - { ESME_RINVSRCNPI, "Invalid Sourec address NPI" }, - { ESME_RINVDSTTON, "Invalid Destination address TON" }, - { ESME_RINVDSTNPI, "Invalid Desetination address NPI" }, - { ESME_RINVSYSTYP, "Invalid system_type field" }, - { ESME_RINVREPFLAG, "Invalid replace_if_present field" }, - { ESME_RINVNUMMSGS, "Invalid number of messages" }, - { ESME_RTHROTTLED, "Throttling error (ESME has exceeded message limits)" }, - { ESME_RINVSCHED, "Invalid Scheduled Delivery Time" }, - { ESME_RINVEXPIRY, "Invalid message validity period (Expiry time)" }, - { ESME_RINVDFTMSGID, "Predefined Message Invalid or Not Found" }, - { ESME_RX_T_APPN, "ESME Receiver Temporary App Error Code" }, - { ESME_RX_P_APPN, "ESME Receiver Permanent App Error Code" }, - { ESME_RX_R_APPN, "ESME Receiver Reject Message Error Code" }, - { ESME_RQUERYFAIL, "query_sm request failed" }, - { ESME_RINVOPTPARSTREAM,"Error in the optional part of the PDU Body" }, - { ESME_ROPTPARNOTALLWD, "Optional Parameter not allowed" }, - { ESME_RINVPARLEN, "Invalid Parameter Length" }, - { ESME_RMISSINGOPTPARAM,"Expected Optional Parameter missing" }, - { ESME_RINVOPTPARAMVAL, "Invalid Optional Parameter Value" }, - { ESME_RDELIVERYFAILURE,"Delivery Failure (used for data_sm_resp)" }, - { ESME_RUNKNOWNERR, "Unknown Error" }, - { 0, NULL } -}; - -/*! \brief compare if two SMPP addresses are equal */ -int smpp_addr_eq(const struct osmo_smpp_addr *a, - const struct osmo_smpp_addr *b) -{ - if (a->ton == b->ton && - a->npi == b->npi && - !strcmp(a->addr, b->addr)) - return 1; - - return 0; -} - - -struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc, - const char *sys_id) -{ - struct osmo_smpp_acl *acl; - - llist_for_each_entry(acl, &smsc->acl_list, list) { - if (!strcmp(acl->system_id, sys_id)) - return acl; - } - - return NULL; -} - -struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id) -{ - struct osmo_smpp_acl *acl; - - if (strlen(sys_id) > SMPP_SYS_ID_LEN) - return NULL; - - if (smpp_acl_by_system_id(smsc, sys_id)) - return NULL; - - acl = talloc_zero(smsc, struct osmo_smpp_acl); - if (!acl) - return NULL; - - acl->smsc = smsc; - strcpy(acl->system_id, sys_id); - acl->alert_notifications = 1; - INIT_LLIST_HEAD(&acl->route_list); - - llist_add_tail(&acl->list, &smsc->acl_list); - - return acl; -} - -void smpp_acl_delete(struct osmo_smpp_acl *acl) -{ - struct osmo_smpp_route *r, *r2; - - llist_del(&acl->list); - - /* kill any active ESMEs */ - if (acl->esme) { - struct osmo_esme *esme = acl->esme; - osmo_fd_unregister(&esme->wqueue.bfd); - close(esme->wqueue.bfd.fd); - esme->wqueue.bfd.fd = -1; - esme->acl = NULL; - smpp_esme_put(esme); - } - - /* delete all routes for this ACL */ - llist_for_each_entry_safe(r, r2, &acl->route_list, list) { - llist_del(&r->list); - llist_del(&r->global_list); - talloc_free(r); - } - - talloc_free(acl); -} - -static struct osmo_smpp_route *route_alloc(struct osmo_smpp_acl *acl) -{ - struct osmo_smpp_route *r; - - r = talloc_zero(acl, struct osmo_smpp_route); - if (!r) - return NULL; - - llist_add_tail(&r->list, &acl->route_list); - llist_add_tail(&r->global_list, &acl->smsc->route_list); - - return r; -} -
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/libmsc/smpp_smsc.h
Deleted
@@ -1,167 +0,0 @@ -#ifndef _SMPP_SMSC_H -#define _SMPP_SMSC_H - -#include <sys/socket.h> -#include <netinet/in.h> - -#include <osmocom/core/utils.h> -#include <osmocom/core/msgb.h> -#include <osmocom/core/write_queue.h> -#include <osmocom/core/timer.h> - -#include <smpp34.h> -#include <smpp34_structs.h> -#include <smpp34_params.h> - -#define SMPP_SYS_ID_LEN 15 -#define SMPP_PASSWD_LEN 8 - -#define MODE_7BIT 7 -#define MODE_8BIT 8 - -struct msc_a; - -enum esme_read_state { - READ_ST_IN_LEN = 0, - READ_ST_IN_MSG = 1, -}; - -struct osmo_smpp_acl; - -struct osmo_smpp_addr { - uint8_t ton; - uint8_t npi; - char addr21+1; -}; - -struct osmo_esme { - struct llist_head list; - struct smsc *smsc; - struct osmo_smpp_acl *acl; - int use; - - struct llist_head smpp_cmd_list; - - uint32_t own_seq_nr; - - struct osmo_wqueue wqueue; - - enum esme_read_state read_state; - uint32_t read_len; - uint32_t read_idx; - struct msgb *read_msg; - - uint8_t smpp_version; - char system_idSMPP_SYS_ID_LEN+1; - - uint8_t bind_flags; -}; - -struct osmo_smpp_acl { - struct llist_head list; - struct smsc *smsc; - struct osmo_esme *esme; - char *description; - char system_idSMPP_SYS_ID_LEN+1; - char passwdSMPP_PASSWD_LEN+1; - int default_route; - int deliver_src_imsi; - int osmocom_ext; - int dcs_transparent; - int alert_notifications; - struct llist_head route_list; -}; - -enum osmo_smpp_rtype { - SMPP_ROUTE_NONE, - SMPP_ROUTE_PREFIX, -}; - -struct osmo_smpp_route { - struct llist_head list; /*!< in acl.route_list */ - struct llist_head global_list; /*!< in smsc->route_list */ - struct osmo_smpp_acl *acl; - enum osmo_smpp_rtype type; - union { - struct osmo_smpp_addr prefix; - } u; -}; - -struct osmo_smpp_cmd { - struct llist_head list; - struct vlr_subscr *vsub; - uint32_t sequence_nr; - uint32_t gsm411_msg_ref; - uint8_t gsm411_trans_id; - bool is_report; - struct osmo_timer_list response_timer; -}; - -struct osmo_smpp_cmd *smpp_cmd_find_by_seqnum(struct osmo_esme *esme, - uint32_t sequence_number); -void smpp_cmd_ack(struct osmo_smpp_cmd *cmd); -void smpp_cmd_err(struct osmo_smpp_cmd *cmd, uint32_t status); -void smpp_cmd_flush_pending(struct osmo_esme *esme); - -struct smsc { - struct osmo_fd listen_ofd; - struct llist_head esme_list; - struct llist_head acl_list; - struct llist_head route_list; - char *bind_addr; - uint16_t listen_port; - char system_idSMPP_SYS_ID_LEN+1; - int accept_all; - int smpp_first; - struct osmo_smpp_acl *def_route; - void *priv; -}; - -int smpp_addr_eq(const struct osmo_smpp_addr *a, - const struct osmo_smpp_addr *b); - -struct smsc *smpp_smsc_alloc_init(void *ctx); -int smpp_smsc_conf(struct smsc *smsc, const char *bind_addr, uint16_t port); -int smpp_smsc_start(struct smsc *smsc, const char *bind_addr, uint16_t port); -int smpp_smsc_restart(struct smsc *smsc, const char *bind_addr, uint16_t port); -void smpp_smsc_stop(struct smsc *smsc); - -void smpp_esme_get(struct osmo_esme *esme); -void smpp_esme_put(struct osmo_esme *esme); - -int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, struct osmo_esme **emse); - -struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id); -struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc, - const char *sys_id); -void smpp_acl_delete(struct osmo_smpp_acl *acl); - -int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr, - uint32_t command_status, char *msg_id); - -int smpp_tx_alert(struct osmo_esme *esme, uint8_t ton, uint8_t npi, - const char *addr, uint8_t avail_status); - -int smpp_tx_deliver(struct osmo_esme *esme, struct deliver_sm_t *deliver); - -int handle_smpp_submit(struct osmo_esme *esme, struct submit_sm_t *submit, - struct submit_sm_resp_t *submit_r); - -int smpp_route_pfx_add(struct osmo_smpp_acl *acl, - const struct osmo_smpp_addr *pfx); -int smpp_route_pfx_del(struct osmo_smpp_acl *acl, - const struct osmo_smpp_addr *pfx); - -int smpp_vty_init(void); - -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; -struct ran_conn; - -bool smpp_route_smpp_first(); -int smpp_try_deliver(struct gsm_sms *sms, struct msc_a *msc_a); -#endif
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/libmsc/smpp_utils.c
Deleted
@@ -1,166 +0,0 @@ - -/* (C) 2012-2022 by Harald Welte <laforge@gnumonks.org> - * - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include <time.h> - -#include "smpp_smsc.h" -#include <osmocom/core/logging.h> - -int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode) -{ - if ((dcs & 0xF0) == 0xF0) { - if (dcs & 0x04) { - /* bit 2 == 1: 8bit data */ - *data_coding = 0x02; - *mode = MODE_8BIT; - } else { - /* bit 2 == 0: default alphabet */ - *data_coding = 0x01; - *mode = MODE_7BIT; - } - } else if ((dcs & 0xE0) == 0) { - switch (dcs & 0xC) { - case 0: - *data_coding = 0x01; - *mode = MODE_7BIT; - break; - case 4: - *data_coding = 0x02; - *mode = MODE_8BIT; - break; - case 8: - *data_coding = 0x08; /* UCS-2 */ - *mode = MODE_8BIT; - break; - default: - goto unknown_mo; - } - } else { -unknown_mo: - LOGP(DLSMS, LOGL_ERROR, "SMPP MO Unknown Data Coding 0x%02x\n", dcs); - return -1; - } - - 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; -} - -#ifndef HAVE_TIMEGM -/* for systems without a timegm() function, provide a reimplementation */ -static time_t timegm(struct tm *tm) -{ - const char *orig_tz = getenv("TZ"); - time_t ret; - - setenv("TZ", "UTC", 1); - - ret = mktime(tm); - - if (orig_tz) - setenv("TZ", orig_tz, 1); - else - unsetenv("TZ"); - - return ret; -} -#endif - - -/*! Parse a SMPP time format as defined in SMPP v3.4 7.1.1. - * \paramin vp string containing the time as encoded in SMPP v3.4 - * \paramin 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; - struct tm tm; - time_t ret; - int rc; - - memset(&tm, 0, sizeof(tm)); - - if (vp0 == '\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; - - 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; - ret = timegm(&tm); - 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; - ret = timegm(&tm); - break; - case 'R': - /* relative time */ - tm.tm_mon = month; - if (t_now) - relative2absolute(&tm, *t_now); - else - relative2absolute(&tm, time(NULL)); - /* here we do want local time, as we're passing local time in above! */ - ret = mktime(&tm); - break; - default: - return (time_t) -1; - } - - return ret; -}
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/libmsc/smpp_vty.c
Deleted
@@ -1,630 +0,0 @@ -/* SMPP vty interface */ - -/* (C) 2012 by Harald Welte <laforge@gnumonks.org> - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#include <ctype.h> -#include <string.h> -#include <errno.h> -#include <netdb.h> -#include <sys/socket.h> - -#include <osmocom/vty/command.h> -#include <osmocom/vty/buffer.h> -#include <osmocom/vty/vty.h> - -#include <osmocom/core/linuxlist.h> -#include <osmocom/core/utils.h> -#include <osmocom/core/socket.h> -#include <osmocom/core/talloc.h> - -#include <osmocom/msc/vty.h> - -#include "smpp_smsc.h" - -struct smsc *smsc_from_vty(struct vty *v); - -static struct cmd_node smpp_node = { - SMPP_NODE, - "%s(config-smpp)# ", - 1, -}; - -static struct cmd_node esme_node = { - SMPP_ESME_NODE, - "%s(config-smpp-esme)# ", - 1, -}; - -DEFUN(cfg_smpp, cfg_smpp_cmd, - "smpp", "Configure SMPP SMS Interface") -{ - vty->node = SMPP_NODE; - - return CMD_SUCCESS; -} - -DEFUN(cfg_smpp_first, cfg_smpp_first_cmd, - "smpp-first", - "Try SMPP routes before the subscriber DB\n") -{ - struct smsc *smsc = smsc_from_vty(vty); - smsc->smpp_first = 1; - return CMD_SUCCESS; -} - -DEFUN(cfg_no_smpp_first, cfg_no_smpp_first_cmd, - "no smpp-first", - NO_STR "Try SMPP before routes before the subscriber DB\n") -{ - struct smsc *smsc = smsc_from_vty(vty); - smsc->smpp_first = 0; - return CMD_SUCCESS; -} - -static int smpp_local_tcp(struct vty *vty, - const char *bind_addr, uint16_t port) -{ - struct smsc *smsc = smsc_from_vty(vty); - int is_running = smsc->listen_ofd.fd > 0; - int same_bind_addr; - int rc; - - /* If it is not up yet, don't rebind, just set values. */ - if (!is_running) { - rc = smpp_smsc_conf(smsc, bind_addr, port); - if (rc < 0) { - vty_out(vty, "%% Cannot configure new address:port%s", - VTY_NEWLINE); - return CMD_WARNING; - } - return CMD_SUCCESS; - } - - rc = smpp_smsc_restart(smsc, bind_addr, port); - if (rc < 0) { - vty_out(vty, "%% Cannot bind to new port %s:%u nor to" - " old port %s:%u%s", - bind_addr? bind_addr : "0.0.0.0", - port, - smsc->bind_addr? smsc->bind_addr : "0.0.0.0", - smsc->listen_port, - VTY_NEWLINE); - return CMD_WARNING; - } - - same_bind_addr = (bind_addr == smsc->bind_addr) - || (bind_addr && smsc->bind_addr - && (strcmp(bind_addr, smsc->bind_addr) == 0)); - - if (!same_bind_addr || port != smsc->listen_port) { - vty_out(vty, "%% Cannot bind to new port %s:%u, staying on" - " old port %s:%u%s", - bind_addr? bind_addr : "0.0.0.0", - port, - smsc->bind_addr? smsc->bind_addr : "0.0.0.0", - smsc->listen_port, - VTY_NEWLINE); - return CMD_WARNING; - } - - return CMD_SUCCESS; -} - -DEFUN(cfg_smpp_port, cfg_smpp_port_cmd, - "local-tcp-port <1-65535>", - "Set the local TCP port on which we listen for SMPP\n" - "TCP port number") -{ - struct smsc *smsc = smsc_from_vty(vty); - uint16_t port = atoi(argv0); - return smpp_local_tcp(vty, smsc->bind_addr, port); -} - -DEFUN(cfg_smpp_addr_port, cfg_smpp_addr_port_cmd, - "local-tcp-ip A.B.C.D <1-65535>", - "Set the local IP address and TCP port on which we listen for SMPP\n" - "Local IP address\n" - "TCP port number") -{ - const char *bind_addr = argv0; - uint16_t port = atoi(argv1); - return smpp_local_tcp(vty, bind_addr, port); -} - -DEFUN(cfg_smpp_sys_id, cfg_smpp_sys_id_cmd, - "system-id ID", - "Set the System ID of this SMSC\n" - "Alphanumeric SMSC System ID\n") -{ - struct smsc *smsc = smsc_from_vty(vty); - - if (strlen(argv0)+1 > sizeof(smsc->system_id)) - return CMD_WARNING; - - strcpy(smsc->system_id, argv0); - - return CMD_SUCCESS; -} - -DEFUN(cfg_smpp_policy, cfg_smpp_policy_cmd, - "policy (accept-all|closed)", - "Set the authentication policy of this SMSC\n" - "Accept all SMPP connections independent of system ID / password\n" - "Accept only SMPP connections from ESMEs explicitly configured") -{ - struct smsc *smsc = smsc_from_vty(vty); - - if (!strcmp(argv0, "accept-all")) - smsc->accept_all = 1; - else - smsc->accept_all = 0; - - return CMD_SUCCESS; -} - - -static int config_write_smpp(struct vty *vty) -{ - struct smsc *smsc = smsc_from_vty(vty); - - vty_out(vty, "smpp%s", VTY_NEWLINE); - if (smsc->bind_addr) - vty_out(vty, " local-tcp-ip %s %u%s", smsc->bind_addr, - smsc->listen_port, VTY_NEWLINE); - else - vty_out(vty, " local-tcp-port %u%s", smsc->listen_port, - VTY_NEWLINE); - if (strlen(smsc->system_id) > 0) - vty_out(vty, " system-id %s%s", smsc->system_id, VTY_NEWLINE); - vty_out(vty, " policy %s%s", - smsc->accept_all ? "accept-all" : "closed", VTY_NEWLINE); - vty_out(vty, " %ssmpp-first%s", - smsc->smpp_first ? "" : "no ", VTY_NEWLINE); -
View file
osmo-msc_1.9.0.14.3948f.202208060002.dsc -> osmo-msc_1.9.0.16.62977.202208070002.dsc
Changed
@@ -2,7 +2,7 @@ Source: osmo-msc Binary: osmo-msc, osmo-msc-dbg, osmo-msc-doc Architecture: any all -Version: 1.9.0.14.3948f.202208060002 +Version: 1.9.0.16.62977.202208070002 Maintainer: Osmocom team <openbsc@lists.osmocom.org> Homepage: https://osmocom.org/projects/osmomsc Standards-Version: 3.9.8 @@ -14,8 +14,8 @@ osmo-msc-dbg deb debug extra arch=any osmo-msc-doc deb doc optional arch=all Checksums-Sha1: - 72cd258fc491c334a405504f027457e75c711520 335692 osmo-msc_1.9.0.14.3948f.202208060002.tar.xz + 8a7667d852a6b29baab6e1e0608ab6b72ff96c8c 335760 osmo-msc_1.9.0.16.62977.202208070002.tar.xz Checksums-Sha256: - 6181150140beacd051ccac4a741c16d0c5e138a2c4346de0d83c695d298cf195 335692 osmo-msc_1.9.0.14.3948f.202208060002.tar.xz + 97b8d8ad444c7dc05fd113dc5c1ca26bcf2ac9e693fb8b717da88f43084544fa 335760 osmo-msc_1.9.0.16.62977.202208070002.tar.xz Files: - eeda9ececbd37e36f924004f34072a83 335692 osmo-msc_1.9.0.14.3948f.202208060002.tar.xz + d5ccca42d226859c3c850f711435687a 335760 osmo-msc_1.9.0.16.62977.202208070002.tar.xz
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/.tarball-version -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/.tarball-version
Changed
@@ -1 +1 @@ -1.9.0.14-3948f.202208060002 +1.9.0.16-62977.202208070002
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/configure.ac -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/configure.ac
Changed
@@ -234,9 +234,11 @@ include/Makefile include/osmocom/Makefile include/osmocom/msc/Makefile + include/osmocom/smpp/Makefile src/Makefile src/libmsc/Makefile src/libvlr/Makefile + src/libsmpputil/Makefile src/osmo-msc/Makefile src/utils/Makefile tests/Makefile
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/contrib/osmo-msc.spec.in -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/contrib/osmo-msc.spec.in
Changed
@@ -18,7 +18,7 @@ %define with_iu 1 Name: osmo-msc -Requires: osmocom-nightly = 202208060002 +Requires: osmocom-nightly = 202208070002 Version: @VERSION@ Release: 0 Summary: Osmocom's MSC for 2G and 3G circuit-switched mobile networks
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/debian/changelog -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/debian/changelog
Changed
@@ -1,8 +1,8 @@ -osmo-msc (1.9.0.14.3948f.202208060002) unstable; urgency=medium +osmo-msc (1.9.0.16.62977.202208070002) unstable; urgency=medium * Automatically generated changelog entry for building the Osmocom nightly feed - -- Osmocom OBS scripts <info@osmocom.org> Sat, 06 Aug 2022 00:03:26 +0000 + -- Osmocom OBS scripts <info@osmocom.org> Sun, 07 Aug 2022 00:03:27 +0000 osmo-msc (1.9.0) unstable; urgency=medium
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/debian/control -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/debian/control
Changed
@@ -31,7 +31,7 @@ Package: osmo-msc Architecture: any Multi-Arch: foreign -Depends: osmocom-nightly (= 202208060002), ${misc:Depends}, ${shlibs:Depends} +Depends: osmocom-nightly (= 202208070002), ${misc:Depends}, ${shlibs:Depends} Recommends: osmo-mgw Description: OsmoMSC: Osmocom's Mobile Switching Center for 2G and 3G circuit-switched mobile networks The Mobile Switching Center (MSC) is the heart of 2G/3G @@ -49,7 +49,7 @@ Section: debug Architecture: any Multi-Arch: same -Depends: osmocom-nightly (= 202208060002), osmo-msc (= ${binary:Version}), ${misc:Depends} +Depends: osmocom-nightly (= 202208070002), osmo-msc (= ${binary:Version}), ${misc:Depends} Description: OsmoMSC: Osmocom's Mobile Switching Center for 2G and 3G circuit-switched mobile networks The Mobile Switching Center (MSC) is the heart of 2G/3G circuit-switched services. It terminates the A-interface links from the @@ -69,7 +69,7 @@ Architecture: all Section: doc Priority: optional -Depends: osmocom-nightly (= 202208060002), ${misc:Depends} +Depends: osmocom-nightly (= 202208070002), ${misc:Depends} Description: ${misc:Package} PDF documentation Various manuals: user manual, VTY reference manual and/or protocol/interface manuals.
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/include/osmocom/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/include/osmocom/Makefile.am
Changed
@@ -1,3 +1,4 @@ SUBDIRS = \ msc \ + smpp \ $(NULL)
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/include/osmocom/msc/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/include/osmocom/msc/Makefile.am
Changed
@@ -45,7 +45,6 @@ sgs_vty.h \ signal.h \ silent_call.h \ - smpp.h \ sms_queue.h \ transaction.h \ vlr.h \
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/include/osmocom/smpp
Added
+(directory)
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/include/osmocom/smpp/Makefile.am
Added
@@ -0,0 +1,4 @@ +noinst_HEADERS = \ + smpp.h \ + smpp_smsc.h \ + $(NULL)
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/include/osmocom/smpp/smpp.h
Added
@@ -0,0 +1,37 @@ +#pragma once + +#include <osmocom/msc/gsm_data.h> + +/* Length limits according to SMPP 3.4 spec including NUL-byte: */ +#define SMPP_SYS_ID_LEN 15 +#define SMPP_PASSWD_LEN 8 + +enum esme_read_state { + READ_ST_IN_LEN = 0, + READ_ST_IN_MSG = 1, +}; + +#define LOGPESME(ESME, LEVEL, FMT, ARGS...) \ + LOGP(DSMPP, LEVEL, "%s " FMT, (ESME)->system_id, ##ARGS) + +#define LOGPESMERR(ESME, FMT, ARGS...) \ + LOGPESME(ESME, LOGL_ERROR, "Error (%s) " FMT, smpp34_strerror, ##ARGS) + +/*! \brief Ugly wrapper. libsmpp34 should do this itself! */ +#define SMPP34_UNPACK(rc, type, str, data, len) { \ + memset(str, 0, sizeof(*str)); \ + rc = smpp34_unpack(type, str, data, len); } + +#define PACK_AND_SEND(esme, ptr) pack_and_send(esme, (ptr)->command_id, ptr) + +/*! \brief initialize the libsmpp34 data structure for a response */ +#define INIT_RESP(type, resp, req) { \ + memset((resp), 0, sizeof(*(resp))); \ + (resp)->command_length = 0; \ + (resp)->command_id = type; \ + (resp)->command_status = ESME_ROK; \ + (resp)->sequence_number = (req)->sequence_number; } + +uint32_t smpp_msgb_cmdid(struct msgb *msg); +int smpp_openbsc_alloc_init(void *ctx); +int smpp_openbsc_start(struct gsm_network *net);
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/include/osmocom/smpp/smpp_smsc.h
Added
@@ -0,0 +1,158 @@ +#pragma once + +#include <sys/socket.h> +#include <netinet/in.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/write_queue.h> +#include <osmocom/core/timer.h> +#include <osmocom/smpp/smpp.h> + +#include <smpp34.h> +#include <smpp34_structs.h> +#include <smpp34_params.h> + +#define MODE_7BIT 7 +#define MODE_8BIT 8 + +struct msc_a; + +struct osmo_smpp_acl; + +struct osmo_smpp_addr { + uint8_t ton; + uint8_t npi; + char addr21+1; +}; + +struct osmo_esme { + struct llist_head list; + struct smsc *smsc; + struct osmo_smpp_acl *acl; + int use; + + struct llist_head smpp_cmd_list; + + uint32_t own_seq_nr; + + struct osmo_wqueue wqueue; + + enum esme_read_state read_state; + uint32_t read_len; + uint32_t read_idx; + struct msgb *read_msg; + + uint8_t smpp_version; + char system_idSMPP_SYS_ID_LEN+1; + + uint8_t bind_flags; +}; + +struct osmo_smpp_acl { + struct llist_head list; + struct smsc *smsc; + struct osmo_esme *esme; + char *description; + char system_idSMPP_SYS_ID_LEN+1; + char passwdSMPP_PASSWD_LEN+1; + int default_route; + int deliver_src_imsi; + int osmocom_ext; + int dcs_transparent; + int alert_notifications; + struct llist_head route_list; +}; + +enum osmo_smpp_rtype { + SMPP_ROUTE_NONE, + SMPP_ROUTE_PREFIX, +}; + +struct osmo_smpp_route { + struct llist_head list; /*!< in acl.route_list */ + struct llist_head global_list; /*!< in smsc->route_list */ + struct osmo_smpp_acl *acl; + enum osmo_smpp_rtype type; + union { + struct osmo_smpp_addr prefix; + } u; +}; + +struct osmo_smpp_cmd { + struct llist_head list; + struct vlr_subscr *vsub; + uint32_t sequence_nr; + uint32_t gsm411_msg_ref; + uint8_t gsm411_trans_id; + bool is_report; + struct osmo_timer_list response_timer; +}; + +struct osmo_smpp_cmd *smpp_cmd_find_by_seqnum(struct osmo_esme *esme, + uint32_t sequence_number); +void smpp_cmd_ack(struct osmo_smpp_cmd *cmd); +void smpp_cmd_err(struct osmo_smpp_cmd *cmd, uint32_t status); +void smpp_cmd_flush_pending(struct osmo_esme *esme); + +struct smsc { + struct osmo_fd listen_ofd; + struct llist_head esme_list; + struct llist_head acl_list; + struct llist_head route_list; + char *bind_addr; + uint16_t listen_port; + char system_idSMPP_SYS_ID_LEN+1; + int accept_all; + int smpp_first; + struct osmo_smpp_acl *def_route; + void *priv; +}; + +int smpp_addr_eq(const struct osmo_smpp_addr *a, + const struct osmo_smpp_addr *b); + +struct smsc *smpp_smsc_alloc_init(void *ctx); +int smpp_smsc_conf(struct smsc *smsc, const char *bind_addr, uint16_t port); +int smpp_smsc_start(struct smsc *smsc, const char *bind_addr, uint16_t port); +int smpp_smsc_restart(struct smsc *smsc, const char *bind_addr, uint16_t port); +void smpp_smsc_stop(struct smsc *smsc); + +void smpp_esme_get(struct osmo_esme *esme); +void smpp_esme_put(struct osmo_esme *esme); + +int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, struct osmo_esme **emse); + +struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id); +struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc, + const char *sys_id); +void smpp_acl_delete(struct osmo_smpp_acl *acl); + +int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr, + uint32_t command_status, char *msg_id); + +int smpp_tx_alert(struct osmo_esme *esme, uint8_t ton, uint8_t npi, + const char *addr, uint8_t avail_status); + +int smpp_tx_deliver(struct osmo_esme *esme, struct deliver_sm_t *deliver); + +int handle_smpp_submit(struct osmo_esme *esme, struct submit_sm_t *submit, + struct submit_sm_resp_t *submit_r); + +int smpp_route_pfx_add(struct osmo_smpp_acl *acl, + const struct osmo_smpp_addr *pfx); +int smpp_route_pfx_del(struct osmo_smpp_acl *acl, + const struct osmo_smpp_addr *pfx); + +int smpp_vty_init(void); + +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; +struct ran_conn; + +bool smpp_route_smpp_first(); +int smpp_try_deliver(struct gsm_sms *sms, struct msc_a *msc_a);
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/Makefile.am
Changed
@@ -25,8 +25,16 @@ libmsc \ $(NULL) +if BUILD_SMPP + +SUBDIRS += \ + libsmpputil \ + utils \ + $(NULL) + +endif + # Programs SUBDIRS += \ osmo-msc \ - utils \ $(NULL)
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/libmsc/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libmsc/Makefile.am
Changed
@@ -20,9 +20,6 @@ $(LIBOSMONETIF_CFLAGS) \ $(NULL) -noinst_HEADERS = \ - $(NULL) - noinst_LIBRARIES = \ libmsc.a \ $(NULL) @@ -81,16 +78,3 @@ ran_msg_iu.c \ $(NULL) endif - -if BUILD_SMPP -noinst_HEADERS += \ - smpp_smsc.h \ - $(NULL) - -libmsc_a_SOURCES += \ - smpp_smsc.c \ - smpp_openbsc.c \ - smpp_vty.c \ - smpp_utils.c \ - $(NULL) -endif
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/libmsc/gsm_04_11.c -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libmsc/gsm_04_11.c
Changed
@@ -58,7 +58,7 @@ #include <osmocom/msc/paging.h> #ifdef BUILD_SMPP -#include "smpp_smsc.h" +#include <osmocom/smpp/smpp_smsc.h> #endif void *tall_gsms_ctx; @@ -1389,4 +1389,3 @@ trans_free(trans); } } -
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libsmpputil
Added
+(directory)
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libsmpputil/Makefile.am
Added
@@ -0,0 +1,25 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) +AM_CFLAGS= \ + -Wall \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOSCCP_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(LIBOSMONETIF_CFLAGS) \ + $(LIBOSMOMGCPCLIENT_CFLAGS) \ + $(LIBOSMOGSUPCLIENT_CFLAGS) \ + $(LIBSMPP34_CFLAGS) \ + $(COVERAGE_CFLAGS) \ + $(NULL) + +noinst_HEADERS = \ + $(NULL) + +noinst_LIBRARIES = libsmpputil.a + +libsmpputil_a_SOURCES = \ + smpp_utils.c \ + smpp_vty.c \ + smpp_msc.c \ + smpp_smsc.c \ + $(NULL)
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libsmpputil/smpp_msc.c
Added
@@ -0,0 +1,861 @@ +/* OpenBSC SMPP 3.4 interface, SMSC-side implementation */ + +/* (C) 2012-2022 by Harald Welte <laforge@gnumonks.org> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <stdint.h> +#include <errno.h> +#include <time.h> + +#include <smpp34.h> +#include <smpp34_structs.h> +#include <smpp34_params.h> +#include <smpp34_heap.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/talloc.h> +#include <osmocom/gsm/protocol/gsm_04_11.h> +#include <osmocom/gsm/protocol/smpp34_osmocom.h> + +#include <osmocom/msc/gsm_subscriber.h> +#include <osmocom/msc/debug.h> +#include <osmocom/msc/db.h> +#include <osmocom/msc/gsm_04_11.h> +#include <osmocom/msc/gsm_data.h> +#include <osmocom/msc/signal.h> +#include <osmocom/msc/transaction.h> +#include <osmocom/msc/gsm_subscriber.h> +#include <osmocom/msc/vlr.h> +#include <osmocom/msc/msc_a.h> +#include <osmocom/smpp/smpp_smsc.h> + +#define VSUB_USE_SMPP "SMPP" +#define VSUB_USE_SMPP_CMD "SMPP-cmd" + +/* talloc integration for libsmpp34 */ + +static struct smsc *g_smsc; + +static void *smpp34_talloc_malloc(size_t sz) +{ + return talloc_size(g_smsc, sz); +} + +static void *smpp34_talloc_realloc(void *ptr, size_t sz) +{ + return talloc_realloc_size(g_smsc, ptr, sz); +} + +static void smpp34_talloc_free(void *ptr) +{ + talloc_free(ptr); +} + +static const struct smpp34_memory_functions smpp34_talloc = { + .malloc_fun = smpp34_talloc_malloc, + .realloc_fun = smpp34_talloc_realloc, + .free_fun = smpp34_talloc_free, +}; + +/*! \brief find vlr_subscr for a given SMPP NPI/TON/Address */ +static struct vlr_subscr *subscr_by_dst(struct gsm_network *net, + uint8_t npi, uint8_t ton, + const char *addr) +{ + struct vlr_subscr *vsub = NULL; + + switch (npi) { + case NPI_Land_Mobile_E212: + vsub = vlr_subscr_find_by_imsi(net->vlr, addr, VSUB_USE_SMPP); + break; + case NPI_ISDN_E163_E164: + case NPI_Private: + vsub = vlr_subscr_find_by_msisdn(net->vlr, addr, VSUB_USE_SMPP); + break; + default: + LOGP(DSMPP, LOGL_NOTICE, "Unsupported NPI: %u\n", npi); + break; + } + + log_set_context(LOG_CTX_VLR_SUBSCR, vsub); + return vsub; +} + +static int smpp34_submit_tlv_msg_payload(const struct tlv_t *t, + const struct submit_sm_t *submit, + const uint8_t **sms_msg, + unsigned int *sms_msg_len) +{ + if (submit->sm_length) { + LOGP(DLSMS, LOGL_ERROR, + "SMPP cannot have payload in TLV _and_ in the header\n"); + return -1; + } + *sms_msg = t->value.octet; + *sms_msg_len = t->length; + + return 0; +} + +/*! \brief convert from submit_sm_t to gsm_sms */ +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; + uint16_t msg_ref = 0; + struct gsm_sms *sms; + struct tlv_t *t; + int mode; + int can_store_sms = ((submit->esm_class & SMPP34_MSG_MODE_MASK) != 2); /* != forward mode */ + + dest = subscr_by_dst(net, submit->dest_addr_npi, + submit->dest_addr_ton, + (const char *)submit->destination_addr); + if (!dest && !can_store_sms) { + LOGP(DLSMS, LOGL_NOTICE, "SMPP SUBMIT-SM for unknown subscriber: " + "%s (NPI=%u)\n", submit->destination_addr, + submit->dest_addr_npi); + return ESME_RINVDSTADR; + } + + smpp34_tlv_for_each(t, submit->tlv) { + switch (t->tag) { + case TLVID_message_payload: + if (smpp34_submit_tlv_msg_payload(t, submit, &sms_msg, + &sms_msg_len) < 0) { + if (dest) + vlr_subscr_put(dest, VSUB_USE_SMPP); + return ESME_ROPTPARNOTALLWD; + } + break; + case TLVID_user_message_reference: + msg_ref = t->value.val16; + break; + default: + break; + } + } + + if (!sms_msg) { + if (submit->sm_length > 0 && submit->sm_length < 255) { + sms_msg = submit->short_message; + sms_msg_len = submit->sm_length; + } else { + LOGP(DLSMS, LOGL_ERROR, + "SMPP neither message payload nor valid sm_length.\n"); + if (dest) + vlr_subscr_put(dest, VSUB_USE_SMPP); + return ESME_RINVPARLEN; + } + } + + sms = sms_alloc(); + sms->source = SMS_SOURCE_SMPP; + sms->smpp.sequence_nr = submit->sequence_number; + sms->status_rep_req = submit->registered_delivery; + sms->msg_ref = msg_ref; + + /* fill in the destination address */ + sms->receiver = dest; + if (dest) { + /* Replace use count from above subscr_by_dst (VSUB_USE_SMPP) by the sms->receiver use count + * (VSUB_USE_SMS_RECEIVER) */ + vlr_subscr_get(sms->receiver, VSUB_USE_SMS_RECEIVER); + vlr_subscr_put(dest, VSUB_USE_SMPP); + } + sms->dst.ton = submit->dest_addr_ton; + sms->dst.npi = submit->dest_addr_npi; + if (dest) + OSMO_STRLCPY_ARRAY(sms->dst.addr, dest->msisdn); + else + OSMO_STRLCPY_ARRAY(sms->dst.addr, + (const char *)submit->destination_addr); + + /* fill in the source address */
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libsmpputil/smpp_smsc.c
Added
@@ -0,0 +1,1003 @@ +/* SMPP 3.4 interface, SMSC-side implementation */ +/* (C) 2012 by Harald Welte <laforge@gnumonks.org> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <stdint.h> +#include <errno.h> +#include <limits.h> + +#include <sys/socket.h> +#include <netinet/in.h> + +#include <smpp34.h> +#include <smpp34_structs.h> +#include <smpp34_params.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/socket.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/write_queue.h> +#include <osmocom/core/talloc.h> +#include <osmocom/gsm/protocol/gsm_04_11.h> + +#include <osmocom/msc/debug.h> +#include <osmocom/msc/gsm_data.h> +#include <osmocom/smpp/smpp_smsc.h> + +enum emse_bind { + ESME_BIND_RX = 0x01, + ESME_BIND_TX = 0x02, +}; + +const struct value_string smpp_status_strs = { + { ESME_ROK, "No Error" }, + { ESME_RINVMSGLEN, "Message Length is invalid" }, + { ESME_RINVCMDLEN, "Command Length is invalid" }, + { ESME_RINVCMDID, "Invalid Command ID" }, + { ESME_RINVBNDSTS, "Incorrect BIND Status for given command" }, + { ESME_RALYBND, "ESME Already in Bound State" }, + { ESME_RINVPRTFLG, "Invalid Priority Flag" }, + { ESME_RINVREGDLVFLG, "Invalid Registered Delivery Flag" }, + { ESME_RSYSERR, "System Error" }, + { ESME_RINVSRCADR, "Invalid Source Address" }, + { ESME_RINVDSTADR, "Invalid Destination Address" }, + { ESME_RINVMSGID, "Message ID is invalid" }, + { ESME_RBINDFAIL, "Bind failed" }, + { ESME_RINVPASWD, "Invalid Password" }, + { ESME_RINVSYSID, "Invalid System ID" }, + { ESME_RCANCELFAIL, "Cancel SM Failed" }, + { ESME_RREPLACEFAIL, "Replace SM Failed" }, + { ESME_RMSGQFUL, "Message Queue Full" }, + { ESME_RINVSERTYP, "Invalid Service Type" }, + { ESME_RINVNUMDESTS, "Invalid number of destinations" }, + { ESME_RINVDLNAME, "Invalid Distribution List name" }, + { ESME_RINVDESTFLAG, "Destination flag is invalid" }, + { ESME_RINVSUBREP, "Invalid submit with replace request" }, + { ESME_RINVESMCLASS, "Invalid esm_class field data" }, + { ESME_RCNTSUBDL, "Cannot Submit to Distribution List" }, + { ESME_RSUBMITFAIL, "submit_sm or submit_multi failed" }, + { ESME_RINVSRCTON, "Invalid Source address TON" }, + { ESME_RINVSRCNPI, "Invalid Sourec address NPI" }, + { ESME_RINVDSTTON, "Invalid Destination address TON" }, + { ESME_RINVDSTNPI, "Invalid Desetination address NPI" }, + { ESME_RINVSYSTYP, "Invalid system_type field" }, + { ESME_RINVREPFLAG, "Invalid replace_if_present field" }, + { ESME_RINVNUMMSGS, "Invalid number of messages" }, + { ESME_RTHROTTLED, "Throttling error (ESME has exceeded message limits)" }, + { ESME_RINVSCHED, "Invalid Scheduled Delivery Time" }, + { ESME_RINVEXPIRY, "Invalid message validity period (Expiry time)" }, + { ESME_RINVDFTMSGID, "Predefined Message Invalid or Not Found" }, + { ESME_RX_T_APPN, "ESME Receiver Temporary App Error Code" }, + { ESME_RX_P_APPN, "ESME Receiver Permanent App Error Code" }, + { ESME_RX_R_APPN, "ESME Receiver Reject Message Error Code" }, + { ESME_RQUERYFAIL, "query_sm request failed" }, + { ESME_RINVOPTPARSTREAM,"Error in the optional part of the PDU Body" }, + { ESME_ROPTPARNOTALLWD, "Optional Parameter not allowed" }, + { ESME_RINVPARLEN, "Invalid Parameter Length" }, + { ESME_RMISSINGOPTPARAM,"Expected Optional Parameter missing" }, + { ESME_RINVOPTPARAMVAL, "Invalid Optional Parameter Value" }, + { ESME_RDELIVERYFAILURE,"Delivery Failure (used for data_sm_resp)" }, + { ESME_RUNKNOWNERR, "Unknown Error" }, + { 0, NULL } +}; + +/*! \brief compare if two SMPP addresses are equal */ +int smpp_addr_eq(const struct osmo_smpp_addr *a, + const struct osmo_smpp_addr *b) +{ + if (a->ton == b->ton && + a->npi == b->npi && + !strcmp(a->addr, b->addr)) + return 1; + + return 0; +} + + +struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc, + const char *sys_id) +{ + struct osmo_smpp_acl *acl; + + llist_for_each_entry(acl, &smsc->acl_list, list) { + if (!strcmp(acl->system_id, sys_id)) + return acl; + } + + return NULL; +} + +struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id) +{ + struct osmo_smpp_acl *acl; + + if (strlen(sys_id) > SMPP_SYS_ID_LEN) + return NULL; + + if (smpp_acl_by_system_id(smsc, sys_id)) + return NULL; + + acl = talloc_zero(smsc, struct osmo_smpp_acl); + if (!acl) + return NULL; + + acl->smsc = smsc; + strcpy(acl->system_id, sys_id); + acl->alert_notifications = 1; + INIT_LLIST_HEAD(&acl->route_list); + + llist_add_tail(&acl->list, &smsc->acl_list); + + return acl; +} + +void smpp_acl_delete(struct osmo_smpp_acl *acl) +{ + struct osmo_smpp_route *r, *r2; + + llist_del(&acl->list); + + /* kill any active ESMEs */ + if (acl->esme) { + struct osmo_esme *esme = acl->esme; + osmo_fd_unregister(&esme->wqueue.bfd); + close(esme->wqueue.bfd.fd); + esme->wqueue.bfd.fd = -1; + esme->acl = NULL; + smpp_esme_put(esme); + } + + /* delete all routes for this ACL */ + llist_for_each_entry_safe(r, r2, &acl->route_list, list) { + llist_del(&r->list); + llist_del(&r->global_list); + talloc_free(r); + } + + talloc_free(acl); +} + +static struct osmo_smpp_route *route_alloc(struct osmo_smpp_acl *acl) +{ + struct osmo_smpp_route *r; + + r = talloc_zero(acl, struct osmo_smpp_route); + if (!r) + return NULL; + + llist_add_tail(&r->list, &acl->route_list); + llist_add_tail(&r->global_list, &acl->smsc->route_list); + + return r; +} + +int smpp_route_pfx_add(struct osmo_smpp_acl *acl, + const struct osmo_smpp_addr *pfx) +{ + struct osmo_smpp_route *r; + + llist_for_each_entry(r, &acl->route_list, list) {
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libsmpputil/smpp_utils.c
Added
@@ -0,0 +1,174 @@ + +/* (C) 2012-2022 by Harald Welte <laforge@gnumonks.org> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <time.h> + +#include <osmocom/core/logging.h> +#include <osmocom/netif/stream.h> +#include <osmocom/smpp/smpp_smsc.h> + +/*! \brief retrieve SMPP command ID from a msgb */ +uint32_t smpp_msgb_cmdid(struct msgb *msg) +{ + uint8_t *tmp = msgb_data(msg) + 4; + return ntohl(*(uint32_t *)tmp); +} + +int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode) +{ + if ((dcs & 0xF0) == 0xF0) { + if (dcs & 0x04) { + /* bit 2 == 1: 8bit data */ + *data_coding = 0x02; + *mode = MODE_8BIT; + } else { + /* bit 2 == 0: default alphabet */ + *data_coding = 0x01; + *mode = MODE_7BIT; + } + } else if ((dcs & 0xE0) == 0) { + switch (dcs & 0xC) { + case 0: + *data_coding = 0x01; + *mode = MODE_7BIT; + break; + case 4: + *data_coding = 0x02; + *mode = MODE_8BIT; + break; + case 8: + *data_coding = 0x08; /* UCS-2 */ + *mode = MODE_8BIT; + break; + default: + goto unknown_mo; + } + } else { +unknown_mo: + LOGP(DLSMS, LOGL_ERROR, "SMPP MO Unknown Data Coding 0x%02x\n", dcs); + return -1; + } + + 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; +} + +#ifndef HAVE_TIMEGM +/* for systems without a timegm() function, provide a reimplementation */ +static time_t timegm(struct tm *tm) +{ + const char *orig_tz = getenv("TZ"); + time_t ret; + + setenv("TZ", "UTC", 1); + + ret = mktime(tm); + + if (orig_tz) + setenv("TZ", orig_tz, 1); + else + unsetenv("TZ"); + + return ret; +} +#endif + + +/*! Parse a SMPP time format as defined in SMPP v3.4 7.1.1. + * \paramin vp string containing the time as encoded in SMPP v3.4 + * \paramin 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; + struct tm tm; + time_t ret; + int rc; + + memset(&tm, 0, sizeof(tm)); + + if (vp0 == '\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; + + 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; + ret = timegm(&tm); + 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; + ret = timegm(&tm); + break; + case 'R': + /* relative time */ + tm.tm_mon = month; + if (t_now) + relative2absolute(&tm, *t_now); + else + relative2absolute(&tm, time(NULL)); + /* here we do want local time, as we're passing local time in above! */ + ret = mktime(&tm); + break; + default: + return (time_t) -1; + } + + return ret; +}
View file
osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/libsmpputil/smpp_vty.c
Added
@@ -0,0 +1,629 @@ +/* SMPP vty interface */ + +/* (C) 2012 by Harald Welte <laforge@gnumonks.org> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <ctype.h> +#include <string.h> +#include <errno.h> +#include <netdb.h> +#include <sys/socket.h> + +#include <osmocom/vty/command.h> +#include <osmocom/vty/buffer.h> +#include <osmocom/vty/vty.h> + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/utils.h> +#include <osmocom/core/socket.h> +#include <osmocom/core/talloc.h> + +#include <osmocom/msc/vty.h> +#include <osmocom/smpp/smpp_smsc.h> + +struct smsc *smsc_from_vty(struct vty *v); + +static struct cmd_node smpp_node = { + SMPP_NODE, + "%s(config-smpp)# ", + 1, +}; + +static struct cmd_node esme_node = { + SMPP_ESME_NODE, + "%s(config-smpp-esme)# ", + 1, +}; + +DEFUN(cfg_smpp, cfg_smpp_cmd, + "smpp", "Configure SMPP SMS Interface") +{ + vty->node = SMPP_NODE; + + return CMD_SUCCESS; +} + +DEFUN(cfg_smpp_first, cfg_smpp_first_cmd, + "smpp-first", + "Try SMPP routes before the subscriber DB\n") +{ + struct smsc *smsc = smsc_from_vty(vty); + smsc->smpp_first = 1; + return CMD_SUCCESS; +} + +DEFUN(cfg_no_smpp_first, cfg_no_smpp_first_cmd, + "no smpp-first", + NO_STR "Try SMPP before routes before the subscriber DB\n") +{ + struct smsc *smsc = smsc_from_vty(vty); + smsc->smpp_first = 0; + return CMD_SUCCESS; +} + +static int smpp_local_tcp(struct vty *vty, + const char *bind_addr, uint16_t port) +{ + struct smsc *smsc = smsc_from_vty(vty); + int is_running = smsc->listen_ofd.fd > 0; + int same_bind_addr; + int rc; + + /* If it is not up yet, don't rebind, just set values. */ + if (!is_running) { + rc = smpp_smsc_conf(smsc, bind_addr, port); + if (rc < 0) { + vty_out(vty, "%% Cannot configure new address:port%s", + VTY_NEWLINE); + return CMD_WARNING; + } + return CMD_SUCCESS; + } + + rc = smpp_smsc_restart(smsc, bind_addr, port); + if (rc < 0) { + vty_out(vty, "%% Cannot bind to new port %s:%u nor to" + " old port %s:%u%s", + bind_addr? bind_addr : "0.0.0.0", + port, + smsc->bind_addr? smsc->bind_addr : "0.0.0.0", + smsc->listen_port, + VTY_NEWLINE); + return CMD_WARNING; + } + + same_bind_addr = (bind_addr == smsc->bind_addr) + || (bind_addr && smsc->bind_addr + && (strcmp(bind_addr, smsc->bind_addr) == 0)); + + if (!same_bind_addr || port != smsc->listen_port) { + vty_out(vty, "%% Cannot bind to new port %s:%u, staying on" + " old port %s:%u%s", + bind_addr? bind_addr : "0.0.0.0", + port, + smsc->bind_addr? smsc->bind_addr : "0.0.0.0", + smsc->listen_port, + VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + +DEFUN(cfg_smpp_port, cfg_smpp_port_cmd, + "local-tcp-port <1-65535>", + "Set the local TCP port on which we listen for SMPP\n" + "TCP port number") +{ + struct smsc *smsc = smsc_from_vty(vty); + uint16_t port = atoi(argv0); + return smpp_local_tcp(vty, smsc->bind_addr, port); +} + +DEFUN(cfg_smpp_addr_port, cfg_smpp_addr_port_cmd, + "local-tcp-ip A.B.C.D <1-65535>", + "Set the local IP address and TCP port on which we listen for SMPP\n" + "Local IP address\n" + "TCP port number") +{ + const char *bind_addr = argv0; + uint16_t port = atoi(argv1); + return smpp_local_tcp(vty, bind_addr, port); +} + +DEFUN(cfg_smpp_sys_id, cfg_smpp_sys_id_cmd, + "system-id ID", + "Set the System ID of this SMSC\n" + "Alphanumeric SMSC System ID\n") +{ + struct smsc *smsc = smsc_from_vty(vty); + + if (strlen(argv0)+1 > sizeof(smsc->system_id)) + return CMD_WARNING; + + strcpy(smsc->system_id, argv0); + + return CMD_SUCCESS; +} + +DEFUN(cfg_smpp_policy, cfg_smpp_policy_cmd, + "policy (accept-all|closed)", + "Set the authentication policy of this SMSC\n" + "Accept all SMPP connections independent of system ID / password\n" + "Accept only SMPP connections from ESMEs explicitly configured") +{ + struct smsc *smsc = smsc_from_vty(vty); + + if (!strcmp(argv0, "accept-all")) + smsc->accept_all = 1; + else + smsc->accept_all = 0; + + return CMD_SUCCESS; +} + + +static int config_write_smpp(struct vty *vty) +{ + struct smsc *smsc = smsc_from_vty(vty); + + vty_out(vty, "smpp%s", VTY_NEWLINE); + if (smsc->bind_addr) + vty_out(vty, " local-tcp-ip %s %u%s", smsc->bind_addr, + smsc->listen_port, VTY_NEWLINE); + else + vty_out(vty, " local-tcp-port %u%s", smsc->listen_port, + VTY_NEWLINE); + if (strlen(smsc->system_id) > 0) + vty_out(vty, " system-id %s%s", smsc->system_id, VTY_NEWLINE); + vty_out(vty, " policy %s%s", + smsc->accept_all ? "accept-all" : "closed", VTY_NEWLINE); + vty_out(vty, " %ssmpp-first%s", + smsc->smpp_first ? "" : "no ", VTY_NEWLINE); + + return CMD_SUCCESS;
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/osmo-msc/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/osmo-msc/Makefile.am
Changed
@@ -43,7 +43,6 @@ $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(LIBOSMONETIF_LIBS) \ - $(LIBSMPP34_LIBS) \ $(LIBOSMORANAP_LIBS) \ $(LIBASN1C_LIBS) \ $(LIBOSMOSIGTRAN_LIBS) \ @@ -52,3 +51,12 @@ $(LIBSQLITE3_LIBS) \ -lsctp \ $(NULL) + +if BUILD_SMPP + +osmo_msc_LDADD += \ + $(top_builddir)/src/libsmpputil/libsmpputil.a \ + $(LIBSMPP34_LIBS) \ + $(NULL) + +endif
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/osmo-msc/msc_main.c -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/osmo-msc/msc_main.c
Changed
@@ -60,7 +60,7 @@ #include <osmocom/ctrl/control_if.h> #include <osmocom/ctrl/control_vty.h> #include <osmocom/ctrl/ports.h> -#include <osmocom/msc/smpp.h> +#include <osmocom/smpp/smpp.h> #include <osmocom/sigtran/osmo_ss7.h> #include <osmocom/mgcp_client/mgcp_client.h> #include <osmocom/msc/sgs_iface.h>
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/utils/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/utils/Makefile.am
Changed
@@ -34,12 +34,16 @@ smpp_mirror_CFLAGS = \ $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOSCCP_CFLAGS) \ + $(LIBOSMOMGCPCLIENT_CFLAGS) \ $(LIBSMPP34_CFLAGS) \ $(NULL) smpp_mirror_LDADD = \ + $(top_builddir)/src/libsmpputil/libsmpputil.a \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ + $(LIBOSMONETIF_LIBS) \ $(LIBSMPP34_LIBS) \ $(NULL) endif
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/src/utils/smpp_mirror.c -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/src/utils/smpp_mirror.c
Changed
@@ -19,18 +19,11 @@ #include <osmocom/core/write_queue.h> #include <osmocom/msc/debug.h> +#include <osmocom/smpp/smpp.h> /* FIXME: merge with smpp_smsc.c */ -#define SMPP_SYS_ID_LEN 16 -enum esme_read_state { - READ_ST_IN_LEN = 0, - READ_ST_IN_MSG = 1, -}; -/* FIXME: merge with smpp_smsc.c */ struct esme { - struct osmo_fd ofd; - uint32_t own_seq_nr; struct osmo_wqueue wqueue; @@ -45,22 +38,6 @@ }; /* FIXME: merge with smpp_smsc.c */ -#define SMPP34_UNPACK(rc, type, str, data, len) \ - memset(str, 0, sizeof(*str)); \ - rc = smpp34_unpack(type, str, data, len) -#define INIT_RESP(type, resp, req) { \ - memset((resp), 0, sizeof(*(resp))); \ - (resp)->command_length = 0; \ - (resp)->command_id = type; \ - (resp)->command_status = ESME_ROK; \ - (resp)->sequence_number = (req)->sequence_number; \ -} -#define PACK_AND_SEND(esme, ptr) pack_and_send(esme, (ptr)->command_id, ptr) -static inline uint32_t smpp_msgb_cmdid(struct msgb *msg) -{ - uint8_t *tmp = msgb_data(msg) + 4; - return ntohl(*(uint32_t *)tmp); -} static uint32_t esme_inc_seq_nr(struct esme *esme) { esme->own_seq_nr++; @@ -78,16 +55,14 @@ rc = smpp34_pack(type, msg->tail, msgb_tailroom(msg), &rlen, ptr); if (rc != 0) { - LOGP(DSMPP, LOGL_ERROR, "%s Error during smpp34_pack(): %s\n", - esme->system_id, smpp34_strerror); + LOGPESMERR(esme, "during smpp34_pack()\n"); msgb_free(msg); return -EINVAL; } msgb_put(msg, rlen); if (osmo_wqueue_enqueue(&esme->wqueue, msg) != 0) { - LOGP(DSMPP, LOGL_ERROR, "%s Write queue full. Dropping message\n", - esme->system_id); + LOGPESME(esme, LOGL_ERROR, "Write queue full. Dropping message\n"); msgb_free(msg); return -EAGAIN; } @@ -238,8 +213,7 @@ rdlen = sizeof(uint32_t) - esme->read_idx; rc = read(ofd->fd, lenptr + esme->read_idx, rdlen); if (rc < 0) { - LOGP(DSMPP, LOGL_ERROR, "%s read returned %d\n", - esme->system_id, rc); + LOGPESME(esme, LOGL_ERROR, "read returned %d\n", rc); } else if (rc == 0) { goto dead_socket; } else @@ -265,8 +239,7 @@ rdlen = esme->read_len - esme->read_idx; rc = read(ofd->fd, msg->tail, OSMO_MIN(rdlen, msgb_tailroom(msg))); if (rc < 0) { - LOGP(DSMPP, LOGL_ERROR, "%s read returned %d\n", - esme->system_id, rc); + LOGPESME(esme, LOGL_ERROR, "read returned %d\n", rc); } else if (rc == 0) { goto dead_socket; } else { @@ -305,7 +278,7 @@ esme->wqueue.bfd.fd = -1; exit(99); } else if (rc < msgb_length(msg)) { - LOGP(DSMPP, LOGL_ERROR, "%s Short write\n", esme->system_id); + LOGPESME(esme, LOGL_ERROR, "Short write\n"); return 0; }
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/tests/db_sms/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/tests/db_sms/Makefile.am
Changed
@@ -14,7 +14,6 @@ $(LIBOSMOSIGTRAN_CFLAGS) \ $(LIBOSMORANAP_CFLAGS) \ $(LIBOSMONETIF_CFLAGS) \ - $(LIBSMPP34_CFLAGS) \ $(LIBOSMOMGCPCLIENT_CFLAGS) \ $(LIBOSMOGSUPCLIENT_CFLAGS) \ $(LIBSQLITE3_CFLAGS) \ @@ -37,7 +36,6 @@ db_sms_test_LDADD = \ $(top_builddir)/src/libmsc/libmsc.a \ $(top_builddir)/src/libvlr/libvlr.a \ - $(LIBSMPP34_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/tests/msc_vlr/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/tests/msc_vlr/Makefile.am
Changed
@@ -8,7 +8,6 @@ -ggdb3 \ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ - $(LIBSMPP34_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(LIBOSMOSIGTRAN_CFLAGS) \ @@ -32,7 +31,6 @@ LDADD = \ $(top_builddir)/src/libmsc/libmsc.a \ $(top_builddir)/src/libvlr/libvlr.a \ - $(LIBSMPP34_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/tests/smpp/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/tests/smpp/Makefile.am
Changed
@@ -11,6 +11,8 @@ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOSCCP_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ + $(LIBOSMOSCCP_CFLAGS) \ + $(LIBOSMOMGCPCLIENT_CFLAGS) \ $(COVERAGE_CFLAGS) \ $(LIBSMPP34_CFLAGS) \ $(NULL) @@ -30,10 +32,10 @@ smpp_test_SOURCES = \ smpp_test.c \ - $(top_builddir)/src/libmsc/smpp_utils.c \ $(NULL) smpp_test_LDADD = \ + $(top_builddir)/src/libsmpputil/libsmpputil.a \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(NULL)
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/tests/smpp/smpp_test.c -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/tests/smpp/smpp_test.c
Changed
@@ -22,12 +22,10 @@ #include <stdio.h> #include <osmocom/msc/debug.h> - +#include <osmocom/smpp/smpp_smsc.h> #include <osmocom/core/application.h> #include <osmocom/core/backtrace.h> -#include "smpp_smsc.h" - struct coding_test { uint8_t dcs; uint8_t coding;
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/tests/sms_queue/Makefile.am -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/tests/sms_queue/Makefile.am
Changed
@@ -36,7 +36,6 @@ sms_queue_test_LDADD = \ $(top_builddir)/src/libmsc/libmsc.a \ $(top_builddir)/src/libvlr/libvlr.a \ - $(LIBSMPP34_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \
View file
osmo-msc_1.9.0.14.3948f.202208060002.tar.xz/tests/stubs.c -> osmo-msc_1.9.0.16.62977.202208070002.tar.xz/tests/stubs.c
Changed
@@ -43,3 +43,11 @@ void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port) {} void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr) {} int sctp_recvmsg(int sd, void *msg, size_t len, void *from, void *fromlen, void *info, int *msg_flags) { return 0; } +struct gsm_sms; +struct msc_a; +struct gsm_trans; +struct osmo_esme; +bool smpp_route_smpp_first() { return false; } +void smpp_esme_put(struct osmo_esme *esme) { return; } +int smpp_try_deliver(struct gsm_sms *sms, struct msc_a *msc_a) { return 0; } +int sms_route_mt_sms(struct gsm_trans *trans, struct gsm_sms *gsms) { return 0; }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.