| 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 - 2021 Aleksander Morgado <[email protected]> |
| 7 |
* Copyright (C) 2021 Intel Corporation |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef _LIBMBIM_GLIB_MBIM_DEVICE_H_ |
| 11 |
#define _LIBMBIM_GLIB_MBIM_DEVICE_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-object.h> |
| 18 |
#include <gio/gio.h> |
| 19 |
|
| 20 |
#include "mbim-message.h" |
| 21 |
|
| 22 |
G_BEGIN_DECLS |
| 23 |
|
| 24 |
/** |
| 25 |
* SECTION:mbim-device |
| 26 |
* @title: MbimDevice |
| 27 |
* @short_description: Generic MBIM device handling routines |
| 28 |
* |
| 29 |
* #MbimDevice is a generic type in charge of controlling the access to the |
| 30 |
* managed MBIM port. |
| 31 |
* |
| 32 |
* A #MbimDevice can only handle one single MBIM port. |
| 33 |
*/ |
| 34 |
|
| 35 |
#define MBIM_TYPE_DEVICE (mbim_device_get_type ()) |
| 36 |
#define MBIM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MBIM_TYPE_DEVICE, MbimDevice)) |
| 37 |
#define MBIM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MBIM_TYPE_DEVICE, MbimDeviceClass)) |
| 38 |
#define MBIM_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MBIM_TYPE_DEVICE)) |
| 39 |
#define MBIM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MBIM_TYPE_DEVICE)) |
| 40 |
#define MBIM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MBIM_TYPE_DEVICE, MbimDeviceClass)) |
| 41 |
|
| 42 |
typedef struct _MbimDevice MbimDevice; |
| 43 |
typedef struct _MbimDeviceClass MbimDeviceClass; |
| 44 |
typedef struct _MbimDevicePrivate MbimDevicePrivate; |
| 45 |
|
| 46 |
/** |
| 47 |
* MBIM_DEVICE_FILE: |
| 48 |
* |
| 49 |
* Symbol defining the #MbimDevice:device-file property. |
| 50 |
* |
| 51 |
* Since: 1.0 |
| 52 |
*/ |
| 53 |
#define MBIM_DEVICE_FILE "device-file" |
| 54 |
|
| 55 |
/** |
| 56 |
* MBIM_DEVICE_TRANSACTION_ID: |
| 57 |
* |
| 58 |
* Symbol defining the #MbimDevice:device-transaction-id property. |
| 59 |
* |
| 60 |
* Since: 1.2 |
| 61 |
*/ |
| 62 |
#define MBIM_DEVICE_TRANSACTION_ID "device-transaction-id" |
| 63 |
|
| 64 |
/** |
| 65 |
* MBIM_DEVICE_IN_SESSION: |
| 66 |
* |
| 67 |
* Symbol defining the #MbimDevice:device-in-session property. |
| 68 |
* |
| 69 |
* Since: 1.4 |
| 70 |
*/ |
| 71 |
#define MBIM_DEVICE_IN_SESSION "device-in-session" |
| 72 |
|
| 73 |
/** |
| 74 |
* MBIM_DEVICE_CONSECUTIVE_TIMEOUTS: |
| 75 |
* |
| 76 |
* Symbol defining the #MbimDevice:device-consecutive-timeouts property. |
| 77 |
* |
| 78 |
* Since: 1.28 |
| 79 |
*/ |
| 80 |
#define MBIM_DEVICE_CONSECUTIVE_TIMEOUTS "device-consecutive-timeouts" |
| 81 |
|
| 82 |
/** |
| 83 |
* MBIM_DEVICE_SIGNAL_INDICATE_STATUS: |
| 84 |
* |
| 85 |
* Symbol defining the #MbimDevice::device-indicate-status signal. |
| 86 |
* |
| 87 |
* Since: 1.0 |
| 88 |
*/ |
| 89 |
#define MBIM_DEVICE_SIGNAL_INDICATE_STATUS "device-indicate-status" |
| 90 |
|
| 91 |
/** |
| 92 |
* MBIM_DEVICE_SIGNAL_ERROR: |
| 93 |
* |
| 94 |
* Symbol defining the #MbimDevice::device-error signal. |
| 95 |
* |
| 96 |
* Since: 1.0 |
| 97 |
*/ |
| 98 |
#define MBIM_DEVICE_SIGNAL_ERROR "device-error" |
| 99 |
|
| 100 |
/** |
| 101 |
* MBIM_DEVICE_SIGNAL_REMOVED: |
| 102 |
* |
| 103 |
* Symbol defining the #MbimDevice::device-removed signal. |
| 104 |
* |
| 105 |
* Since: 1.10 |
| 106 |
*/ |
| 107 |
#define MBIM_DEVICE_SIGNAL_REMOVED "device-removed" |
| 108 |
|
| 109 |
/** |
| 110 |
* MbimDevice: |
| 111 |
* |
| 112 |
* The #MbimDevice structure contains private data and should only be accessed |
| 113 |
* using the provided API. |
| 114 |
* |
| 115 |
* Since: 1.0 |
| 116 |
*/ |
| 117 |
struct _MbimDevice { |
| 118 |
/*< private >*/ |
| 119 |
GObject parent; |
| 120 |
MbimDevicePrivate *priv; |
| 121 |
}; |
| 122 |
|
| 123 |
struct _MbimDeviceClass { |
| 124 |
/*< private >*/ |
| 125 |
GObjectClass parent; |
| 126 |
}; |
| 127 |
|
| 128 |
GType mbim_device_get_type (void); |
| 129 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MbimDevice, g_object_unref) |
| 130 |
|
| 131 |
/** |
| 132 |
* mbim_device_new: |
| 133 |
* @file: a #GFile. |
| 134 |
* @cancellable: optional #GCancellable object, #NULL to ignore. |
| 135 |
* @callback: a #GAsyncReadyCallback to call when the initialization is finished. |
| 136 |
* @user_data: the data to pass to callback function. |
| 137 |
* |
| 138 |
* Asynchronously creates a #MbimDevice object to manage @file. |
| 139 |
* When the operation is finished, @callback will be invoked. You can then call |
| 140 |
* mbim_device_new_finish() to get the result of the operation. |
| 141 |
* |
| 142 |
* Since: 1.0 |
| 143 |
*/ |
| 144 |
void mbim_device_new (GFile *file, |
| 145 |
GCancellable *cancellable, |
| 146 |
GAsyncReadyCallback callback, |
| 147 |
gpointer user_data); |
| 148 |
|
| 149 |
/** |
| 150 |
* mbim_device_new_finish: |
| 151 |
* @res: a #GAsyncResult. |
| 152 |
* @error: Return location for error or %NULL. |
| 153 |
* |
| 154 |
* Finishes an operation started with mbim_device_new(). |
| 155 |
* |
| 156 |
* Returns: (transfer full): a newly created #MbimDevice, or #NULL if @error is set. |
| 157 |
* |
| 158 |
* Since: 1.0 |
| 159 |
*/ |
| 160 |
MbimDevice *mbim_device_new_finish (GAsyncResult *res, |
| 161 |
GError **error); |
| 162 |
|
| 163 |
/** |
| 164 |
* mbim_device_get_file: (skip) |
| 165 |
* @self: a #MbimDevice. |
| 166 |
* |
| 167 |
* Get the #GFile associated with this #MbimDevice. |
| 168 |
* |
| 169 |
* Returns: (transfer full): a #GFile that must be freed with g_object_unref(). |
| 170 |
* |
| 171 |
* Since: 1.0 |
| 172 |
*/ |
| 173 |
GFile *mbim_device_get_file (MbimDevice *self); |
| 174 |
|
| 175 |
/** |
| 176 |
* mbim_device_peek_file: (skip) |
| 177 |
* @self: a #MbimDevice. |
| 178 |
* |
| 179 |
* Get the #GFile associated with this #MbimDevice, without increasing the reference count |
| 180 |
* on the returned object. |
| 181 |
* |
| 182 |
* Returns: (transfer none): a #GFile. Do not free the returned object, it is owned by @self. |
| 183 |
* |
| 184 |
* Since: 1.0 |
| 185 |
*/ |
| 186 |
GFile *mbim_device_peek_file (MbimDevice *self); |
| 187 |
|
| 188 |
/** |
| 189 |
* mbim_device_get_path: |
| 190 |
* @self: a #MbimDevice. |
| 191 |
* |
| 192 |
* Get the system path of the underlying MBIM device. |
| 193 |
* |
| 194 |
* Returns: the system path of the device. |
| 195 |
* |
| 196 |
* Since: 1.0 |
| 197 |
*/ |
| 198 |
const gchar *mbim_device_get_path (MbimDevice *self); |
| 199 |
|
| 200 |
/** |
| 201 |
* mbim_device_get_path_display: |
| 202 |
* @self: a #MbimDevice. |
| 203 |
* |
| 204 |
* Get the system path of the underlying MBIM device in UTF-8. |
| 205 |
* |
| 206 |
* Returns: UTF-8 encoded system path of the device. |
| 207 |
* |
| 208 |
* Since: 1.0 |
| 209 |
*/ |
| 210 |
const gchar *mbim_device_get_path_display (MbimDevice *self); |
| 211 |
|
| 212 |
/** |
| 213 |
* mbim_device_is_open: |
| 214 |
* @self: a #MbimDevice. |
| 215 |
* |
| 216 |
* Checks whether the #MbimDevice is open for I/O. |
| 217 |
* |
| 218 |
* Returns: %TRUE if @self is open, %FALSE otherwise. |
| 219 |
* |
| 220 |
* Since: 1.0 |
| 221 |
*/ |
| 222 |
gboolean mbim_device_is_open (MbimDevice *self); |
| 223 |
|
| 224 |
/** |
| 225 |
* mbim_device_get_ms_mbimex_version: |
| 226 |
* @self: a #MbimDevice. |
| 227 |
* @out_ms_mbimex_version_minor: output location for the minor version number of |
| 228 |
* the MS MBIMEx support, or %NULL if not needed. |
| 229 |
* |
| 230 |
* Get the version number of the MS MBIMEx support. |
| 231 |
* |
| 232 |
* The reported version will be 1 if the initialization sequence to agree on |
| 233 |
* which version to use hasn't been run (e.g. with mbim_device_open_full() and |
| 234 |
* the explicit %MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V2 or |
| 235 |
* %MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V3 flag). |
| 236 |
* |
| 237 |
* Returns: the major version number of the MS MBIMEx support. |
| 238 |
* |
| 239 |
* Since: 1.28 |
| 240 |
*/ |
| 241 |
guint8 mbim_device_get_ms_mbimex_version (MbimDevice *self, |
| 242 |
guint8 *out_ms_mbimex_version_minor); |
| 243 |
|
| 244 |
/** |
| 245 |
* mbim_device_set_ms_mbimex_version: |
| 246 |
* @self: a #MbimDevice. |
| 247 |
* @ms_mbimex_version_major: major version number of the MS MBIMEx support. |
| 248 |
* @ms_mbimex_version_minor: minor version number of the MS MBIMEx support. |
| 249 |
* @error: Return location for error or %NULL. |
| 250 |
* |
| 251 |
* Set the version number of the MS MBIMEx support assumed in the device |
| 252 |
* instance, which may have been set already by a different process or |
| 253 |
* device instance. |
| 254 |
* |
| 255 |
* If this operation specifies the wrong MBIMEx version agreed between host |
| 256 |
* and device, the message processing on this device instance may fail. |
| 257 |
* |
| 258 |
* This operation does not do any MBIMEx version exchange with the device, |
| 259 |
* the only way to do that is with mbim_device_open_full() and the explicit |
| 260 |
* %MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V2 or %MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V3 |
| 261 |
* flag. |
| 262 |
* |
| 263 |
* Returns: %TRUE if successful, %FALSE if @error is set. |
| 264 |
* |
| 265 |
* Since: 1.28 |
| 266 |
*/ |
| 267 |
gboolean mbim_device_set_ms_mbimex_version (MbimDevice *self, |
| 268 |
guint8 ms_mbimex_version_major, |
| 269 |
guint8 ms_mbimex_version_minor, |
| 270 |
GError **error); |
| 271 |
|
| 272 |
/** |
| 273 |
* mbim_device_check_ms_mbimex_version: |
| 274 |
* @self: a #MbimDevice. |
| 275 |
* @ms_mbimex_version_major: major version number of the MS MBIMEx support. |
| 276 |
* @ms_mbimex_version_minor: minor version number of the MS MBIMEx support. |
| 277 |
* |
| 278 |
* Checks the version number of the MS MBIMEx support in the device instance |
| 279 |
* against the one given as input. |
| 280 |
* |
| 281 |
* Returns: %TRUE if the version of the device instance is the same as or newer |
| 282 |
* than the passed-in version. |
| 283 |
* |
| 284 |
* Since: 1.28 |
| 285 |
*/ |
| 286 |
gboolean mbim_device_check_ms_mbimex_version (MbimDevice *self, |
| 287 |
guint8 ms_mbimex_version_major, |
| 288 |
guint8 ms_mbimex_version_minor); |
| 289 |
|
| 290 |
/** |
| 291 |
* MbimDeviceOpenFlags: |
| 292 |
* @MBIM_DEVICE_OPEN_FLAGS_NONE: None. |
| 293 |
* @MBIM_DEVICE_OPEN_FLAGS_PROXY: Try to open the port through the 'mbim-proxy'. |
| 294 |
* @MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V2: Try to enable MS MBIMEx 2.0 support. Since 1.28. |
| 295 |
* @MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V3: Try to enable MS MBIMEx 3.0 support. Since 1.28. |
| 296 |
* |
| 297 |
* Flags to specify which actions to be performed when the device is open. |
| 298 |
* |
| 299 |
* Since: 1.10 |
| 300 |
*/ |
| 301 |
typedef enum { /*< since=1.10 >*/ |
| 302 |
MBIM_DEVICE_OPEN_FLAGS_NONE = 0, |
| 303 |
MBIM_DEVICE_OPEN_FLAGS_PROXY = 1 << 0, |
| 304 |
MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V2 = 1 << 1, |
| 305 |
MBIM_DEVICE_OPEN_FLAGS_MS_MBIMEX_V3 = 1 << 2, |
| 306 |
} MbimDeviceOpenFlags; |
| 307 |
|
| 308 |
/** |
| 309 |
* mbim_device_open_full: |
| 310 |
* @self: a #MbimDevice. |
| 311 |
* @flags: a set of #MbimDeviceOpenFlags. |
| 312 |
* @timeout: maximum time, in seconds, to wait for the device to be opened. |
| 313 |
* @cancellable: optional #GCancellable object, #NULL to ignore. |
| 314 |
* @callback: a #GAsyncReadyCallback to call when the operation is finished. |
| 315 |
* @user_data: the data to pass to callback function. |
| 316 |
* |
| 317 |
* Asynchronously opens a #MbimDevice for I/O. |
| 318 |
* |
| 319 |
* This method is an extension of the generic mbim_device_open(), which allows |
| 320 |
* launching the #MbimDevice with proxy support. |
| 321 |
* |
| 322 |
* When the operation is finished @callback will be called. You can then call |
| 323 |
* mbim_device_open_full_finish() to get the result of the operation. |
| 324 |
* |
| 325 |
* Since: 1.10 |
| 326 |
*/ |
| 327 |
void mbim_device_open_full (MbimDevice *self, |
| 328 |
MbimDeviceOpenFlags flags, |
| 329 |
guint timeout, |
| 330 |
GCancellable *cancellable, |
| 331 |
GAsyncReadyCallback callback, |
| 332 |
gpointer user_data); |
| 333 |
|
| 334 |
/** |
| 335 |
* mbim_device_open_full_finish: |
| 336 |
* @self: a #MbimDevice. |
| 337 |
* @res: a #GAsyncResult. |
| 338 |
* @error: Return location for error or %NULL. |
| 339 |
* |
| 340 |
* Finishes an asynchronous open operation started with mbim_device_open_full(). |
| 341 |
* |
| 342 |
* Returns: %TRUE if successful, %FALSE if @error is set. |
| 343 |
* |
| 344 |
* Since: 1.10 |
| 345 |
*/ |
| 346 |
gboolean mbim_device_open_full_finish (MbimDevice *self, |
| 347 |
GAsyncResult *res, |
| 348 |
GError **error); |
| 349 |
|
| 350 |
/** |
| 351 |
* mbim_device_open: |
| 352 |
* @self: a #MbimDevice. |
| 353 |
* @timeout: maximum time, in seconds, to wait for the device to be opened. |
| 354 |
* @cancellable: optional #GCancellable object, #NULL to ignore. |
| 355 |
* @callback: a #GAsyncReadyCallback to call when the operation is finished. |
| 356 |
* @user_data: the data to pass to callback function. |
| 357 |
* |
| 358 |
* Asynchronously opens a #MbimDevice for I/O. |
| 359 |
* |
| 360 |
* When the operation is finished @callback will be called. You can then call |
| 361 |
* mbim_device_open_finish() to get the result of the operation. |
| 362 |
* |
| 363 |
* Since: 1.0 |
| 364 |
*/ |
| 365 |
void mbim_device_open (MbimDevice *self, |
| 366 |
guint timeout, |
| 367 |
GCancellable *cancellable, |
| 368 |
GAsyncReadyCallback callback, |
| 369 |
gpointer user_data); |
| 370 |
|
| 371 |
/** |
| 372 |
* mbim_device_open_finish: |
| 373 |
* @self: a #MbimDevice. |
| 374 |
* @res: a #GAsyncResult. |
| 375 |
* @error: Return location for error or %NULL. |
| 376 |
* |
| 377 |
* Finishes an asynchronous open operation started with mbim_device_open(). |
| 378 |
* |
| 379 |
* Returns: %TRUE if successful, %FALSE if @error is set. |
| 380 |
* |
| 381 |
* Since: 1.0 |
| 382 |
*/ |
| 383 |
gboolean mbim_device_open_finish (MbimDevice *self, |
| 384 |
GAsyncResult *res, |
| 385 |
GError **error); |
| 386 |
|
| 387 |
/** |
| 388 |
* mbim_device_close: |
| 389 |
* @self: a #MbimDevice. |
| 390 |
* @timeout: maximum time, in seconds, to wait for the device to be closed. |
| 391 |
* @cancellable: optional #GCancellable object, #NULL to ignore. |
| 392 |
* @callback: a #GAsyncReadyCallback to call when the operation is finished. |
| 393 |
* @user_data: the data to pass to callback function. |
| 394 |
* |
| 395 |
* Asynchronously closes a #MbimDevice for I/O. |
| 396 |
* |
| 397 |
* When the operation is finished @callback will be called. You can then call |
| 398 |
* mbim_device_close_finish() to get the result of the operation. |
| 399 |
* |
| 400 |
* Since: 1.0 |
| 401 |
*/ |
| 402 |
void mbim_device_close (MbimDevice *self, |
| 403 |
guint timeout, |
| 404 |
GCancellable *cancellable, |
| 405 |
GAsyncReadyCallback callback, |
| 406 |
gpointer user_data); |
| 407 |
|
| 408 |
/** |
| 409 |
* mbim_device_close_finish: |
| 410 |
* @self: a #MbimDevice. |
| 411 |
* @res: a #GAsyncResult. |
| 412 |
* @error: Return location for error or %NULL. |
| 413 |
* |
| 414 |
* Finishes an asynchronous close operation started with mbim_device_close(). |
| 415 |
* |
| 416 |
* Returns: %TRUE if successful, %FALSE if @error is set. |
| 417 |
* |
| 418 |
* Since: 1.0 |
| 419 |
*/ |
| 420 |
gboolean mbim_device_close_finish (MbimDevice *self, |
| 421 |
GAsyncResult *res, |
| 422 |
GError **error); |
| 423 |
|
| 424 |
/** |
| 425 |
* mbim_device_close_force: |
| 426 |
* @self: a #MbimDevice. |
| 427 |
* @error: Return location for error or %NULL. |
| 428 |
* |
| 429 |
* Forces the #MbimDevice to be closed. |
| 430 |
* |
| 431 |
* Returns: %TRUE if @self if no error happens, otherwise %FALSE and @error is set. |
| 432 |
* |
| 433 |
* Since: 1.0 |
| 434 |
*/ |
| 435 |
gboolean mbim_device_close_force (MbimDevice *self, |
| 436 |
GError **error); |
| 437 |
|
| 438 |
/** |
| 439 |
* mbim_device_get_next_transaction_id: |
| 440 |
* @self: A #MbimDevice. |
| 441 |
* |
| 442 |
* Acquire the next transaction ID of this #MbimDevice. |
| 443 |
* The internal transaction ID gets incremented. |
| 444 |
* |
| 445 |
* Returns: the next transaction ID. |
| 446 |
* |
| 447 |
* Since: 1.0 |
| 448 |
*/ |
| 449 |
guint32 mbim_device_get_next_transaction_id (MbimDevice *self); |
| 450 |
|
| 451 |
/** |
| 452 |
* mbim_device_get_transaction_id: |
| 453 |
* @self: A #MbimDevice. |
| 454 |
* |
| 455 |
* Acquire the transaction ID of this #MbimDevice without |
| 456 |
* incrementing the internal transaction ID. |
| 457 |
* |
| 458 |
* Returns: the current transaction ID. |
| 459 |
* |
| 460 |
* Since: 1.24.4 |
| 461 |
*/ |
| 462 |
guint32 mbim_device_get_transaction_id (MbimDevice *self); |
| 463 |
|
| 464 |
/** |
| 465 |
* mbim_device_get_consecutive_timeouts: |
| 466 |
* @self: a #MbimDevice. |
| 467 |
* |
| 468 |
* Gets the number of consecutive transaction timeouts in the device. |
| 469 |
* |
| 470 |
* Returns: a #guint. |
| 471 |
* |
| 472 |
* Since: 1.28 |
| 473 |
*/ |
| 474 |
guint mbim_device_get_consecutive_timeouts (MbimDevice *self); |
| 475 |
|
| 476 |
/** |
| 477 |
* mbim_device_command: |
| 478 |
* @self: a #MbimDevice. |
| 479 |
* @message: the message to send. |
| 480 |
* @timeout: maximum time, in seconds, to wait for the response. |
| 481 |
* @cancellable: a #GCancellable, or %NULL. |
| 482 |
* @callback: a #GAsyncReadyCallback to call when the operation is finished. |
| 483 |
* @user_data: the data to pass to callback function. |
| 484 |
* |
| 485 |
* Asynchronously sends a #MbimMessage to the device. |
| 486 |
* |
| 487 |
* When the operation is finished @callback will be called. You can then call |
| 488 |
* mbim_device_command_finish() to get the result of the operation. |
| 489 |
* |
| 490 |
* Since: 1.0 |
| 491 |
*/ |
| 492 |
void mbim_device_command (MbimDevice *self, |
| 493 |
MbimMessage *message, |
| 494 |
guint timeout, |
| 495 |
GCancellable *cancellable, |
| 496 |
GAsyncReadyCallback callback, |
| 497 |
gpointer user_data); |
| 498 |
|
| 499 |
/** |
| 500 |
* mbim_device_command_finish: |
| 501 |
* @self: a #MbimDevice. |
| 502 |
* @res: a #GAsyncResult. |
| 503 |
* @error: Return location for error or %NULL. |
| 504 |
* |
| 505 |
* Finishes an operation started with mbim_device_command(). |
| 506 |
* |
| 507 |
* The returned #MbimMessage is ensured to be valid and complete (i.e. not a |
| 508 |
* partial fragment). There is no need to call mbim_message_validate() again. |
| 509 |
* |
| 510 |
* Returns: a #MbimMessage response, or #NULL if @error is set. The returned value should be freed with mbim_message_unref(). |
| 511 |
* |
| 512 |
* Since: 1.0 |
| 513 |
*/ |
| 514 |
MbimMessage *mbim_device_command_finish (MbimDevice *self, |
| 515 |
GAsyncResult *res, |
| 516 |
GError **error); |
| 517 |
|
| 518 |
/** |
| 519 |
* MBIM_DEVICE_SESSION_ID_AUTOMATIC: |
| 520 |
* |
| 521 |
* Symbol defining a session id that will be automatically allocated during |
| 522 |
* runtime when creating net links. |
| 523 |
* |
| 524 |
* Since: 1.26 |
| 525 |
*/ |
| 526 |
#define MBIM_DEVICE_SESSION_ID_AUTOMATIC G_MAXUINT |
| 527 |
|
| 528 |
/** |
| 529 |
* MBIM_DEVICE_SESSION_ID_MIN: |
| 530 |
* |
| 531 |
* Symbol defining the minimum supported session id.. |
| 532 |
* |
| 533 |
* Since: 1.26 |
| 534 |
*/ |
| 535 |
#define MBIM_DEVICE_SESSION_ID_MIN 0 |
| 536 |
|
| 537 |
/** |
| 538 |
* MBIM_DEVICE_SESSION_ID_MAX: |
| 539 |
* |
| 540 |
* Symbol defining the maximum supported session id. |
| 541 |
* |
| 542 |
* Since: 1.26 |
| 543 |
*/ |
| 544 |
#define MBIM_DEVICE_SESSION_ID_MAX 0xFF |
| 545 |
|
| 546 |
/** |
| 547 |
* mbim_device_add_link: |
| 548 |
* @self: a #MbimDevice. |
| 549 |
* @session_id: the session id for the link, in the |
| 550 |
* [#MBIM_DEVICE_SESSION_ID_MIN,#MBIM_DEVICE_SESSION_ID_MAX] range, or |
| 551 |
* #MBIM_DEVICE_SESSION_ID_AUTOMATIC to find the first available session id. |
| 552 |
* @base_ifname: the interface which the new link will be created on. |
| 553 |
* @ifname_prefix: the prefix suggested to be used for the name of the new link |
| 554 |
* created. |
| 555 |
* @cancellable: a #GCancellable, or %NULL. |
| 556 |
* @callback: a #GAsyncReadyCallback to call when the operation is finished. |
| 557 |
* @user_data: the data to pass to callback function. |
| 558 |
* |
| 559 |
* Asynchronously creates a new virtual network device node on top of |
| 560 |
* @base_ifname. This allows having multiple net interfaces running on top of |
| 561 |
* another using multiplexing. |
| 562 |
* |
| 563 |
* If the kernel driver doesn't allow this functionality, a |
| 564 |
* %MBIM_CORE_ERROR_UNSUPPORTED error will be returned. |
| 565 |
* |
| 566 |
* The operation may fail if the given interface name is not associated to the |
| 567 |
* MBIM control port managed by the #MbimDevice. |
| 568 |
* |
| 569 |
* Depending on the kernel driver in use, the given @ifname_prefix may be |
| 570 |
* ignored. The user should not assume that the returned link interface name is |
| 571 |
* prefixed with @ifname_prefix as it may not be the case. |
| 572 |
* |
| 573 |
* When the operation is finished @callback will be called. You can then call |
| 574 |
* mbim_device_add_link_finish() to get the result of the operation. |
| 575 |
* |
| 576 |
* Since: 1.26 |
| 577 |
*/ |
| 578 |
void mbim_device_add_link (MbimDevice *self, |
| 579 |
guint session_id, |
| 580 |
const gchar *base_ifname, |
| 581 |
const gchar *ifname_prefix, |
| 582 |
GCancellable *cancellable, |
| 583 |
GAsyncReadyCallback callback, |
| 584 |
gpointer user_data); |
| 585 |
|
| 586 |
/** |
| 587 |
* mbim_device_add_link_finish: |
| 588 |
* @self: a #MbimDevice. |
| 589 |
* @res: a #GAsyncResult. |
| 590 |
* @session_id: the session ID for the link created. |
| 591 |
* @error: Return location for error or %NULL. |
| 592 |
* |
| 593 |
* Finishes an operation started with mbim_device_add_link(). |
| 594 |
* |
| 595 |
* Returns: The name of the net interface created, %NULL if @error is set. |
| 596 |
* |
| 597 |
* Since: 1.26 |
| 598 |
*/ |
| 599 |
gchar *mbim_device_add_link_finish (MbimDevice *self, |
| 600 |
GAsyncResult *res, |
| 601 |
guint *session_id, |
| 602 |
GError **error); |
| 603 |
|
| 604 |
/** |
| 605 |
* mbim_device_delete_link: |
| 606 |
* @self: a #MbimDevice. |
| 607 |
* @ifname: the name of the link to remove. |
| 608 |
* @cancellable: a #GCancellable, or %NULL. |
| 609 |
* @callback: a #GAsyncReadyCallback to call when the operation is finished. |
| 610 |
* @user_data: the data to pass to callback function. |
| 611 |
* |
| 612 |
* Asynchronously deletes a virtual network interface that has been previously |
| 613 |
* created with mbim_device_add_link(). |
| 614 |
* |
| 615 |
* If the kernel driver doesn't allow this functionality, a |
| 616 |
* %MBIM_CORE_ERROR_UNSUPPORTED error will be returned. |
| 617 |
* |
| 618 |
* When the operation is finished @callback will be called. You can then call |
| 619 |
* mbim_device_delete_link_finish() to get the result of the operation. |
| 620 |
* |
| 621 |
* Since: 1.26 |
| 622 |
*/ |
| 623 |
void mbim_device_delete_link (MbimDevice *self, |
| 624 |
const gchar *ifname, |
| 625 |
GCancellable *cancellable, |
| 626 |
GAsyncReadyCallback callback, |
| 627 |
gpointer user_data); |
| 628 |
|
| 629 |
/** |
| 630 |
* mbim_device_delete_link_finish: |
| 631 |
* @self: a #MbimDevice. |
| 632 |
* @res: a #GAsyncResult. |
| 633 |
* @error: Return location for error or %NULL. |
| 634 |
* |
| 635 |
* Finishes an operation started with mbim_device_delete_link(). |
| 636 |
* |
| 637 |
* Returns: %TRUE if successful, %FALSE if @error is set. |
| 638 |
* |
| 639 |
* Since: 1.26 |
| 640 |
*/ |
| 641 |
gboolean mbim_device_delete_link_finish (MbimDevice *self, |
| 642 |
GAsyncResult *res, |
| 643 |
GError **error); |
| 644 |
|
| 645 |
/** |
| 646 |
* mbim_device_delete_all_links: |
| 647 |
* @self: a #MbimDevice. |
| 648 |
* @base_ifname: the interface where all links are available. |
| 649 |
* @cancellable: a #GCancellable, or %NULL. |
| 650 |
* @callback: a #GAsyncReadyCallback to call when the operation is finished. |
| 651 |
* @user_data: the data to pass to callback function. |
| 652 |
* |
| 653 |
* Asynchronously deletes all virtual network interfaces that have been previously |
| 654 |
* created with mbim_device_add_link() in @base_ifname. |
| 655 |
* |
| 656 |
* When the operation is finished @callback will be called. You can then call |
| 657 |
* mbim_device_delete_link_finish() to get the result of the operation. |
| 658 |
* |
| 659 |
* <note><para> |
| 660 |
* There is no guarantee that other processes haven't created new links by the |
| 661 |
* time this method returns. This method should be used with caution, or in setups |
| 662 |
* where only one single process is expected to do MBIM network interface link |
| 663 |
* management. |
| 664 |
* </para></note> |
| 665 |
* |
| 666 |
* Since: 1.26 |
| 667 |
*/ |
| 668 |
void mbim_device_delete_all_links (MbimDevice *self, |
| 669 |
const gchar *base_ifname, |
| 670 |
GCancellable *cancellable, |
| 671 |
GAsyncReadyCallback callback, |
| 672 |
gpointer user_data); |
| 673 |
|
| 674 |
/** |
| 675 |
* mbim_device_delete_all_links_finish: |
| 676 |
* @self: a #MbimDevice. |
| 677 |
* @res: a #GAsyncResult. |
| 678 |
* @error: Return location for error or %NULL. |
| 679 |
* |
| 680 |
* Finishes an operation started with mbim_device_delete_all_links(). |
| 681 |
* |
| 682 |
* Returns: %TRUE if successful, %FALSE if @error is set. |
| 683 |
* |
| 684 |
* Since: 1.26 |
| 685 |
*/ |
| 686 |
gboolean mbim_device_delete_all_links_finish (MbimDevice *self, |
| 687 |
GAsyncResult *res, |
| 688 |
GError **error); |
| 689 |
|
| 690 |
/** |
| 691 |
* mbim_device_list_links: |
| 692 |
* @self: a #MbimDevice. |
| 693 |
* @base_ifname: the base interface. |
| 694 |
* @out_links: (out)(transfer full)(element-type utf8): a placeholder for the |
| 695 |
* output #GPtrArray of link names. |
| 696 |
* @error: Return location for error or %NULL. |
| 697 |
* |
| 698 |
* Synchronously lists all virtual network interfaces that have been previously |
| 699 |
* created with mbim_device_add_link() in @base_ifname. |
| 700 |
* |
| 701 |
* Returns: %TRUE if successful, %FALSE if @error is set. |
| 702 |
* |
| 703 |
* Since: 1.26 |
| 704 |
*/ |
| 705 |
gboolean mbim_device_list_links (MbimDevice *self, |
| 706 |
const gchar *base_ifname, |
| 707 |
GPtrArray **out_links, |
| 708 |
GError **error); |
| 709 |
|
| 710 |
/** |
| 711 |
* mbim_device_check_link_supported: |
| 712 |
* @self: a #MbimDevice. |
| 713 |
* @error: Return location for error or %NULL. |
| 714 |
* |
| 715 |
* Checks whether link management is supported by the kernel. |
| 716 |
* |
| 717 |
* Returns: %TRUE if link management is supported, or %FALSE if @error is set. |
| 718 |
* |
| 719 |
* Since: 1.26 |
| 720 |
*/ |
| 721 |
gboolean mbim_device_check_link_supported (MbimDevice *self, |
| 722 |
GError **error); |
| 723 |
|
| 724 |
G_END_DECLS |
| 725 |
|
| 726 |
#endif /* _LIBMBIM_GLIB_MBIM_DEVICE_H_ */ |