| 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) 2022 Daniele Palmas <[email protected]> |
| 7 |
* |
| 8 |
* Based on previous work: |
| 9 |
* Copyright (C) 2020-2021 Eric Caruso <[email protected]> |
| 10 |
* Copyright (C) 2020-2021 Andrew Lassalle <[email protected]> |
| 11 |
* Copyright (C) 2021 Aleksander Morgado <[email protected]> |
| 12 |
*/ |
| 13 |
|
| 14 |
#ifndef _LIBMBIM_GLIB_MBIM_HELPERS_NETLINK_H_ |
| 15 |
#define _LIBMBIM_GLIB_MBIM_HELPERS_NETLINK_H_ |
| 16 |
|
| 17 |
#if !defined (LIBMBIM_GLIB_COMPILATION) |
| 18 |
#error "This is a private header!!" |
| 19 |
#endif |
| 20 |
|
| 21 |
#include <glib.h> |
| 22 |
#include <gio/gio.h> |
| 23 |
|
| 24 |
G_BEGIN_DECLS |
| 25 |
|
| 26 |
typedef GByteArray NetlinkMessage; |
| 27 |
|
| 28 |
typedef struct { |
| 29 |
struct nlmsghdr msghdr; |
| 30 |
struct ifinfomsg ifreq; |
| 31 |
} NetlinkHeader; |
| 32 |
|
| 33 |
G_GNUC_INTERNAL |
| 34 |
NetlinkHeader *mbim_helpers_netlink_get_message_header (NetlinkMessage *msg); |
| 35 |
|
| 36 |
G_GNUC_INTERNAL |
| 37 |
guint mbim_helpers_netlink_get_pos_of_next_attr (NetlinkMessage *msg); |
| 38 |
|
| 39 |
G_GNUC_INTERNAL |
| 40 |
void mbim_helpers_netlink_append_attribute_nested (NetlinkMessage *msg, |
| 41 |
gushort type); |
| 42 |
|
| 43 |
G_GNUC_INTERNAL |
| 44 |
void mbim_helpers_netlink_append_attribute_string (NetlinkMessage *msg, |
| 45 |
gushort type, |
| 46 |
const gchar *value); |
| 47 |
|
| 48 |
G_GNUC_INTERNAL |
| 49 |
void mbim_helpers_netlink_append_attribute_string_null (NetlinkMessage *msg, |
| 50 |
gushort type, |
| 51 |
const gchar *value); |
| 52 |
|
| 53 |
G_GNUC_INTERNAL |
| 54 |
void mbim_helpers_netlink_append_attribute_uint16 (NetlinkMessage *msg, |
| 55 |
gushort type, |
| 56 |
guint16 value); |
| 57 |
|
| 58 |
G_GNUC_INTERNAL |
| 59 |
void mbim_helpers_netlink_append_attribute_uint32 (NetlinkMessage *msg, |
| 60 |
gushort type, |
| 61 |
guint32 value); |
| 62 |
|
| 63 |
G_GNUC_INTERNAL |
| 64 |
NetlinkMessage *mbim_helpers_netlink_message_new (guint16 type, |
| 65 |
guint16 extra_flags); |
| 66 |
|
| 67 |
G_GNUC_INTERNAL |
| 68 |
void mbim_helpers_netlink_message_free (NetlinkMessage *msg); |
| 69 |
|
| 70 |
typedef struct { |
| 71 |
guint32 sequence_id; |
| 72 |
GSource *timeout_source; |
| 73 |
GTask *completion_task; |
| 74 |
} NetlinkTransaction; |
| 75 |
|
| 76 |
G_GNUC_INTERNAL |
| 77 |
void mbim_helpers_netlink_transaction_complete_with_error (NetlinkTransaction *tr, |
| 78 |
GHashTable *transactions, |
| 79 |
GError *error); |
| 80 |
|
| 81 |
G_GNUC_INTERNAL |
| 82 |
void mbim_helpers_netlink_transaction_complete (NetlinkTransaction *tr, |
| 83 |
GHashTable *transactions, |
| 84 |
gint saved_errno); |
| 85 |
|
| 86 |
G_GNUC_INTERNAL |
| 87 |
void mbim_helpers_netlink_transaction_free (NetlinkTransaction *tr); |
| 88 |
|
| 89 |
G_GNUC_INTERNAL |
| 90 |
NetlinkTransaction *mbim_helpers_netlink_transaction_new (guint *sequence_id, |
| 91 |
GHashTable *transactions, |
| 92 |
NetlinkMessage *msg, |
| 93 |
guint timeout, |
| 94 |
GTask *task); |
| 95 |
|
| 96 |
G_GNUC_INTERNAL |
| 97 |
void mbim_helpers_netlink_set_callback (GSource **source, |
| 98 |
GSocket *socket, |
| 99 |
GHashTable *transactions); |
| 100 |
|
| 101 |
G_END_DECLS |
| 102 |
|
| 103 |
#endif /* _LIBMBIM_GLIB_MBIM_HELPERS_NETLINK_H_ */ |