diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-06 14:17:30 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-06 14:17:36 +0200 |
commit | 01ce054d8de1aefb4240a234ca7687293fac8530 (patch) | |
tree | f63b31fbea07c4198eb0c818116b229bc67005ce | |
parent | 51680ce50be75789897529bd3b9750a09150a97b (diff) | |
download | libmbim-01ce054d8de1aefb4240a234ca7687293fac8530.tar.gz |
basic-connect: implement 'Service Activation' command handling
Also add unit tests for the message builder and response parser, as we're
testing the new 'byte-array' type reader.
-rw-r--r-- | data/mbim-service-basic-connect.json | 13 | ||||
-rw-r--r-- | libmbim-glib/test/test-message-command-builder.c | 59 | ||||
-rw-r--r-- | libmbim-glib/test/test-message-contents.c | 52 |
3 files changed, 124 insertions, 0 deletions
diff --git a/data/mbim-service-basic-connect.json b/data/mbim-service-basic-connect.json index 96ffdcd..b787586 100644 --- a/data/mbim-service-basic-connect.json +++ b/data/mbim-service-basic-connect.json @@ -483,6 +483,19 @@ "array-size-field" : "ProvisionedContextsCount" } ] }, // ********************************************************************************* + + { "name" : "Service Activation", + "service" : "Basic Connect", + "type" : "Command", + "set" : [ { "name" : "Buffer", + "format" : "byte-array" } ], + "response" : [ { "name" : "NwError", + "format" : "guint32", + "public-format" : "MbimNwError" }, + { "name" : "Buffer", + "format" : "byte-array" } ] }, + + // ********************************************************************************* { "name" : "MbimIPv4Element", "type" : "Struct", "contents" : [ { "name" : "OnLinkPrefixLength", diff --git a/libmbim-glib/test/test-message-command-builder.c b/libmbim-glib/test/test-message-command-builder.c index 9743638..a04b098 100644 --- a/libmbim-glib/test/test-message-command-builder.c +++ b/libmbim-glib/test/test-message-command-builder.c @@ -349,6 +349,63 @@ test_message_command_builder_set_connect (void) mbim_message_unref (message); } +static void +test_message_command_builder_set_service_activation (void) +{ + GError *error = NULL; + MbimMessage *message; + const guint8 buffer [] = { + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08 + }; + const guint8 expected_message [] = { + /* header */ + 0x03, 0x00, 0x00, 0x00, /* type */ + 0x38, 0x00, 0x00, 0x00, /* length */ + 0x01, 0x00, 0x00, 0x00, /* transaction id */ + /* fragment header */ + 0x01, 0x00, 0x00, 0x00, /* total */ + 0x00, 0x00, 0x00, 0x00, /* current */ + /* command_message */ + 0xA2, 0x89, 0xCC, 0x33, /* service id */ + 0xBC, 0xBB, 0x8B, 0x4F, + 0xB6, 0xB0, 0x13, 0x3E, + 0xC2, 0xAA, 0xE6, 0xDF, + 0x0E, 0x00, 0x00, 0x00, /* command id */ + 0x01, 0x00, 0x00, 0x00, /* command_type */ + 0x08, 0x00, 0x00, 0x00, /* buffer_length */ + /* information buffer */ + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08 }; + + /* CONNECT set message */ + message = (mbim_message_service_activation_set_new ( + sizeof (buffer), + buffer, + &error)); + g_assert_no_error (error); + g_assert (message != NULL); + mbim_message_set_transaction_id (message, 1); + + test_message_trace ((const guint8 *)((GByteArray *)message)->data, + ((GByteArray *)message)->len, + expected_message, + sizeof (expected_message)); + + g_assert_cmpuint (mbim_message_get_transaction_id (message), ==, 1); + g_assert_cmpuint (mbim_message_get_message_type (message), ==, MBIM_MESSAGE_TYPE_COMMAND); + g_assert_cmpuint (mbim_message_get_message_length (message), ==, sizeof (expected_message)); + + g_assert_cmpuint (mbim_message_command_get_service (message), ==, MBIM_SERVICE_BASIC_CONNECT); + g_assert_cmpuint (mbim_message_command_get_cid (message), ==, MBIM_CID_BASIC_CONNECT_SERVICE_ACTIVATION); + g_assert_cmpuint (mbim_message_command_get_command_type (message), ==, MBIM_MESSAGE_COMMAND_TYPE_SET); + + g_assert_cmpuint (((GByteArray *)message)->len, ==, sizeof (expected_message)); + g_assert (memcmp (((GByteArray *)message)->data, expected_message, sizeof (expected_message)) == 0); + + mbim_message_unref (message); +} + int main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); @@ -359,5 +416,7 @@ int main (int argc, char **argv) g_test_add_func ("/libmbim-glib/message/command-builder/raw/set-connect", test_message_command_builder_raw_set_connect); g_test_add_func ("/libmbim-glib/message/command-builder/set-connect", test_message_command_builder_set_connect); + g_test_add_func ("/libmbim-glib/message/command-builder/set-service-activation", test_message_command_builder_set_service_activation); + return g_test_run (); } diff --git a/libmbim-glib/test/test-message-contents.c b/libmbim-glib/test/test-message-contents.c index 0ecf72f..33117aa 100644 --- a/libmbim-glib/test/test-message-contents.c +++ b/libmbim-glib/test/test-message-contents.c @@ -482,6 +482,57 @@ test_message_contents_basic_connect_ip_configuration (void) mbim_message_unref (response); } +static void +test_message_contents_basic_connect_service_activation (void) +{ + MbimMessage *response; + GError *error = NULL; + guint32 nw_error; + const guint8 *databuffer; + guint32 databuffer_size; + const guint8 expected_databuffer [] = { + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08 + }; + const guint8 buffer [] = { + /* header */ + 0x03, 0x00, 0x00, 0x80, /* type */ + 0x3C, 0x00, 0x00, 0x00, /* length */ + 0x02, 0x00, 0x00, 0x00, /* transaction id */ + /* fragment header */ + 0x01, 0x00, 0x00, 0x00, /* total */ + 0x00, 0x00, 0x00, 0x00, /* current */ + /* command_done_message */ + 0xA2, 0x89, 0xCC, 0x33, /* service id */ + 0xBC, 0xBB, 0x8B, 0x4F, + 0xB6, 0xB0, 0x13, 0x3E, + 0xC2, 0xAA, 0xE6, 0xDF, + 0x0E, 0x00, 0x00, 0x00, /* command id */ + 0x00, 0x00, 0x00, 0x00, /* status code */ + 0x0C, 0x00, 0x00, 0x00, /* buffer length */ + /* information buffer */ + 0x06, 0x00, 0x00, 0x00, /* nw error */ + 0x01, 0x02, 0x03, 0x04, /* buffer */ + 0x05, 0x06, 0x07, 0x08 }; + + response = mbim_message_new (buffer, sizeof (buffer)); + + g_assert (mbim_message_service_activation_response_parse ( + response, + &nw_error, + &databuffer_size, + &databuffer, + &error)); + + g_assert_no_error (error); + + g_assert_cmpuint (nw_error, ==, MBIM_NW_ERROR_ILLEGAL_ME); + g_assert_cmpuint (databuffer_size, ==, sizeof (expected_databuffer)); + g_assert (memcmp (databuffer, expected_databuffer, databuffer_size) == 0); + + mbim_message_unref (response); +} + int main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); @@ -490,6 +541,7 @@ int main (int argc, char **argv) g_test_add_func ("/libmbim-glib/message-contents/basic-connect/subscriber-ready-status", test_message_contents_basic_connect_subscriber_ready_status); g_test_add_func ("/libmbim-glib/message-contents/basic-connect/device-caps", test_message_contents_basic_connect_device_caps); g_test_add_func ("/libmbim-glib/message-contents/basic-connect/ip-configuration", test_message_contents_basic_connect_ip_configuration); + g_test_add_func ("/libmbim-glib/message-contents/basic-connect/service-activation", test_message_contents_basic_connect_service_activation); return g_test_run (); } |