How to start ofono-phonesim in ubuntu-10.04 -reg
Hi Zhenhua, Thanks for your reply.. I added the following code in /usr/share/alsa/pcm/modem.conf file... 1. # #Sample for using phone simulator # [phonesim] Driver=phonesim Address=127.0.0.1 port=12345 - I tried to ./list_modems. I got nothing on command prompt. According to my knowledge i should get the available modems (atleast phonesim0) I tried to enable the modem using the following command.. ./enable-modem /phonesim0 I got output as follows... -- Connecting modem /phonesim0... Traceback (most recent call last): File ./enable-modem, line 20, in module modem.SetProperty(Powered, dbus.Boolean(1)) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 68, in __call__ return self._proxy_method(*args, **keywords) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 140, in __call__ **keywords) File /usr/lib/pymodules/python2.6/dbus/connection.py, line 620, in call_blocking message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist -- Have a nice time. Regards, Krishna K Kandula _ Bollywood This Decade http://entertainment.in.msn.com/bollywoodthisdecade/___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
RE: How to start ofono-phonesim in ubuntu-10.04 -reg
Hi Krishna, You should put your modem.conf file under /etc/ofono/. Thanks, Yoon From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of krishna k Sent: Monday, May 10, 2010 3:43 PM To: ofono@ofono.org Subject: How to start ofono-phonesim in ubuntu-10.04 -reg Hi Zhenhua, Thanks for your reply.. I added the following code in /usr/share/alsa/pcm/modem.conf file... 1. # #Sample for using phone simulator # [phonesim] Driver=phonesim Address=127.0.0.1 port=12345 - I tried to ./list_modems. I got nothing on command prompt. According to my knowledge i should get the available modems (atleast phonesim0) I tried to enable the modem using the following command.. ./enable-modem /phonesim0 I got output as follows... -- Connecting modem /phonesim0... Traceback (most recent call last): File ./enable-modem, line 20, in module modem.SetProperty(Powered, dbus.Boolean(1)) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 68, in __call__ return self._proxy_method(*args, **keywords) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 140, in __call__ **keywords) File /usr/lib/pymodules/python2.6/dbus/connection.py, line 620, in call_blocking message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist -- Have a nice time. Regards, Krishna K Kandula The battle for the FIH Hockey World Cup Drag n' drop ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
RE: How to start ofono-phonesim in ubuntu-10.04 -reg
Hi Krishna, From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of krishna k Sent: Monday, May 10, 2010 2:43 PM To: ofono@ofono.org Subject: How to start ofono-phonesim in ubuntu-10.04 -reg Hi Zhenhua, Thanks for your reply.. I added the following code in /usr/share/alsa/pcm/modem.conf file... [Zhenhua] Please put modem.conf under /etc/ofono. You should see phonesim0 from list_modems output like your E71 modem. 1. # #Sample for using phone simulator # [phonesim] Driver=phonesim Address=127.0.0.1 port=12345 - I tried to ./list_modems. I got nothing on command prompt. According to my knowledge i should get the available modems (atleast phonesim0) I tried to enable the modem using the following command.. ./enable-modem /phonesim0 I got output as follows... -- Connecting modem /phonesim0... Traceback (most recent call last): File ./enable-modem, line 20, in module modem.SetProperty(Powered, dbus.Boolean(1)) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 68, in __call__ return self._proxy_method(*args, **keywords) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 140, in __call__ **keywords) File /usr/lib/pymodules/python2.6/dbus/connection.py, line 620, in call_blocking message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist -- Have a nice time. Regards, Krishna K Kandula The battle for the FIH Hockey World Cup Drag n' drop http://specials.msn.co.in/sp10/hockey/index.aspx ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
How to start ofono-phonesim in ubuntu-10.04 -reg
Hi Yoon, I placed modem.conf file under /etc/ofono, and i tried with ./test/list-modems script. Still it is not showing any thing on command line. I tried to enable the phonesim0 modem with following command and i am getting the same o/p == ./enable-modem /phonesim0 **etc. dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist. == The same error as below. It is not able to detect the phonesim0? regards, Krishna K Kandula. Hi Krishna, You should put your modem.conf file under /etc/ofono/. Thanks, Yoon From: ofono-bounces at ofono.org [mailto:ofono-bounces at ofono.org] On Behalf Of krishna k Sent: Monday, May 10, 2010 3:43 PM To: ofono at ofono.org Subject: How to start ofono-phonesim in ubuntu-10.04 -reg Hi Zhenhua, Thanks for your reply.. I added the following code in /usr/share/alsa/pcm/modem.conf file... 1. # #Sample for using phone simulator # [phonesim] Driver=phonesim Address=127.0.0.1 port=12345 - I tried to ./list_modems. I got nothing on command prompt. According to my knowledge i should get the available modems (atleast phonesim0) I tried to enable the modem using the following command.. ./enable-modem /phonesim0 I got output as follows... -- Connecting modem /phonesim0... Traceback (most recent call last): File ./enable-modem, line 20, in module modem.SetProperty(Powered, dbus.Boolean(1)) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 68, in __call__ return self._proxy_method(*args, **keywords) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 140, in __call__ **keywords) File /usr/lib/pymodules/python2.6/dbus/connection.py, line 620, in call_blocking message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist -- Have a nice time. Regards, Krishna K Kandula _ Bollywood This Decade http://entertainment.in.msn.com/bollywoodthisdecade/___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
RE: How to start ofono-phonesim in ubuntu-10.04 -reg
Hi Krishna, From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of krishna k Sent: Monday, May 10, 2010 4:13 PM To: ofono@ofono.org Subject: How to start ofono-phonesim in ubuntu-10.04 -reg Hi Yoon, I placed modem.conf file under /etc/ofono, and i tried with ./test/list-modems script. Still it is not showing any thing on command line. I tried to enable the phonesim0 modem with following command and i am getting the same o/p [Zhenhua] Do you build oFono with bootscrap-configure? If does, you will have '--prefix=/usr --sysconfdir=/etc ...' configuration. So oFono reads configuration from /etc/ofono. Without that, you might put modem.conf under /usr/local/etc/ofono. Btw, you could raise your question on our IRC room #ofono at irc.freenode.net as well. == ./enable-modem /phonesim0 **etc. dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist. == The same error as below. It is not able to detect the phonesim0? regards, Krishna K Kandula. Hi Krishna, You should put your modem.conf file under /etc/ofono/. Thanks, Yoon From: ofono-bounces at ofono.org http://lists.ofono.org/listinfo/ofono [mailto:ofono-bounces at ofono.org http://lists.ofono.org/listinfo/ofono ] On Behalf Of krishna k Sent: Monday, May 10, 2010 3:43 PM To: ofono at ofono.org http://lists.ofono.org/listinfo/ofono Subject: How to start ofono-phonesim in ubuntu-10.04 -reg Hi Zhenhua, Thanks for your reply.. I added the following code in /usr/share/alsa/pcm/modem.conf file... 1. # #Sample for using phone simulator # [phonesim] Driver=phonesim Address=127.0.0.1 port=12345 - I tried to ./list_modems. I got nothing on command prompt. According to my knowledge i should get the available modems (atleast phonesim0) I tried to enable the modem using the following command.. ./enable-modem /phonesim0 I got output as follows... -- Connecting modem /phonesim0... Traceback (most recent call last): File ./enable-modem, line 20, in module modem.SetProperty(Powered, dbus.Boolean(1)) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 68, in __call__ return self._proxy_method(*args, **keywords) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 140, in __call__ **keywords) File /usr/lib/pymodules/python2.6/dbus/connection.py, line 620, in call_blocking message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist -- Have a nice time. Regards, Krishna K Kandula The battle for the FIH Hockey World Cup Drag n' drop http://specials.msn.co.in/sp10/hockey/index.aspx ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
How to start ofono-phonesim in ubuntu-10.04 -reg
Hi Zhenhua, I installed ofono-phonesim from Synaptic Package Manager (Ubuntu Lucid have this facility). I guess it is with bootscrap-configure only. So that I am able to find ofono directory in /etc (/etc/ofono). I placed my modem.conf file inside /etc/ofono. After that also it is giving the same problem... I tried to list the modem with the following command... ./ofono/test/list-modems === Traceback (most recent call last): File ./ofono/test/list-modems, line 7, in module manager = dbus.Interface(bus.get_object('org.ofono', '/'), File /usr/lib/pymodules/python2.6/dbus/bus.py, line 244, in get_object follow_name_owner_changes=follow_name_owner_changes) File /usr/lib/pymodules/python2.6/dbus/proxies.py, line 241, in __init__ self._named_service = conn.activate_name_owner(bus_name) File /usr/lib/pymodules/python2.6/dbus/bus.py, line 183, in activate_name_owner self.start_service_by_name(bus_name) File /usr/lib/pymodules/python2.6/dbus/bus.py, line 281, in start_service_by_name 'su', (bus_name, flags))) File /usr/lib/pymodules/python2.6/dbus/connection.py, line 620, in call_blocking message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.ofono was not provided by any .service files === regards, Krishna K Kandula. Hi Krishna, From: ofono-bounces at ofono.org [mailto:ofono-bounces at ofono.org] On Behalf Of krishna k Sent: Monday, May 10, 2010 4:13 PM To: ofono at ofono.org Subject: How to start ofono-phonesim in ubuntu-10.04 -reg Hi Yoon, I placed modem.conf file under /etc/ofono, and i tried with ./test/list-modems script. Still it is not showing any thing on command line. I tried to enable the phonesim0 modem with following command and i am getting the same o/p [Zhenhua] Do you build oFono with bootscrap-configure? If does, you will have '--prefix=/usr --sysconfdir=/etc ...' configuration. So oFono reads configuration from /etc/ofono. Without that, you might put modem.conf under /usr/local/etc/ofono. Btw, you could raise your question on our IRC room #ofono at irc.freenode.net as well. == ./enable-modem /phonesim0 **etc. dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method SetProperty with signature sb on interface org.ofono.Modem doesn't exist. == The same error as below. It is not able to detect the phonesim0? regards, Krishna K Kandula. Hi Krishna, You should put your modem.conf file under /etc/ofono/. Thanks, Yoon From: ofono-bounces at ofono.org http://lists.ofono.org/listinfo/ofono [mailto:ofono-bounces at ofono.org http://lists.ofono.org/listinfo/ofono ] On Behalf Of krishna k Sent: Monday, May 10, 2010 3:43 PM To: ofono at ofono.org http://lists.ofono.org/listinfo/ofono Subject: How to start ofono-phonesim in ubuntu-10.04 -reg Hi Zhenhua, Thanks for your reply.. I added the following code in /usr/share/alsa/pcm/modem.conf file... 1. # #Sample for using phone simulator # [phonesim] Driver=phonesim Address=127.0.0.1 port=12345 - I tried to ./list_modems. I got nothing on command prompt. According to my knowledge i should get the available modems (atleast phonesim0) I tried to enable the modem using the following command.. ./enable-modem /phonesim0 I got output as follows... -- Connecting modem /phonesim0... Traceback (most recent call last): File ./enable-modem, line 20, in module modem.SetProperty(Powered, dbus.Boolean(1)) File
[PATCH 01/19] stkutil: Free default text for get input parser
--- src/stkutil.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 50fa4c1..09fbec9 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2149,6 +2149,7 @@ static gboolean parse_get_inkey(struct stk_command *command, static void destroy_get_input(struct stk_command *command) { g_free(command-get_input.text); + g_free(command-get_input.default_text); } static gboolean parse_get_input(struct stk_command *command, -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 02/19] test-stkutil: Add unit test for get input parser
--- unit/test-stkutil.c | 1412 ++- 1 files changed, 1392 insertions(+), 20 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index 82f2a1c..abb82c9 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -60,9 +60,23 @@ static void check_duration(const struct stk_duration *command, g_assert(command-interval == test-interval); } +/* Defined in TS 102.223 Section 8.11 */ +static void check_response_length(const struct stk_response_length *command, + const struct stk_response_length *test) +{ + g_assert(command-min == test-min); + g_assert(command-max == test-max); +} + /* Defined in TS 102.223 Section 8.15 */ static inline void check_text(const char *command, const char *test) { + if (test == NULL) { + g_assert(command == NULL); + return; + } + + g_assert(command != NULL); g_assert(g_str_equal(command, test)); } @@ -1284,11 +1298,12 @@ struct get_input_test { const unsigned char *pdu; unsigned int pdu_len; unsigned char qualifier; - const char *expected; - unsigned char min; - unsigned char max; - unsigned char icon_qualifier; - unsigned char icon_id; + char *text; + struct stk_response_length response_length; + char *default_text; + struct stk_icon_id icon_id; + struct stk_text_attribute text_attribute; + struct stk_frame_id frame_id; }; static unsigned char get_input_111[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x23, @@ -1298,13 +1313,1262 @@ static unsigned char get_input_111[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x23, 0x32, 0x33, 0x34, 0x35, 0x91, 0x02, 0x05, 0x05 }; +static unsigned char get_input_121[] = { 0xD0, 0x1A, 0x81, 0x03, 0x01, 0x23, + 0x08, 0x82, 0x02, 0x81, 0x82, + 0x8D, 0x0B, 0x00, 0x45, 0x37, + 0xBD, 0x2C, 0x07, 0xD9, 0x6E, + 0xAA, 0xD1, 0x0A, 0x91, 0x02, + 0x05, 0x05 }; + +static unsigned char get_input_131[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x23, + 0x01, 0x82, 0x02, 0x81, 0x82, + 0x8D, 0x0C, 0x04, 0x45, 0x6E, + 0x74, 0x65, 0x72, 0x20, 0x41, + 0x62, 0x43, 0x64, 0x45, 0x91, + 0x02, 0x05, 0x05 }; + +static unsigned char get_input_141[] = { 0xD0, 0x27, 0x81, 0x03, 0x01, 0x23, + 0x04, 0x82, 0x02, 0x81, 0x82, + 0x8D, 0x18, 0x04, 0x50, 0x61, + 0x73, 0x73, 0x77, 0x6F, 0x72, + 0x64, 0x20, 0x31, 0x3C, 0x53, + 0x45, 0x4E, 0x44, 0x3E, 0x32, + 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x91, 0x02, 0x04, 0x08 }; + +static unsigned char get_input_151[] = { 0xD0, 0x24, 0x81, 0x03, 0x01, 0x23, + 0x00, 0x82, 0x02, 0x81, 0x82, + 0x8D, 0x15, 0x04, 0x45, 0x6E, + 0x74, 0x65, 0x72, 0x20, 0x31, + 0x2E, 0x2E, 0x39, 0x2C, 0x30, + 0x2E, 0x2E, 0x39, 0x2C, 0x30, + 0x28, 0x31, 0x29, 0x91, 0x02, + 0x01, 0x14 }; + +static unsigned char get_input_161[] = { 0xD0, 0x1E, 0x81, 0x03, 0x01, 0x23, + 0x00, 0x82, 0x02, 0x81, 0x82, + 0x8D, 0x0F, 0x04, 0x3C, 0x47, + 0x4F, 0x2D, 0x42, 0x41, 0x43, + 0x4B, 0x57, 0x41, 0x52, 0x44, + 0x53, 0x3E, 0x91, 0x02, 0x00, + 0x08 }; + +static unsigned char get_input_171[] = { 0xD0, 0x17, 0x81, 0x03, 0x01, 0x23, + 0x00, 0x82, 0x02, 0x81, 0x82, + 0x8D, 0x08, 0x04, 0x3C, 0x41, + 0x42, 0x4F, 0x52, 0x54, 0x3E, + 0x91, 0x02, 0x00, 0x08 }; + +static unsigned char get_input_181[] = { 0xD0, 0x81,
[PATCH 05/19] stkutil: Add play tone proactive command parser
--- src/stkutil.c | 42 ++ src/stkutil.h | 10 ++ 2 files changed, 52 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 5bddb93..0f0ea34 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2200,6 +2200,45 @@ static gboolean parse_more_time(struct stk_command *command, return TRUE; } +static void destroy_play_tone(struct stk_command *command) +{ + g_free(command-play_tone.alpha_id); +} + +static gboolean parse_play_tone(struct stk_command *command, + struct comprehension_tlv_iter *iter) +{ + struct stk_command_play_tone *obj = command-play_tone; + gboolean ret; + + if (command-src != STK_DEVICE_IDENTITY_TYPE_UICC) + return FALSE; + + if (command-dst != STK_DEVICE_IDENTITY_TYPE_EARPIECE) + return FALSE; + + ret = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_ALPHA_ID, 0, + obj-alpha_id, + STK_DATA_OBJECT_TYPE_TONE, 0, + obj-tone, + STK_DATA_OBJECT_TYPE_DURATION, 0, + obj-duration, + STK_DATA_OBJECT_TYPE_ICON_ID, 0, + obj-icon_id, + STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, + obj-text_attr, + STK_DATA_OBJECT_TYPE_FRAME_ID, 0, + obj-frame_id, + STK_DATA_OBJECT_TYPE_INVALID); + + if (ret == FALSE) + return FALSE; + + command-destructor = destroy_play_tone; + + return TRUE; +} + static void destroy_send_sms(struct stk_command *command) { g_free(command-send_sms.alpha_id); @@ -2317,6 +2356,9 @@ struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu, case STK_COMMAND_TYPE_MORE_TIME: ok = parse_more_time(command, iter); break; + case STK_COMMAND_TYPE_PLAY_TONE: + ok = parse_play_tone(command, iter); + break; case STK_COMMAND_TYPE_SEND_SMS: ok = parse_send_sms(command, iter); break; diff --git a/src/stkutil.h b/src/stkutil.h index 70c6b01..00c001b 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -815,6 +815,15 @@ struct stk_command_get_input { struct stk_frame_id frame_id; }; +struct stk_command_play_tone { + char *alpha_id; + unsigned char tone; + struct stk_duration duration; + struct stk_icon_id icon_id; + struct stk_text_attribute text_attr; + struct stk_frame_id frame_id; +}; + struct stk_command_send_sms { char *alpha_id; struct stk_address address; @@ -835,6 +844,7 @@ struct stk_command { struct stk_command_display_text display_text; struct stk_command_get_inkey get_inkey; struct stk_command_get_input get_input; + struct stk_command_play_tone play_tone; struct stk_command_send_sms send_sms; }; -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 03/19] stk: Unify variable names to use abbreviation
--- src/stkutil.c |8 +- src/stkutil.h |8 +- unit/test-stkutil.c | 161 +-- 3 files changed, 88 insertions(+), 89 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 09fbec9..5bddb93 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2095,7 +2095,7 @@ static gboolean parse_display_text(struct stk_command *command, STK_DATA_OBJECT_TYPE_DURATION, 0, obj-duration, STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, - obj-text_attribute, + obj-text_attr, STK_DATA_OBJECT_TYPE_FRAME_ID, 0, obj-frame_id, STK_DATA_OBJECT_TYPE_INVALID); @@ -2169,13 +2169,13 @@ static gboolean parse_get_input(struct stk_command *command, obj-text, STK_DATA_OBJECT_TYPE_RESPONSE_LENGTH, DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM, - obj-response_length, + obj-resp_len, STK_DATA_OBJECT_TYPE_DEFAULT_TEXT, 0, obj-default_text, STK_DATA_OBJECT_TYPE_ICON_ID, 0, obj-icon_id, STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, - obj-text_attribute, + obj-text_attr, STK_DATA_OBJECT_TYPE_FRAME_ID, 0, obj-frame_id, STK_DATA_OBJECT_TYPE_INVALID); @@ -2228,7 +2228,7 @@ static gboolean parse_send_sms(struct stk_command *command, STK_DATA_OBJECT_TYPE_ICON_ID, 0, obj-icon_id, STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, - obj-text_attribute, + obj-text_attr, STK_DATA_OBJECT_TYPE_FRAME_ID, 0, obj-frame_id, STK_DATA_OBJECT_TYPE_INVALID); diff --git a/src/stkutil.h b/src/stkutil.h index 41c03a7..70c6b01 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -794,7 +794,7 @@ struct stk_command_display_text { struct stk_icon_id icon_id; ofono_bool_t immediate_response; struct stk_duration duration; - struct stk_text_attribute text_attribute; + struct stk_text_attribute text_attr; struct stk_frame_id frame_id; }; @@ -808,10 +808,10 @@ struct stk_command_get_inkey { struct stk_command_get_input { char *text; - struct stk_response_length response_length; + struct stk_response_length resp_len; char *default_text; struct stk_icon_id icon_id; - struct stk_text_attribute text_attribute; + struct stk_text_attribute text_attr; struct stk_frame_id frame_id; }; @@ -820,7 +820,7 @@ struct stk_command_send_sms { struct stk_address address; struct sms gsm_sms; struct stk_icon_id icon_id; - struct stk_text_attribute text_attribute; + struct stk_text_attribute text_attr; struct stk_frame_id frame_id; }; diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index abb82c9..6d57109 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -113,7 +113,7 @@ struct display_text_test { struct stk_icon_id icon_id; ofono_bool_t immediate_response; struct stk_duration duration; - struct stk_text_attribute text_attribute; + struct stk_text_attribute text_attr; struct stk_frame_id frame_id; }; @@ -352,8 +352,8 @@ static void test_display_text(gconstpointer data) check_common_bool(command-display_text.immediate_response, test-immediate_response); check_duration(command-display_text.duration, test-duration); - check_text_attr(command-display_text.text_attribute, - test-text_attribute); + check_text_attr(command-display_text.text_attr, + test-text_attr); check_frame_id(command-display_text.frame_id, test-frame_id); stk_command_free(command); @@ -1299,10 +1299,10 @@ struct get_input_test { unsigned int pdu_len; unsigned char qualifier; char *text; - struct stk_response_length response_length; + struct stk_response_length resp_len; char *default_text; struct stk_icon_id icon_id; - struct stk_text_attribute text_attribute; + struct stk_text_attribute text_attr; struct stk_frame_id frame_id; }; @@ -1864,7 +1864,7 @@
[PATCH 04/19] test-stkutil: Use enum for icon_id
--- unit/test-stkutil.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index 6d57109..e1f6a3e 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -270,7 +270,7 @@ static struct display_text_test display_text_data_511 = { .qualifier = 0x80, .text = Basic Icon, .icon_id = { - .qualifier = 0x00, + .qualifier = STK_ICON_QUALIFIER_TYPE_SELF_EXPLANATORY, .id = 0x01 } }; @@ -281,7 +281,7 @@ static struct display_text_test display_text_data_521 = { .qualifier = 0x80, .text = Colour Icon, .icon_id = { - .qualifier = 0x00, + .qualifier = STK_ICON_QUALIFIER_TYPE_SELF_EXPLANATORY, .id = 0x02 } }; @@ -292,7 +292,7 @@ static struct display_text_test display_text_data_531 = { .qualifier = 0x80, .text = Basic Icon, .icon_id = { - .qualifier = 0x01, + .qualifier = STK_ICON_QUALIFIER_TYPE_NON_SELF_EXPLANATORY, .id = 0x01 } }; -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 07/19] stkutil: Refactor parser for tone objects
--- src/stkutil.c | 13 ++--- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 0f0ea34..44cef10 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -511,17 +511,8 @@ static gboolean parse_dataobj_text(struct comprehension_tlv_iter *iter, static gboolean parse_dataobj_tone(struct comprehension_tlv_iter *iter, void *user) { - unsigned char *tone = user; - const unsigned char *data; - - if (comprehension_tlv_iter_get_length(iter) != 1) - return FALSE; - - data = comprehension_tlv_iter_get_data(iter); - - *tone = data[0]; - - return TRUE; + unsigned char *byte = user; + return parse_dataobj_common_byte(iter, byte); } /* Defined in TS 102.223 Section 8.18 */ -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 09/19] stkutil: Add poll interval proactive command parser
--- src/stkutil.c | 27 +++ src/stkutil.h |1 + 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 44cef10..2074d19 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2230,6 +2230,30 @@ static gboolean parse_play_tone(struct stk_command *command, return TRUE; } +static gboolean parse_poll_interval(struct stk_command *command, + struct comprehension_tlv_iter *iter) +{ + gboolean ret; + + if (command-src != STK_DEVICE_IDENTITY_TYPE_UICC) + return FALSE; + + if (command-dst != STK_DEVICE_IDENTITY_TYPE_TERMINAL) + return FALSE; + + ret = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_DURATION, + DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM, + command-duration, + STK_DATA_OBJECT_TYPE_INVALID); + + if (ret == FALSE) + return FALSE; + + command-destructor = NULL; + + return TRUE; +} + static void destroy_send_sms(struct stk_command *command) { g_free(command-send_sms.alpha_id); @@ -2350,6 +2374,9 @@ struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu, case STK_COMMAND_TYPE_PLAY_TONE: ok = parse_play_tone(command, iter); break; + case STK_COMMAND_TYPE_POLL_INTERVAL: + ok = parse_poll_interval(command, iter); + break; case STK_COMMAND_TYPE_SEND_SMS: ok = parse_send_sms(command, iter); break; diff --git a/src/stkutil.h b/src/stkutil.h index 00c001b..dc25f99 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -841,6 +841,7 @@ struct stk_command { enum stk_device_identity_type dst; union { + struct stk_duration duration; struct stk_command_display_text display_text; struct stk_command_get_inkey get_inkey; struct stk_command_get_input get_input; -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 06/19] Replace check_text with check_common_text
--- unit/test-stkutil.c | 31 +++ 1 files changed, 15 insertions(+), 16 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index e1f6a3e..11b088b 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -52,6 +52,17 @@ static inline void check_common_bool(const ofono_bool_t command, g_assert(command == test); } +static inline void check_common_text(const char *command, const char *test) +{ + if (test == NULL) { + g_assert(command == NULL); + return; + } + + g_assert(command != NULL); + g_assert(g_str_equal(command, test)); +} + /* Defined in TS 102.223 Section 8.8 */ static void check_duration(const struct stk_duration *command, const struct stk_duration *test) @@ -68,18 +79,6 @@ static void check_response_length(const struct stk_response_length *command, g_assert(command-max == test-max); } -/* Defined in TS 102.223 Section 8.15 */ -static inline void check_text(const char *command, const char *test) -{ - if (test == NULL) { - g_assert(command == NULL); - return; - } - - g_assert(command != NULL); - g_assert(g_str_equal(command, test)); -} - /* Defined in TS 102.223 Section 8.31 */ static void check_icon_id(const struct stk_icon_id *command, const struct stk_icon_id *test) @@ -347,7 +346,7 @@ static void test_display_text(gconstpointer data) g_assert(command-dst == STK_DEVICE_IDENTITY_TYPE_DISPLAY); g_assert(command-display_text.text); - check_text(command-display_text.text, test-text); + check_common_text(command-display_text.text, test-text); check_icon_id(command-display_text.icon_id, test-icon_id); check_common_bool(command-display_text.immediate_response, test-immediate_response); @@ -1284,7 +1283,7 @@ static void test_get_inkey(gconstpointer data) g_assert(command-dst == STK_DEVICE_IDENTITY_TYPE_TERMINAL); g_assert(command-get_inkey.text); - check_text(command-get_inkey.text, test-text); + check_common_text(command-get_inkey.text, test-text); check_icon_id(command-get_inkey.icon_id, test-icon_id); check_duration(command-get_inkey.duration, test-duration); check_text_attr(command-get_inkey.text_attr, @@ -2590,9 +2589,9 @@ static void test_get_input(gconstpointer data) if (test-text) g_assert(command-get_input.text); - check_text(command-get_input.text, test-text); + check_common_text(command-get_input.text, test-text); check_response_length(command-get_input.resp_len, test-resp_len); - check_text(command-get_input.default_text, test-default_text); + check_common_text(command-get_input.default_text, test-default_text); check_icon_id(command-get_input.icon_id, test-icon_id); check_text_attr(command-get_input.text_attr, test-text_attr); -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 08/19] test-stkutil: Add unit test for play tone parser
--- unit/test-stkutil.c | 1356 +++ 1 files changed, 1356 insertions(+), 0 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index 11b088b..65688ea 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -52,6 +52,12 @@ static inline void check_common_bool(const ofono_bool_t command, g_assert(command == test); } +static inline void check_common_byte(const unsigned char command, + const unsigned char test) +{ + g_assert(command == test); +} + static inline void check_common_text(const char *command, const char *test) { if (test == NULL) { @@ -2635,6 +2641,1247 @@ static void test_more_time(gconstpointer data) stk_command_free(command); } +struct play_tone_test { + const unsigned char *pdu; + unsigned int pdu_len; + unsigned char qualifier; + char *alpha_id; + unsigned char tone; + struct stk_duration duration; + struct stk_icon_id icon_id; + struct stk_text_attribute text_attr; + struct stk_frame_id frame_id; +}; + +static unsigned char play_tone_111[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x09, 0x44, 0x69, 0x61, + 0x6C, 0x20, 0x54, 0x6F, 0x6E, + 0x65, 0x8E, 0x01, 0x01, 0x84, + 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_112[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x09, 0x53, 0x75, 0x62, + 0x2E, 0x20, 0x42, 0x75, 0x73, + 0x79, 0x8E, 0x01, 0x02, 0x84, + 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_113[] = { 0xD0, 0x1C, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x0A, 0x43, 0x6F, 0x6E, + 0x67, 0x65, 0x73, 0x74, 0x69, + 0x6F, 0x6E, 0x8E, 0x01, 0x03, + 0x84, 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_114[] = { 0xD0, 0x18, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x06, 0x52, 0x50, 0x20, + 0x41, 0x63, 0x6B, 0x8E, 0x01, + 0x04, 0x84, 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_115[] = { 0xD0, 0x17, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x05, 0x4E, 0x6F, 0x20, + 0x52, 0x50, 0x8E, 0x01, 0x05, + 0x84, 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_116[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x09, 0x53, 0x70, 0x65, + 0x63, 0x20, 0x49, 0x6E, 0x66, + 0x6F, 0x8E, 0x01, 0x06, 0x84, + 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_117[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x09, 0x43, 0x61, 0x6C, + 0x6C, 0x20, 0x57, 0x61, 0x69, + 0x74, 0x8E, 0x01, 0x07, 0x84, + 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_118[] = { 0xD0, 0x1B, 0x81, 0x03, 0x01, 0x20, + 0x00, 0x82, 0x02, 0x81, 0x03, + 0x85, 0x09, 0x52, 0x69, 0x6E, + 0x67, 0x20, 0x54, 0x6F, 0x6E, + 0x65, 0x8E, 0x01, 0x08, 0x84, + 0x02, 0x01, 0x05 }; + +static unsigned char play_tone_119[] = { 0xD0, 0x81, 0xFD, 0x81, 0x03, 0x01, + 0x20, 0x00, 0x82, 0x02, 0x81, + 0x03, 0x85, 0x81, 0xF1, 0x54, + 0x68, 0x69, 0x73, 0x20, 0x63, +
[PATCH 16/19] stkutil: Parse cdma tpdu in send sms parser
--- src/stkutil.c | 16 src/stkutil.h |1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index ebe1114..b6212b3 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2414,13 +2414,14 @@ static void destroy_send_sms(struct stk_command *command) { g_free(command-send_sms.alpha_id); g_free(command-send_sms.address.number); + g_free(command-send_sms.cdma_sms.array); } static gboolean parse_send_sms(struct stk_command *command, struct comprehension_tlv_iter *iter) { struct stk_command_send_sms *obj = command-send_sms; - struct gsm_sms_tpdu tpdu; + struct gsm_sms_tpdu gsm_tpdu; gboolean ret; if (command-src != STK_DEVICE_IDENTITY_TYPE_UICC) @@ -2434,7 +2435,9 @@ static gboolean parse_send_sms(struct stk_command *command, STK_DATA_OBJECT_TYPE_ADDRESS, 0, obj-address, STK_DATA_OBJECT_TYPE_GSM_SMS_TPDU, 0, - tpdu, + gsm_tpdu, + STK_DATA_OBJECT_TYPE_CDMA_SMS_TPDU, 0, + obj-cdma_sms, STK_DATA_OBJECT_TYPE_ICON_ID, 0, obj-icon_id, STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, @@ -2448,8 +2451,13 @@ static gboolean parse_send_sms(struct stk_command *command, command-destructor = destroy_send_sms; - if (sms_decode(tpdu.tpdu, tpdu.len, TRUE, tpdu.len, obj-gsm_sms) - == FALSE) { + if (gsm_tpdu.len 0) { + if (sms_decode(gsm_tpdu.tpdu, gsm_tpdu.len, TRUE, gsm_tpdu.len, + obj-gsm_sms) == FALSE) { + command-destructor(command); + return FALSE; + } + } else if (obj-cdma_sms.len == 0) { command-destructor(command); return FALSE; } diff --git a/src/stkutil.h b/src/stkutil.h index 143679f..b936ee9 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -850,6 +850,7 @@ struct stk_command_send_sms { char *alpha_id; struct stk_address address; struct sms gsm_sms; + struct stk_common_byte_array cdma_sms; struct stk_icon_id icon_id; struct stk_text_attribute text_attr; struct stk_frame_id frame_id; -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 12/19] test-stkutil: Add unit test for setup menu parser
--- unit/test-stkutil.c | 1617 ++- 1 files changed, 1616 insertions(+), 1 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index fdfaf68..941c443 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -23,7 +23,6 @@ #include config.h #endif -#include stdio.h #include unistd.h #include stdlib.h #include string.h @@ -35,6 +34,8 @@ #include smsutil.h #include stkutil.h +#define MAX_ITEM 100 + static gboolean g_mem_equal(const unsigned char *v1, const unsigned char *v2, unsigned int len) { @@ -77,6 +78,28 @@ static void check_duration(const struct stk_duration *command, g_assert(command-interval == test-interval); } +/* Defined in TS 102.223 Section 8.9 */ +static void check_item(const struct stk_item *command, + const struct stk_item *test) +{ + g_assert(command-id == test-id); + g_assert(g_str_equal(command-text, test-text)); +} + +static void check_items(GSList *command, const struct stk_item *test) +{ + struct stk_item *si; + GSList *l; + unsigned int i = 0; + + for (l = command; l; l = l-next) { + si = l-data; + check_item(si, test[i++]); + } + + g_assert(test[i].id == 0); +} + /* Defined in TS 102.223 Section 8.11 */ static void check_response_length(const struct stk_response_length *command, const struct stk_response_length *test) @@ -85,6 +108,15 @@ static void check_response_length(const struct stk_response_length *command, g_assert(command-max == test-max); } +/* Defined in TS 102.223 Section 8.24 */ +static void check_items_next_action_indicator( + const struct stk_items_next_action_indicator *command, + const struct stk_items_next_action_indicator *test) +{ + g_assert(command-len == test-len); + g_assert(g_mem_equal(command-list, test-list, test-len)); +} + /* Defined in TS 102.223 Section 8.31 */ static void check_icon_id(const struct stk_icon_id *command, const struct stk_icon_id *test) @@ -93,6 +125,15 @@ static void check_icon_id(const struct stk_icon_id *command, g_assert(command-qualifier == test-qualifier); } +/* Defined in TS 102.223 Section 8.32 */ +static void check_item_icon_id_list(const struct stk_item_icon_id_list *command, + const struct stk_item_icon_id_list *test) +{ + g_assert(command-qualifier == test-qualifier); + g_assert(command-len == test-len); + g_assert(g_mem_equal(command-list, test-list, test-len)); +} + /* Defined in TS 102.223 Section 8.72 */ static void check_text_attr(const struct stk_text_attribute *command, const struct stk_text_attribute *test) @@ -101,6 +142,15 @@ static void check_text_attr(const struct stk_text_attribute *command, g_assert(g_mem_equal(command-attributes, test-attributes, test-len)); } +/* Defined in TS 102.223 Section 8.73 */ +static void check_item_text_attribute_list( + const struct stk_item_text_attribute_list *command, + const struct stk_item_text_attribute_list *test) +{ + g_assert(command-len == test-len); + g_assert(g_mem_equal(command-list, test-list, test-len)); +} + /* Defined in TS 102.223 Section 8.80 */ static void check_frame_id(const struct stk_frame_id *command, const struct stk_frame_id *test) @@ -3925,6 +3975,1500 @@ static void test_poll_interval(gconstpointer data) stk_command_free(command); } +struct setup_menu_test { + const unsigned char *pdu; + unsigned int pdu_len; + unsigned char qualifier; + char *alpha_id; + struct stk_item items[MAX_ITEM]; + struct stk_items_next_action_indicator next_act; + struct stk_icon_id icon_id; + struct stk_item_icon_id_list item_icon_id_list; + struct stk_text_attribute text_attr; + struct stk_item_text_attribute_list item_text_attr_list; +}; + +static unsigned char setup_menu_111[] = { 0xD0, 0x3B, 0x81, 0x03, 0x01, 0x25, + 0x00, 0x82, 0x02, 0x81, 0x82, + 0x85, 0x0C, 0x54, 0x6F, 0x6F, + 0x6C, 0x6B, 0x69, 0x74, 0x20, + 0x4D, 0x65, 0x6E, 0x75, 0x8F, + 0x07, 0x01, 0x49, 0x74, 0x65, + 0x6D, 0x20, 0x31, 0x8F, 0x07, + 0x02, 0x49, 0x74, 0x65, 0x6D, + 0x20, 0x32, 0x8F, 0x07, 0x03, + 0x49, 0x74, 0x65, 0x6D, 0x20, +
[PATCH 17/19] test-stkutil: Refactor test for send sms parser
--- unit/test-stkutil.c | 132 -- 1 files changed, 84 insertions(+), 48 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index 52aa050..ffe0a3f 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -70,6 +70,27 @@ static inline void check_common_text(const char *command, const char *test) g_assert(g_str_equal(command, test)); } +static inline void check_common_byte_array( + const struct stk_common_byte_array *command, + const struct stk_common_byte_array *test) +{ + if (test-len == 0) { + g_assert(command-len == 0); + return; + } + + g_assert(command-len != 0); + g_assert(g_mem_equal(command-array, test-array, test-len)); +} + +/* Defined in TS 102.223 Section 8.1 */ +static inline void check_address(const struct stk_address *command, + const struct stk_address *test) +{ + g_assert(command-ton_npi == test-ton_npi); + g_assert(g_str_equal(command-number, test-number)); +} + /* Defined in TS 102.223 Section 8.2 */ static inline void check_alpha_id(const char *command, const char *test) { @@ -121,6 +142,18 @@ static void check_response_length(const struct stk_response_length *command, g_assert(command-max == test-max); } +/* Defined in TS 102.223 Section 8.13 */ +static void check_gsm_sms_tpdu(const struct sms *command, + const struct sms *test) +{ + g_assert(command-submit.mr == test-submit.mr); + g_assert(command-submit.udl == test-submit.udl); + g_assert(g_str_equal(command-submit.daddr.address, + test-submit.daddr.address)); + g_assert(g_mem_equal(command-submit.ud, test-submit.ud, + test-submit.udl)); +} + /* Defined in TS 102.223 Section 8.15 */ static inline void check_text(const char *command, const char *test) { @@ -173,6 +206,14 @@ static inline void check_imm_resp(const unsigned char command, check_common_byte(command, test); } +/* Defined in TS 102.223 Section 8.71 */ +static inline void check_cdma_sms_tpdu( + const struct stk_common_byte_array *command, + const struct stk_common_byte_array *test) +{ + check_common_byte_array(command, test); +} + /* Defined in TS 102.223 Section 8.72 */ static void check_text_attr(const struct stk_text_attribute *command, const struct stk_text_attribute *test) @@ -7443,45 +7484,51 @@ struct send_sms_test { const unsigned char *pdu; unsigned int pdu_len; unsigned char qualifier; - const char *alpha_id; - unsigned char ton_npi; - const char *address; - unsigned char sms_mr; - const char *sms_address; - unsigned char sms_udl; - const char *sms_ud; + char *alpha_id; + struct stk_address address; + struct sms gsm_sms; + struct stk_common_byte_array cdma_sms; + struct stk_icon_id icon_id; + struct stk_text_attribute text_attr; + struct stk_frame_id frame_id; }; /* 3GPP TS 31.124 Section 27.22.4.10.1.4.2 */ -static unsigned char send_sms_11[] = { 0xD0, 0x37, 0x81, 0x03, 0x01, 0x13, 0x00, - 0x82, 0x02, 0x81, 0x83, 0x85, 0x07, - 0x53, 0x65, 0x6E, 0x64, 0x20, 0x53, - 0x4D, 0x86, 0x09, 0x91, 0x11, 0x22, - 0x33, 0x44, 0x55, 0x66, 0x77, 0xF8, - 0x8B, 0x18, 0x01, 0x00, 0x09, 0x91, - 0x10, 0x32, 0x54, 0x76, 0xF8, 0x40, - 0xF4, 0x0C, 0x54, 0x65, 0x73, 0x74, - 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65 }; - -static struct send_sms_test send_sms_data_11 = { - .pdu = send_sms_11, - .pdu_len = sizeof(send_sms_11), +static unsigned char send_sms_111[] = { 0xD0, 0x37, 0x81, 0x03, 0x01, 0x13, + 0x00, 0x82, 0x02, 0x81, 0x83, 0x85, + 0x07, 0x53, 0x65, 0x6E, 0x64, 0x20, + 0x53, 0x4D, 0x86, 0x09, 0x91, 0x11, + 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0xF8, 0x8B, 0x18, 0x01, 0x00, 0x09, + 0x91, 0x10, 0x32, 0x54, 0x76, 0xF8, + 0x40, 0xF4, 0x0C, 0x54, 0x65, 0x73, + 0x74, 0x20, 0x4D, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65 }; + +static struct send_sms_test send_sms_data_111 = { +
[PATCH 15/19] test-stkutil: Use dedicated functions to check
--- unit/test-stkutil.c | 50 +- 1 files changed, 41 insertions(+), 9 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index 70d87d3..52aa050 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -70,6 +70,12 @@ static inline void check_common_text(const char *command, const char *test) g_assert(g_str_equal(command, test)); } +/* Defined in TS 102.223 Section 8.2 */ +static inline void check_alpha_id(const char *command, const char *test) +{ + check_common_text(command, test); +} + /* Defined in TS 102.223 Section 8.8 */ static void check_duration(const struct stk_duration *command, const struct stk_duration *test) @@ -115,6 +121,25 @@ static void check_response_length(const struct stk_response_length *command, g_assert(command-max == test-max); } +/* Defined in TS 102.223 Section 8.15 */ +static inline void check_text(const char *command, const char *test) +{ + check_common_text(command, test); +} + +/* Defined in TS 102.223 Section 8.16 */ +static inline void check_tone(const ofono_bool_t command, + const ofono_bool_t test) +{ + check_common_bool(command, test); +} + +/* Defined in TS 102.223 Section 8.23 */ +static inline void check_default_text(const char *command, const char *test) +{ + check_common_text(command, test); +} + /* Defined in TS 102.223 Section 8.24 */ static void check_items_next_action_indicator( const struct stk_items_next_action_indicator *command, @@ -141,6 +166,13 @@ static void check_item_icon_id_list(const struct stk_item_icon_id_list *command, g_assert(g_mem_equal(command-list, test-list, test-len)); } +/* Defined in TS 102.223 Section 8.43 */ +static inline void check_imm_resp(const unsigned char command, + const unsigned char test) +{ + check_common_byte(command, test); +} + /* Defined in TS 102.223 Section 8.72 */ static void check_text_attr(const struct stk_text_attribute *command, const struct stk_text_attribute *test) @@ -409,9 +441,9 @@ static void test_display_text(gconstpointer data) g_assert(command-dst == STK_DEVICE_IDENTITY_TYPE_DISPLAY); g_assert(command-display_text.text); - check_common_text(command-display_text.text, test-text); + check_text(command-display_text.text, test-text); check_icon_id(command-display_text.icon_id, test-icon_id); - check_common_bool(command-display_text.immediate_response, + check_imm_resp(command-display_text.immediate_response, test-immediate_response); check_duration(command-display_text.duration, test-duration); check_text_attr(command-display_text.text_attr, @@ -1346,7 +1378,7 @@ static void test_get_inkey(gconstpointer data) g_assert(command-dst == STK_DEVICE_IDENTITY_TYPE_TERMINAL); g_assert(command-get_inkey.text); - check_common_text(command-get_inkey.text, test-text); + check_text(command-get_inkey.text, test-text); check_icon_id(command-get_inkey.icon_id, test-icon_id); check_duration(command-get_inkey.duration, test-duration); check_text_attr(command-get_inkey.text_attr, @@ -2652,9 +2684,9 @@ static void test_get_input(gconstpointer data) if (test-text) g_assert(command-get_input.text); - check_common_text(command-get_input.text, test-text); + check_text(command-get_input.text, test-text); check_response_length(command-get_input.resp_len, test-resp_len); - check_common_text(command-get_input.default_text, test-default_text); + check_default_text(command-get_input.default_text, test-default_text); check_icon_id(command-get_input.icon_id, test-icon_id); check_text_attr(command-get_input.text_attr, test-text_attr); @@ -3929,8 +3961,8 @@ static void test_play_tone(gconstpointer data) g_assert(command-src == STK_DEVICE_IDENTITY_TYPE_UICC); g_assert(command-dst == STK_DEVICE_IDENTITY_TYPE_EARPIECE); - check_common_text(command-play_tone.alpha_id, test-alpha_id); - check_common_byte(command-play_tone.tone, test-tone); + check_alpha_id(command-play_tone.alpha_id, test-alpha_id); + check_tone(command-play_tone.tone, test-tone); check_duration(command-play_tone.duration, test-duration); check_icon_id(command-play_tone.icon_id, test-icon_id); check_text_attr(command-play_tone.text_attr, test-text_attr); @@ -5462,7 +5494,7 @@ static void test_setup_menu(gconstpointer data) if (test-alpha_id) g_assert(command-setup_menu.alpha_id); - check_common_text(command-setup_menu.alpha_id, test-alpha_id); +
[PATCH 11/19] stkutil: Add setup menu proactive command parser
--- src/stkutil.c | 133 +++- src/stkutil.h | 11 + 2 files changed, 132 insertions(+), 12 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 2074d19..45bb285 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -281,8 +281,9 @@ static gboolean parse_dataobj_alpha_id(struct comprehension_tlv_iter *iter, char *utf8; len = comprehension_tlv_iter_get_length(iter); - if (len 1) - return FALSE; + + if (len == 0) + return TRUE; data = comprehension_tlv_iter_get_data(iter); utf8 = sim_string_to_utf8(data, len); @@ -373,8 +374,10 @@ static gboolean parse_dataobj_item(struct comprehension_tlv_iter *iter, char *utf8; len = comprehension_tlv_iter_get_length(iter); - if (len 2) - return FALSE; + + if (len == 0) + return TRUE; + data = comprehension_tlv_iter_get_data(iter); @@ -2006,6 +2009,7 @@ static gboolean parse_dataobj(struct comprehension_tlv_iter *iter, GSList *l; va_list args; gboolean minimum_set = TRUE; + GSList **list = NULL; va_start(args, type); @@ -2022,29 +2026,74 @@ static gboolean parse_dataobj(struct comprehension_tlv_iter *iter, entries = g_slist_prepend(entries, entry); } - if (comprehension_tlv_iter_next(iter) != TRUE) goto out; entries = g_slist_reverse(entries); - for (l = entries; l; l = l-next) { + for (l = entries; l;) { dataobj_handler handler; struct dataobj_handler_entry *entry = l-data; + unsigned short tag; + gboolean ret; + void *dataobj; handler = handler_for_type(entry-type); - if (handler == NULL) + if (handler == NULL) { + l = l-next; continue; + } - if (comprehension_tlv_iter_get_tag(iter) == entry-type) { - if (handler(iter, entry-data)) - entry-parsed = TRUE; - if (comprehension_tlv_iter_next(iter) == FALSE) - break; + tag = comprehension_tlv_iter_get_tag(iter); + if (tag != entry-type) { + l = l-next; + continue; } + + if (tag == STK_DATA_OBJECT_TYPE_PROVISIONING_FILE_REFERENCE || + tag == STK_DATA_OBJECT_TYPE_ITEM) { + + if (tag == STK_DATA_OBJECT_TYPE_ITEM) + dataobj = g_try_new0(struct stk_item, 1); + else + dataobj = g_try_new0(struct stk_file, 1); + + if (!dataobj) + goto out; + + if (!list) + list = entry-data; + + ret = handler(iter, dataobj); + } else + ret = handler(iter, entry-data); + + if (ret) + entry-parsed = TRUE; + + if (tag == STK_DATA_OBJECT_TYPE_PROVISIONING_FILE_REFERENCE || + tag == STK_DATA_OBJECT_TYPE_ITEM) { + + if (tag == STK_DATA_OBJECT_TYPE_ITEM) { + struct stk_item *item = dataobj; + /* either return is FALSE or item is empty */ + if (item-id == 0) + g_free(item); + else + *list = g_slist_prepend(*list, item); + } else + *list = g_slist_prepend(*list, dataobj); + } else + l = l-next; + + if (comprehension_tlv_iter_next(iter) == FALSE) + break; } out: + if (list) + *list = g_slist_reverse(*list); + for (l = entries; l; l = l-next) { struct dataobj_handler_entry *entry = l-data; @@ -2254,6 +2303,63 @@ static gboolean parse_poll_interval(struct stk_command *command, return TRUE; } +static void destroy_stk_item(struct stk_item *item) +{ + g_free(item-text); + g_free(item); +} + +static void destroy_setup_menu(struct stk_command *command) +{ + g_free(command-setup_menu.alpha_id); + g_slist_foreach(command-setup_menu.items, + (GFunc)destroy_stk_item, NULL); + g_slist_free(command-setup_menu.items); +} + +static gboolean parse_setup_menu(struct stk_command *command, + struct comprehension_tlv_iter *iter) +{ + struct stk_command_setup_menu *obj = command-setup_menu; +
[PATCH 13/19] stkutil: Add select item proactive command parser
--- src/stkutil.c | 53 + src/stkutil.h | 13 + 2 files changed, 66 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 45bb285..ebe1114 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2360,6 +2360,56 @@ error: return FALSE; } +static void destroy_select_item(struct stk_command *command) +{ + g_free(command-select_item.alpha_id); + g_slist_foreach(command-select_item.items, + (GFunc)destroy_stk_item, NULL); + g_slist_free(command-select_item.items); +} + +static gboolean parse_select_item(struct stk_command *command, + struct comprehension_tlv_iter *iter) +{ + struct stk_command_select_item *obj = command-select_item; + gboolean ret; + + if (command-src != STK_DEVICE_IDENTITY_TYPE_UICC) + return FALSE; + + if (command-dst != STK_DEVICE_IDENTITY_TYPE_TERMINAL) + return FALSE; + + ret = parse_dataobj(iter, + STK_DATA_OBJECT_TYPE_ALPHA_ID, 0, + obj-alpha_id, + STK_DATA_OBJECT_TYPE_ITEM, + DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM, + obj-items, + STK_DATA_OBJECT_TYPE_ITEMS_NEXT_ACTION_INDICATOR, 0, + obj-next_act, + STK_DATA_OBJECT_TYPE_ITEM_ID, 0, + obj-item_id, + STK_DATA_OBJECT_TYPE_ICON_ID, 0, + obj-icon_id, + STK_DATA_OBJECT_TYPE_ITEM_ICON_ID_LIST, 0, + obj-item_icon_id_list, + STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, + obj-text_attr, + STK_DATA_OBJECT_TYPE_ITEM_TEXT_ATTRIBUTE_LIST, 0, + obj-item_text_attr_list, + STK_DATA_OBJECT_TYPE_FRAME_ID, 0, + obj-frame_id, + STK_DATA_OBJECT_TYPE_INVALID); + + if (ret == FALSE) + return FALSE; + + command-destructor = destroy_select_item; + + return TRUE; +} + static void destroy_send_sms(struct stk_command *command) { g_free(command-send_sms.alpha_id); @@ -2486,6 +2536,9 @@ struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu, case STK_COMMAND_TYPE_SETUP_MENU: ok = parse_setup_menu(command, iter); break; + case STK_COMMAND_TYPE_SELECT_ITEM: + ok = parse_select_item(command, iter); + break; case STK_COMMAND_TYPE_SEND_SMS: ok = parse_send_sms(command, iter); break; diff --git a/src/stkutil.h b/src/stkutil.h index d91ac66..143679f 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -834,6 +834,18 @@ struct stk_command_setup_menu { struct stk_item_text_attribute_list item_text_attr_list; }; +struct stk_command_select_item { + char *alpha_id; + GSList *items; + struct stk_items_next_action_indicator next_act; + unsigned char item_id; + struct stk_icon_id icon_id; + struct stk_item_icon_id_list item_icon_id_list; + struct stk_text_attribute text_attr; + struct stk_item_text_attribute_list item_text_attr_list; + struct stk_frame_id frame_id; +}; + struct stk_command_send_sms { char *alpha_id; struct stk_address address; @@ -857,6 +869,7 @@ struct stk_command { struct stk_command_get_input get_input; struct stk_command_play_tone play_tone; struct stk_command_setup_menu setup_menu; + struct stk_command_select_item select_item; struct stk_command_send_sms send_sms; }; -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 18/19] stkutil: Add setup call proactive command parser
--- src/stkutil.c | 55 +++ src/stkutil.h | 15 +++ 2 files changed, 70 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index b6212b3..75cfdef 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2465,6 +2465,58 @@ static gboolean parse_send_sms(struct stk_command *command, return TRUE; } +static void destroy_setup_call(struct stk_command *command) +{ + g_free(command-setup_call.alpha_id_usr_cfm); + g_free(command-setup_call.addr.number); + g_free(command-setup_call.alpha_id_call_setup); +} + +static gboolean parse_setup_call(struct stk_command *command, + struct comprehension_tlv_iter *iter) +{ + struct stk_command_setup_call *obj = command-setup_call; + gboolean ret; + + if (command-src != STK_DEVICE_IDENTITY_TYPE_UICC) + return FALSE; + + if (command-dst != STK_DEVICE_IDENTITY_TYPE_NETWORK) + return FALSE; + + ret = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_ALPHA_ID, 0, + obj-alpha_id_usr_cfm, + STK_DATA_OBJECT_TYPE_ADDRESS, + DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM, + obj-addr, + STK_DATA_OBJECT_TYPE_CCP, 0, + obj-ccp, + STK_DATA_OBJECT_TYPE_SUBADDRESS, 0, + obj-subaddr, + STK_DATA_OBJECT_TYPE_DURATION, 0, + obj-duration, + STK_DATA_OBJECT_TYPE_ICON_ID, 0, + obj-icon_id_usr_cfm, + STK_DATA_OBJECT_TYPE_ALPHA_ID, 0, + obj-alpha_id_call_setup, + STK_DATA_OBJECT_TYPE_ICON_ID, 0, + obj-icon_id_call_setup, + STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, + obj-text_attr_usr_cfm, + STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE, 0, + obj-text_attr_call_setup, + STK_DATA_OBJECT_TYPE_FRAME_ID, 0, + obj-frame_id, + STK_DATA_OBJECT_TYPE_INVALID); + + if (ret == FALSE) + return FALSE; + + command-destructor = destroy_setup_call; + + return TRUE; +} + struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu, unsigned int len) { @@ -2550,6 +2602,9 @@ struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu, case STK_COMMAND_TYPE_SEND_SMS: ok = parse_send_sms(command, iter); break; + case STK_COMMAND_TYPE_SETUP_CALL: + ok = parse_setup_call(command, iter); + break; default: ok = FALSE; break; diff --git a/src/stkutil.h b/src/stkutil.h index b936ee9..17028fc 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -856,6 +856,20 @@ struct stk_command_send_sms { struct stk_frame_id frame_id; }; +struct stk_command_setup_call { + char *alpha_id_usr_cfm; + struct stk_address addr; + struct stk_ccp ccp; + struct stk_subaddress subaddr; + struct stk_duration duration; + struct stk_icon_id icon_id_usr_cfm; + char *alpha_id_call_setup; + struct stk_icon_id icon_id_call_setup; + struct stk_text_attribute text_attr_usr_cfm; + struct stk_text_attribute text_attr_call_setup; + struct stk_frame_id frame_id; +}; + struct stk_command { unsigned char number; unsigned char type; @@ -872,6 +886,7 @@ struct stk_command { struct stk_command_setup_menu setup_menu; struct stk_command_select_item select_item; struct stk_command_send_sms send_sms; + struct stk_command_setup_call setup_call; }; void (*destructor)(struct stk_command *command); -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 19/19] test-stkutil: Add unit test for setup call parser
--- unit/test-stkutil.c | 1395 +++ 1 files changed, 1395 insertions(+), 0 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index ffe0a3f..428ffd4 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -97,6 +97,32 @@ static inline void check_alpha_id(const char *command, const char *test) check_common_text(command, test); } +/* Defined in TS 102.223 Section 8.3 */ +static void check_subaddress(const struct stk_subaddress *command, + const struct stk_subaddress *test) +{ + if (test-len == 0) { + g_assert(command-len == 0); + return; + } + + g_assert(command-len != 0); + g_assert(g_mem_equal(command-subaddr, test-subaddr, test-len)); +} + +/* Defined in TS 102.223 Section 8.4 */ +static void check_ccp(const struct stk_ccp *command, + const struct stk_ccp *test) +{ + if (test-len == 0) { + g_assert(command-len == 0); + return; + } + + g_assert(command-len != 0); + g_assert(g_mem_equal(command-ccp, test-ccp, test-len)); +} + /* Defined in TS 102.223 Section 8.8 */ static void check_duration(const struct stk_duration *command, const struct stk_duration *test) @@ -7552,6 +7578,1284 @@ static void test_send_sms(gconstpointer data) stk_command_free(command); } +struct setup_call_test { + const unsigned char *pdu; + unsigned int pdu_len; + unsigned char qualifier; + char *alpha_id_usr_cfm; + struct stk_address addr; + struct stk_ccp ccp; + struct stk_subaddress subaddr; + struct stk_duration duration; + struct stk_icon_id icon_id_usr_cfm; + char *alpha_id_call_setup; + struct stk_icon_id icon_id_call_setup; + struct stk_text_attribute text_attr_usr_cfm; + struct stk_text_attribute text_attr_call_setup; + struct stk_frame_id frame_id; +}; + +static unsigned char setup_call_111[] = { 0xD0, 0x1E, 0x81, 0x03, 0x01, 0x10, + 0x00, 0x82, 0x02, 0x81, 0x83, + 0x85, 0x08, 0x4E, 0x6F, 0x74, + 0x20, 0x62, 0x75, 0x73, 0x79, + 0x86, 0x09, 0x91, 0x10, 0x32, + 0x04, 0x21, 0x43, 0x65, 0x1C, + 0x2C }; + +static unsigned char setup_call_141[] = { 0xD0, 0x1D, 0x81, 0x03, 0x01, 0x10, + 0x02, 0x82, 0x02, 0x81, 0x83, + 0x85, 0x07, 0x4F, 0x6E, 0x20, + 0x68, 0x6F, 0x6C, 0x64, 0x86, + 0x09, 0x91, 0x10, 0x32, 0x04, + 0x21, 0x43, 0x65, 0x1C, 0x2C }; + +static unsigned char setup_call_151[] = { 0xD0, 0x20, 0x81, 0x03, 0x01, 0x10, + 0x04, 0x82, 0x02, 0x81, 0x83, + 0x85, 0x0A, 0x44, 0x69, 0x73, + 0x63, 0x6F, 0x6E, 0x6E, 0x65, + 0x63, 0x74, 0x86, 0x09, 0x91, + 0x10, 0x32, 0x04, 0x21, 0x43, + 0x65, 0x1C, 0x2C }; + +static unsigned char setup_call_181[] = { 0xD0, 0x2B, 0x81, 0x03, 0x01, 0x10, + 0x00, 0x82, 0x02, 0x81, 0x83, + 0x85, 0x11, 0x43, 0x61, 0x70, + 0x61, 0x62, 0x69, 0x6C, 0x69, + 0x74, 0x79, 0x20, 0x63, 0x6F, + 0x6E, 0x66, 0x69, 0x67, 0x86, + 0x09, 0x91, 0x10, 0x32, 0x04, + 0x21, 0x43, 0x65, 0x1C, 0x2C, + 0x87, 0x02, 0x01, 0xA0 }; + +static unsigned char setup_call_191[] = { 0xD0, 0x1C, 0x81, 0x03, 0x01, 0x10, + 0x01, 0x82, 0x02, 0x81, 0x83, + 0x86, 0x11, 0x91, 0x10, 0x32, + 0x54, 0x76, 0x98, 0x10, 0x32, + 0x54, 0x76, 0x98, 0x10, 0x32, + 0x54, 0x76, 0x98, 0x10 }; + +static unsigned char setup_call_1101[] = { 0xD0, 0x81, 0xFD, 0x81, 0x03, 0x01, + 0x10, 0x01, 0x82, 0x02, 0x81, + 0x83, 0x85, 0x81,
How to start ofono-phonesim in ubuntu-10.04 -reg
Hi, I installed phonesim1.1 source. I compiled and installed. I started phonesim as you suggested ./phonesim -p gui default.xml (now i got default.xml file in /phonesim/src) I started ofono using ofonod -n -d I executed ./list-modems. It is not displaying any thing. I am just getting prompt. For your reference i am posting ofonod -n -d o/p at the end of the mail. == Please note this is additional information.. I found one file named blacklist-modem.conf in /etc/modprobe.d path. Please find the content of that file. # Uncomment these entries in order to blacklist unwanted modem drivers # blacklist snd-atiixp-modem # blacklist snd-intel8x0m # blacklist snd-via82xx-modem Is it creating any trouble for me to start the phonesim? Any idea on this? modem.conf file is presented in 2 locations. 1. /etc/ofono 2. /usr/share/alsa/pcm After changing the modem.conf am I need to restart the system? Thanks in advance. Note:- oFono version is 0.9 and phonesim version is 1.1 sudo ofono -n -d (output) == ofonod[5458]: oFono version 0.9 ofonod[5458]: src/plugin.c:__ofono_plugin_init() ofonod[5458]: plugins/hfp.c:hfp_init() ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66de80, name: hfp ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66de00, name: novatel ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66dd80, name: huawei ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66dd00, name: hso ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66dc60, name: mbm ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66dbe0, name: calypso ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66db60, name: g1 ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66dae0, name: atgen ofonod[5458]: src/modem.c:ofono_modem_driver_register() driver: 0x66da60, name: phonesim ofonod[5458]: Reading of /etc/ofono/modem.conf failed: Key file contains line 'pcm.!phoneline {' which is not a key-value pair, group, or comment ofonod[5458]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x66d9a0, name: mbm ofonod[5458]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x66d8c0, name: hfpmodem ofonod[5458]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x66d7e0, name: calypsomodem ofonod[5458]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x66d4e0, name: atmodem ofonod[5458]: src/modem.c:ofono_devinfo_driver_register() driver: 0x66d660, name: atmodem ofonod[5458]: src/call-barring.c:ofono_call_barring_driver_register() driver: 0x66d5a0, name: atmodem ofonod[5458]: src/call-forwarding.c:ofono_call_forwarding_driver_register() driver: 0x66d280, name: atmodem ofonod[5458]: src/call-meter.c:ofono_call_meter_driver_register() driver: 0x66d2e0, name: atmodem ofonod[5458]: src/call-settings.c:ofono_call_settings_driver_register() driver: 0x66d100, name: atmodem ofonod[5458]: src/phonebook.c:ofono_phonebook_driver_register() driver: 0x66d5e0, name: atmodem ofonod[5458]: src/ssn.c:ofono_ssn_driver_register() driver: 0x66d630, name: atmodem ofonod[5458]: src/ussd.c:ofono_ussd_driver_register() driver: 0x66d4a0, name: atmodem ofonod[5458]: src/sms.c:ofono_sms_driver_register() driver: 0x66d1a0, name: atmodem ofonod[5458]: src/sim.c:ofono_sim_driver_register() driver: 0x66d400, name: atmodem ofonod[5458]: src/network.c:ofono_netreg_driver_register() driver: 0x66d380, name: atmodem ofonod[5458]: src/cbs.c:ofono_cbs_driver_register() driver: 0x66d240, name: atmodem ofonod[5458]: src/call-volume.c:ofono_call_volume_driver_register() driver: 0x66d6a0, name: atmodem ofonod[5458]: src/gprs.c:ofono_gprs_driver_register() driver: 0x66d700, name: atmodem ofonod[5458]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x66d760, name: atmodem ofonod[5458]: src/modem.c:ofono_devinfo_driver_register() driver: 0x66cb00, name: isimodem ofonod[5458]: src/phonebook.c:ofono_phonebook_driver_register() driver: 0x66cae0, name: isimodem ofonod[5458]: src/network.c:ofono_netreg_driver_register() driver: 0x66cb40, name: isimodem ofonod[5458]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x66cba0, name: isimodem ofonod[5458]: src/sms.c:ofono_sms_driver_register() driver: 0x66cc40, name: isimodem ofonod[5458]: src/cbs.c:ofono_cbs_driver_register() driver: 0x66cc80, name: isimodem ofonod[5458]: src/sim.c:ofono_sim_driver_register() driver: 0x66ccc0, name: isimodem ofonod[5458]: src/ssn.c:ofono_ssn_driver_register() driver: 0x66cd50, name: isimodem ofonod[5458]: src/ussd.c:ofono_ussd_driver_register() driver: 0x66cd80, name: isimodem ofonod[5458]:
How to start ofono-phonesim in ubuntu-10.04 -reg
Hi, After starting ofonod with command sudo ofonod -n -d, I am getting below messages Reading of /etc/ofono/modem.conf failed: Key file contains line 'pcm.!phoneline {' which is not a key-value pair, group, or comment Does it mean that it is not able to recognize the modem presented in modem.conf file? if i try to execute ./list-modems then it is listing any thing. Please suggest me. modem.conf file contents -- # # raw modem - phoneline # pcm.!phoneline { @args [ CARD DEV ] @args.CARD { type string default { @func getenv vars [ ALSA_MODEM_CARD ALSA_PCM_CARD ALSA_CARD ] default { @func refer name defaults.pcm.modem.card } } } @args.DEV { type integer default { @func igetenv vars [ ALSA_MODEM_DEVICE ] default { @func refer name defaults.pcm.modem.device } } } @func refer name { @func concat strings [ cards. { @func card_driver card $CARD } .pcm.modem. $DEV :CARD= $CARD ] } hint.show off } # # autohooked modem # pcm.!modem { @args [ CARD DEV ] @args.CARD { type string default { @func getenv vars [ ALSA_MODEM_CARD ALSA_PCM_CARD ALSA_CARD ] default { @func refer name defaults.pcm.modem.card } } } @args.DEV { type integer default { @func igetenv vars [ ALSA_MODEM_DEVICE ] default { @func refer name defaults.pcm.modem.device } } } type hooks slave { pcm { @func concat strings [ cards.pcm.phoneline:CARD= $CARD ,DEV= $DEV ] } } hooks.0 { type ctl_elems hook_args [ { name Off-hook Switch preserve true value on lock false optional true } ] } hint.show off } # #Sample for using phone simulator # [phonesim] Driver=phonesim Address=127.0.0.1 port=12345 -- Thanks and Regards, Krishna K Kandula _ The amazing world in sharp snaps http://news.in.msn.com/gallery/archive.aspx___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] gatio: do not read if no read_handler
Hi Kristen, If no read_handler specified, leave data alone in case someone else wants to read it. --- gatchat/gatio.c |4 gatchat/gsmdial.c | 12 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gatchat/gatio.c b/gatchat/gatio.c index 61b0260..b4a3806 100644 --- a/gatchat/gatio.c +++ b/gatchat/gatio.c @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (cond G_IO_NVAL) return FALSE; + /* if nobody wants this data, leave it alone */ + if (io-read_handler == NULL) + return TRUE; + This is a really bad idea, we should never have cases where the read handler is unset, and if we do we should end up closing the socket when the buffer is full. /* Regardless of condition, try to read all the data available */ do { toread = ring_buffer_avail_no_wrap(io-buf); diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c index a531aa3..5fb406d 100644 --- a/gatchat/gsmdial.c +++ b/gatchat/gsmdial.c @@ -235,6 +235,8 @@ static void ppp_connect(const char *iface, const char *ip, static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data) { g_print(PPP Link down: %d\n, reason); + g_at_chat_resume(control); + g_at_chat_resume(modem); } static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data) @@ -249,14 +251,8 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data) /* get the data IO channel */ channel = g_at_chat_get_channel(modem); - /* - * shutdown gatchat or else it tries to take all the input - * from the modem and does not let PPP get it. - */ - g_at_chat_unref(control); - control = NULL; - g_at_chat_unref(modem); - modem = NULL; + g_at_chat_suspend(control); + g_at_chat_suspend(modem); Please send gsmdial patches separately. Also, can you make g_at_ppp use the new_from_io constructor? In that case you don't need the gatio modifications above. /* open ppp */ ppp = g_at_ppp_new(channel); Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] ppp: transition phase to DEAD when lcp finishes
Hi Kristen, change the state to DEAD when lcp finishes. This prevents us from calling our disconnect function again if we are already dead. I'm curious under what circumstances tlf gets called on LCP when we're already down? --- gatchat/gatppp.c |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 70669b0..dd6d84d 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -186,9 +186,6 @@ static inline void ppp_enter_phase(GAtPPP *ppp, enum ppp_phase phase) { g_print(Entering new phase: %d\n, phase); ppp-phase = phase; - - if (phase == PPP_PHASE_DEAD) - ppp_dead(ppp); } void ppp_set_auth(GAtPPP *ppp, const guint8* auth_data) @@ -290,6 +287,10 @@ void ppp_lcp_down_notify(GAtPPP *ppp) void ppp_lcp_finished_notify(GAtPPP *ppp) { + if (ppp-phase == PPP_PHASE_DEAD) + return; I prefer we move this to ppp_enter_phase + + ppp_enter_phase(ppp, PPP_PHASE_DEAD); Keep this ppp_dead(ppp); And remove this. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 1/2] Fix Use hashtable to record udev path
Hi Zhenhua, Sometimes, Udev device 'remove' event could not report correct parent node of current udev_device. Current code replies on the devpath attached on the parent node to find modem and then remove it. This fix is to change the way to store the devpath info into a hashtable. So that we search hashtable to get devpath and remove the modem. --- plugins/udev.c | 59 +-- 1 files changed, 40 insertions(+), 19 deletions(-) diff --git a/plugins/udev.c b/plugins/udev.c index 964ac65..6850bf9 100644 --- a/plugins/udev.c +++ b/plugins/udev.c @@ -36,6 +36,7 @@ #include ofono/log.h static GSList *modem_list = NULL; +static GHashTable *devpath_list = NULL; static struct ofono_modem *find_modem(const char *devpath) { @@ -258,7 +259,7 @@ static void add_modem(struct udev_device *udev_device) { struct ofono_modem *modem; struct udev_device *parent; - const char *devpath, *driver; + const char *devpath, *curpath, *driver; parent = udev_device_get_parent(udev_device); if (parent == NULL) @@ -294,6 +295,12 @@ static void add_modem(struct udev_device *udev_device) modem_list = g_slist_prepend(modem_list, modem); } + curpath = udev_device_get_devpath(udev_device); + if (curpath == NULL) + return; + + g_hash_table_insert(devpath_list, g_strdup(curpath), g_strdup(devpath)); + if (g_strcmp0(driver, mbm) == 0) add_mbm(modem, udev_device); else if (g_strcmp0(driver, hso) == 0) @@ -306,30 +313,28 @@ static void add_modem(struct udev_device *udev_device) add_novatel(modem, udev_device); } +static gboolean devpath_remove(gpointer key, gpointer value, gpointer user_data) +{ + const char *path = value; + const char *devpath = user_data; + + if (!g_strcmp0(path, devpath)) + return TRUE; How about a simple return g_str_equals here? + + return FALSE; +} + static void remove_modem(struct udev_device *udev_device) { struct ofono_modem *modem; - struct udev_device *parent; - const char *devpath, *driver = NULL; + const char *curpath = udev_device_get_devpath(udev_device); + char *devpath, *remove; - parent = udev_device_get_parent(udev_device); - if (parent == NULL) + if (curpath == NULL) return; - driver = get_driver(parent); - if (driver == NULL) { - parent = udev_device_get_parent(parent); - driver = get_driver(parent); - if (driver == NULL) { - parent = udev_device_get_parent(parent); - driver = get_driver(parent); - if (driver == NULL) - return; - } - } - - devpath = udev_device_get_devpath(parent); - if (devpath == NULL) + devpath = g_hash_table_lookup(devpath_list, curpath); + if (!devpath) return; modem = find_modem(devpath); @@ -339,6 +344,12 @@ static void remove_modem(struct udev_device *udev_device) modem_list = g_slist_remove(modem_list, modem); ofono_modem_remove(modem); + + remove = g_strdup(devpath); + + g_hash_table_foreach_remove(devpath_list, devpath_remove, remove); + + g_free(remove); } static void enumerate_devices(struct udev *context) @@ -443,6 +454,13 @@ static void udev_start(void) static int udev_init(void) { + devpath_list = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); + if (!devpath_list) { + ofono_error(Failed to create udev path list); + return -ENOMEM; + } + You now need to take care of freeing the devpath_list on any further error conditions that might occur, otherwise you leak memory. udev_ctx = udev_new(); if (udev_ctx == NULL) { ofono_error(Failed to create udev context); @@ -483,6 +501,9 @@ static void udev_exit(void) g_slist_free(modem_list); modem_list = NULL; + g_hash_table_destroy(devpath_list); + devpath_list = NULL; + if (udev_ctx == NULL) return; Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 2/2] Fix check data device before register the modem
Hi Zhenhua, To avoid the race condition that modem is registered before we retrieve the data device property. --- plugins/udev.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] ppp: transition phase to DEAD when lcp finishes
On Mon, 10 May 2010 09:21:37 -0500 Denis Kenzior denk...@gmail.com wrote: Hi Kristen, change the state to DEAD when lcp finishes. This prevents us from calling our disconnect function again if we are already dead. I'm curious under what circumstances tlf gets called on LCP when we're already down? A timeout after sending a terminate ack causes a tlf and switches us to the STOPPED state. disconnect function is called at tlf, and disconnect reason correctly set. Then, our read watcher is destroyed and we signal down (transitions us to state STARTING) and close (calls tlf and transitions us to INITIAL). Disconnect function is called with disconnect reason set to link dead. ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] gatio: do not read if no read_handler
On Mon, 10 May 2010 09:11:52 -0500 Denis Kenzior denk...@gmail.com wrote: Hi Kristen, If no read_handler specified, leave data alone in case someone else wants to read it. --- gatchat/gatio.c |4 gatchat/gsmdial.c | 12 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gatchat/gatio.c b/gatchat/gatio.c index 61b0260..b4a3806 100644 --- a/gatchat/gatio.c +++ b/gatchat/gatio.c @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (cond G_IO_NVAL) return FALSE; + /* if nobody wants this data, leave it alone */ + if (io-read_handler == NULL) + return TRUE; + This is a really bad idea, we should never have cases where the read handler is unset, and if we do we should end up closing the socket when the buffer is full. In your implementation of g_at_chat_suspend, you set the read handler to NULL. ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] ppp: transition phase to DEAD when lcp finishes
Hi Kristen, On Mon, 10 May 2010 09:21:37 -0500 Denis Kenzior denk...@gmail.com wrote: Hi Kristen, change the state to DEAD when lcp finishes. This prevents us from calling our disconnect function again if we are already dead. I'm curious under what circumstances tlf gets called on LCP when we're already down? A timeout after sending a terminate ack causes a tlf and switches us to the STOPPED state. disconnect function is called at tlf, and disconnect reason correctly set. Then, our read watcher is destroyed and we signal down (transitions us to state STARTING) and close (calls tlf and transitions us to INITIAL). Disconnect function is called with disconnect reason set to link dead. Ah yes, the silly Huawei hardware. Sounds like we should ignore GAtIO disconnects when we're already in PPP_DEAD phase. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] gatio: do not read if no read_handler
Hi Kristen, On Mon, 10 May 2010 09:11:52 -0500 Denis Kenzior denk...@gmail.com wrote: Hi Kristen, If no read_handler specified, leave data alone in case someone else wants to read it. --- gatchat/gatio.c |4 gatchat/gsmdial.c | 12 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gatchat/gatio.c b/gatchat/gatio.c index 61b0260..b4a3806 100644 --- a/gatchat/gatio.c +++ b/gatchat/gatio.c @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (cond G_IO_NVAL) return FALSE; + /* if nobody wants this data, leave it alone */ + if (io-read_handler == NULL) + return TRUE; + This is a really bad idea, we should never have cases where the read handler is unset, and if we do we should end up closing the socket when the buffer is full. In your implementation of g_at_chat_suspend, you set the read handler to NULL. Correct, with the intent that someone else sets the read handler (e.g. g_at_ppp) Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] gatio: do not read if no read_handler
Hi Kristen, On Mon, 10 May 2010 12:23:04 -0500 Denis Kenzior denk...@gmail.com wrote: Hi Kristen, On Mon, 10 May 2010 09:11:52 -0500 Denis Kenzior denk...@gmail.com wrote: Hi Kristen, If no read_handler specified, leave data alone in case someone else wants to read it. --- gatchat/gatio.c |4 gatchat/gsmdial.c | 12 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gatchat/gatio.c b/gatchat/gatio.c index 61b0260..b4a3806 100644 --- a/gatchat/gatio.c +++ b/gatchat/gatio.c @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (cond G_IO_NVAL) return FALSE; + /* if nobody wants this data, leave it alone */ + if (io-read_handler == NULL) + return TRUE; + This is a really bad idea, we should never have cases where the read handler is unset, and if we do we should end up closing the socket when the buffer is full. In your implementation of g_at_chat_suspend, you set the read handler to NULL. Correct, with the intent that someone else sets the read handler (e.g. g_at_ppp) What if you receive data after the read handler is set to NULL, but before someone else sets the read handler? shouldn't we safe guard against that? We do safe guard, once the buffer runs out of space we close the GAtIO. However, letting GAtIO enter the event-loop (since only then the io watch will fire) without a read handler is a user error. Having an active GAtIO without a read handler is useless... Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 0/3] Allow use of from_io constructor
Create a way to get the GAtIO object from GAtChat. Use it to call g_at_ppp_new_from_io so that g_at_chat_suspend will work properly. Kristen Carlson Accardi (3): gsmdial: use g_at_chat_suspend gatchat: implement g_at_chat_get_io() gsmdial: use g_at_ppp_new_from_io() gatchat/gatchat.c |8 gatchat/gatchat.h |2 ++ gatchat/gsmdial.c | 14 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 3/3] gsmdial: use g_at_ppp_new_from_io()
--- gatchat/gsmdial.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c index fd9b73b..cfdec87 100644 --- a/gatchat/gsmdial.c +++ b/gatchat/gsmdial.c @@ -241,7 +241,7 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data) static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data) { - GIOChannel *channel; + GAtIO *io; if (!ok) { g_print(Unable to define context\n); @@ -249,7 +249,7 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data) } /* get the data IO channel */ - channel = g_at_chat_get_channel(modem); + io = g_at_chat_get_io(modem); /* * shutdown gatchat or else it tries to take all the input @@ -259,7 +259,7 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data) g_at_chat_suspend(modem); /* open ppp */ - ppp = g_at_ppp_new(channel); + ppp = g_at_ppp_new_from_io(io); if (!ppp) { g_print(Unable to create PPP object\n); exit(1); -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 2/3] gatchat: implement g_at_chat_get_io()
--- gatchat/gatchat.c |8 gatchat/gatchat.h |2 ++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index f94605f..3f238a2 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -876,6 +876,14 @@ GIOChannel *g_at_chat_get_channel(GAtChat *chat) return g_at_io_get_channel(chat-io); } +GAtIO *g_at_chat_get_io(GAtChat *chat) +{ + if (chat == NULL) + return NULL; + + return chat-io; +} + GAtChat *g_at_chat_ref(GAtChat *chat) { if (chat == NULL) diff --git a/gatchat/gatchat.h b/gatchat/gatchat.h index ea6626e..9fd7ced 100644 --- a/gatchat/gatchat.h +++ b/gatchat/gatchat.h @@ -29,6 +29,7 @@ extern C { #include gatresult.h #include gatsyntax.h #include gatutil.h +#include gatio.h struct _GAtChat; @@ -42,6 +43,7 @@ GAtChat *g_at_chat_new(GIOChannel *channel, GAtSyntax *syntax); GAtChat *g_at_chat_new_blocking(GIOChannel *channel, GAtSyntax *syntax); GIOChannel *g_at_chat_get_channel(GAtChat *chat); +GAtIO *g_at_chat_get_io(GAtChat *chat); GAtChat *g_at_chat_ref(GAtChat *chat); void g_at_chat_unref(GAtChat *chat); -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH] ppp: transition to dead when lcp finished
Transition to DEAD when lcp is finished and ignore any io disconnects if we are already dead. --- gatchat/gatppp.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 70669b0..cb2fef9 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -290,7 +290,7 @@ void ppp_lcp_down_notify(GAtPPP *ppp) void ppp_lcp_finished_notify(GAtPPP *ppp) { - ppp_dead(ppp); + ppp_enter_phase(ppp, PPP_PHASE_DEAD); } void ppp_set_recv_accm(GAtPPP *ppp, guint32 accm) @@ -318,6 +318,9 @@ static void io_disconnect(gpointer user_data) { GAtPPP *ppp = user_data; + if (ppp-phase == PPP_PHASE_DEAD) + return; + ppp-disconnect_reason = G_AT_PPP_REASON_LINK_DEAD; pppcp_signal_down(ppp-lcp); pppcp_signal_close(ppp-lcp); -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 5/6] Add mbmmodem STK driver.
Hi Andrew, Tested with a F3607gw data card. --- Makefile.am |3 +- drivers/mbmmodem/mbmmodem.c |2 + drivers/mbmmodem/mbmmodem.h |3 + drivers/mbmmodem/stk.c | 254 +++ plugins/mbm.c | 45 +++- 5 files changed, 302 insertions(+), 5 deletions(-) create mode 100644 drivers/mbmmodem/stk.c diff --git a/plugins/mbm.c b/plugins/mbm.c index 53bd7ae..199aa17 100644 --- a/plugins/mbm.c +++ b/plugins/mbm.c @@ -37,6 +37,7 @@ #include ofono/devinfo.h #include ofono/netreg.h #include ofono/sim.h +#include ofono/stk.h #include ofono/sms.h #include ofono/cbs.h #include ofono/ssn.h @@ -54,11 +55,13 @@ #include drivers/atmodem/vendor.h static const char *cfun_prefix[] = { +CFUN:, NULL }; +static const char *crsm_prefix[] = { +CRSM:, NULL }; static const char *none_prefix[] = { NULL }; struct mbm_data { GAtChat *modem_port; GAtChat *data_port; + gboolean have_sim; }; static int mbm_probe(struct ofono_modem *modem) @@ -96,18 +99,51 @@ static void mbm_debug(const char *str, void *user_data) ofono_info(%s %s, prefix, str); } -static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) +static void status_check(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_modem *modem = user_data; + struct mbm_data *data = ofono_modem_get_data(modem); + GAtResultIter iter; + gint sw[2]; DBG(); if (!ok) - ofono_modem_set_powered(modem, FALSE); + goto poweron; + + /* Modem fakes a 94 04 response from card (File Id not found / + * Pattern not found) when there's no card in the slot. + */ + g_at_result_iter_init(iter, result); + + if (!g_at_result_iter_next(iter, +CRSM:)) + goto poweron; + + g_at_result_iter_next_number(iter, sw[0]); + g_at_result_iter_next_number(iter, sw[1]); + data-have_sim = sw[0] != 0x94 || sw[1] != 0x04; + +poweron: ofono_modem_set_powered(modem, TRUE); } This has to do with SIM inserted / removed detection. Can you send this as a separate patch from the STK driver? +static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) +{ + struct ofono_modem *modem = user_data; + struct mbm_data *data = ofono_modem_get_data(modem); + + DBG(); + + if (!ok) { + ofono_modem_set_powered(modem, FALSE); + return; + } + + g_at_chat_send(data-modem_port, AT+CRSM=242, crsm_prefix, + status_check, modem); +} + static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_modem *modem = user_data; @@ -133,7 +169,7 @@ static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data) return; } - ofono_modem_set_powered(modem, TRUE); + cfun_enable(TRUE, NULL, modem); } static void emrdy_notifier(GAtResult *result, gpointer user_data) @@ -290,8 +326,9 @@ static void mbm_pre_sim(struct ofono_modem *modem) ofono_devinfo_create(modem, 0, atmodem, data-modem_port); sim = ofono_sim_create(modem, 0, atmodem, data-modem_port); ofono_voicecall_create(modem, 0, atmodem, data-modem_port); + ofono_stk_create(modem, 0, mbmmodem, data-modem_port); This part is actually related to STK support in this driver. Please break it out into a separate patch as well. - if (sim) + if (data-have_sim sim) ofono_sim_inserted_notify(sim, TRUE); } Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH] ppp: set address and control field
Before sending to hdlc, set the address and control field. Fix hardcode of ppp header size. --- gatchat/gatppp.c |9 +++-- gatchat/ppp.h |4 gatchat/ppp_auth.c |2 +- gatchat/ppp_cp.c |6 ++ gatchat/ppp_net.c |3 ++- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 70669b0..c4f59f2 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -148,7 +148,8 @@ static void ppp_receive(const unsigned char *buf, gsize len, void *data) */ void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint infolen) { - guint16 proto = get_host_short(packet); + struct ppp_header *header = (struct ppp_header *) packet; + guint16 proto = ppp_proto(packet); guint8 code; gboolean lcp = (proto == LCP_PROTOCOL); guint32 xmit_accm = 0; @@ -167,7 +168,11 @@ void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint infolen) g_at_hdlc_set_xmit_accm(ppp-hdlc, ~0U); } - if (g_at_hdlc_send(ppp-hdlc, packet, infolen + 2) == FALSE) + header-address = PPP_ADDR_FIELD; + header-control = PPP_CTRL; + + if (g_at_hdlc_send(ppp-hdlc, packet, + infolen + sizeof(*header)) == FALSE) g_print(Failed to send a frame\n); if (lcp) diff --git a/gatchat/ppp.h b/gatchat/ppp.h index 41cf50a..e872496 100644 --- a/gatchat/ppp.h +++ b/gatchat/ppp.h @@ -26,11 +26,15 @@ #define IPCP_PROTO 0x8021 #define PPP_IP_PROTO 0x0021 #define MD55 +#define PPP_ADDR_FIELD 0xff +#define PPP_CTRL 0x03 struct ppp_chap; struct ppp_net; struct ppp_header { + guint8 address; + guint8 control; guint16 proto; guint8 info[0]; } __attribute__((packed)); diff --git a/gatchat/ppp_auth.c b/gatchat/ppp_auth.c index 6e55297..eae5d17 100644 --- a/gatchat/ppp_auth.c +++ b/gatchat/ppp_auth.c @@ -83,7 +83,7 @@ static void chap_process_challenge(struct ppp_chap *chap, const guint8 *packet) */ digest_len = g_checksum_type_get_length(chap-method); response_length = digest_len + sizeof(*header) + 1; - ppp_packet = g_try_malloc0(response_length + 2); + ppp_packet = g_try_malloc0(response_length + sizeof(struct ppp_header)); if (!ppp_packet) goto challenge_out; diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c index 00acb73..e152f6e 100644 --- a/gatchat/ppp_cp.c +++ b/gatchat/ppp_cp.c @@ -61,10 +61,8 @@ static const char *pppcp_event_strings[] = { g_free(str); \ } while (0); -#define PPP_HEADROOM 2 - #define pppcp_to_ppp_packet(p) \ - (((guint8 *) p) - PPP_HEADROOM) + (((guint8 *) p) - sizeof(struct ppp_header)) #define INITIAL_RESTART_TIMEOUT3 /* restart interval in seconds */ #define MAX_TERMINATE 2 @@ -206,7 +204,7 @@ static struct pppcp_packet *pppcp_packet_new(struct pppcp_data *data, struct ppp_header *ppp_packet; guint16 packet_length = bufferlen + sizeof(*packet); - ppp_packet = g_try_malloc0(packet_length + 2); + ppp_packet = g_try_malloc0(packet_length + sizeof(*ppp_packet)); if (!ppp_packet) return NULL; diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index afebf58..4e45ef1 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -105,7 +105,8 @@ static gboolean ppp_net_callback(GIOChannel *channel, GIOCondition cond, if (cond G_IO_IN) { /* leave space to add PPP protocol field */ - status = g_io_channel_read_chars(channel, buf + 2, net-mtu, + status = g_io_channel_read_chars(channel, + buf + sizeof(struct ppp_header), net-mtu, bytes_read, error); if (bytes_read 0) { ppp-proto = htons(PPP_IP_PROTO); -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH v2 6/6] Add calypsomodem STK driver.
Hi Andrew, There is an issue with the atom drivers not running at the time we issue AT+CFUN=1 so if that triggers an important notification, it'll be lost. It could be fixed properly but with major change to initialisation order, instead I added an extra ugly hack to store the initial %SATI notification, please comment if that it too ugly :) What is the proper way? :) Given that SATI needs to be preserved and the contents stored for future reference I agree your proposal is the best way to do it. +void calypsomodem_stk_sati_notify(struct ofono_stk *stk, + const guint8 *pdu, gint len) +{ + struct stk_data *sd = ofono_stk_get_data(stk); + int length_bytes; + + ofono_stk_proactive_command_notify(stk, len, pdu); + + /* Check if this is a Set Up Menu command, if so, cache the PDU + * because Calypso sends it only once. */ + + while (len 0 (*pdu == 0x00 || *pdu == 0xff)) + pdu++, len--; + if (len 7) + return; + if (pdu[0] != 0xd0) /* Command BER-TLV tag */ + return; + if (pdu[1] 0x80) + length_bytes = 1; + else + length_bytes = pdu[1] - 0x7f; + if (len length_bytes + 6) + return; + if (pdu[1 + length_bytes] != 0x01) /* Command Details CTLV tag */ + return; + if (pdu[2 + length_bytes] != 0x03) /* Command Details CTLV length */ + return; + if (pdu[4 + length_bytes] != 0x25) /* Set Up Menu command type */ + return; + + if (sd-set_up_menu_pdu) + g_free(sd-set_up_menu_pdu); + + sd-set_up_menu_pdu = g_memdup(pdu, len); + sd-set_up_menu_pdu_len = len; +} Can we implement SetUp menu command parser or at least use tlv iterators? This is just too ugly. struct phonesim_data { GAtMux *mux; GAtChat *chat; gboolean calypso; gboolean use_mux; + gboolean have_sim; + + guint sati_cb_id; + unsigned int stk_watch; + guint8 *stk_early_pdu; + guint stk_early_pdu_len; }; +static const char *cpin_prefix[] = { +CPIN:, NULL }; +static const char *none_prefix[] = { NULL }; + static int phonesim_probe(struct ofono_modem *modem) { struct phonesim_data *data; @@ -98,13 +109,32 @@ static void phonesim_debug(const char *str, void *user_data) ofono_info(%s, str); } +static void cpin_check_cb(gboolean ok, GAtResult *result, gpointer user_data) +{ + struct ofono_modem *modem = user_data; + struct phonesim_data *data = ofono_modem_get_data(modem); + + DBG(); + + data-have_sim = ok; + + ofono_modem_set_powered(modem, TRUE); +} + Again, looks like this belongs in a separate patch... +static void cfun_enable(struct phonesim_data *data, struct ofono_modem *modem) +{ + /* It looks like the PROFILE DOWNLOAD is done by the modem + * as part of +CFUN=1. By default the profile indicates that + * TE supports no Proactive UICC. We need to enable the + * %SATA and other notifications here for STK support and + * give the modem our profile bits (first N bytes) according + * to ETSI TS 102 223 section 5.2. The modem seems to AND + * the given value with its own capabilities and OR with some + * minimum value. The bits are reset to the minimal values + * on +CFUN=0. + * + * Default value is 450F80021FA40200. + * The mask is 4DFF973F7F0200FC0303FF9FFFE7. + */ + g_at_chat_send(data-chat, + AT%SATC=1,\19E1FF7FFF03FE\, + none_prefix, NULL, NULL); + + /* The initial %SATI notification should arrive together with + * AT+CFUN=1 response, that may be before the STK driver registers + * the notification. At the same time with Calypso we can't + * lose this first notification or STK will not be + * functional. This is a hack to save the PDU and supply it + * to STK driver once it's brought up. + */ + data-sati_cb_id = g_at_chat_register(data-chat, + %SATI:, sati_notify, FALSE, modem, NULL); + data-stk_watch = __ofono_modem_add_atom_watch(modem, + OFONO_ATOM_TYPE_STK, stk_watch, modem, NULL); + + g_at_chat_send(data-chat, AT+CFUN=1, + none_prefix, cfun_set_on_cb, modem); +} + Send this part as a separate patch from calypso stk support and SIM inserted changes. static void mux_setup(GAtMux *mux, gpointer user_data) { struct ofono_modem *modem = user_data; @@ -163,7 +271,7 @@ static void mux_setup(GAtMux *mux, gpointer user_data) if (data-calypso) g_at_chat_set_wakeup_command(data-chat, AT\r, 500, 5000); - g_at_chat_send(data-chat, AT+CFUN=1, NULL, cfun_set_on_cb, modem); + cfun_enable(data, modem); } static int phonesim_enable(struct ofono_modem *modem) @@
Re: [PATCH v2 1/6] Don't remove atoms when state goes from INSERTED to NOT PRESENT.
Hi Andrew, --- src/modem.c |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modem.c b/src/modem.c index 8319702..0d0cb2a 100644 Patch has been applied with a modified description. However, I'm thinking we should manipulate the lists directly based on SIM presence / pin state inside ofono_modem_add_atom. The logic is a little too complicated now. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH] ppp: transition to dead when lcp finished
Hi Kristen, Transition to DEAD when lcp is finished and ignore any io disconnects if we are already dead. --- gatchat/gatppp.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH] ppp: fix another hardcode of ppp_packet size
--- gatchat/ppp_net.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index 4e45ef1..bd1a60e 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -95,7 +95,7 @@ static gboolean ppp_net_callback(GIOChannel *channel, GIOCondition cond, { struct ppp_net *net = (struct ppp_net *) userdata; GIOStatus status; - gchar buf[MAX_PACKET + 2]; + gchar buf[MAX_PACKET + sizeof(struct ppp_header)]; gsize bytes_read; GError *error = NULL; struct ppp_header *ppp = (struct ppp_header *) buf; -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 1/8] Add utilities for encoding BTLVs and CTLVs.
This version is simplified and avoids memcpy'ing when encoding BER-TLVs, at the cost of robustness. Every BER-TLV now needs to be closed using .._next() or .._optimize() before it's valid. --- src/simutil.c | 316 + src/simutil.h | 50 + 2 files changed, 366 insertions(+), 0 deletions(-) diff --git a/src/simutil.c b/src/simutil.c index 941c551..f0876d3 100644 --- a/src/simutil.c +++ b/src/simutil.c @@ -486,6 +486,322 @@ static const guint8 *ber_tlv_find_by_tag(const guint8 *pdu, guint8 in_tag, return NULL; } +#define MAX_BER_TLV_HEADER 8 + +gboolean ber_tlv_builder_init(struct ber_tlv_builder *builder, + unsigned char *pdu, unsigned int size) +{ + if (size MAX_BER_TLV_HEADER) + return FALSE; + + builder-pdu = pdu; + builder-pos = 0; + builder-max = size; + builder-parent = NULL; + builder-tag = 0; + builder-len = 0; + + return TRUE; +} + +static void ber_tlv_builder_write_header(struct ber_tlv_builder *builder) +{ + int header_len = 0; + int start = builder-pos + MAX_BER_TLV_HEADER; + + /* Write length at end of the header space */ + if (builder-len = 0x7f) + builder-pdu[start - ++header_len] = builder-len; + else { + while (builder-len (header_len * 8)) { + builder-pdu[start - 1 - header_len] = + builder-len (header_len * 8); + header_len++; + } + builder-pdu[start - 1 - header_len] = 0x80 + header_len; + header_len++; + } + + /* Write the tag before length */ + if (builder-tag 0x1f) + builder-pdu[start - ++header_len] = + (builder-class 6) | + (builder-encoding 5) | + builder-tag; + else { + int i = 0; + + while (builder-tag (i * 7)) { + builder-pdu[start - ++header_len] = + i ? 0x80 | (builder-tag (i * 7)) : + (builder-tag 0x7f); + i++; + } + + builder-pdu[start - ++header_len] = + (builder-class 6) | (builder-encoding 5) | 0x1f; + } + + /* Pad with stuff bytes */ + if (header_len MAX_BER_TLV_HEADER) + memset(builder-pdu + builder-pos, 0xff, + MAX_BER_TLV_HEADER - header_len); +} + +gboolean ber_tlv_builder_next(struct ber_tlv_builder *builder) +{ + ber_tlv_builder_write_header(builder); + + builder-pos += MAX_BER_TLV_HEADER + builder-len; + + if (builder-pos + MAX_BER_TLV_HEADER builder-max) + return FALSE; + + if (builder-parent) + if (ber_tlv_builder_set_length(builder-parent, builder-pos + + MAX_BER_TLV_HEADER) == FALSE) + return FALSE; + + builder-tag = 0; + builder-len = 0; + + return TRUE; +} + +gboolean ber_tlv_builder_set_tag(struct ber_tlv_builder *builder, + enum ber_tlv_data_type class, + enum ber_tlv_data_encoding_type encoding, + unsigned int new_tag) +{ + builder-class = class; + builder-encoding = encoding; + builder-tag = new_tag; + + return TRUE; +} + +/* Resize the TLV because the content of Value field needs more space. If + * this TLV is part of another TLV, resize that one too. */ +gboolean ber_tlv_builder_set_length(struct ber_tlv_builder *builder, + unsigned int new_len) +{ + if (builder-pos + MAX_BER_TLV_HEADER + new_len builder-max) + return FALSE; + + if (builder-parent) + if (ber_tlv_builder_set_length(builder-parent, + builder-pos + MAX_BER_TLV_HEADER + + new_len) == FALSE) + return FALSE; + + builder-len = new_len; + + return TRUE; +} + +unsigned char *ber_tlv_builder_get_data(struct ber_tlv_builder *builder) +{ + return builder-pdu + builder-pos + MAX_BER_TLV_HEADER; +} + +gboolean ber_tlv_builder_recurse(struct ber_tlv_builder *builder, + struct ber_tlv_builder *recurse) +{ + unsigned char *end = builder-pdu + builder-max; + unsigned char *data = ber_tlv_builder_get_data(builder); + + if (ber_tlv_builder_init(recurse, data, end - data) == FALSE) + return FALSE; + + recurse-parent = builder; + + return TRUE; +} + +gboolean ber_tlv_builder_recurse_comprehension(struct ber_tlv_builder *builder, + struct comprehension_tlv_builder
[PATCH 2/8] Add a BER-TLV encoding test.
--- unit/test-simutil.c | 59 -- 1 files changed, 56 insertions(+), 3 deletions(-) diff --git a/unit/test-simutil.c b/unit/test-simutil.c index 2c8cb30..49a40cd 100644 --- a/unit/test-simutil.c +++ b/unit/test-simutil.c @@ -48,16 +48,15 @@ const unsigned char valid_mms_params[] = { 0x6D, 0x65, 0x00, 0x1B, 0x64, 0x75, 0x6D, 0x6D, 0x79, 0x5F, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64, 0x00 }; -static void test_ber_tlv_iter() +static void test_buffer(const unsigned char *buf, size_t size) { struct ber_tlv_iter iter; struct ber_tlv_iter cont; - ber_tlv_iter_init(iter, valid_mms_params, sizeof(valid_mms_params)); + ber_tlv_iter_init(iter, buf, size); g_assert(ber_tlv_iter_next(iter) == TRUE); g_assert(ber_tlv_iter_get_short_tag(iter) == 0xAB); - g_assert(ber_tlv_iter_get_length(iter) == 136); ber_tlv_iter_recurse(iter, cont); @@ -81,6 +80,59 @@ static void test_ber_tlv_iter() g_assert(ber_tlv_iter_next(iter) == FALSE); } +static void test_ber_tlv_iter() +{ + test_buffer(valid_mms_params, sizeof(valid_mms_params)); +} + +static void test_ber_tlv_builder() +{ + struct ber_tlv_iter iter[2]; + struct ber_tlv_builder builder[2]; + unsigned char buf[512], *pdu; + unsigned int pdulen, i[2]; + + ber_tlv_iter_init(iter[0], valid_mms_params, sizeof(valid_mms_params)); + g_assert(ber_tlv_builder_init(builder[0], buf, sizeof(buf))); + + i[0] = 0; + while (ber_tlv_iter_next(iter[0]) == TRUE) { + if (i[0]++) + g_assert(ber_tlv_builder_next(builder[1])); + + g_assert(ber_tlv_builder_set_tag(builder[0], + ber_tlv_iter_get_class(iter[0]), + ber_tlv_iter_get_encoding(iter[0]), + ber_tlv_iter_get_tag(iter[0]))); + + ber_tlv_iter_recurse(iter[0], iter[1]); + g_assert(ber_tlv_builder_recurse(builder[0], builder[1])); + + i[1] = 0; + while (ber_tlv_iter_next(iter[1]) == TRUE) { + if (i[1]++) + g_assert(ber_tlv_builder_next(builder[1])); + + g_assert(ber_tlv_builder_set_tag(builder[1], + ber_tlv_iter_get_class(iter[1]), + ber_tlv_iter_get_encoding(iter[1]), + ber_tlv_iter_get_tag(iter[1]))); + g_assert(ber_tlv_builder_set_length(builder[1], + ber_tlv_iter_get_length(iter[1]))); + + memcpy(ber_tlv_builder_get_data(builder[1]), + ber_tlv_iter_get_data(iter[1]), + ber_tlv_iter_get_length(iter[1])); + } + + ber_tlv_builder_optimize(builder[1], NULL, NULL); + } + + ber_tlv_builder_optimize(builder[0], pdu, pdulen); + + test_buffer(pdu, pdulen); +} + const unsigned char valid_efopl[] = { 0x42, 0xf6, 0x1d, 0x00, 0x00, 0xff, 0xfe, 0x01, }; @@ -190,6 +242,7 @@ int main(int argc, char **argv) g_test_init(argc, argv, NULL); g_test_add_func(/testsimutil/ber tlv iter, test_ber_tlv_iter); + g_test_add_func(/testsimutil/ber tlv builder, test_ber_tlv_builder); g_test_add_func(/testsimutil/EONS Handling, test_eons); g_test_add_func(/testsimutil/Elementary File DB, test_ef_db); g_test_add_func(/testsimutil/3G Status response, test_3g_status_data); -- 1.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 3/8] Add STK-specific CTLV encoding utilities.
--- src/stkutil.c | 155 + 1 files changed, 155 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 50fa4c1..e51090c 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2343,3 +2343,158 @@ void stk_command_free(struct stk_command *command) g_free(command); } + +struct stk_tlv_builder { + struct comprehension_tlv_builder ctlv; + unsigned char *value; + int len; +}; + +static inline void stk_tlv_builder_init(struct stk_tlv_builder *iter, + unsigned char *pdu, unsigned int size) +{ + comprehension_tlv_builder_init(iter-ctlv, pdu, size); + iter-value = NULL; +} + +static inline gboolean stk_tlv_open_container(struct stk_tlv_builder *iter, + gboolean cr, + unsigned char shorttag, + gboolean relocatable) +{ + comprehension_tlv_builder_set_tag(iter-ctlv, cr, shorttag); + comprehension_tlv_builder_set_length(iter-ctlv, + relocatable ? 0xff : 0x7f); + iter-len = 0; + iter-value = comprehension_tlv_builder_get_data(iter-ctlv); + + return TRUE; +} + +static inline gboolean stk_tlv_close_container(struct stk_tlv_builder *iter) +{ + return comprehension_tlv_builder_set_length(iter-ctlv, iter-len) + comprehension_tlv_builder_next(iter-ctlv); +} + +static inline unsigned int stk_tlv_get_length(struct stk_tlv_builder *iter) +{ + return iter-ctlv.pos; +} + +static inline void stk_tlv_append_byte(struct stk_tlv_builder *iter, + unsigned char num) +{ + iter-value[iter-len++] = num; +} + +static inline void stk_tlv_append_short(struct stk_tlv_builder *iter, + unsigned short num) +{ + iter-value[iter-len++] = num 8; + iter-value[iter-len++] = num 0xff; +} + +static inline gboolean stk_tlv_append_text(struct stk_tlv_builder *iter, + int dcs, const char *text) +{ + unsigned int len; + unsigned char *gsm, *ucs2; + long written = 0; + gsize gwritten; + + if (text == NULL) + return TRUE; + + len = strlen(text); + + switch (dcs) { + case 0x00: + gsm = convert_utf8_to_gsm(text, len, NULL, NULL, 0); + if (gsm == NULL len 0) + return FALSE; + + iter-value[iter-len++] = 0x00; + + pack_7bit_own_buf(gsm, len, 0, FALSE, written, 0, + iter-value + iter-len); + g_free(gsm); + if (written 1 len 0) + return FALSE; + iter-len += written; + + return TRUE; + case 0x04: + gsm = convert_utf8_to_gsm(text, len, NULL, written, 0); + if (gsm == NULL len 0) + return FALSE; + + iter-value[iter-len++] = 0x04; + + memcpy(iter-value + iter-len, gsm, written); + iter-len += written; + + g_free(gsm); + + return TRUE; + case 0x08: + ucs2 = (unsigned char *) g_convert((const gchar *) text, len, + UCS-2BE, UTF-8//TRANSLIT, + NULL, gwritten, NULL); + if (ucs2 == NULL) + return FALSE; + + iter-value[iter-len++] = 0x08; + + memcpy(iter-value + iter-len, ucs2, gwritten); + iter-len += gwritten; + + g_free(ucs2); + + return TRUE; + case -1: + /* Fake DCS to mean unpacked GSM alphabet if possible +* to encode the string and UCS2 if not. */ + gsm = convert_utf8_to_gsm(text, len, NULL, written, 0); + + if (gsm == NULL len 0) { + /* Use UCS2. */ + ucs2 = (unsigned char *) g_convert( + (const gchar *) text, len, + UCS-2BE, UTF-8//TRANSLIT, + NULL, gwritten, NULL); + if (ucs2 == NULL) + return FALSE; + + iter-value[iter-len++] = 0x08; + + memcpy(iter-value + iter-len, ucs2, gwritten); + iter-len += gwritten; + + g_free(ucs2); + + return TRUE; + } + + iter-value[iter-len++] = 0x04; + + memcpy(iter-value + iter-len, gsm, written); + iter-len += written; + + g_free(gsm); + + return TRUE; + }
[PATCH 4/8] Encoding of the four TERMINAL RESPONSE pdus.
--- src/stkutil.c | 171 + src/stkutil.h | 45 +++ 2 files changed, 216 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index e51090c..1205f40 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -2498,3 +2498,174 @@ static inline gboolean stk_tlv_append_bytes(struct stk_tlv_builder *iter, return TRUE; } + +/* Described in TS 102.223 Section 8.8 */ +static gboolean build_dataobj_duration(struct stk_tlv_builder *tlv, + const void *data) +{ + const struct stk_duration *duration = data; + + if (duration-interval == 0x00) + return TRUE; + + if (stk_tlv_open_container(tlv, FALSE, STK_DATA_OBJECT_TYPE_DURATION, + FALSE) != TRUE) + return FALSE; + + stk_tlv_append_byte(tlv, duration-unit); + stk_tlv_append_byte(tlv, duration-interval); + + return stk_tlv_close_container(tlv); +} + +/* Described in TS 102.223 Section 8.12 */ +static gboolean build_dataobj_result(struct stk_tlv_builder *tlv, + const void *data) +{ + const struct stk_result *result = data; + + if (stk_tlv_open_container(tlv, TRUE, STK_DATA_OBJECT_TYPE_RESULT, + FALSE) != TRUE) + return FALSE; + + stk_tlv_append_byte(tlv, result-type); + if (result-additional_len) + if (stk_tlv_append_bytes(tlv, result-additional, + result-additional_len) != + TRUE) + return FALSE; + + return stk_tlv_close_container(tlv); +} + +/* Defined in TS 102.223 Section 8.15 */ +static gboolean build_dataobj_text(struct stk_tlv_builder *tlv, + const void *data) +{ + const struct stk_answer_text *text = data; + + if (!text-text !text-yesno) + return TRUE; + + /* See note about CR in stk_pdu_from_response */ + if (stk_tlv_open_container(tlv, TRUE, STK_DATA_OBJECT_TYPE_TEXT, + TRUE) != TRUE) + return FALSE; + + if (text-yesno == TRUE) { + /* Section 6.8.5: +* When the terminal issues [...] command qualifier set +* to Yes/No, it shall supply the value 01 when the +* answer is positive and the value '00' when the +* answer is negative in the text string data object. +*/ + stk_tlv_append_byte(tlv, 0x04); + stk_tlv_append_byte(tlv, text-text ? 0x01 : 0x00); + } else if (text-packed) { + if (stk_tlv_append_text(tlv, 0x00, text-text) != TRUE) + return FALSE; + } else { + if (stk_tlv_append_text(tlv, -1, text-text) != TRUE) + return FALSE; + } + return stk_tlv_close_container(tlv); +} + +static gboolean build_dataobj(struct stk_tlv_builder *tlv, gboolean + (*builder_func)(struct stk_tlv_builder *, + const void *), ...) +{ + va_list args; + + va_start(args, builder_func); + + while (builder_func) { + const void *data = va_arg(args, const void *); + + if (builder_func(tlv, data) != TRUE) + return FALSE; + + builder_func = va_arg(args, gboolean (*)( + struct stk_tlv_builder *, + const void *)); + } + + return TRUE; +} + +unsigned int stk_pdu_from_response(const struct stk_response *response, + unsigned char *pdu, unsigned int size) +{ + struct stk_tlv_builder builder; + gboolean ok = TRUE; + + stk_tlv_builder_init(builder, pdu, size); + + /* +* Encode command details, they come in order with +* Command Details TLV first, followed by Device Identities TLV +* and the Result TLV. Comprehension required everywhere. +*/ + if (stk_tlv_open_container(builder, TRUE, + STK_DATA_OBJECT_TYPE_COMMAND_DETAILS, + FALSE) != TRUE) + return 0; + + stk_tlv_append_byte(builder, response-number); + stk_tlv_append_byte(builder, response-type); + stk_tlv_append_byte(builder, response-qualifier); + + if (stk_tlv_close_container(builder) != TRUE) + return 0; + + /* TS 102 223 section 6.8 states: +* For all COMPREHENSION-TLV objects with Min = N, the terminal +* should set the CR flag to comprehension not required. +* All the data objects except Command Details and Result have +
[PATCH 7/8] test-stkutil: Add unit test for Get Input response encoding.
--- unit/test-stkutil.c | 778 +++ 1 files changed, 778 insertions(+), 0 deletions(-) diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c index 7574fa1..2f2a725 100644 --- a/unit/test-stkutil.c +++ b/unit/test-stkutil.c @@ -2142,6 +2142,717 @@ static const struct terminal_response_test get_inkey_response_data_1311 = { }, }; +static const unsigned char get_input_response_111[] = { + 0x81, 0x03, 0x01, 0x23, 0x00, 0x82, 0x02, 0x82, + 0x81, 0x83, 0x01, 0x00, 0x8d, 0x06, 0x04, 0x31, + 0x32, 0x33, 0x34, 0x35, +}; + +static const struct terminal_response_test get_input_response_data_111 = { + .pdu = get_input_response_111, + .pdu_len = sizeof(get_input_response_111), + .response = { + .number = 1, + .type = STK_COMMAND_TYPE_GET_INPUT, + .qualifier = 0x00, + .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL, + .dst = STK_DEVICE_IDENTITY_TYPE_UICC, + .result = { + .type = STK_RESULT_TYPE_SUCCESS, + .additional_len = 0, + }, + { .get_input = { + .text = { + .text = 12345, + .packed = FALSE, + .yesno = FALSE, + }, + }}, + }, +}; + +static const unsigned char get_input_response_121[] = { + 0x81, 0x03, 0x01, 0x23, 0x08, 0x82, 0x02, 0x82, + 0x81, 0x83, 0x01, 0x00, 0x8d, 0x06, 0x00, 0xb6, + 0x9b, 0x6a, 0xb4, 0x02, +}; + +static const struct terminal_response_test get_input_response_data_121 = { + .pdu = get_input_response_121, + .pdu_len = sizeof(get_input_response_121), + .response = { + .number = 1, + .type = STK_COMMAND_TYPE_GET_INPUT, + .qualifier = 0x08, + .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL, + .dst = STK_DEVICE_IDENTITY_TYPE_UICC, + .result = { + .type = STK_RESULT_TYPE_SUCCESS, + .additional_len = 0, + }, + { .get_input = { + .text = { + .text = 67*#+, + .packed = TRUE, + .yesno = FALSE, + }, + }}, + }, +}; + +static const unsigned char get_input_response_131[] = { + 0x81, 0x03, 0x01, 0x23, 0x01, 0x82, 0x02, 0x82, + 0x81, 0x83, 0x01, 0x00, 0x8d, 0x06, 0x04, 0x41, + 0x62, 0x43, 0x64, 0x45, +}; + +static const struct terminal_response_test get_input_response_data_131 = { + .pdu = get_input_response_131, + .pdu_len = sizeof(get_input_response_131), + .response = { + .number = 1, + .type = STK_COMMAND_TYPE_GET_INPUT, + .qualifier = 0x01, + .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL, + .dst = STK_DEVICE_IDENTITY_TYPE_UICC, + .result = { + .type = STK_RESULT_TYPE_SUCCESS, + .additional_len = 0, + }, + { .get_input = { + .text = { + .text = AbCdE, + .packed = FALSE, + .yesno = FALSE, + }, + }}, + }, +}; + +static const unsigned char get_input_response_141[] = { + 0x81, 0x03, 0x01, 0x23, 0x04, 0x82, 0x02, 0x82, + 0x81, 0x83, 0x01, 0x00, 0x8d, 0x08, 0x04, 0x32, + 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, +}; + +static const struct terminal_response_test get_input_response_data_141 = { + .pdu = get_input_response_141, + .pdu_len = sizeof(get_input_response_141), + .response = { + .number = 1, + .type = STK_COMMAND_TYPE_GET_INPUT, + .qualifier = 0x04, + .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL, + .dst = STK_DEVICE_IDENTITY_TYPE_UICC, + .result = { + .type = STK_RESULT_TYPE_SUCCESS, + .additional_len = 0, + }, + { .get_input = { + .text = { + .text = 2345678, + .packed = FALSE, + .yesno = FALSE, + }, + }}, + }, +}; + +static const unsigned char get_input_response_151[] = { + 0x81, 0x03, 0x01, 0x23, 0x00, 0x82, 0x02, 0x82, + 0x81, 0x83, 0x01, 0x00, 0x8d, 0x15, 0x04, 0x31, + 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x30, +}; + +static const struct terminal_response_test get_input_response_data_151 = { + .pdu =
RE: [PATCH 6/8] test-stkutil: Add unit test for Get Inkey response encoding.
Hi Andrew, +#define NO_DURATION { .interval = 0x00, } +#define NO_TEXT { .text = NULL, .yesno = FALSE, } There is no need to define these as static variables will be initialized to zero automatically. We must guarentee zero means non-existence. If some meaningful initialization happens to be missed, later check would catch them. Hope this can save several lines of code;) + +static const unsigned char get_inkey_response_111[] = { + 0x81, 0x03, 0x01, 0x22, 0x00, 0x82, 0x02, 0x82, + 0x81, 0x83, 0x01, 0x00, 0x8d, 0x02, 0x04, 0x2b, Regards, -Yang ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono