| 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) 2021 Aleksander Morgado <[email protected]> |
| 7 |
* |
| 8 |
* Based on the QmiNetPortManagerRmnet from libqmi: |
| 9 |
* Copyright (C) 2020-2021 Eric Caruso <[email protected]> |
| 10 |
* Copyright (C) 2020-2021 Andrew Lassalle <[email protected]> |
| 11 |
*/ |
| 12 |
|
| 13 |
#ifndef _LIBMBIM_GLIB_MBIM_NET_PORT_MANAGER_H_ |
| 14 |
#define _LIBMBIM_GLIB_MBIM_NET_PORT_MANAGER_H_ |
| 15 |
|
| 16 |
#include <gio/gio.h> |
| 17 |
#include <glib-object.h> |
| 18 |
|
| 19 |
#define MBIM_TYPE_NET_PORT_MANAGER (mbim_net_port_manager_get_type ()) |
| 20 |
#define MBIM_NET_PORT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MBIM_TYPE_NET_PORT_MANAGER, MbimNetPortManager)) |
| 21 |
#define MBIM_NET_PORT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MBIM_TYPE_NET_PORT_MANAGER, MbimNetPortManagerClass)) |
| 22 |
#define MBIM_IS_NET_PORT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MBIM_TYPE_NET_PORT_MANAGER)) |
| 23 |
#define MBIM_IS_NET_PORT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MBIM_TYPE_NET_PORT_MANAGER)) |
| 24 |
#define MBIM_NET_PORT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MBIM_TYPE_NET_PORT_MANAGER, MbimNetPortManagerClass)) |
| 25 |
|
| 26 |
typedef struct _MbimNetPortManager MbimNetPortManager; |
| 27 |
typedef struct _MbimNetPortManagerClass MbimNetPortManagerClass; |
| 28 |
typedef struct _MbimNetPortManagerPrivate MbimNetPortManagerPrivate; |
| 29 |
|
| 30 |
struct _MbimNetPortManager { |
| 31 |
GObject parent; |
| 32 |
MbimNetPortManagerPrivate *priv; |
| 33 |
}; |
| 34 |
|
| 35 |
struct _MbimNetPortManagerClass { |
| 36 |
GObjectClass parent; |
| 37 |
|
| 38 |
gboolean (* list_links) (MbimNetPortManager *self, |
| 39 |
const gchar *base_ifname, |
| 40 |
GPtrArray **out_links, |
| 41 |
GError **error); |
| 42 |
|
| 43 |
void (* add_link) (MbimNetPortManager *self, |
| 44 |
guint session_id, |
| 45 |
const gchar *base_ifname, |
| 46 |
const gchar *ifname_prefix, |
| 47 |
guint timeout, |
| 48 |
GCancellable *cancellable, |
| 49 |
GAsyncReadyCallback callback, |
| 50 |
gpointer user_data); |
| 51 |
gchar * (* add_link_finish) (MbimNetPortManager *self, |
| 52 |
guint *session_id, |
| 53 |
GAsyncResult *res, |
| 54 |
GError **error); |
| 55 |
|
| 56 |
void (* del_link) (MbimNetPortManager *self, |
| 57 |
const gchar *ifname, |
| 58 |
guint timeout, |
| 59 |
GCancellable *cancellable, |
| 60 |
GAsyncReadyCallback callback, |
| 61 |
gpointer user_data); |
| 62 |
gboolean (* del_link_finish) (MbimNetPortManager *self, |
| 63 |
GAsyncResult *res, |
| 64 |
GError **error); |
| 65 |
|
| 66 |
void (* del_all_links) (MbimNetPortManager *self, |
| 67 |
const gchar *base_ifname, |
| 68 |
GCancellable *cancellable, |
| 69 |
GAsyncReadyCallback callback, |
| 70 |
gpointer user_data); |
| 71 |
gboolean (* del_all_links_finish) (MbimNetPortManager *self, |
| 72 |
GAsyncResult *res, |
| 73 |
GError **error); |
| 74 |
}; |
| 75 |
|
| 76 |
GType mbim_net_port_manager_get_type (void); |
| 77 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MbimNetPortManager, g_object_unref) |
| 78 |
|
| 79 |
gboolean mbim_net_port_manager_list_links (MbimNetPortManager *self, |
| 80 |
const gchar *base_ifname, |
| 81 |
GPtrArray **out_links, |
| 82 |
GError **error); |
| 83 |
|
| 84 |
void mbim_net_port_manager_add_link (MbimNetPortManager *self, |
| 85 |
guint session_id, |
| 86 |
const gchar *base_ifname, |
| 87 |
const gchar *ifname_prefix, |
| 88 |
guint timeout, |
| 89 |
GCancellable *cancellable, |
| 90 |
GAsyncReadyCallback callback, |
| 91 |
gpointer user_data); |
| 92 |
gchar *mbim_net_port_manager_add_link_finish (MbimNetPortManager *self, |
| 93 |
guint *session_id, |
| 94 |
GAsyncResult *res, |
| 95 |
GError **error); |
| 96 |
|
| 97 |
void mbim_net_port_manager_del_link (MbimNetPortManager *self, |
| 98 |
const gchar *ifname, |
| 99 |
guint timeout, |
| 100 |
GCancellable *cancellable, |
| 101 |
GAsyncReadyCallback callback, |
| 102 |
gpointer user_data); |
| 103 |
gboolean mbim_net_port_manager_del_link_finish (MbimNetPortManager *self, |
| 104 |
GAsyncResult *res, |
| 105 |
GError **error); |
| 106 |
|
| 107 |
void mbim_net_port_manager_del_all_links (MbimNetPortManager *self, |
| 108 |
const gchar *base_ifname, |
| 109 |
GCancellable *cancellable, |
| 110 |
GAsyncReadyCallback callback, |
| 111 |
gpointer user_data); |
| 112 |
gboolean mbim_net_port_manager_del_all_links_finish (MbimNetPortManager *self, |
| 113 |
GAsyncResult *res, |
| 114 |
GError **error); |
| 115 |
|
| 116 |
GHashTable *mbim_net_port_manager_peek_transactions (MbimNetPortManager *self); |
| 117 |
|
| 118 |
gchar *mbim_net_port_manager_peek_iface (MbimNetPortManager *self); |
| 119 |
|
| 120 |
guint *mbim_net_port_manager_peek_current_sequence_id (MbimNetPortManager *self); |
| 121 |
|
| 122 |
GSocket *mbim_net_port_manager_peek_socket (MbimNetPortManager *self); |
| 123 |
|
| 124 |
void mbim_net_port_manager_common_setup (MbimNetPortManager *self, |
| 125 |
const gchar *iface, |
| 126 |
GSocket *gsocket); |
| 127 |
|
| 128 |
gchar *mbim_net_port_manager_util_session_id_to_ifname (const gchar *ifname_prefix, |
| 129 |
guint session_id); |
| 130 |
|
| 131 |
gboolean mbim_net_port_manager_util_get_first_free_session_id (const gchar *ifname_prefix, |
| 132 |
guint *session_id); |
| 133 |
|
| 134 |
#endif /* _LIBMBIM_GLIB_MBIM_NET_PORT_MANAGER_H_ */ |