diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2016-09-28 18:49:08 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-09-29 15:43:05 +0200 |
commit | c4a584416ab4af81b6cae653625c78f9158de1e6 (patch) | |
tree | b76526a1b1eed1abc11a4a740b4e7c55261be54d /libmm-glib/mm-kernel-event-properties.h | |
parent | aa4577dfb9b5a7863a4939ec2409eae392e2fc0c (diff) |
core: allow disabling auto-scan and notifying ports one by one via API
This commit enables a new core ModemManager daemon option, so that automatic
detection of available modems is totally disabled: '--no-auto-scan'. Note that
this option also replaces the previously used '--test-no-auto-scan' option,
which was only used during tests.
Along with the new ModemManager option, a new ReportKernelEvent() method in
the API is defined, which allows notifying the daemon of which interfaces it
should be accessing, as well as the main details of each interface. The only
mandatory parameters in the new method are 'action' (add/remove), 'name' (the
name of the interface) and 'subsystem' (the subsystem of the interface).
The mmcli tool has support for using the new api method via several new options:
* The '--report-kernel-event' option allows specifying device ports one by
one, and is a direct mapping of the ReportKernelEvent() method:
$ sudo mmcli --report-kernel-event="action=add,name=wwan0,subsystem=net"
$ sudo mmcli --report-kernel-event="action=add,name=cdc-wdm0,subsystem=usbmisc"
* The '--report-kernel-event-auto-scan' option uses udev monitoring to notify
events automatically to the daemon. This allows to operate in a way
equivalent to the default daemon operation (with implicit auto-scan).
Worth noting that the ReportKernelEvent() method is only usable when
'--no-auto-scan' is explicitly used in the daemon. An error will be reported if
the method is tried while standard udev monitoring is enabled (implicit if
auto scan isn't explicitly disabled in the daemon).
If mmcli is going to be used only to report 'real time' events, an optional
'--initial-kernel-events=[PATH]' may be given in the ModemManager call to
automatically process a set of port kernel events one by one on boot. The file
may e.g. contain:
action=add,name=wwan0,subsystem=net
action=add,name=cdc-wdm0,subsystem=usbmisc
Diffstat (limited to 'libmm-glib/mm-kernel-event-properties.h')
-rw-r--r-- | libmm-glib/mm-kernel-event-properties.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/libmm-glib/mm-kernel-event-properties.h b/libmm-glib/mm-kernel-event-properties.h new file mode 100644 index 00000000..576e356b --- /dev/null +++ b/libmm-glib/mm-kernel-event-properties.h @@ -0,0 +1,97 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details: + * + * Copyright (C) 2016 Velocloud, Inc. + */ + +#ifndef MM_KERNEL_EVENT_PROPERTIES_H +#define MM_KERNEL_EVENT_PROPERTIES_H + +#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION) +#error "Only <libmm-glib.h> can be included directly." +#endif + +#include <ModemManager.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MM_TYPE_KERNEL_EVENT_PROPERTIES (mm_kernel_event_properties_get_type ()) +#define MM_KERNEL_EVENT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_KERNEL_EVENT_PROPERTIES, MMKernelEventProperties)) +#define MM_KERNEL_EVENT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_KERNEL_EVENT_PROPERTIES, MMKernelEventPropertiesClass)) +#define MM_IS_KERNEL_EVENT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_KERNEL_EVENT_PROPERTIES)) +#define MM_IS_KERNEL_EVENT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_KERNEL_EVENT_PROPERTIES)) +#define MM_KERNEL_EVENT_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_KERNEL_EVENT_PROPERTIES, MMKernelEventPropertiesClass)) + +typedef struct _MMKernelEventProperties MMKernelEventProperties; +typedef struct _MMKernelEventPropertiesClass MMKernelEventPropertiesClass; +typedef struct _MMKernelEventPropertiesPrivate MMKernelEventPropertiesPrivate; + +/** + * MMKernelEventProperties: + * + * The #MMKernelEventProperties structure contains private data and should only be + * accessed using the provided API. + */ +struct _MMKernelEventProperties { + /*< private >*/ + GObject parent; + MMKernelEventPropertiesPrivate *priv; +}; + +struct _MMKernelEventPropertiesClass { + /*< private >*/ + GObjectClass parent; +}; + +GType mm_kernel_event_properties_get_type (void); + +MMKernelEventProperties *mm_kernel_event_properties_new (void); + +void mm_kernel_event_properties_set_action (MMKernelEventProperties *self, + const gchar *action); +const gchar *mm_kernel_event_properties_get_action (MMKernelEventProperties *self); + +void mm_kernel_event_properties_set_subsystem (MMKernelEventProperties *self, + const gchar *subsystem); +const gchar *mm_kernel_event_properties_get_subsystem (MMKernelEventProperties *self); + +void mm_kernel_event_properties_set_name (MMKernelEventProperties *self, + const gchar *name); +const gchar *mm_kernel_event_properties_get_name (MMKernelEventProperties *self); + +void mm_kernel_event_properties_set_uid (MMKernelEventProperties *self, + const gchar *uid); +const gchar *mm_kernel_event_properties_get_uid (MMKernelEventProperties *self); + +/*****************************************************************************/ +/* ModemManager/libmm-glib/mmcli specific methods */ + +#if defined (_LIBMM_INSIDE_MM) || \ + defined (_LIBMM_INSIDE_MMCLI) || \ + defined (LIBMM_GLIB_COMPILATION) + +MMKernelEventProperties *mm_kernel_event_properties_new_from_string (const gchar *str, + GError **error); + +MMKernelEventProperties *mm_kernel_event_properties_new_from_dictionary (GVariant *dictionary, + GError **error); + +MMKernelEventProperties *mm_kernel_event_properties_dup (MMKernelEventProperties *orig); + +GVariant *mm_kernel_event_properties_get_dictionary (MMKernelEventProperties *self); + +#endif + +G_END_DECLS + +#endif /* MM_KERNEL_EVENT_PROPERTIES_H */ |