• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2015 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""
6This module implements the classes for information structures encapsulated in
7either |MBIMCommandMessage| or |MBIMCommandDone|.
8
9Reference:
10    [1] Universal Serial Bus Communications Class Subclass Specification for
11        Mobile Broadband Interface Model
12        http://www.usb.org/developers/docs/devclass_docs/
13        MBIM10Errata1_073013.zip
14"""
15from autotest_lib.client.cros.cellular.mbim_compliance import mbim_constants
16from autotest_lib.client.cros.cellular.mbim_compliance \
17        import mbim_message_request
18from autotest_lib.client.cros.cellular.mbim_compliance \
19        import mbim_message_response
20
21
22class MBIMSetConnect(mbim_message_request.MBIMCommand):
23    """ The class for MBIM_SET_CONNECT structure. """
24
25    _FIELDS = (('I', 'session_id', ''),
26               ('I', 'activation_command', ''),
27               ('I', 'access_string_offset', ''),
28               ('I', 'access_string_size', ''),
29               ('I', 'user_name_offset', ''),
30               ('I', 'user_name_size', ''),
31               ('I', 'password_offset', ''),
32               ('I', 'password_size', ''),
33               ('I', 'compression', ''),
34               ('I', 'auth_protocol', ''),
35               ('I', 'ip_type', ''),
36               ('16s', 'context_type', ''))
37    _DEFAULTS = {'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
38                 'cid' : mbim_constants.MBIM_CID_CONNECT,
39                 'command_type' : mbim_constants.COMMAND_TYPE_SET}
40
41
42class MBIMConnectQuery(mbim_message_request.MBIMCommand):
43    """ The class for MBIM_CONNECT_QUERY structure. """
44
45    _FIELDS = (('I', 'session_id', ''),
46               ('I', 'activation_state', ''),
47               ('I', 'voice_call_state', ''),
48               ('I', 'ip_type', ''),
49               ('16s', 'context_type', ''),
50               ('I', 'nw_error', ''))
51    _DEFAULTS = {'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
52                 'cid' : mbim_constants.MBIM_CID_CONNECT,
53                 'command_type' : mbim_constants.COMMAND_TYPE_QUERY,
54                 'information_buffer_length' : 36,
55                 'activation_state' : 0,
56                 'voice_call_state' : 0,
57                 'ip_type' : 0,
58                 'context_type' : mbim_constants.MBIM_CONTEXT_TYPE_NONE.bytes,
59                 'nw_error' : 0}
60
61
62class MBIMConnectInfo(mbim_message_response.MBIMCommandDone):
63    """ The class for MBIM_CONNECT_INFO structure. """
64
65    _FIELDS = (('I', 'session_id', ''),
66               ('I', 'activation_state', ''),
67               ('I', 'voice_call_state', ''),
68               ('I', 'ip_type', ''),
69               ('16s', 'context_type', ''),
70               ('I', 'nw_error', ''))
71    _IDENTIFIERS = {
72            'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
73            'cid' : mbim_constants.MBIM_CID_CONNECT}
74
75
76class MBIMDeviceCapsQuery(mbim_message_request.MBIMCommand):
77    """ The class for MBIM_DEVICE_CAPS_QUERY structure. """
78
79    _DEFAULTS = {'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
80                 'cid' : mbim_constants.MBIM_CID_DEVICE_CAPS,
81                 'command_type' : mbim_constants.COMMAND_TYPE_QUERY,
82                 'information_buffer_length' : 0}
83
84
85class MBIMDeviceCapsInfo(mbim_message_response.MBIMCommandDone):
86    """ The class for MBIM_DEVICE_CAPS_INFO structure. """
87
88    _FIELDS = (('I', 'device_type', ''),
89               ('I', 'cellular_class', ''),
90               ('I', 'voice_class', ''),
91               ('I', 'sim_class', ''),
92               ('I', 'data_class', ''),
93               ('I', 'sms_caps', ''),
94               ('I', 'control_caps', ''),
95               ('I', 'max_sessions', ''),
96               ('I', 'custom_data_class_offset', ''),
97               ('I', 'custom_data_class_size', ''),
98               ('I', 'device_id_offset', ''),
99               ('I', 'device_id_size', ''),
100               ('I', 'firmware_info_offset', ''),
101               ('I', 'firmware_info_size', ''),
102               ('I', 'hardware_info_offset', ''),
103               ('I', 'hardware_info_size', ''))
104    _IDENTIFIERS = {
105            'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
106            'cid' : mbim_constants.MBIM_CID_DEVICE_CAPS}
107
108
109class MBIMDeviceServicesQuery(mbim_message_request.MBIMCommand):
110    """ The class for MBIM_DEVICE_SERVICES_QUERY structure. """
111
112    _DEFAULTS = {'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
113                 'cid' : mbim_constants.MBIM_CID_DEVICE_SERVICES,
114                 'command_type' : mbim_constants.COMMAND_TYPE_QUERY,
115                 'information_buffer_length' : 0}
116
117
118class MBIMDeviceServicesInfo(mbim_message_response.MBIMCommandDone):
119    """ The class for MBIM_DEVICE_SERVICES_INFO structure. """
120
121    # The length of |device_services_ref_list| depends on the value of
122    # |device_services_count|.
123    _FIELDS = (('I', 'device_services_count', ''),
124               ('I', 'max_dss_sessions', ''))
125               #('Q', 'device_services_ref_list', ''))
126    _IDENTIFIERS = {
127            'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
128            'cid' : mbim_constants.MBIM_CID_DEVICE_SERVICES}
129
130
131class MBIMRadioStateInfo(mbim_message_response.MBIMCommandDone):
132    """ The class for MBIM_RADIO_STATE_INFO structure. """
133
134    _FIELDS = (('I', 'hw_radio_state', ''),
135               ('I', 'sw_radio_state', ''))
136
137
138class MBIMIPConfigurationQuery(mbim_message_request.MBIMCommand):
139    """ The class for MBIM_IP_CONFIGURATION_INFO structure. """
140
141    _FIELDS = (('I', 'session_id', ''),
142               ('I', 'ipv4_configuration_available', ''),
143               ('I', 'ipv6_configuration_available', ''),
144               ('I', 'ipv4_address_count', ''),
145               ('I', 'ipv4_address_offset', ''),
146               ('I', 'ipv6_address_count', ''),
147               ('I', 'ipv6_address_offset', ''),
148               ('I', 'ipv4_gateway_offset', ''),
149               ('I', 'ipv6_gateway_offset', ''),
150               ('I', 'ipv4_dns_server_count', ''),
151               ('I', 'ipv4_dns_server_offset', ''),
152               ('I', 'ipv6_dns_server_count', ''),
153               ('I', 'ipv6_dns_server_offset', ''),
154               ('I', 'ipv4_mtu', ''),
155               ('I', 'ipv6_mtu', ''))
156    _DEFAULTS = {'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
157                 'cid' : mbim_constants.MBIM_CID_IP_CONFIGURATION,
158                 'command_type' : mbim_constants.COMMAND_TYPE_QUERY,
159                 'information_buffer_length' : 60,
160                 'ipv4_configuration_available' : 0,
161                 'ipv6_configuration_available' : 0,
162                 'ipv4_address_count' : 0,
163                 'ipv4_address_offset' : 0,
164                 'ipv6_address_count' : 0,
165                 'ipv6_address_offset' : 0,
166                 'ipv4_gateway_offset' : 0,
167                 'ipv6_gateway_offset' : 0,
168                 'ipv4_dns_server_count' : 0,
169                 'ipv4_dns_server_offset' : 0,
170                 'ipv6_dns_server_count' : 0,
171                 'ipv6_dns_server_offset' : 0,
172                 'ipv4_mtu' : 0,
173                 'ipv6_mtu' : 0}
174
175
176class MBIMIPConfigurationInfo(mbim_message_response.MBIMCommandDone):
177    """ The class for MBIM_IP_CONFIGURATION_INFO structure. """
178
179    _FIELDS = (('I', 'session_id', ''),
180               ('I', 'ipv4_configuration_available', ''),
181               ('I', 'ipv6_configuration_available', ''),
182               ('I', 'ipv4_address_count', ''),
183               ('I', 'ipv4_address_offset', ''),
184               ('I', 'ipv6_address_count', ''),
185               ('I', 'ipv6_address_offset', ''),
186               ('I', 'ipv4_gateway_offset', ''),
187               ('I', 'ipv6_gateway_offset', ''),
188               ('I', 'ipv4_dns_server_count', ''),
189               ('I', 'ipv4_dns_server_offset', ''),
190               ('I', 'ipv6_dns_server_count', ''),
191               ('I', 'ipv6_dns_server_offset', ''),
192               ('I', 'ipv4_mtu', ''),
193               ('I', 'ipv6_mtu', ''))
194    _IDENTIFIERS = {
195            'device_service_id' : mbim_constants.UUID_BASIC_CONNECT.bytes,
196            'cid' : mbim_constants.MBIM_CID_IP_CONFIGURATION}
197