diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-09-19 19:43:09 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-10-07 15:46:02 +0200 |
commit | 0573656eebe0b19b1e24700bd2f00b546f36a8ff (patch) | |
tree | 3f79b5aa9440c9294196da1fe414650165c4d386 | |
parent | ae38d43e660e0298d67dc98558f019a355b8a902 (diff) | |
download | NetworkManager-0573656eebe0b19b1e24700bd2f00b546f36a8ff.tar.gz |
platform/wpan: allow setting channel
-rw-r--r-- | src/platform/nm-linux-platform.c | 8 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 10 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 2 | ||||
-rw-r--r-- | src/platform/wpan/nm-wpan-utils.c | 18 | ||||
-rw-r--r-- | src/platform/wpan/nm-wpan-utils.h | 2 |
5 files changed, 40 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 8cb3911332..82f872f54e 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -6947,6 +6947,13 @@ wpan_set_short_addr (NMPlatform *platform, int ifindex, guint16 short_addr) return nm_wpan_utils_set_short_addr (wpan_data, short_addr); } +static gboolean +wpan_set_channel (NMPlatform *platform, int ifindex, guint8 page, guint8 channel) +{ + WPAN_GET_WPAN_DATA (wpan_data, platform, ifindex, FALSE); + return nm_wpan_utils_set_channel (wpan_data, page, channel); +} + /*****************************************************************************/ static gboolean @@ -8067,6 +8074,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass) platform_class->wpan_set_pan_id = wpan_set_pan_id; platform_class->wpan_get_short_addr = wpan_get_short_addr; platform_class->wpan_set_short_addr = wpan_set_short_addr; + platform_class->wpan_set_channel = wpan_set_channel; platform_class->link_gre_add = link_gre_add; platform_class->link_ip6tnl_add = link_ip6tnl_add; diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 3b79670480..1667edaa25 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -3128,6 +3128,16 @@ nm_platform_wpan_set_short_addr (NMPlatform *self, int ifindex, guint16 short_ad return klass->wpan_set_short_addr (self, ifindex, short_addr); } +gboolean +nm_platform_wpan_set_channel (NMPlatform *self, int ifindex, guint8 page, guint8 channel) +{ + _CHECK_SELF (self, klass, FALSE); + + g_return_val_if_fail (ifindex > 0, FALSE); + + return klass->wpan_set_channel (self, ifindex, page, channel); +} + #define TO_STRING_DEV_BUF_SIZE (5+15+1) static const char * _to_string_dev (NMPlatform *self, int ifindex, char *buf, size_t size) diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index c1ce90947a..00dd02e9a6 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -927,6 +927,7 @@ typedef struct { gboolean (*wpan_set_pan_id) (NMPlatform *, int ifindex, guint16 pan_id); guint16 (*wpan_get_short_addr) (NMPlatform *, int ifindex); gboolean (*wpan_set_short_addr) (NMPlatform *, int ifindex, guint16 short_addr); + gboolean (*wpan_set_channel) (NMPlatform *, int ifindex, guint8 page, guint8 channel); gboolean (*object_delete) (NMPlatform *, const NMPObject *obj); @@ -1317,6 +1318,7 @@ guint16 nm_platform_wpan_get_pan_id (NMPlatform *platform, int ifindex gboolean nm_platform_wpan_set_pan_id (NMPlatform *platform, int ifindex, guint16 pan_id); guint16 nm_platform_wpan_get_short_addr (NMPlatform *platform, int ifindex); gboolean nm_platform_wpan_set_short_addr (NMPlatform *platform, int ifindex, guint16 short_addr); +gboolean nm_platform_wpan_set_channel (NMPlatform *platform, int ifindex, guint8 page, guint8 channel); void nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, guint8 plen); const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Address *addr); diff --git a/src/platform/wpan/nm-wpan-utils.c b/src/platform/wpan/nm-wpan-utils.c index feb32d7759..53bd677d23 100644 --- a/src/platform/wpan/nm-wpan-utils.c +++ b/src/platform/wpan/nm-wpan-utils.c @@ -243,6 +243,24 @@ nla_put_failure: return FALSE; } +gboolean +nm_wpan_utils_set_channel (NMWpanUtils *self, guint8 page, guint8 channel) +{ + nm_auto_nlmsg struct nl_msg *msg = NULL; + int err; + + g_return_val_if_fail (self != NULL, FALSE); + + msg = nl802154_alloc_msg (self, NL802154_CMD_SET_CHANNEL, 0); + NLA_PUT_U8 (msg, NL802154_ATTR_PAGE, page); + NLA_PUT_U8 (msg, NL802154_ATTR_CHANNEL, channel); + err = nl802154_send_and_recv (self, msg, NULL, NULL); + return err >= 0; + +nla_put_failure: + return FALSE; +} + /*****************************************************************************/ static void diff --git a/src/platform/wpan/nm-wpan-utils.h b/src/platform/wpan/nm-wpan-utils.h index f7d0c03e98..1b54ec49b7 100644 --- a/src/platform/wpan/nm-wpan-utils.h +++ b/src/platform/wpan/nm-wpan-utils.h @@ -44,4 +44,6 @@ gboolean nm_wpan_utils_set_pan_id (NMWpanUtils *self, guint16 pan_id); guint16 nm_wpan_utils_get_short_addr (NMWpanUtils *self); gboolean nm_wpan_utils_set_short_addr (NMWpanUtils *self, guint16 short_addr); +gboolean nm_wpan_utils_set_channel (NMWpanUtils *self, guint8 page, guint8 channel); + #endif /* __WPAN_UTILS_H__ */ |