platform/wpan: allow setting channel
This commit is contained in:
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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__ */
|
||||
|
Reference in New Issue
Block a user