diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-05-22 11:50:05 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-06-26 16:21:55 +0200 |
commit | 47c51b3f26a75af52a771621986bb85fae1edcad (patch) | |
tree | 1206c7ab2b8cdcef428a462cd8b69f21bb5f153f | |
parent | 49844ea55f1cdaec729b5e90c6dd8db6c890b044 (diff) | |
download | NetworkManager-47c51b3f26a75af52a771621986bb85fae1edcad.tar.gz |
platform: add support for 6LoWPAN links
The 6LoWPAN devices tunnel IPv6 over IEEE 802.14.5 WPAN links.
They are software devices without any interesting properties but the
parent linke.
-rw-r--r-- | src/platform/nm-platform.c | 65 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 12 |
2 files changed, 77 insertions, 0 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 3acdb7db2a..1fcb4d79c5 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2088,6 +2088,70 @@ nm_platform_link_tun_add (NMPlatform *self, return NM_PLATFORM_ERROR_SUCCESS; } +/** + * nm_platform_6lowpan_add: + * @self: platform instance + * @parent: parent link + * @name: name of the new interface + * @out_link: on success, the link object + * + * Create a 6LoWPAN interface. + */ +NMPlatformError +nm_platform_link_6lowpan_add (NMPlatform *self, + const char *name, + int parent, + const NMPlatformLink **out_link) +{ + NMPlatformError plerr; + + _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG); + + g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG); + + plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_6LOWPAN, out_link); + if (plerr != NM_PLATFORM_ERROR_SUCCESS) + return plerr; + + _LOGD ("adding 6lowpan '%s' parent %u", name, parent); + + if (!klass->link_6lowpan_add (self, name, parent, out_link)) + return NM_PLATFORM_ERROR_UNSPECIFIED; + return NM_PLATFORM_ERROR_SUCCESS; +} + +gboolean +nm_platform_link_6lowpan_get_properties (NMPlatform *self, int ifindex, int *out_parent) +{ + const NMPlatformLink *plink; + _CHECK_SELF (self, klass, FALSE); + + plink = nm_platform_link_get (self, ifindex); + + if (!plink) + return FALSE; + if (plink->type != NM_LINK_TYPE_6LOWPAN) + return FALSE; + + if (plink->parent != 0) { + NM_SET_OUT (out_parent, plink->parent); + return TRUE; + } + + /* As of 4.16 kernel does not expose the peer_ifindex as IFA_LINK. + * Find the WPAN device with the same MAC address. */ + if (out_parent) { + const NMPlatformLink *parent_plink; + + parent_plink = nm_platform_link_get_by_address (self, NM_LINK_TYPE_WPAN, + plink->addr.data, + plink->addr.len); + NM_SET_OUT (out_parent, parent_plink ? parent_plink->ifindex : -1); + } + + return TRUE; +} + /*****************************************************************************/ static gboolean @@ -2539,6 +2603,7 @@ nm_platform_link_ipip_add (NMPlatform *self, * nm_platform_macsec_add: * @self: platform instance * @name: name of the new interface + * @parent: parent link * @props: interface properties * @out_link: on success, the link object * diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 435cb905c2..986df9b63f 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -854,6 +854,11 @@ typedef struct { const NMPlatformLink **out_link, int *out_fd); + gboolean (*link_6lowpan_add) (NMPlatform *platform, + const char *name, + int parent, + const NMPlatformLink **out_link); + gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, const NMPlatformLink **out_link); gboolean (*infiniband_partition_delete) (NMPlatform *, int parent, int p_key); @@ -1301,6 +1306,13 @@ NMPlatformError nm_platform_link_tun_add (NMPlatform *self, const NMPlatformLnkTun *props, const NMPlatformLink **out_link, int *out_fd); +NMPlatformError nm_platform_link_6lowpan_add (NMPlatform *self, + const char *name, + int parent, + const NMPlatformLink **out_link); +gboolean nm_platform_link_6lowpan_get_properties (NMPlatform *self, + int ifindex, + int *out_parent); const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address); |