2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
2017-05-19 10:19:25 +02:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2007 - 2008 Novell, Inc.
|
|
|
|
|
* Copyright (C) 2007 - 2018 Red Hat, Inc.
|
2017-05-19 10:19:25 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "nm-default.h"
|
|
|
|
|
|
|
|
|
|
#include "nm-libnm-utils.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
libnm: add logging NML_DBUS_LOG*() for debugging D-Bus for NMClient
Commonly, a library (like libnm) is not supposed to log anything.
Logging is not a suitable way to notify the calling application
about anything. When something of importance happens, then the
application must be notified via the library's API.
However, logging can be very useful for debugging to see what is going
on. Add a logging macro that by default does nothing, but can be turned
on via an environment variable "LIBNM_CLIENT_DEBUG=debug".
Another point is that libnm relies on the server side NetworkManager
D-Bus interface to be in an expected manner. For example, we require a
D-Bus object "org.freedesktop.NetworkManager" to be present and certain
D-Bus interfaces implemented.
However libnm should treat NetworkManager as external and untrusted component.
That means, we cannot assert against the expectations we have. There are two
reasons for this:
- a bug in NetworkManager, dbus-daemon or else may cause such errors.
This must not trigger an assertion failure in the client
application, at least not unless requested.
- libnm must be forward and backward compatible against a different
NetworkManager server version. That is only possibly by ignoring
anything that is unexpected. Asserting by default might prevent
to implement API changes, both on libnm and server side.
Note that we also don't notify the calling application via dedicated
API. On the one hand, these things *can* happen. On the other hand, what
would the calling appication do about it anyway? libnm by default must
just behave gracefully and pretend all is good.
For testing, development and debugging that is however not useful. We
want the user to opt in to strict API validation. The user will be able
to do that by setting "LIBNM_CLIENT_DEBUG=warning", which causes API
violations being logged with g_warning(). These are assertions when
running with G_DEBUG=fatal-warnings.
This is inspired by GDBus' G_DBUS_DEBUG variable.
Note that LIBNM_CLIENT_DEBUG environment variables is undocumented, unstable
API. It's used for debugging and testing of the current libnm version at hand.
There is no guaranteed stable behavior how a different libnm version
might behave.
2019-10-14 08:06:33 +02:00
|
|
|
volatile int _nml_dbus_log_level = 0;
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_nml_dbus_log_level_init (void)
|
|
|
|
|
{
|
|
|
|
|
const GDebugKey keys[] = {
|
|
|
|
|
{ "trace", _NML_DBUS_LOG_LEVEL_TRACE },
|
|
|
|
|
{ "debug", _NML_DBUS_LOG_LEVEL_DEBUG },
|
|
|
|
|
{ "warning", _NML_DBUS_LOG_LEVEL_WARN },
|
|
|
|
|
{ "error", _NML_DBUS_LOG_LEVEL_ERROR },
|
|
|
|
|
};
|
|
|
|
|
int l;
|
|
|
|
|
|
|
|
|
|
l = _NML_DBUS_LOG_LEVEL_INITIALIZED
|
|
|
|
|
| nm_utils_parse_debug_string (g_getenv ("LIBNM_CLIENT_DEBUG"),
|
|
|
|
|
keys,
|
|
|
|
|
G_N_ELEMENTS (keys));
|
|
|
|
|
|
|
|
|
|
if (!g_atomic_int_compare_and_exchange (&_nml_dbus_log_level, 0, l))
|
|
|
|
|
l = g_atomic_int_get (&_nml_dbus_log_level);
|
|
|
|
|
|
|
|
|
|
nm_assert (l & _NML_DBUS_LOG_LEVEL_INITIALIZED);
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_nml_dbus_log (NMLDBusLogLevel level,
|
|
|
|
|
const char *fmt,
|
|
|
|
|
...) {
|
|
|
|
|
NMLDBusLogLevel configured_log_level;
|
|
|
|
|
gs_free char *msg = NULL;
|
|
|
|
|
va_list args;
|
|
|
|
|
const char *prefix = "";
|
|
|
|
|
|
|
|
|
|
/* we only call _nml_dbus_log() after nml_dbus_log_enabled(), which already does
|
|
|
|
|
* an atomic access to the variable. Since the value is only initialized once and
|
|
|
|
|
* never changes, we can just access it without additional locking. */
|
|
|
|
|
configured_log_level = _nml_dbus_log_level;
|
|
|
|
|
|
|
|
|
|
nm_assert (level & configured_log_level);
|
|
|
|
|
|
|
|
|
|
va_start (args, fmt);
|
|
|
|
|
msg = g_strdup_vprintf (fmt, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
|
|
switch (level) {
|
|
|
|
|
case NML_DBUS_LOG_LEVEL_TRACE:
|
|
|
|
|
prefix = "<trace> ";
|
|
|
|
|
break;
|
|
|
|
|
case NML_DBUS_LOG_LEVEL_DEBUG:
|
|
|
|
|
prefix = "<debug> ";
|
|
|
|
|
break;
|
|
|
|
|
case NML_DBUS_LOG_LEVEL_WARN:
|
|
|
|
|
prefix = "<warn > ";
|
|
|
|
|
if (NM_FLAGS_HAS (configured_log_level, _NML_DBUS_LOG_LEVEL_WARN)) {
|
|
|
|
|
g_warning ("libnm-dbus: %s%s", prefix, msg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NML_DBUS_LOG_LEVEL_ERROR:
|
|
|
|
|
prefix = "<error> ";
|
|
|
|
|
if (NM_FLAGS_HAS (configured_log_level, _NML_DBUS_LOG_LEVEL_ERROR)) {
|
|
|
|
|
g_critical ("libnm-dbus: %s%s", prefix, msg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (NM_FLAGS_HAS (configured_log_level, _NML_DBUS_LOG_LEVEL_WARN)) {
|
|
|
|
|
g_warning ("libnm-dbus: %s%s", prefix, msg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_printerr ("libnm-dbus: %s%s\n", prefix, msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-02-23 14:52:00 +01:00
|
|
|
static char *
|
|
|
|
|
_fixup_string (const char *desc,
|
|
|
|
|
const char *const *ignored_phrases,
|
2018-02-23 14:52:05 +01:00
|
|
|
const char *const *ignored_words,
|
|
|
|
|
gboolean square_brackets_sensible)
|
2017-05-19 10:32:13 +02:00
|
|
|
{
|
|
|
|
|
char *desc_full;
|
2018-02-23 14:52:05 +01:00
|
|
|
gboolean in_paren = FALSE;
|
2017-05-19 10:32:13 +02:00
|
|
|
char *p, *q;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!desc || !desc[0])
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* restore original non-UTF-8-safe text. */
|
|
|
|
|
desc_full = nm_utils_str_utf8safe_unescape_cp (desc);
|
|
|
|
|
|
|
|
|
|
/* replace all invalid UTF-8 bytes with space. */
|
|
|
|
|
p = desc_full;
|
|
|
|
|
while (!g_utf8_validate (p, -1, (const char **) &q)) {
|
|
|
|
|
/* the byte is invalid UTF-8. Replace it with space and proceed. */
|
|
|
|
|
*q = ' ';
|
|
|
|
|
p = q + 1;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-23 14:52:05 +01:00
|
|
|
/* replace '_', ',', ASCII control characters and parentheses, with space. */
|
2017-05-19 10:32:13 +02:00
|
|
|
for (p = desc_full; p[0]; p++) {
|
2018-02-23 14:52:05 +01:00
|
|
|
if (*p == '(')
|
|
|
|
|
in_paren = TRUE;
|
2017-05-19 10:32:13 +02:00
|
|
|
if ( NM_IN_SET (*p, '_', ',')
|
2018-02-23 14:52:05 +01:00
|
|
|
|| *p < ' '
|
|
|
|
|
|| in_paren)
|
2017-05-19 10:32:13 +02:00
|
|
|
*p = ' ';
|
2018-02-23 14:52:05 +01:00
|
|
|
if (*p == ')')
|
|
|
|
|
in_paren = FALSE;
|
2017-05-19 10:32:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Attempt to shorten ID by ignoring certain phrases */
|
2018-02-23 14:52:00 +01:00
|
|
|
for (i = 0; ignored_phrases[i]; i++) {
|
|
|
|
|
p = strstr (desc_full, ignored_phrases[i]);
|
2017-05-19 10:32:13 +02:00
|
|
|
if (p) {
|
2018-02-23 14:52:00 +01:00
|
|
|
const char *eow = &p[strlen (ignored_phrases[i])];
|
2017-05-19 10:32:13 +02:00
|
|
|
|
|
|
|
|
/* require that the phrase is delimited by space, or
|
|
|
|
|
* at the beginning or end of the description. */
|
|
|
|
|
if ( (p == desc_full || p[-1] == ' ')
|
|
|
|
|
&& NM_IN_SET (eow[0], '\0', ' '))
|
|
|
|
|
memmove (p, eow, strlen (eow) + 1); /* +1 for the \0 */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Attempt to shorten ID by ignoring certain individual words.
|
|
|
|
|
* - word-split the description at spaces
|
|
|
|
|
* - coalesce multiple spaces
|
2018-02-23 14:52:00 +01:00
|
|
|
* - skip over ignored_words */
|
2017-05-19 10:32:13 +02:00
|
|
|
p = desc_full;
|
|
|
|
|
q = desc_full;
|
|
|
|
|
for (;;) {
|
|
|
|
|
char *eow;
|
|
|
|
|
gsize l;
|
|
|
|
|
|
|
|
|
|
/* skip leading spaces. */
|
|
|
|
|
while (p[0] == ' ')
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
|
|
if (!p[0])
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* split leading word on first space */
|
|
|
|
|
eow = strchr (p, ' ');
|
|
|
|
|
if (eow)
|
|
|
|
|
*eow = '\0';
|
|
|
|
|
|
2018-02-23 14:52:00 +01:00
|
|
|
if (nm_utils_strv_find_first ((char **) ignored_words, -1, p) >= 0)
|
2017-05-19 10:32:13 +02:00
|
|
|
goto next;
|
|
|
|
|
|
|
|
|
|
l = strlen (p);
|
|
|
|
|
if (q != p) {
|
|
|
|
|
if (q != desc_full)
|
|
|
|
|
*q++ = ' ';
|
|
|
|
|
memmove (q, p, l);
|
|
|
|
|
}
|
|
|
|
|
q += l;
|
|
|
|
|
|
|
|
|
|
next:
|
|
|
|
|
if (!eow)
|
|
|
|
|
break;
|
|
|
|
|
p = eow + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*q++ = '\0';
|
|
|
|
|
|
2018-02-23 14:52:05 +01:00
|
|
|
p = strchr (desc_full, '[');
|
|
|
|
|
if (p == desc_full) {
|
|
|
|
|
/* All we're left with is in square brackets.
|
|
|
|
|
* Always prefer that to a blank string.*/
|
|
|
|
|
square_brackets_sensible = TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (square_brackets_sensible) {
|
|
|
|
|
/* If there's a [<string>] that survived the substitution, then the string
|
2018-09-15 07:20:54 -04:00
|
|
|
* is a short form that is generally preferable. */
|
2018-02-23 14:52:05 +01:00
|
|
|
q = strchr (desc_full, ']');
|
|
|
|
|
if (p && q > p) {
|
|
|
|
|
p++;
|
|
|
|
|
memmove (desc_full, p, q - p);
|
|
|
|
|
desc_full[q - p] = '\0';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* [<string>] sometimes contains the preferred human-readable name, but
|
|
|
|
|
* mostly it's utterly useless. Sigh. Drop it. */
|
|
|
|
|
if (p) {
|
|
|
|
|
if (p > desc_full && p[-1] == ' ')
|
|
|
|
|
p--;
|
|
|
|
|
*p = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 10:32:13 +02:00
|
|
|
if (!desc_full[0]) {
|
|
|
|
|
g_free (desc_full);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-23 14:52:00 +01:00
|
|
|
return desc_full;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
nm_utils_fixup_vendor_string (const char *desc)
|
|
|
|
|
{
|
|
|
|
|
static const char *const IGNORED_PHRASES[] = {
|
2018-02-23 14:52:05 +01:00
|
|
|
"Access Systems",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Business Mobile Networks BV",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Communications & Multimedia",
|
|
|
|
|
"Company of Japan",
|
|
|
|
|
"Computer Co.",
|
|
|
|
|
"Computer Corp.",
|
|
|
|
|
"Computer Corporation",
|
|
|
|
|
"Computer Inc.",
|
|
|
|
|
"Computer, Inc.",
|
|
|
|
|
"Information and Communication Products",
|
|
|
|
|
"Macao Commercial Offshore",
|
|
|
|
|
"Mobile Phones",
|
|
|
|
|
"(M) Son",
|
|
|
|
|
"Multimedia Internet Technology",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Technology Group Ltd.",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Wireless Networks",
|
|
|
|
|
"Wireless Solutions",
|
2018-02-23 14:52:00 +01:00
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
static const char *const IGNORED_WORDS[] = {
|
2018-02-23 14:52:05 +01:00
|
|
|
"AB",
|
|
|
|
|
"AG",
|
|
|
|
|
"A/S",
|
|
|
|
|
"ASA",
|
|
|
|
|
"B.V.",
|
|
|
|
|
"Chips",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Co.",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Co",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Communications",
|
|
|
|
|
"Components",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Computers",
|
|
|
|
|
"Computertechnik",
|
|
|
|
|
"corp.",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Corp.",
|
|
|
|
|
"Corp",
|
|
|
|
|
"Corporation",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Design",
|
|
|
|
|
"Electronics",
|
|
|
|
|
"Enterprise",
|
|
|
|
|
"Enterprises",
|
|
|
|
|
"Europe",
|
|
|
|
|
"GmbH",
|
|
|
|
|
"Hardware",
|
2018-02-23 14:52:00 +01:00
|
|
|
"[hex]",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Holdings",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Inc.",
|
|
|
|
|
"Inc",
|
2018-02-23 14:52:05 +01:00
|
|
|
"INC.",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Incorporated",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Instruments",
|
|
|
|
|
"International",
|
|
|
|
|
"Intl.",
|
|
|
|
|
"Labs",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Limited.",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Limited",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Ltd.",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Ltd",
|
|
|
|
|
"Microelectronics",
|
|
|
|
|
"Microsystems",
|
|
|
|
|
"MSM",
|
|
|
|
|
"Multimedia",
|
|
|
|
|
"Networks",
|
|
|
|
|
"Norway",
|
|
|
|
|
"Optical",
|
|
|
|
|
"PCS",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Semiconductor",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Systems",
|
|
|
|
|
"Systemtechnik",
|
|
|
|
|
"Techcenter",
|
|
|
|
|
"Technik",
|
|
|
|
|
"Technologies",
|
|
|
|
|
"Technology",
|
|
|
|
|
"TECHNOLOGY",
|
|
|
|
|
"Telephonics",
|
|
|
|
|
"USA",
|
|
|
|
|
"WCDMA",
|
2018-02-23 14:52:00 +01:00
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
char *desc_full;
|
2018-02-23 14:52:05 +01:00
|
|
|
char *p;
|
2018-02-23 14:52:00 +01:00
|
|
|
|
2018-02-23 14:52:05 +01:00
|
|
|
desc_full = _fixup_string (desc, IGNORED_PHRASES, IGNORED_WORDS, TRUE);
|
2018-02-23 14:52:05 +01:00
|
|
|
if (!desc_full)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Chop off everything after a slash. */
|
|
|
|
|
for (p = desc_full; *p; p++) {
|
|
|
|
|
if ((p[0] == ' ' && p[1] == '/') || p[0] == '/') {
|
|
|
|
|
p[0] = '\0';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_assert (g_utf8_validate (desc_full, -1, NULL));
|
2018-02-23 14:52:00 +01:00
|
|
|
|
|
|
|
|
return desc_full;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
2018-02-23 14:52:05 +01:00
|
|
|
nm_utils_fixup_product_string (const char *desc)
|
2018-02-23 14:52:00 +01:00
|
|
|
{
|
|
|
|
|
static const char *const IGNORED_PHRASES[] = {
|
2018-02-23 14:52:05 +01:00
|
|
|
"100/10 MBit",
|
|
|
|
|
"10/100 Mbps",
|
|
|
|
|
"1.0 GbE",
|
|
|
|
|
"10 GbE",
|
|
|
|
|
"10 Gigabit",
|
|
|
|
|
"10 Mbps",
|
|
|
|
|
"1/10 Gigabit",
|
|
|
|
|
"150 Mbps",
|
|
|
|
|
"2.5 GbE",
|
|
|
|
|
"54 Mbps",
|
|
|
|
|
"Attached Port",
|
|
|
|
|
"+ BT",
|
|
|
|
|
"\"CDC Subset\"",
|
|
|
|
|
"CE Media Processor",
|
|
|
|
|
"Controller Area Network",
|
|
|
|
|
"Converged Network",
|
|
|
|
|
"DEC-Tulip compatible",
|
|
|
|
|
"Dish Adapter",
|
|
|
|
|
"Double 108 Mbps",
|
|
|
|
|
"Dual Band",
|
|
|
|
|
"Dual Port",
|
|
|
|
|
"Embedded UTP",
|
|
|
|
|
"Ethernet Connection",
|
|
|
|
|
"Ethernet Pro 100",
|
|
|
|
|
"Express Module",
|
|
|
|
|
"Fabric Adapter",
|
|
|
|
|
"Fast Ethernet",
|
|
|
|
|
"for 10GBASE-T" ,
|
|
|
|
|
"for 10GbE backplane" ,
|
|
|
|
|
"for 10GbE QSFP+" ,
|
|
|
|
|
"for 10GbE SFP+" ,
|
|
|
|
|
"for 1GbE",
|
|
|
|
|
"for 20GbE backplane" ,
|
|
|
|
|
"for 25GbE backplane" ,
|
|
|
|
|
"for 25GbE SFP28" ,
|
|
|
|
|
"for 40GbE backplane" ,
|
|
|
|
|
"for 40GbE QSFP+" ,
|
|
|
|
|
"G Adapter",
|
|
|
|
|
"Gigabit Desktop Network",
|
|
|
|
|
"Gigabit Ethernet",
|
|
|
|
|
"Gigabit or",
|
|
|
|
|
"Host Interface",
|
|
|
|
|
"Host Virtual Interface",
|
|
|
|
|
"IEEE 802.11a/b/g",
|
|
|
|
|
"IEEE 802.11g",
|
|
|
|
|
"IEEE 802.11G",
|
|
|
|
|
"IEEE 802.11n",
|
|
|
|
|
"MAC + PHY",
|
|
|
|
|
"Mini Card",
|
|
|
|
|
"Mini Wireless",
|
|
|
|
|
"multicore SoC",
|
|
|
|
|
"Multi Function",
|
|
|
|
|
"N Draft 11n Wireless",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Network Connection",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Network Everywhere",
|
|
|
|
|
"N Wireless",
|
|
|
|
|
"N+ Wireless",
|
|
|
|
|
"OCT To Fast Ethernet Converter",
|
|
|
|
|
"PC Card",
|
|
|
|
|
"PCI Express",
|
|
|
|
|
"Platform Controller Hub",
|
|
|
|
|
"Plus Bluetooth",
|
|
|
|
|
"Quad Gigabit",
|
|
|
|
|
"rev 1",
|
|
|
|
|
"rev 17",
|
|
|
|
|
"rev 2",
|
|
|
|
|
"rev A",
|
|
|
|
|
"rev B",
|
|
|
|
|
"rev F",
|
|
|
|
|
"TO Ethernet",
|
|
|
|
|
"Turbo Wireless Adapter",
|
|
|
|
|
"Unified Wire",
|
|
|
|
|
"USB 1.1",
|
|
|
|
|
"USB 2.0",
|
|
|
|
|
"Virtual media for",
|
|
|
|
|
"WiFi Link",
|
|
|
|
|
"+ WiMAX",
|
|
|
|
|
"WiMAX/WiFi Link",
|
|
|
|
|
"Wireless G",
|
|
|
|
|
"Wireless G+",
|
|
|
|
|
"Wireless Lan",
|
|
|
|
|
"Wireless Mini adapter",
|
|
|
|
|
"Wireless Mini Adapter",
|
|
|
|
|
"Wireless N",
|
|
|
|
|
"with 1000-BASE-T interface",
|
|
|
|
|
"with CX4 copper interface",
|
|
|
|
|
"with Range Amplifier",
|
|
|
|
|
"with SR-XFP optical interface",
|
|
|
|
|
"w/ Upgradable Antenna",
|
2018-02-23 14:52:00 +01:00
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
static const char *const IGNORED_WORDS[] = {
|
2018-02-23 14:52:05 +01:00
|
|
|
"1000BaseSX",
|
|
|
|
|
"1000BASE-T",
|
|
|
|
|
"1000Base-ZX",
|
|
|
|
|
"100/10M",
|
|
|
|
|
"100baseFx",
|
|
|
|
|
"100Base-MII",
|
|
|
|
|
"100Base-T",
|
|
|
|
|
"100BaseT4",
|
|
|
|
|
"100Base-TX",
|
|
|
|
|
"100BaseTX",
|
|
|
|
|
"100GbE",
|
|
|
|
|
"100Mbps",
|
|
|
|
|
"100MBps",
|
|
|
|
|
"10/100",
|
|
|
|
|
"10/100/1000",
|
|
|
|
|
"10/100/1000Base-T",
|
|
|
|
|
"10/100/1000BASE-T",
|
|
|
|
|
"10/100BaseT",
|
|
|
|
|
"10/100baseTX",
|
|
|
|
|
"10/100BaseTX",
|
|
|
|
|
"10/100/BNC",
|
|
|
|
|
"10/100M",
|
|
|
|
|
"10/20-Gigabit",
|
|
|
|
|
"10/25/40/50GbE",
|
|
|
|
|
"10/40G",
|
|
|
|
|
"10base-FL",
|
|
|
|
|
"10BaseT",
|
|
|
|
|
"10BASE-T",
|
|
|
|
|
"10G",
|
|
|
|
|
"10Gb",
|
|
|
|
|
"10Gb/25Gb",
|
|
|
|
|
"10Gb/25Gb/40Gb/50Gb",
|
|
|
|
|
"10Gbase-T",
|
|
|
|
|
"10GBase-T",
|
|
|
|
|
"10GBASE-T",
|
|
|
|
|
"10GbE",
|
|
|
|
|
"10Gbps",
|
|
|
|
|
"10-Giga",
|
|
|
|
|
"10-Gigabit",
|
|
|
|
|
"10mbps",
|
|
|
|
|
"10Mbps",
|
|
|
|
|
"1/10GbE",
|
|
|
|
|
"1/10-Gigabit",
|
|
|
|
|
"11b/g/n",
|
|
|
|
|
"11g",
|
|
|
|
|
"150Mbps",
|
|
|
|
|
"16Gbps/10Gbps",
|
|
|
|
|
"1GbE",
|
|
|
|
|
"1x2:2",
|
|
|
|
|
"20GbE",
|
|
|
|
|
"25Gb",
|
|
|
|
|
"25GbE",
|
|
|
|
|
"2-Port",
|
|
|
|
|
"2x3:3",
|
|
|
|
|
"3G",
|
|
|
|
|
"3G/4G",
|
|
|
|
|
"3x3:3",
|
|
|
|
|
"40GbE",
|
|
|
|
|
"4G",
|
|
|
|
|
"54g",
|
|
|
|
|
"54M",
|
|
|
|
|
"54Mbps",
|
|
|
|
|
"56k",
|
|
|
|
|
"5G",
|
|
|
|
|
"802.11",
|
|
|
|
|
"802.11a/b/g",
|
|
|
|
|
"802.11abg",
|
|
|
|
|
"802.11a/b/g/n",
|
|
|
|
|
"802.11abgn",
|
|
|
|
|
"802.11ac",
|
|
|
|
|
"802.11ad",
|
|
|
|
|
"802.11a/g",
|
|
|
|
|
"802.11b",
|
|
|
|
|
"802.11b/g",
|
|
|
|
|
"802.11bg",
|
|
|
|
|
"802.11b/g/n",
|
|
|
|
|
"802.11bgn",
|
|
|
|
|
"802.11b/g/n-draft",
|
|
|
|
|
"802.11g",
|
|
|
|
|
"802.11n",
|
|
|
|
|
"802.11N",
|
|
|
|
|
"802.11n/b/g",
|
|
|
|
|
"802.11ng",
|
|
|
|
|
"802AIN",
|
|
|
|
|
"802UIG-1",
|
2018-02-23 14:52:00 +01:00
|
|
|
"adapter",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Adapter",
|
|
|
|
|
"adaptor",
|
|
|
|
|
"ADSL",
|
|
|
|
|
"Basic",
|
|
|
|
|
"CAN-Bus",
|
|
|
|
|
"card",
|
|
|
|
|
"Card",
|
|
|
|
|
"Cardbus",
|
|
|
|
|
"CardBus",
|
|
|
|
|
"CDMA",
|
|
|
|
|
"CNA",
|
|
|
|
|
"Composite",
|
|
|
|
|
"controller",
|
|
|
|
|
"Controller",
|
|
|
|
|
"Copper",
|
|
|
|
|
"DB",
|
|
|
|
|
"Desktop",
|
|
|
|
|
"device",
|
|
|
|
|
"Device",
|
|
|
|
|
"dongle",
|
|
|
|
|
"driver",
|
|
|
|
|
"Dual-band",
|
|
|
|
|
"Dual-Protocol",
|
|
|
|
|
"EISA",
|
|
|
|
|
"Enhanced",
|
|
|
|
|
"ethernet.",
|
|
|
|
|
"ethernet",
|
|
|
|
|
"Ethernet",
|
|
|
|
|
"Ethernet/RNDIS",
|
|
|
|
|
"ExpressModule",
|
|
|
|
|
"family",
|
|
|
|
|
"Family",
|
|
|
|
|
"Fast/Gigabit",
|
|
|
|
|
"Fiber",
|
|
|
|
|
"gigabit",
|
|
|
|
|
"Gigabit",
|
|
|
|
|
"G-NIC",
|
|
|
|
|
"Hi-Gain",
|
|
|
|
|
"Hi-Speed",
|
|
|
|
|
"HSDPA",
|
|
|
|
|
"HSUPA",
|
|
|
|
|
"integrated",
|
|
|
|
|
"Integrated",
|
|
|
|
|
"interface",
|
|
|
|
|
"LAN",
|
|
|
|
|
"LAN+Winmodem",
|
|
|
|
|
"Laptop",
|
|
|
|
|
"LTE",
|
|
|
|
|
"LTE/UMTS/GSM",
|
|
|
|
|
"MAC",
|
|
|
|
|
"Micro",
|
|
|
|
|
"Mini-Card",
|
|
|
|
|
"Mini-USB",
|
|
|
|
|
"misprogrammed",
|
|
|
|
|
"modem",
|
|
|
|
|
"Modem",
|
|
|
|
|
"Modem/Networkcard",
|
2018-02-23 14:52:00 +01:00
|
|
|
"Module",
|
2018-02-23 14:52:05 +01:00
|
|
|
"Multimode",
|
|
|
|
|
"Multithreaded",
|
|
|
|
|
"Name:",
|
|
|
|
|
"net",
|
|
|
|
|
"network",
|
|
|
|
|
"Network",
|
|
|
|
|
"n/g/b",
|
|
|
|
|
"NIC",
|
|
|
|
|
"Notebook",
|
|
|
|
|
"OEM",
|
|
|
|
|
"PCI",
|
|
|
|
|
"PCI64",
|
|
|
|
|
"PCIe",
|
|
|
|
|
"PCI-E",
|
|
|
|
|
"PCI-Express",
|
|
|
|
|
"PCI-X",
|
|
|
|
|
"PCMCIA",
|
|
|
|
|
"PDA",
|
|
|
|
|
"PnP",
|
|
|
|
|
"RDMA",
|
|
|
|
|
"RJ-45",
|
|
|
|
|
"Series",
|
|
|
|
|
"Server",
|
|
|
|
|
"SoC",
|
|
|
|
|
"Switch",
|
|
|
|
|
"Technologies",
|
|
|
|
|
"TOE",
|
|
|
|
|
"USB",
|
|
|
|
|
"USB2.0",
|
|
|
|
|
"USB/Ethernet",
|
|
|
|
|
"UTP",
|
|
|
|
|
"UTP/Coax",
|
|
|
|
|
"v1",
|
|
|
|
|
"v1.1",
|
|
|
|
|
"v2",
|
|
|
|
|
"V2.0",
|
|
|
|
|
"v3",
|
|
|
|
|
"v4",
|
|
|
|
|
"wifi",
|
|
|
|
|
"Wi-Fi",
|
|
|
|
|
"WiFi",
|
|
|
|
|
"wireless",
|
|
|
|
|
"Wireless",
|
|
|
|
|
"Wireless-150N",
|
|
|
|
|
"Wireless-300N",
|
|
|
|
|
"Wireless-G",
|
|
|
|
|
"Wireless-N",
|
|
|
|
|
"WLAN",
|
2018-02-23 14:52:00 +01:00
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
char *desc_full;
|
2018-02-23 14:52:05 +01:00
|
|
|
char *p;
|
2018-02-23 14:52:00 +01:00
|
|
|
|
2018-02-23 14:52:05 +01:00
|
|
|
desc_full = _fixup_string (desc, IGNORED_PHRASES, IGNORED_WORDS, FALSE);
|
|
|
|
|
if (!desc_full)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2018-02-23 14:52:05 +01:00
|
|
|
/* Chop off everything after a '-'. */
|
|
|
|
|
for (p = desc_full; *p; p++) {
|
|
|
|
|
if (p[0] == ' ' && p[1] == '-' && p[2] == ' ') {
|
|
|
|
|
p[0] = '\0';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-23 14:52:05 +01:00
|
|
|
nm_assert (g_utf8_validate (desc_full, -1, NULL));
|
2018-02-23 14:52:00 +01:00
|
|
|
|
2017-05-19 10:32:13 +02:00
|
|
|
return desc_full;
|
|
|
|
|
}
|