* [isimodem-ussd PATCH 0/5] USSD fixes @ 2010-09-16 17:32 Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 1/5] ussd.h: +CUSD is documented in 27.007 section 7.15 Pekka.Pessi 2010-09-16 18:54 ` [isimodem-ussd PATCH 0/5] USSD fixes Denis Kenzior 0 siblings, 2 replies; 8+ messages in thread From: Pekka.Pessi @ 2010-09-16 17:32 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 356 bytes --] Hi all, I've updated the isimodem ussd implementation to allow network-initiated operations. I've added some debug logging to the core ussd, too. The isimodem ussd now works with simple USSD applications with puSS-Request and uSS-Requests, but uSS-Notifys while a mobile-originated puSS-Request is pending seem not to work properly. --Pekka ^ permalink raw reply [flat|nested] 8+ messages in thread
* [isimodem-ussd PATCH 1/5] ussd.h: +CUSD is documented in 27.007 section 7.15 2010-09-16 17:32 [isimodem-ussd PATCH 0/5] USSD fixes Pekka.Pessi @ 2010-09-16 17:32 ` Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 2/5] ussd: debug log notifys Pekka.Pessi 2010-09-16 18:54 ` [isimodem-ussd PATCH 0/5] USSD fixes Denis Kenzior 1 sibling, 1 reply; 8+ messages in thread From: Pekka.Pessi @ 2010-09-16 17:32 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 485 bytes --] From: Pekka Pessi <Pekka.Pessi@nokia.com> --- include/ussd.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/ussd.h b/include/ussd.h index 360ef00..82057f2 100644 --- a/include/ussd.h +++ b/include/ussd.h @@ -28,6 +28,7 @@ extern "C" { #include <ofono/types.h> +/* 3GPP TS 27.007 section 7.15, values for <m> */ enum ofono_ussd_status { OFONO_USSD_STATUS_NOTIFY = 0, OFONO_USSD_STATUS_ACTION_REQUIRED = 1, -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [isimodem-ussd PATCH 2/5] ussd: debug log notifys 2010-09-16 17:32 ` [isimodem-ussd PATCH 1/5] ussd.h: +CUSD is documented in 27.007 section 7.15 Pekka.Pessi @ 2010-09-16 17:32 ` Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 3/5] test-ussd: read stdin for Response()s Pekka.Pessi 0 siblings, 1 reply; 8+ messages in thread From: Pekka.Pessi @ 2010-09-16 17:32 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1734 bytes --] From: Pekka Pessi <Pekka.Pessi@nokia.com> --- src/ussd.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/src/ussd.c b/src/ussd.c index 57390f1..bbb9aed 100644 --- a/src/ussd.c +++ b/src/ussd.c @@ -350,6 +350,43 @@ static int ussd_status_to_failure_code(int status) return 0; } +static char const *ussd_status_name(int status) +{ + switch (status) { + case OFONO_USSD_STATUS_NOTIFY: + return "NOTIFY"; + case OFONO_USSD_STATUS_ACTION_REQUIRED: + return "ACTION_REQUIRED"; + case OFONO_USSD_STATUS_TERMINATED: + return "TERMINATED"; + case OFONO_USSD_STATUS_LOCAL_CLIENT_RESPONDED: + return "LOCAL_CLIENT_RESPONDED"; + case OFONO_USSD_STATUS_NOT_SUPPORTED: + return "NOT_SUPPORTED"; + case OFONO_USSD_STATUS_TIMED_OUT: + return "TIMED_OUT"; + } + + return "????"; +} + +static const char *ussd_state_name(enum ussd_state state) +{ + switch (state) { + case USSD_STATE_IDLE: + return "IDLE"; + case USSD_STATE_ACTIVE: + return "ACTIVE"; + case USSD_STATE_RESPONSE_SENT: + return "RESPONSE_SENT"; + case USSD_STATE_USER_ACTION: + return "USER_ACTION"; + } + + return "????"; +} + + void ofono_ussd_notify(struct ofono_ussd *ussd, int status, int dcs, const unsigned char *data, int data_len) { @@ -362,6 +399,10 @@ void ofono_ussd_notify(struct ofono_ussd *ussd, int status, int dcs, DBusMessageIter iter; DBusMessageIter variant; + DBG("status: %d %s, state: %d %s", + status, ussd_status_name(status), + ussd->state, ussd_state_name(ussd->state)); + if (ussd->req && (status == OFONO_USSD_STATUS_NOTIFY || status == OFONO_USSD_STATUS_TERMINATED || -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [isimodem-ussd PATCH 3/5] test-ussd: read stdin for Response()s 2010-09-16 17:32 ` [isimodem-ussd PATCH 2/5] ussd: debug log notifys Pekka.Pessi @ 2010-09-16 17:32 ` Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 4/5] isimodem/debug: debug USSD type Pekka.Pessi 0 siblings, 1 reply; 8+ messages in thread From: Pekka.Pessi @ 2010-09-16 17:32 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1326 bytes --] From: Pekka Pessi <Pekka.Pessi@nokia.com> --- test/test-ussd | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/test/test-ussd b/test/test-ussd index 6e24de8..d4c1e27 100755 --- a/test/test-ussd +++ b/test/test-ussd @@ -2,10 +2,13 @@ import sys import gobject +import os import dbus import dbus.mainloop.glib +state = None + def ussd_notification_received(content): print("Network sent a Notification: " + content) @@ -14,9 +17,23 @@ def ussd_request_received(content): ss.Cancel() def ussd_property_changed(name, value): + global state if name != "State": return print("USSD session state is " + value) + state = str(value) + +def stdin_handler(fd, condition): + s = os.read(fd.fileno(), 160).rstrip() + if not s: + ss.Cancel() + elif state == "user-response": + print ss.Respond(s, timeout = 100) + elif state == "idle": + print ss.Initiate(s, timeout = 100) + else: + print "Invalid state", state + return True if __name__ == "__main__": if (len(sys.argv) < 2): @@ -44,5 +61,7 @@ if __name__ == "__main__": print ss.Initiate(sys.argv[1], timeout=100) + gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler) + mainloop = gobject.MainLoop() mainloop.run() -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [isimodem-ussd PATCH 4/5] isimodem/debug: debug USSD type 2010-09-16 17:32 ` [isimodem-ussd PATCH 3/5] test-ussd: read stdin for Response()s Pekka.Pessi @ 2010-09-16 17:32 ` Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 5/5] isimodem/ussd: fix mobile-terminated cases Pekka.Pessi 0 siblings, 1 reply; 8+ messages in thread From: Pekka.Pessi @ 2010-09-16 17:32 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1294 bytes --] From: Pekka Pessi <Pekka.Pessi@nokia.com> --- drivers/isimodem/debug.c | 13 +++++++++++++ drivers/isimodem/debug.h | 1 + 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/isimodem/debug.c b/drivers/isimodem/debug.c index b398797..d226c51 100644 --- a/drivers/isimodem/debug.c +++ b/drivers/isimodem/debug.c @@ -70,6 +70,19 @@ const char *ss_message_id_name(enum ss_message_id value) return "SS_<UNKNOWN>"; } +const char *ss_ussd_type_name(enum ss_ussd_type value) +{ + switch (value) { + _(SS_GSM_USSD_MT_REPLY); + _(SS_GSM_USSD_COMMAND); + _(SS_GSM_USSD_REQUEST); + _(SS_GSM_USSD_NOTIFY); + _(SS_GSM_USSD_END); + } + return "SS_<UNKNOWN>"; +} + + const char *ss_subblock_name(enum ss_subblock value) { switch (value) { diff --git a/drivers/isimodem/debug.h b/drivers/isimodem/debug.h index 1ad5547..f03f4ec 100644 --- a/drivers/isimodem/debug.h +++ b/drivers/isimodem/debug.h @@ -34,6 +34,7 @@ const char *ss_message_id_name(enum ss_message_id value); const char *ss_subblock_name(enum ss_subblock value); +const char *ss_ussd_type_name(enum ss_ussd_type value); const char *mtc_isi_cause_name(enum mtc_isi_cause value); const char *mtc_message_id_name(enum mtc_message_id value); -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [isimodem-ussd PATCH 5/5] isimodem/ussd: fix mobile-terminated cases 2010-09-16 17:32 ` [isimodem-ussd PATCH 4/5] isimodem/debug: debug USSD type Pekka.Pessi @ 2010-09-16 17:32 ` Pekka.Pessi 0 siblings, 0 replies; 8+ messages in thread From: Pekka.Pessi @ 2010-09-16 17:32 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 5711 bytes --] From: Pekka Pessi <Pekka.Pessi@nokia.com> ACK notifys. Handle mobile-terminated requests gracefully. --- drivers/isimodem/ussd.c | 130 +++++++++++++++++++++++++++------------------- 1 files changed, 76 insertions(+), 54 deletions(-) diff --git a/drivers/isimodem/ussd.c b/drivers/isimodem/ussd.c index 2f4091c..94fe4d7 100644 --- a/drivers/isimodem/ussd.c +++ b/drivers/isimodem/ussd.c @@ -1,7 +1,7 @@ /* * This file is part of oFono - Open Source Telephony * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Aki Niemi <aki.niemi@nokia.com> * @@ -50,41 +50,84 @@ struct ussd_data { GIsiClient *client; + int mt_session; }; -static inline int isi_type_to_status(uint8_t type) +static void ussd_notify_ack(struct ussd_data *ud) { + const unsigned char msg[] = { + SS_GSM_USSD_SEND_REQ, + SS_GSM_USSD_NOTIFY, + 0x00 /* subblock count */ + }; + + g_isi_send(ud->client, msg, sizeof(msg), SS_TIMEOUT, NULL, NULL, NULL); +} + +static void ussd_ind_cb(GIsiClient *client, + const void *restrict data, size_t len, + uint16_t object, void *opaque) +{ + const unsigned char *msg = data; + struct ofono_ussd *ussd = opaque; + struct ussd_data *ud = ofono_ussd_get_data(ussd); + int dcs; + int type; + size_t ussdlen; + int status; + + if (!msg || len < 4 || msg[0] != SS_GSM_USSD_RECEIVE_IND) + return; + + dcs = msg[1]; + type = msg[2]; + ussdlen = msg[3]; + + if (len < 4 + ussdlen) + ussdlen = len - 4; + switch (type) { + case 0: + /* Nothing - this is response to NOTIFY_ACK REQ */ + return; + case SS_GSM_USSD_MT_REPLY: - return OFONO_USSD_STATUS_LOCAL_CLIENT_RESPONDED; + /* This never happens, but.. */ + status = OFONO_USSD_STATUS_LOCAL_CLIENT_RESPONDED; + break; + case SS_GSM_USSD_COMMAND: - return OFONO_USSD_STATUS_ACTION_REQUIRED; + if (ud->mt_session) + /* Ignore, we get SS_GSM_USSD_REQUEST, too */ + return; + status = OFONO_USSD_STATUS_ACTION_REQUIRED; + break; + case SS_GSM_USSD_NOTIFY: - return OFONO_USSD_STATUS_NOTIFY; + status = OFONO_USSD_STATUS_NOTIFY; + ussd_notify_ack(ud); + break; + case SS_GSM_USSD_END: - return OFONO_USSD_STATUS_TERMINATED; + status = OFONO_USSD_STATUS_TERMINATED; + ud->mt_session = 0; + break; + case SS_GSM_USSD_REQUEST: + ud->mt_session = 1; + status = OFONO_USSD_STATUS_ACTION_REQUIRED; + break; + default: - return OFONO_USSD_STATUS_NOT_SUPPORTED; + status = OFONO_USSD_STATUS_NOT_SUPPORTED; } -} - -static void ussd_parse(struct ofono_ussd *ussd, const void *restrict data, - size_t len) -{ - const unsigned char *msg = data; - int status = OFONO_USSD_STATUS_NOT_SUPPORTED; - if (!msg || len < 4) - ofono_ussd_notify(ussd, status, 0, NULL, 0); + DBG("type: %u %s, dcs: 0x%02x, len: %u", + type, ss_ussd_type_name(type), dcs, ussdlen); - status = isi_type_to_status(msg[2]); - - if (msg[3] == 0 || (size_t)(msg[3] + 4) > len) - ofono_ussd_notify(ussd, status, msg[1], msg + 4, msg[3]); + ofono_ussd_notify(ussd, status, dcs, msg + 4, ussdlen); } - static gboolean ussd_send_resp_cb(GIsiClient *client, const void *restrict data, size_t len, uint16_t object, void *opaque) @@ -104,12 +147,11 @@ static gboolean ussd_send_resp_cb(GIsiClient *client, if (msg[0] == SS_SERVICE_FAILED_RESP) goto error; - if (len < 4 || msg[0] != SS_GSM_USSD_SEND_RESP) + if (msg[0] != SS_GSM_USSD_SEND_RESP) return FALSE; CALLBACK_WITH_SUCCESS(cb, cbd->data); - ussd_parse(cbd->user, data, len); return TRUE; error: @@ -118,13 +160,17 @@ error: } -static GIsiRequest *ussd_send(GIsiClient *client, - int dcs, uint8_t const *str, size_t len, - void *data, GDestroyNotify notify) +static void isi_request(struct ofono_ussd *ussd, int dcs, + const unsigned char *pdu, int len, + ofono_ussd_cb_t cb, void *data) { + struct ussd_data *ud = ofono_ussd_get_data(ussd); + struct isi_cb_data *cbd = isi_cb_data_new(ussd, cb, data); const uint8_t msg[] = { SS_GSM_USSD_SEND_REQ, - SS_GSM_USSD_COMMAND, + ud->mt_session + ? SS_GSM_USSD_MT_REPLY + : SS_GSM_USSD_COMMAND, 0x01, /* subblock count */ SS_GSM_USSD_STRING, 4 + len + 3, /* subblock length */ @@ -132,27 +178,16 @@ static GIsiRequest *ussd_send(GIsiClient *client, len, /* string length */ /* USSD string goes here */ }; - const struct iovec iov[2] = { { (uint8_t *)msg, sizeof(msg) }, - { (uint8_t *)str, len } + { (uint8_t *)pdu, len } }; - return g_isi_vsend(client, iov, 2, SS_TIMEOUT, - ussd_send_resp_cb, data, notify); -} - -static void isi_request(struct ofono_ussd *ussd, int dcs, - const unsigned char *pdu, int len, - ofono_ussd_cb_t cb, void *data) -{ - struct ussd_data *ud = ofono_ussd_get_data(ussd); - struct isi_cb_data *cbd = isi_cb_data_new(ussd, cb, data); - if (!cbd) goto error; - if (ussd_send(ud->client, dcs, pdu, len, cbd, g_free)) + if (g_isi_vsend(ud->client, iov, 2, SS_TIMEOUT, + ussd_send_resp_cb, cbd, g_free)) return; error: @@ -184,19 +219,6 @@ error: g_free(cbd); } -static void ussd_ind_cb(GIsiClient *client, - const void *restrict data, size_t len, - uint16_t object, void *opaque) -{ - const unsigned char *msg = data; - struct ofono_ussd *ussd = opaque; - - if (!msg || len < 4 || msg[0] != SS_GSM_USSD_RECEIVE_IND) - return; - - ussd_parse(ussd, data, len); -} - static gboolean isi_ussd_register(gpointer user) { struct ofono_ussd *ussd = user; -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [isimodem-ussd PATCH 0/5] USSD fixes 2010-09-16 17:32 [isimodem-ussd PATCH 0/5] USSD fixes Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 1/5] ussd.h: +CUSD is documented in 27.007 section 7.15 Pekka.Pessi @ 2010-09-16 18:54 ` Denis Kenzior 2010-09-17 12:35 ` Pekka Pessi 1 sibling, 1 reply; 8+ messages in thread From: Denis Kenzior @ 2010-09-16 18:54 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 588 bytes --] Hi Pekka, On 09/16/2010 12:32 PM, Pekka.Pessi(a)nokia.com wrote: > Hi all, > > I've updated the isimodem ussd implementation to allow network-initiated > operations. I've added some debug logging to the core ussd, too. > > The isimodem ussd now works with simple USSD applications with > puSS-Request and uSS-Requests, but uSS-Notifys while a mobile-originated > puSS-Request is pending seem not to work properly. > All five patches have been pushed. I did get a small compilation error (64 bit system). Please check that the fix is appropriate. Regards, -Denis ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [isimodem-ussd PATCH 0/5] USSD fixes 2010-09-16 18:54 ` [isimodem-ussd PATCH 0/5] USSD fixes Denis Kenzior @ 2010-09-17 12:35 ` Pekka Pessi 0 siblings, 0 replies; 8+ messages in thread From: Pekka Pessi @ 2010-09-17 12:35 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 266 bytes --] Hi Denis, 2010/9/16 Denis Kenzior <denkenz@gmail.com>: > All five patches have been pushed. I did get a small compilation error > (64 bit system). Please check that the fix is appropriate. Cool. The fix is perfect. -- Pekka.Pessi mail at nokia.com ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-09-17 12:35 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-09-16 17:32 [isimodem-ussd PATCH 0/5] USSD fixes Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 1/5] ussd.h: +CUSD is documented in 27.007 section 7.15 Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 2/5] ussd: debug log notifys Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 3/5] test-ussd: read stdin for Response()s Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 4/5] isimodem/debug: debug USSD type Pekka.Pessi 2010-09-16 17:32 ` [isimodem-ussd PATCH 5/5] isimodem/ussd: fix mobile-terminated cases Pekka.Pessi 2010-09-16 18:54 ` [isimodem-ussd PATCH 0/5] USSD fixes Denis Kenzior 2010-09-17 12:35 ` Pekka Pessi
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.