mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 14:50:10 +01:00
core: add nm_match_spec_device_by_pllink()
Add a variant of nm_device_spec_match_list() that looks up the match paramters from a platform link instance. Usually, we have a NMDevice instance that we use for matching. However, at some places (like inside the device factory's create_device() method), we might not have a NMDevice instance to get the match paramters. Add an alternative form, that gets the match paramters from a platform link instance. The code is placed inside src/NetworkManagerUtils.c, because src/nm-core-utils.c is supposed to be independent of platform.
This commit is contained in:
parent
02a26de6f8
commit
00c1e560f9
2 changed files with 38 additions and 0 deletions
|
|
@ -935,3 +935,37 @@ nm_utils_g_value_set_object_path_array (GValue *value,
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int
|
||||
nm_match_spec_device_by_pllink (const NMPlatformLink *pllink,
|
||||
const GSList *specs,
|
||||
int no_match_value)
|
||||
{
|
||||
NMMatchSpecMatchType m;
|
||||
|
||||
/* we can only match by certain properties that are available on the
|
||||
* platform link (and even @pllink might be missing.
|
||||
*
|
||||
* It's still useful because of specs like "*" and "except:interface-name:eth0",
|
||||
* which match even in that case. */
|
||||
m = nm_match_spec_device (specs,
|
||||
pllink ? pllink->name : NULL,
|
||||
NULL,
|
||||
pllink ? pllink->driver : NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
switch (m) {
|
||||
case NM_MATCH_SPEC_MATCH:
|
||||
return TRUE;
|
||||
case NM_MATCH_SPEC_NEG_MATCH:
|
||||
return FALSE;
|
||||
case NM_MATCH_SPEC_NO_MATCH:
|
||||
return no_match_value;
|
||||
}
|
||||
nm_assert_not_reached ();
|
||||
return no_match_value;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ void nm_utils_g_value_set_object_path_array (GValue *value,
|
|||
NMUtilsObjectFunc filter_func,
|
||||
gpointer user_data);
|
||||
|
||||
int nm_match_spec_device_by_pllink (const NMPlatformLink *pllink,
|
||||
const GSList *specs,
|
||||
int no_match_value);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* __NETWORKMANAGER_UTILS_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue