]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: add default mesh Power Mode and Awake Window to mesh config
authorMarco Porsch <marco@cozybit.com>
Fri, 18 Jan 2013 12:05:31 +0000 (13:05 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 29 Jan 2013 11:54:44 +0000 (12:54 +0100)
The default mesh power mode is the power mode that will be
assigned to newly established peer links.
The awake window is the duration the local STA will stay awake
after sending its own beacon in PS mode.
Both values can be modified as part of the mesh params.

Signed-off-by: Marco Porsch <marco@cozybit.com>
Signed-off-by: Ivan Bezyazychnyy <ivan.bezyazychnyy@gmail.com>
mesh.c

diff --git a/mesh.c b/mesh.c
index 958c2c077a8b503cc3bf5730bb1b2af7415e43b4..5a09b62a8edf952de4b61c8762c27b03e594f44c 100644 (file)
--- a/mesh.c
+++ b/mesh.c
@@ -109,6 +109,23 @@ static uint32_t _parse_s32(const char *str, _any *ret)
        return 0;
 }
 
+static uint32_t _parse_u32_power_mode(const char *str, _any *ret)
+{
+       unsigned long int v;
+
+       /* Parse attribute for the name of power mode */
+       if (!strcmp(str, "active"))
+               v = NL80211_MESH_POWER_ACTIVE;
+       else if (!strcmp(str, "light"))
+               v = NL80211_MESH_POWER_LIGHT_SLEEP;
+       else if (!strcmp(str, "deep"))
+               v = NL80211_MESH_POWER_DEEP_SLEEP;
+       else
+               return 0xff;
+
+       ret->u.as_32 = (uint32_t)v;
+       return 0;
+}
 
 static void _print_u8(struct nlattr *a)
 {
@@ -145,6 +162,26 @@ static void _print_u32_in_TUs(struct nlattr *a)
        printf("%d TUs", nla_get_u32(a));
 }
 
+static void _print_u32_power_mode(struct nlattr *a)
+{
+       unsigned long v = nla_get_u32(a);
+
+       switch (v) {
+       case NL80211_MESH_POWER_ACTIVE:
+               printf("active");
+               break;
+       case NL80211_MESH_POWER_LIGHT_SLEEP:
+               printf("light");
+               break;
+       case NL80211_MESH_POWER_DEEP_SLEEP:
+               printf("deep");
+               break;
+       default:
+               printf("undefined");
+               break;
+       }
+}
+
 static void _print_s32_in_dBm(struct nlattr *a)
 {
        printf("%d dBm", (int32_t) nla_get_u32(a));
@@ -217,6 +254,10 @@ const static struct mesh_param_descr _mesh_param_descrs[] =
        {"mesh_hwmp_confirmation_interval",
        NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
        _my_nla_put_u16, _parse_u16, _print_u16_in_TUs},
+       {"mesh_power_mode", NL80211_MESHCONF_POWER_MODE,
+       _my_nla_put_u32, _parse_u32_power_mode, _print_u32_power_mode},
+       {"mesh_awake_window", NL80211_MESHCONF_AWAKE_WINDOW,
+       _my_nla_put_u16, _parse_u16, _print_u16_in_TUs},
 };
 
 static void print_all_mesh_param_descr(void)
@@ -294,8 +335,15 @@ static int set_interface_meshparam(struct nl80211_state *state,
                /* Parse the new value */
                ret = mdescr->parse_fn(value, &any);
                if (ret != 0) {
-                       printf("%s must be set to a number "
-                              "between 0 and %u\n", mdescr->name, ret);
+                       if (mdescr->mesh_param_num
+                           == NL80211_MESHCONF_POWER_MODE)
+                               printf("%s must be set to active, light or "
+                                       "deep.\n", mdescr->name);
+                       else
+                               printf("%s must be set to a number "
+                                       "between 0 and %u\n",
+                                       mdescr->name, ret);
+
                        return 2;
                }