mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 11:19:16 +02:00
core: add nm_match_spec_device_data_init_from_platform() helper
(cherry picked from commit ccaecf7f3e)
This commit is contained in:
parent
75f240704b
commit
8ea3f77a3b
2 changed files with 38 additions and 15 deletions
|
|
@ -936,6 +936,32 @@ nm_match_spec_device_data_init_from_device(struct _NMMatchSpecDeviceData *out_da
|
||||||
return out_data;
|
return out_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NMMatchSpecDeviceData *
|
||||||
|
nm_match_spec_device_data_init_from_platform(NMMatchSpecDeviceData *out_data,
|
||||||
|
const NMPlatformLink *pllink,
|
||||||
|
const char *match_device_type,
|
||||||
|
const char *match_dhcp_plugin)
|
||||||
|
{
|
||||||
|
nm_assert(out_data);
|
||||||
|
|
||||||
|
/* 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. */
|
||||||
|
|
||||||
|
*out_data = (NMMatchSpecDeviceData){
|
||||||
|
.interface_name = pllink ? pllink->name : NULL,
|
||||||
|
.device_type = match_device_type,
|
||||||
|
.driver = pllink ? pllink->driver : NULL,
|
||||||
|
.driver_version = NULL,
|
||||||
|
.hwaddr = NULL,
|
||||||
|
.s390_subchannels = NULL,
|
||||||
|
.dhcp_plugin = match_dhcp_plugin,
|
||||||
|
};
|
||||||
|
return out_data;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -945,23 +971,14 @@ nm_match_spec_device_by_pllink(const NMPlatformLink *pllink,
|
||||||
const GSList *specs,
|
const GSList *specs,
|
||||||
int no_match_value)
|
int no_match_value)
|
||||||
{
|
{
|
||||||
NMMatchSpecMatchType m;
|
NMMatchSpecMatchType m;
|
||||||
|
NMMatchSpecDeviceData data;
|
||||||
|
|
||||||
/* 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,
|
m = nm_match_spec_device(specs,
|
||||||
&((const NMMatchSpecDeviceData){
|
nm_match_spec_device_data_init_from_platform(&data,
|
||||||
.interface_name = pllink ? pllink->name : NULL,
|
pllink,
|
||||||
.device_type = match_device_type,
|
match_device_type,
|
||||||
.driver = pllink ? pllink->driver : NULL,
|
match_dhcp_plugin));
|
||||||
.driver_version = NULL,
|
|
||||||
.hwaddr = NULL,
|
|
||||||
.s390_subchannels = NULL,
|
|
||||||
.dhcp_plugin = match_dhcp_plugin,
|
|
||||||
}));
|
|
||||||
return nm_match_spec_match_type_to_bool(m, no_match_value);
|
return nm_match_spec_match_type_to_bool(m, no_match_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,12 @@ const struct _NMMatchSpecDeviceData *
|
||||||
nm_match_spec_device_data_init_from_device(struct _NMMatchSpecDeviceData *out_data,
|
nm_match_spec_device_data_init_from_device(struct _NMMatchSpecDeviceData *out_data,
|
||||||
NMDevice *device);
|
NMDevice *device);
|
||||||
|
|
||||||
|
const struct _NMMatchSpecDeviceData *
|
||||||
|
nm_match_spec_device_data_init_from_platform(struct _NMMatchSpecDeviceData *out_data,
|
||||||
|
const NMPlatformLink *pllink,
|
||||||
|
const char *match_device_type,
|
||||||
|
const char *match_dhcp_plugin);
|
||||||
|
|
||||||
int nm_match_spec_device_by_pllink(const NMPlatformLink *pllink,
|
int nm_match_spec_device_by_pllink(const NMPlatformLink *pllink,
|
||||||
const char *match_device_type,
|
const char *match_device_type,
|
||||||
const char *match_dhcp_plugin,
|
const char *match_dhcp_plugin,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue