Signed-off-by: Alexander Aring <alex.aring@xxxxxxxxx> --- src/mac.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/nl802154.h | 8 ++++++ 2 files changed, 92 insertions(+) diff --git a/src/mac.c b/src/mac.c index 16d1156..233bdf4 100644 --- a/src/mac.c +++ b/src/mac.c @@ -67,3 +67,87 @@ nla_put_failure: COMMAND(set, max_frame_retries, "<retries>", NL802154_CMD_SET_MAX_FRAME_RETRIES, 0, CIB_NETDEV, handle_max_frame_retries_set, NULL); + +static int handle_max_be(struct nl802154_state *state, + struct nl_cb *cb, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + unsigned long max_be; + char *end; + + if (argc < 1) + return 1; + + /* MAX_BE */ + max_be = strtoul(argv[0], &end, 0); + if (*end != '\0') + return 1; + + NLA_PUT_U8(msg, NL802154_ATTR_MAX_BE, max_be); + + return 0; + +nla_put_failure: + return -ENOBUFS; +} +COMMAND(set, max_be, "<max_be>", + NL802154_CMD_SET_MAX_BE, 0, CIB_NETDEV, + handle_max_be, NULL); + +static int handle_max_csma_backoffs(struct nl802154_state *state, + struct nl_cb *cb, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + unsigned long backoffs; + char *end; + + if (argc < 1) + return 1; + + /* BACKOFFS */ + backoffs = strtoul(argv[0], &end, 0); + if (*end != '\0') + return 1; + + NLA_PUT_U8(msg, NL802154_ATTR_MAX_CSMA_BACKOFFS, backoffs); + + return 0; + +nla_put_failure: + return -ENOBUFS; +} +COMMAND(set, max_csma_backoffs, "<backoffs>", + NL802154_CMD_SET_MAX_CSMA_BACKOFFS, 0, CIB_NETDEV, + handle_max_csma_backoffs, NULL); + +static int handle_min_be(struct nl802154_state *state, + struct nl_cb *cb, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + unsigned long min_be; + char *end; + + if (argc < 1) + return 1; + + /* MIN_BE */ + min_be = strtoul(argv[0], &end, 0); + if (*end != '\0') + return 1; + + NLA_PUT_U8(msg, NL802154_ATTR_MIN_BE, min_be); + + return 0; + +nla_put_failure: + return -ENOBUFS; +} +COMMAND(set, min_be, "<min_be>", + NL802154_CMD_SET_MIN_BE, 0, CIB_NETDEV, + handle_min_be, NULL); diff --git a/src/nl802154.h b/src/nl802154.h index a23c34f..963feda 100644 --- a/src/nl802154.h +++ b/src/nl802154.h @@ -48,6 +48,10 @@ enum nl802154_commands { NL802154_CMD_SET_MAX_FRAME_RETRIES, + NL802154_CMD_SET_MAX_BE, + NL802154_CMD_SET_MAX_CSMA_BACKOFFS, + NL802154_CMD_SET_MIN_BE, + /* add new commands above here */ /* used to define NL802154_CMD_MAX below */ @@ -82,6 +86,10 @@ enum nl802154_attrs { NL802154_ATTR_MAX_FRAME_RETRIES, + NL802154_ATTR_MAX_BE, + NL802154_ATTR_MAX_CSMA_BACKOFFS, + NL802154_ATTR_MIN_BE, + /* add attributes here, update the policy in nl802154.c */ __NL802154_ATTR_AFTER_LAST, -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html