| 1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 3 |
/* |
| 4 |
* libmbim-glib -- GLib/GIO based library to control MBIM devices |
| 5 |
* |
| 6 |
* Copyright (C) 2013 - 2022 Aleksander Morgado <[email protected]> |
| 7 |
* Copyright (C) 2022 Google, Inc. |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef _LIBMBIM_GLIB_MBIM_MESSAGE_H_ |
| 11 |
#define _LIBMBIM_GLIB_MBIM_MESSAGE_H_ |
| 12 |
|
| 13 |
#if !defined (__LIBMBIM_GLIB_H_INSIDE__) && !defined (LIBMBIM_GLIB_COMPILATION) |
| 14 |
#error "Only <libmbim-glib.h> can be included directly." |
| 15 |
#endif |
| 16 |
|
| 17 |
#include <glib.h> |
| 18 |
#include <glib-object.h> |
| 19 |
|
| 20 |
#include "mbim-uuid.h" |
| 21 |
#include "mbim-errors.h" |
| 22 |
|
| 23 |
G_BEGIN_DECLS |
| 24 |
|
| 25 |
/** |
| 26 |
* SECTION:mbim-message |
| 27 |
* @title: MbimMessage |
| 28 |
* @short_description: Generic MBIM message handling routines |
| 29 |
* |
| 30 |
* #MbimMessage is a generic type representing a MBIM message of any kind |
| 31 |
* (request, response, indication). |
| 32 |
**/ |
| 33 |
|
| 34 |
/** |
| 35 |
* MbimMessage: |
| 36 |
* |
| 37 |
* An opaque type representing a MBIM message. |
| 38 |
* |
| 39 |
* Since: 1.0 |
| 40 |
*/ |
| 41 |
typedef struct _MbimMessage MbimMessage; |
| 42 |
|
| 43 |
GType mbim_message_get_type (void) G_GNUC_CONST; |
| 44 |
#define MBIM_TYPE_MESSAGE (mbim_message_get_type ()) |
| 45 |
|
| 46 |
/** |
| 47 |
* MbimIPv4: |
| 48 |
* @addr: 4 bytes specifying the IPv4 address. |
| 49 |
* |
| 50 |
* An IPv4 address. |
| 51 |
* |
| 52 |
* Since: 1.0 |
| 53 |
*/ |
| 54 |
typedef struct _MbimIPv4 MbimIPv4; |
| 55 |
struct _MbimIPv4 { |
| 56 |
guint8 addr[4]; |
| 57 |
}; |
| 58 |
|
| 59 |
/** |
| 60 |
* MbimIPv6: |
| 61 |
* @addr: 16 bytes specifying the IPv6 address. |
| 62 |
* |
| 63 |
* An IPv6 address. |
| 64 |
* |
| 65 |
* Since: 1.0 |
| 66 |
*/ |
| 67 |
typedef struct _MbimIPv6 MbimIPv6; |
| 68 |
struct _MbimIPv6 { |
| 69 |
guint8 addr[16]; |
| 70 |
}; |
| 71 |
|
| 72 |
/** |
| 73 |
* MbimMessageType: |
| 74 |
* @MBIM_MESSAGE_TYPE_INVALID: Invalid MBIM message. |
| 75 |
* @MBIM_MESSAGE_TYPE_OPEN: Initialization request. |
| 76 |
* @MBIM_MESSAGE_TYPE_CLOSE: Close request. |
| 77 |
* @MBIM_MESSAGE_TYPE_COMMAND: Command request. |
| 78 |
* @MBIM_MESSAGE_TYPE_HOST_ERROR: Host-reported error in the communication. |
| 79 |
* @MBIM_MESSAGE_TYPE_OPEN_DONE: Response to initialization request. |
| 80 |
* @MBIM_MESSAGE_TYPE_CLOSE_DONE: Response to close request. |
| 81 |
* @MBIM_MESSAGE_TYPE_COMMAND_DONE: Response to command request. |
| 82 |
* @MBIM_MESSAGE_TYPE_FUNCTION_ERROR: Function-reported error in the communication. |
| 83 |
* @MBIM_MESSAGE_TYPE_INDICATE_STATUS: Unsolicited message from the function. |
| 84 |
* |
| 85 |
* Type of MBIM messages. |
| 86 |
* |
| 87 |
* Since: 1.0 |
| 88 |
*/ |
| 89 |
typedef enum { /*< since=1.0 >*/ |
| 90 |
MBIM_MESSAGE_TYPE_INVALID = 0x00000000, |
| 91 |
/* From Host to Function */ |
| 92 |
MBIM_MESSAGE_TYPE_OPEN = 0x00000001, |
| 93 |
MBIM_MESSAGE_TYPE_CLOSE = 0x00000002, |
| 94 |
MBIM_MESSAGE_TYPE_COMMAND = 0x00000003, |
| 95 |
MBIM_MESSAGE_TYPE_HOST_ERROR = 0x00000004, |
| 96 |
/* From Function to Host */ |
| 97 |
MBIM_MESSAGE_TYPE_OPEN_DONE = 0x80000001, |
| 98 |
MBIM_MESSAGE_TYPE_CLOSE_DONE = 0x80000002, |
| 99 |
MBIM_MESSAGE_TYPE_COMMAND_DONE = 0x80000003, |
| 100 |
MBIM_MESSAGE_TYPE_FUNCTION_ERROR = 0x80000004, |
| 101 |
MBIM_MESSAGE_TYPE_INDICATE_STATUS = 0x80000007 |
| 102 |
} MbimMessageType; |
| 103 |
|
| 104 |
/*****************************************************************************/ |
| 105 |
/* Generic message interface */ |
| 106 |
|
| 107 |
/** |
| 108 |
* mbim_message_new: |
| 109 |
* @data: contents of the message. |
| 110 |
* @data_length: length of the message. |
| 111 |
* |
| 112 |
* Create a #MbimMessage with the given contents. |
| 113 |
* |
| 114 |
* Returns: (transfer full): a newly created #MbimMessage, which should be freed with mbim_message_unref(). |
| 115 |
* |
| 116 |
* Since: 1.0 |
| 117 |
*/ |
| 118 |
MbimMessage *mbim_message_new (const guint8 *data, |
| 119 |
guint32 data_length); |
| 120 |
|
| 121 |
/** |
| 122 |
* mbim_message_dup: |
| 123 |
* @self: a #MbimMessage to duplicate. |
| 124 |
* |
| 125 |
* Create a #MbimMessage with the same contents as @self. |
| 126 |
* |
| 127 |
* Returns: (transfer full): a newly created #MbimMessage, which should be freed with mbim_message_unref(). |
| 128 |
* |
| 129 |
* Since: 1.0 |
| 130 |
*/ |
| 131 |
MbimMessage *mbim_message_dup (const MbimMessage *self); |
| 132 |
|
| 133 |
/** |
| 134 |
* mbim_message_ref: |
| 135 |
* @self: a #MbimMessage. |
| 136 |
* |
| 137 |
* Atomically increments the reference count of @self by one. |
| 138 |
* |
| 139 |
* Returns: (transfer full): the new reference to @self. |
| 140 |
* |
| 141 |
* Since: 1.0 |
| 142 |
*/ |
| 143 |
MbimMessage *mbim_message_ref (MbimMessage *self); |
| 144 |
|
| 145 |
/** |
| 146 |
* mbim_message_unref: |
| 147 |
* @self: a #MbimMessage. |
| 148 |
* |
| 149 |
* Atomically decrements the reference count of @self by one. |
| 150 |
* If the reference count drops to 0, @self is completely disposed. |
| 151 |
* |
| 152 |
* Since: 1.0 |
| 153 |
*/ |
| 154 |
void mbim_message_unref (MbimMessage *self); |
| 155 |
|
| 156 |
/** |
| 157 |
* mbim_message_get_printable: |
| 158 |
* @self: a #MbimMessage. |
| 159 |
* @line_prefix: prefix string to use in each new generated line. |
| 160 |
* @headers_only: %TRUE if only basic headers should be printed. |
| 161 |
* |
| 162 |
* Gets a printable string with the contents of the whole MBIM message. |
| 163 |
* |
| 164 |
* This method will not fail if the parsing of the message contents fails, |
| 165 |
* a fallback text with the error will be included in the generated printable |
| 166 |
* information instead. |
| 167 |
* |
| 168 |
* Returns: a newly allocated string, which should be freed with g_free(). |
| 169 |
* |
| 170 |
* Since: 1.0 |
| 171 |
*/ |
| 172 |
gchar *mbim_message_get_printable (const MbimMessage *self, |
| 173 |
const gchar *line_prefix, |
| 174 |
gboolean headers_only); |
| 175 |
|
| 176 |
/** |
| 177 |
* mbim_message_get_printable_full: |
| 178 |
* @self: a #MbimMessage. |
| 179 |
* @mbimex_version_major: major version of the agreed MBIMEx support. |
| 180 |
* @mbimex_version_minor: minor version of the agreed MBIMEx support. |
| 181 |
* @line_prefix: prefix string to use in each new generated line. |
| 182 |
* @headers_only: %TRUE if only basic headers should be printed. |
| 183 |
* @error: return location for error or %NULL. |
| 184 |
* |
| 185 |
* Gets a printable string with the contents of the whole MBIM message. |
| 186 |
* |
| 187 |
* Unlike mbim_message_get_printable(), this method allows specifying the |
| 188 |
* MBIMEx version agreed between host and device, so that the correct |
| 189 |
* processing and parsing is done on messages in the newer MBIMEx versions. |
| 190 |
* |
| 191 |
* If @mbimex_version_major < 2, this method behaves exactly as |
| 192 |
* mbim_message_get_printable(). |
| 193 |
* |
| 194 |
* If the specified @mbimex_version_major is unsupported, an error will be |
| 195 |
* returned. |
| 196 |
* |
| 197 |
* This method will not fail if the parsing of the message contents fails, |
| 198 |
* a fallback text with the error will be included in the generated printable |
| 199 |
* information instead. |
| 200 |
* |
| 201 |
* Returns: a newly allocated string which should be freed with g_free(), or |
| 202 |
* #NULL if @error is set. |
| 203 |
* |
| 204 |
* Since: 1.28 |
| 205 |
*/ |
| 206 |
gchar *mbim_message_get_printable_full (const MbimMessage *self, |
| 207 |
guint8 mbimex_version_major, |
| 208 |
guint8 mbimex_version_minor, |
| 209 |
const gchar *line_prefix, |
| 210 |
gboolean headers_only, |
| 211 |
GError **error); |
| 212 |
|
| 213 |
/** |
| 214 |
* mbim_message_get_raw: |
| 215 |
* @self: a #MbimMessage. |
| 216 |
* @length: (out): return location for the size of the output buffer. |
| 217 |
* @error: return location for error or %NULL. |
| 218 |
* |
| 219 |
* Gets the whole raw data buffer of the #MbimMessage. |
| 220 |
* |
| 221 |
* Returns: The raw data buffer, or #NULL if @error is set. |
| 222 |
* |
| 223 |
* Since: 1.0 |
| 224 |
*/ |
| 225 |
const guint8 *mbim_message_get_raw (const MbimMessage *self, |
| 226 |
guint32 *length, |
| 227 |
GError **error); |
| 228 |
|
| 229 |
/** |
| 230 |
* mbim_message_get_message_type: |
| 231 |
* @self: a #MbimMessage. |
| 232 |
* |
| 233 |
* Gets the message type. |
| 234 |
* |
| 235 |
* Returns: a #MbimMessageType. |
| 236 |
* |
| 237 |
* Since: 1.0 |
| 238 |
*/ |
| 239 |
MbimMessageType mbim_message_get_message_type (const MbimMessage *self); |
| 240 |
|
| 241 |
/** |
| 242 |
* mbim_message_get_message_length: |
| 243 |
* @self: a #MbimMessage. |
| 244 |
* |
| 245 |
* Gets the whole message length. |
| 246 |
* |
| 247 |
* Returns: the length of the message. |
| 248 |
* |
| 249 |
* Since: 1.0 |
| 250 |
*/ |
| 251 |
guint32 mbim_message_get_message_length (const MbimMessage *self); |
| 252 |
|
| 253 |
/** |
| 254 |
* mbim_message_get_transaction_id: |
| 255 |
* @self: a #MbimMessage. |
| 256 |
* |
| 257 |
* Gets the transaction ID of the message. |
| 258 |
* |
| 259 |
* Returns: the transaction ID. |
| 260 |
* |
| 261 |
* Since: 1.0 |
| 262 |
*/ |
| 263 |
guint32 mbim_message_get_transaction_id (const MbimMessage *self); |
| 264 |
|
| 265 |
/** |
| 266 |
* mbim_message_set_transaction_id: |
| 267 |
* @self: a #MbimMessage. |
| 268 |
* @transaction_id: the transaction id. |
| 269 |
* |
| 270 |
* Sets the transaction ID of the message. |
| 271 |
* |
| 272 |
* Since: 1.0 |
| 273 |
*/ |
| 274 |
void mbim_message_set_transaction_id (MbimMessage *self, |
| 275 |
guint32 transaction_id); |
| 276 |
|
| 277 |
/** |
| 278 |
* mbim_message_validate: |
| 279 |
* @self: a #MbimMessage. |
| 280 |
* @error: return location for error or %NULL. |
| 281 |
* |
| 282 |
* Validates the contents of the headers in the MBIM message. |
| 283 |
* |
| 284 |
* This operation may be used to ensure that the message contains all bytes |
| 285 |
* it is expected to contain and that it is of a valid type. |
| 286 |
* |
| 287 |
* This operation also ensures the message is complete and not a partial |
| 288 |
* MBIM fragment. |
| 289 |
* |
| 290 |
* This operation does not validate that the specific contents of a given |
| 291 |
* message type are available, that is done by the methods retrieving those |
| 292 |
* specific contents. |
| 293 |
* |
| 294 |
* Returns: %TRUE if the message is valid, %FALSE if @error is set. |
| 295 |
* |
| 296 |
* Since: 1.28 |
| 297 |
*/ |
| 298 |
gboolean mbim_message_validate (const MbimMessage *self, |
| 299 |
GError **error); |
| 300 |
|
| 301 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MbimMessage, mbim_message_unref) |
| 302 |
|
| 303 |
/*****************************************************************************/ |
| 304 |
/* 'Open' message interface */ |
| 305 |
|
| 306 |
/** |
| 307 |
* mbim_message_open_new: |
| 308 |
* @transaction_id: transaction ID. |
| 309 |
* @max_control_transfer: maximum control transfer. |
| 310 |
* |
| 311 |
* Create a new #MbimMessage of type %MBIM_MESSAGE_TYPE_OPEN with the specified |
| 312 |
* parameters. |
| 313 |
* |
| 314 |
* Returns: (transfer full): a newly created #MbimMessage. The returned value |
| 315 |
* should be freed with mbim_message_unref(). |
| 316 |
* |
| 317 |
* Since: 1.0 |
| 318 |
*/ |
| 319 |
MbimMessage *mbim_message_open_new (guint32 transaction_id, |
| 320 |
guint32 max_control_transfer); |
| 321 |
|
| 322 |
/** |
| 323 |
* mbim_message_open_get_max_control_transfer: |
| 324 |
* @self: a #MbimMessage. |
| 325 |
* |
| 326 |
* Get the maximum control transfer set to be used in the #MbimMessage of type |
| 327 |
* %MBIM_MESSAGE_TYPE_OPEN. |
| 328 |
* |
| 329 |
* Returns: the maximum control transfer. |
| 330 |
* |
| 331 |
* Since: 1.0 |
| 332 |
*/ |
| 333 |
guint32 mbim_message_open_get_max_control_transfer (const MbimMessage *self); |
| 334 |
|
| 335 |
/*****************************************************************************/ |
| 336 |
/* 'Open Done' message interface */ |
| 337 |
|
| 338 |
/** |
| 339 |
* mbim_message_open_done_new: |
| 340 |
* @transaction_id: transaction ID. |
| 341 |
* @error_status_code: a #MbimStatusError. |
| 342 |
* |
| 343 |
* Create a new #MbimMessage of type %MBIM_MESSAGE_TYPE_OPEN_DONE with the specified |
| 344 |
* parameters. |
| 345 |
* |
| 346 |
* Returns: (transfer full): a newly created #MbimMessage, which should be freed with mbim_message_unref(). |
| 347 |
* |
| 348 |
* Since: 1.10 |
| 349 |
*/ |
| 350 |
MbimMessage *mbim_message_open_done_new (guint32 transaction_id, |
| 351 |
MbimStatusError error_status_code); |
| 352 |
|
| 353 |
/** |
| 354 |
* mbim_message_open_done_get_status_code: |
| 355 |
* @self: a #MbimMessage. |
| 356 |
* |
| 357 |
* Get status code from the %MBIM_MESSAGE_TYPE_OPEN_DONE message. |
| 358 |
* |
| 359 |
* Returns: a #MbimStatusError. |
| 360 |
* |
| 361 |
* Since: 1.0 |
| 362 |
*/ |
| 363 |
MbimStatusError mbim_message_open_done_get_status_code (const MbimMessage *self); |
| 364 |
|
| 365 |
/** |
| 366 |
* mbim_message_open_done_get_result: |
| 367 |
* @self: a #MbimMessage. |
| 368 |
* @error: return location for error or %NULL. |
| 369 |
* |
| 370 |
* Gets the result of the 'Open' operation in the %MBIM_MESSAGE_TYPE_OPEN_DONE message. |
| 371 |
* |
| 372 |
* Returns: %TRUE if the operation succeeded, %FALSE if @error is set. |
| 373 |
* |
| 374 |
* Since: 1.0 |
| 375 |
*/ |
| 376 |
gboolean mbim_message_open_done_get_result (const MbimMessage *self, |
| 377 |
GError **error); |
| 378 |
|
| 379 |
/*****************************************************************************/ |
| 380 |
/* 'Close' message interface */ |
| 381 |
|
| 382 |
/** |
| 383 |
* mbim_message_close_new: |
| 384 |
* @transaction_id: transaction ID. |
| 385 |
* |
| 386 |
* Create a new #MbimMessage of type %MBIM_MESSAGE_TYPE_CLOSE with the specified |
| 387 |
* parameters. |
| 388 |
* |
| 389 |
* Returns: (transfer full): a newly created #MbimMessage. The returned value |
| 390 |
* should be freed with mbim_message_unref(). |
| 391 |
* |
| 392 |
* Since: 1.0 |
| 393 |
*/ |
| 394 |
MbimMessage *mbim_message_close_new (guint32 transaction_id); |
| 395 |
|
| 396 |
/*****************************************************************************/ |
| 397 |
/* 'Close Done' message interface */ |
| 398 |
|
| 399 |
/** |
| 400 |
* mbim_message_close_done_new: |
| 401 |
* @transaction_id: transaction ID. |
| 402 |
* @error_status_code: a #MbimStatusError. |
| 403 |
* |
| 404 |
* Create a new #MbimMessage of type %MBIM_MESSAGE_TYPE_CLOSE_DONE with the specified |
| 405 |
* parameters. |
| 406 |
* |
| 407 |
* Returns: (transfer full): a newly created #MbimMessage, which should be freed with mbim_message_unref(). |
| 408 |
* |
| 409 |
* Since: 1.10 |
| 410 |
*/ |
| 411 |
MbimMessage *mbim_message_close_done_new (guint32 transaction_id, |
| 412 |
MbimStatusError error_status_code); |
| 413 |
|
| 414 |
/** |
| 415 |
* mbim_message_close_done_get_status_code: |
| 416 |
* @self: a #MbimMessage. |
| 417 |
* |
| 418 |
* Get status code from the %MBIM_MESSAGE_TYPE_CLOSE_DONE message. |
| 419 |
* |
| 420 |
* Returns: a #MbimStatusError. |
| 421 |
* |
| 422 |
* Since: 1.0 |
| 423 |
*/ |
| 424 |
MbimStatusError mbim_message_close_done_get_status_code (const MbimMessage *self); |
| 425 |
|
| 426 |
/** |
| 427 |
* mbim_message_close_done_get_result: |
| 428 |
* @self: a #MbimMessage. |
| 429 |
* @error: return location for error or %NULL. |
| 430 |
* |
| 431 |
* Gets the result of the 'Close' operation in the %MBIM_MESSAGE_TYPE_CLOSE_DONE message. |
| 432 |
* |
| 433 |
* Returns: %TRUE if the operation succeeded, %FALSE if @error is set. |
| 434 |
* |
| 435 |
* Since: 1.0 |
| 436 |
*/ |
| 437 |
gboolean mbim_message_close_done_get_result (const MbimMessage *self, |
| 438 |
GError **error); |
| 439 |
|
| 440 |
/*****************************************************************************/ |
| 441 |
/* 'Error' message interface */ |
| 442 |
|
| 443 |
/** |
| 444 |
* mbim_message_error_new: |
| 445 |
* @transaction_id: transaction ID. |
| 446 |
* @error_status_code: a #MbimProtocolError. |
| 447 |
* |
| 448 |
* Create a new #MbimMessage of type %MBIM_MESSAGE_TYPE_HOST_ERROR with the specified |
| 449 |
* parameters. |
| 450 |
* |
| 451 |
* Returns: (transfer full): a newly created #MbimMessage. The returned value |
| 452 |
* should be freed with mbim_message_unref(). |
| 453 |
* |
| 454 |
* Since: 1.0 |
| 455 |
*/ |
| 456 |
MbimMessage *mbim_message_error_new (guint32 transaction_id, |
| 457 |
MbimProtocolError error_status_code); |
| 458 |
|
| 459 |
/** |
| 460 |
* mbim_message_function_error_new: |
| 461 |
* @transaction_id: transaction ID. |
| 462 |
* @error_status_code: a #MbimProtocolError. |
| 463 |
* |
| 464 |
* Create a new #MbimMessage of type %MBIM_MESSAGE_TYPE_FUNCTION_ERROR with the specified |
| 465 |
* parameters. |
| 466 |
* |
| 467 |
* Returns: (transfer full): a newly created #MbimMessage. The returned value |
| 468 |
* should be freed with mbim_message_unref(). |
| 469 |
* |
| 470 |
* Since: 1.12 |
| 471 |
*/ |
| 472 |
MbimMessage *mbim_message_function_error_new (guint32 transaction_id, |
| 473 |
MbimProtocolError error_status_code); |
| 474 |
|
| 475 |
/** |
| 476 |
* mbim_message_error_get_error_status_code: |
| 477 |
* @self: a #MbimMessage. |
| 478 |
* |
| 479 |
* Get the error code in a %MBIM_MESSAGE_TYPE_HOST_ERROR or |
| 480 |
* %MBIM_MESSAGE_TYPE_FUNCTION_ERROR message. |
| 481 |
* |
| 482 |
* Returns: a #MbimProtocolError. |
| 483 |
* |
| 484 |
* Since: 1.0 |
| 485 |
*/ |
| 486 |
MbimProtocolError mbim_message_error_get_error_status_code (const MbimMessage *self); |
| 487 |
|
| 488 |
/** |
| 489 |
* mbim_message_error_get_error: |
| 490 |
* @self: a #MbimMessage. |
| 491 |
* |
| 492 |
* Get the error in a %MBIM_MESSAGE_TYPE_HOST_ERROR or |
| 493 |
* %MBIM_MESSAGE_TYPE_FUNCTION_ERROR message. |
| 494 |
* |
| 495 |
* Returns: a newly allocated #GError, which should be freed with g_error_free(). |
| 496 |
* |
| 497 |
* Since: 1.0 |
| 498 |
*/ |
| 499 |
GError *mbim_message_error_get_error (const MbimMessage *self); |
| 500 |
|
| 501 |
/*****************************************************************************/ |
| 502 |
/* 'Command' message interface */ |
| 503 |
|
| 504 |
/** |
| 505 |
* MbimMessageCommandType: |
| 506 |
* @MBIM_MESSAGE_COMMAND_TYPE_UNKNOWN: Unknown type. |
| 507 |
* @MBIM_MESSAGE_COMMAND_TYPE_QUERY: Query command. |
| 508 |
* @MBIM_MESSAGE_COMMAND_TYPE_SET: Set command. |
| 509 |
* |
| 510 |
* Type of command message. |
| 511 |
* |
| 512 |
* Since: 1.0 |
| 513 |
*/ |
| 514 |
typedef enum { /*< since=1.0 >*/ |
| 515 |
MBIM_MESSAGE_COMMAND_TYPE_UNKNOWN = -1, |
| 516 |
MBIM_MESSAGE_COMMAND_TYPE_QUERY = 0, |
| 517 |
MBIM_MESSAGE_COMMAND_TYPE_SET = 1 |
| 518 |
} MbimMessageCommandType; |
| 519 |
|
| 520 |
/** |
| 521 |
* mbim_message_command_new: |
| 522 |
* @transaction_id: transaction ID. |
| 523 |
* @service: a #MbimService. |
| 524 |
* @cid: the command ID. |
| 525 |
* @command_type: the command type. |
| 526 |
* |
| 527 |
* Create a new #MbimMessage of type %MBIM_MESSAGE_TYPE_COMMAND with the |
| 528 |
* specified parameters and an empty information buffer. |
| 529 |
* |
| 530 |
* Returns: (transfer full): a newly created #MbimMessage. The returned value |
| 531 |
* should be freed with mbim_message_unref(). |
| 532 |
* |
| 533 |
* Since: 1.0 |
| 534 |
*/ |
| 535 |
MbimMessage *mbim_message_command_new (guint32 transaction_id, |
| 536 |
MbimService service, |
| 537 |
guint32 cid, |
| 538 |
MbimMessageCommandType command_type); |
| 539 |
|
| 540 |
/** |
| 541 |
* mbim_message_command_append: |
| 542 |
* @self: a #MbimMessage. |
| 543 |
* @buffer: raw buffer to append to the message. |
| 544 |
* @buffer_size: length of the data in @buffer. |
| 545 |
* |
| 546 |
* Appends the contents of @buffer to @self. |
| 547 |
* |
| 548 |
* Since: 1.0 |
| 549 |
*/ |
| 550 |
void mbim_message_command_append (MbimMessage *self, |
| 551 |
const guint8 *buffer, |
| 552 |
guint32 buffer_size); |
| 553 |
|
| 554 |
/** |
| 555 |
* mbim_message_command_get_service: |
| 556 |
* @self: a #MbimMessage. |
| 557 |
* |
| 558 |
* Get the service of a %MBIM_MESSAGE_TYPE_COMMAND message. |
| 559 |
* |
| 560 |
* Returns: a #MbimService. |
| 561 |
* |
| 562 |
* Since: 1.0 |
| 563 |
*/ |
| 564 |
MbimService mbim_message_command_get_service (const MbimMessage *self); |
| 565 |
|
| 566 |
/** |
| 567 |
* mbim_message_command_get_service_id: |
| 568 |
* @self: a #MbimMessage. |
| 569 |
* |
| 570 |
* Get the service UUID of a %MBIM_MESSAGE_TYPE_COMMAND message. |
| 571 |
* |
| 572 |
* Returns: a #MbimUuid. |
| 573 |
* |
| 574 |
* Since: 1.0 |
| 575 |
*/ |
| 576 |
const MbimUuid *mbim_message_command_get_service_id (const MbimMessage *self); |
| 577 |
|
| 578 |
/** |
| 579 |
* mbim_message_command_get_cid: |
| 580 |
* @self: a #MbimMessage. |
| 581 |
* |
| 582 |
* Get the command id of a %MBIM_MESSAGE_TYPE_COMMAND message. |
| 583 |
* |
| 584 |
* Returns: a CID. |
| 585 |
* |
| 586 |
* Since: 1.0 |
| 587 |
*/ |
| 588 |
guint32 mbim_message_command_get_cid (const MbimMessage *self); |
| 589 |
|
| 590 |
/** |
| 591 |
* mbim_message_command_get_command_type: |
| 592 |
* @self: a #MbimMessage. |
| 593 |
* |
| 594 |
* Get the command type of a %MBIM_MESSAGE_TYPE_COMMAND message. |
| 595 |
* |
| 596 |
* Returns: a #MbimMessageCommandType. |
| 597 |
* |
| 598 |
* Since: 1.0 |
| 599 |
*/ |
| 600 |
MbimMessageCommandType mbim_message_command_get_command_type (const MbimMessage *self); |
| 601 |
|
| 602 |
/** |
| 603 |
* mbim_message_command_get_raw_information_buffer: |
| 604 |
* @self: a #MbimMessage. |
| 605 |
* @out_length: (out): return location for the size of the output buffer. |
| 606 |
* |
| 607 |
* Gets the information buffer of the %MBIM_MESSAGE_TYPE_COMMAND message. |
| 608 |
* |
| 609 |
* Returns: (transfer none): The raw data buffer, or #NULL if empty. |
| 610 |
* |
| 611 |
* Since: 1.0 |
| 612 |
*/ |
| 613 |
const guint8 *mbim_message_command_get_raw_information_buffer (const MbimMessage *self, |
| 614 |
guint32 *out_length); |
| 615 |
|
| 616 |
/*****************************************************************************/ |
| 617 |
/* 'Command Done' message interface */ |
| 618 |
|
| 619 |
/** |
| 620 |
* mbim_message_command_done_get_service: |
| 621 |
* @self: a #MbimMessage. |
| 622 |
* |
| 623 |
* Get the service of a %MBIM_MESSAGE_TYPE_COMMAND_DONE message. |
| 624 |
* |
| 625 |
* Returns: a #MbimService. |
| 626 |
* |
| 627 |
* Since: 1.0 |
| 628 |
*/ |
| 629 |
MbimService mbim_message_command_done_get_service (const MbimMessage *self); |
| 630 |
|
| 631 |
/** |
| 632 |
* mbim_message_command_done_get_service_id: |
| 633 |
* @self: a #MbimMessage. |
| 634 |
* |
| 635 |
* Get the service UUID of a %MBIM_MESSAGE_TYPE_COMMAND_DONE message. |
| 636 |
* |
| 637 |
* Returns: a #MbimUuid. |
| 638 |
* |
| 639 |
* Since: 1.0 |
| 640 |
*/ |
| 641 |
const MbimUuid *mbim_message_command_done_get_service_id (const MbimMessage *self); |
| 642 |
|
| 643 |
/** |
| 644 |
* mbim_message_command_done_get_cid: |
| 645 |
* @self: a #MbimMessage. |
| 646 |
* |
| 647 |
* Get the command id of a %MBIM_MESSAGE_TYPE_COMMAND_DONE message. |
| 648 |
* |
| 649 |
* Returns: a CID. |
| 650 |
* |
| 651 |
* Since: 1.0 |
| 652 |
*/ |
| 653 |
guint32 mbim_message_command_done_get_cid (const MbimMessage *self); |
| 654 |
|
| 655 |
/** |
| 656 |
* mbim_message_command_done_get_status_code: |
| 657 |
* @self: a #MbimMessage. |
| 658 |
* |
| 659 |
* Get status code from the %MBIM_MESSAGE_TYPE_COMMAND_DONE message. |
| 660 |
* |
| 661 |
* Returns: a #MbimStatusError. |
| 662 |
* |
| 663 |
* Since: 1.0 |
| 664 |
*/ |
| 665 |
MbimStatusError mbim_message_command_done_get_status_code (const MbimMessage *self); |
| 666 |
|
| 667 |
/** |
| 668 |
* mbim_message_command_done_get_result: |
| 669 |
* @self: a #MbimMessage. |
| 670 |
* @error: return location for error or %NULL. |
| 671 |
* |
| 672 |
* Gets the result of the 'Command' operation in the %MBIM_MESSAGE_TYPE_COMMAND_DONE message. |
| 673 |
* |
| 674 |
* Returns: %TRUE if the operation succeeded, %FALSE if @error is set. |
| 675 |
* |
| 676 |
* Since: 1.0 |
| 677 |
*/ |
| 678 |
gboolean mbim_message_command_done_get_result (const MbimMessage *self, |
| 679 |
GError **error); |
| 680 |
|
| 681 |
/** |
| 682 |
* mbim_message_command_done_get_raw_information_buffer: |
| 683 |
* @self: a #MbimMessage. |
| 684 |
* @out_length: (out): return location for the size of the output buffer. |
| 685 |
* |
| 686 |
* Gets the information buffer of the %MBIM_MESSAGE_TYPE_COMMAND_DONE message. |
| 687 |
* |
| 688 |
* Returns: (transfer none): The raw data buffer, or #NULL if empty. |
| 689 |
* |
| 690 |
* Since: 1.0 |
| 691 |
*/ |
| 692 |
const guint8 *mbim_message_command_done_get_raw_information_buffer (const MbimMessage *self, |
| 693 |
guint32 *out_length); |
| 694 |
|
| 695 |
/*****************************************************************************/ |
| 696 |
/* 'Indicate Status' message interface */ |
| 697 |
|
| 698 |
/** |
| 699 |
* mbim_message_indicate_status_get_service: |
| 700 |
* @self: a #MbimMessage. |
| 701 |
* |
| 702 |
* Get the service of a %MBIM_MESSAGE_TYPE_INDICATE_STATUS message. |
| 703 |
* |
| 704 |
* Returns: a #MbimService. |
| 705 |
* |
| 706 |
* Since: 1.0 |
| 707 |
*/ |
| 708 |
MbimService mbim_message_indicate_status_get_service (const MbimMessage *self); |
| 709 |
|
| 710 |
/** |
| 711 |
* mbim_message_indicate_status_get_service_id: |
| 712 |
* @self: a #MbimMessage. |
| 713 |
* |
| 714 |
* Get the service UUID of a %MBIM_MESSAGE_TYPE_INDICATE_STATUS message. |
| 715 |
* |
| 716 |
* Returns: a #MbimUuid. |
| 717 |
* |
| 718 |
* Since: 1.0 |
| 719 |
*/ |
| 720 |
const MbimUuid *mbim_message_indicate_status_get_service_id (const MbimMessage *self); |
| 721 |
|
| 722 |
/** |
| 723 |
* mbim_message_indicate_status_get_cid: |
| 724 |
* @self: a #MbimMessage. |
| 725 |
* |
| 726 |
* Get the command id of a %MBIM_MESSAGE_TYPE_INDICATE_STATUS message. |
| 727 |
* |
| 728 |
* Returns: a CID. |
| 729 |
* |
| 730 |
* Since: 1.0 |
| 731 |
*/ |
| 732 |
guint32 mbim_message_indicate_status_get_cid (const MbimMessage *self); |
| 733 |
|
| 734 |
/** |
| 735 |
* mbim_message_indicate_status_get_raw_information_buffer: |
| 736 |
* @self: a #MbimMessage. |
| 737 |
* @out_length: (out): return location for the size of the output buffer. |
| 738 |
* |
| 739 |
* Gets the information buffer of the %MBIM_MESSAGE_TYPE_INDICATE_STATUS message. |
| 740 |
* |
| 741 |
* Returns: (transfer none): The raw data buffer, or #NULL if empty. |
| 742 |
* |
| 743 |
* Since: 1.0 |
| 744 |
*/ |
| 745 |
const guint8 *mbim_message_indicate_status_get_raw_information_buffer (const MbimMessage *self, |
| 746 |
guint32 *out_length); |
| 747 |
|
| 748 |
/*****************************************************************************/ |
| 749 |
/* Other helpers */ |
| 750 |
|
| 751 |
/** |
| 752 |
* mbim_message_response_get_result: |
| 753 |
* @self: a #MbimMessage response message. |
| 754 |
* @expected: expected #MbimMessageType if there isn't any error in the operation. |
| 755 |
* @error: return location for error or %NULL. |
| 756 |
* |
| 757 |
* Gets the result of the operation from the response message, which |
| 758 |
* can be either a %MBIM_MESSAGE_TYPE_FUNCTION_ERROR message or a message of the |
| 759 |
* specified @expected type. |
| 760 |
* |
| 761 |
* Returns: %TRUE if the operation succeeded, %FALSE if @error is set. |
| 762 |
* |
| 763 |
* Since: 1.12 |
| 764 |
*/ |
| 765 |
gboolean mbim_message_response_get_result (const MbimMessage *self, |
| 766 |
MbimMessageType expected, |
| 767 |
GError **error); |
| 768 |
|
| 769 |
G_END_DECLS |
| 770 |
|
| 771 |
#endif /* _LIBMBIM_GLIB_MBIM_MESSAGE_H_ */ |