diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-13 17:09:56 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-27 20:03:10 +0200 |
commit | a7328a5642566bf7b07c6d0e58dfe5da018873a5 (patch) | |
tree | 7242bc7481b70b956a7e7b373b4d285226afe2a3 /openbsc/src/libmsc/smpp_openbsc.c | |
parent | 5ecbc93656edf49c8042b269299e31e157763511 (diff) |
smpp: Move the coding/mode detection into a utils file
Make sure to not ever have issues with this code again, move the
utility code to a new file and create a basic testcase. The method
currently has 100% line and branch coverage. My initial patched
missed the smpp_utils.c file and I re-did the copying (and verifying
the branch coverage)
Diffstat (limited to 'openbsc/src/libmsc/smpp_openbsc.c')
-rw-r--r-- | openbsc/src/libmsc/smpp_openbsc.c | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index f898cae6f..8e0085d0c 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -79,9 +79,6 @@ static struct tlv_t *find_tlv(struct tlv_t *head, uint16_t tag) return NULL; } -#define MODE_7BIT 7 -#define MODE_8BIT 8 - /*! \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) @@ -469,39 +466,8 @@ static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms, /* Figure out SMPP DCS from TP-DCS */ dcs = sms->data_coding_scheme; - if ((dcs & 0xF0) == 0xF0) { - if (dcs & 0x04) { - /* bit 2 == 1: 8bit data */ - deliver.data_coding = 0x02; - mode = MODE_8BIT; - } else { - /* bit 2 == 0: default alphabet */ - deliver.data_coding = 0x01; - mode = MODE_7BIT; - } - } else if ((dcs & 0xE0) == 0) { - switch (dcs & 0xC) { - case 0: - deliver.data_coding = 0x01; - mode = MODE_7BIT; - break; - case 4: - deliver.data_coding = 0x02; - mode = MODE_8BIT; - break; - case 8: - deliver.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); + if (smpp_determine_scheme(dcs, &deliver.data_coding, &mode) == -1) return -1; - } /* Transparently pass on DCS via SMPP if requested */ if (esme->acl && esme->acl->dcs_transparent) |