Re: [OpenWrt-Devel] [PATCH 2/2] add channel information for scan results
Hi, comments inline. ~ Jo > diff --git a/include/iwinfo.h b/include/iwinfo.h > index c3c25ff..b1b39a1 100644 > --- a/include/iwinfo.h > +++ b/include/iwinfo.h > @@ -145,6 +145,24 @@ struct iwinfo_crypto_entry { > uint8_t auth_suites; > uint8_t auth_algs; > }; > +struct iwinfo_channel_info_entry { > + /** > + * sec_channel_offset - Secondary channel offset for HT40 > + * > + * 0 = HT40 disabled, > + * -1 = HT40 enabled, secondary channel below primary, > + * 1 = HT40 enabled, secondary channel above primary > + */ > + int sec_channel_offset; > + /** > + * Center channel for VHT80 > + */ > + int center_idx0; > + /** > + * Center channel for VHT160 > + */ > + int center_idx1; > +}; Do we really need three ints? I think the sec_channel_offset could be an u8 and the channel indexes u8 or u16 values. > > struct iwinfo_scanlist_entry { > uint8_t mac[6]; > @@ -154,8 +172,9 @@ struct iwinfo_scanlist_entry { > uint8_t signal; > uint8_t quality; > uint8_t quality_max; > -int htmodelist; > + int htmodelist; Please use an u8 here. > struct iwinfo_crypto_entry crypto; > + struct iwinfo_channel_info_entry channel_info; > }; > > struct iwinfo_country_entry { > diff --git a/iwinfo_cli.c b/iwinfo_cli.c > index 2d58020..0d899e0 100644 > --- a/iwinfo_cli.c > +++ b/iwinfo_cli.c > @@ -612,6 +612,16 @@ static void print_scanlist(const struct iwinfo_ops *iw, > const char *ifname) > if (e->htmodelist & (1 << h)) > printf("%s ", IWINFO_HTMODE_NAMES[h]); > printf ("\n"); > + if (e->channel_info.sec_channel_offset) > + printf (" HT secondary channel is > %s\n", > + > e->channel_info.sec_channel_offset < 0 ? "below" : > + "above"); > + if (e->channel_info.center_idx0) > + printf (" VHT Center IDX0: %d\n", > + e->channel_info.center_idx0); > + if (e->channel_info.center_idx1) > + printf (" VHT Center IDX1: %d\n", > + e->channel_info.center_idx1); > } > printf ("\n"); > } > diff --git a/iwinfo_lua.c b/iwinfo_lua.c > index 01581a3..bd7f0d3 100644 > --- a/iwinfo_lua.c > +++ b/iwinfo_lua.c > @@ -446,6 +446,17 @@ static int iwinfo_L_scanlist(lua_State *L, int > (*func)(const char *, char *, int > lua_pushnil(L); > lua_setfield(L, -2, "htmodelist"); > > + lua_pushinteger(L, e->channel_info.sec_channel_offset); > + lua_setfield(L, -2, "sec_channel_offset"); > + if (e->channel_info.center_idx0) { > + lua_pushinteger(L, e->channel_info.center_idx0); > + lua_setfield(L, -2, "center_idx0"); > + } > + if (e->channel_info.center_idx1) { > + lua_pushinteger(L, e->channel_info.center_idx1); > + lua_setfield(L, -2, "center_idx1"); > + } > + > lua_rawseti(L, -2, x); > } > } > diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c > index 542ac7d..fb137b2 100644 > --- a/iwinfo_nl80211.c > +++ b/iwinfo_nl80211.c > @@ -1996,6 +1996,27 @@ static void nl80211_parse_ht_capa(struct > iwinfo_scanlist_entry *e, > e->htmodelist |= IWINFO_HTMODE_VHT40; > } > } > +static void nl80211_parse_ht_oper(struct iwinfo_scanlist_entry *e, > + unsigned char > *ie, > + int len) > +{ > + uint8_t oper_info; > + > + if (len < 6) > + return; > + oper_info = ie[1]; > + switch (oper_info & 3) { > + case 0: > + e->channel_info.sec_channel_offset = 0; > + break; > + case 1: > + e->channel_info.sec_channel_offset = 1; > + break; > + case 3: > + e->channel_info.sec_channel_offset = -1; > + break; > + } > +} > static void nl80211_parse_vht_capa(struct iwinfo_scanlist_entry *e, > unsigned > char *ie, > int len) > @@ -2024,7 +2045,7 @@ static void nl80211_parse_vht_oper(struct > iwinfo_scanlist_entry *e, > int len) > { > int chanwidth; > - if (len < 1) > + if (len < 3) >
Re: [OpenWrt-Devel] [PATCH 1/2] add htmodelist for scan results
Hi, comments inline. On 07/13/2018 10:57 AM, Yury Shvedov wrote: > diff --git a/include/iwinfo.h b/include/iwinfo.h > index 929f697..c3c25ff 100644 > --- a/include/iwinfo.h > +++ b/include/iwinfo.h > @@ -154,6 +154,7 @@ struct iwinfo_scanlist_entry { > uint8_t signal; > uint8_t quality; > uint8_t quality_max; > +int htmodelist; Do we really need a full int here? I think an u8 or u16 should suffice. > struct iwinfo_crypto_entry crypto; > }; > > diff --git a/iwinfo_cli.c b/iwinfo_cli.c > index 49c9035..2d58020 100644 > --- a/iwinfo_cli.c > +++ b/iwinfo_cli.c > @@ -572,7 +572,7 @@ static void print_info(const struct iwinfo_ops *iw, const > char *ifname) > > static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname) > { > - int i, x, len; > + int i, h, x, len; > char buf[IWINFO_BUFSIZE]; > struct iwinfo_scanlist_entry *e; > > @@ -603,8 +603,17 @@ static void print_scanlist(const struct iwinfo_ops *iw, > const char *ifname) > format_signal(e->signal - 0x100), > format_quality(e->quality), > format_quality_max(e->quality_max)); > - printf(" Encryption: %s\n\n", > + printf(" Encryption: %s\n", > format_encryption(>crypto)); > + if (e->htmodelist) > + { > + printf(" HT Capabilities: "); > + for (h = 0; h < ARRAY_SIZE(IWINFO_HTMODE_NAMES); h++) > + if (e->htmodelist & (1 << h)) > + printf("%s ", IWINFO_HTMODE_NAMES[h]); > + printf ("\n"); > + } > + printf ("\n"); Please adhere to the coding style and remove the space between "printf" and the opening paren. > } > } > > diff --git a/iwinfo_lua.c b/iwinfo_lua.c > index eebab8e..01581a3 100644 > --- a/iwinfo_lua.c > +++ b/iwinfo_lua.c > @@ -378,7 +378,7 @@ static int iwinfo_L_txpwrlist(lua_State *L, int > (*func)(const char *, char *, in > /* Wrapper for scan list */ > static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, > int *)) > { > - int i, x, len = 0; > + int i, x, h, len = 0; > char rv[IWINFO_BUFSIZE]; > char macstr[18]; > const char *ifname = luaL_checkstring(L, 1); > @@ -432,6 +432,20 @@ static int iwinfo_L_scanlist(lua_State *L, int > (*func)(const char *, char *, int > iwinfo_L_cryptotable(L, >crypto); > lua_setfield(L, -2, "encryption"); > > + /* HT Modes */ > + if (e->htmodelist) > + { > + lua_newtable(L); > + for (h = 0; h < > ARRAY_SIZE(IWINFO_HTMODE_NAMES); h++) > + { > + lua_pushboolean(L, e->htmodelist & (1 > << h)); > + lua_setfield(L, -2, > IWINFO_HTMODE_NAMES[h]); > + } > + } > + else > + lua_pushnil(L); > + lua_setfield(L, -2, "htmodelist"); Please move the lua_setfield() into the if-condition and drop the else case. > + > lua_rawseti(L, -2, x); > } > } > diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c > index ecd2d6a..542ac7d 100644 > --- a/iwinfo_nl80211.c > +++ b/iwinfo_nl80211.c > @@ -1980,6 +1980,71 @@ struct nl80211_scanlist { > int len; > }; > > +static void nl80211_parse_ht_capa(struct iwinfo_scanlist_entry *e, > + unsigned char > *ie, > + int len) > +{ > + int capa; > + if (len < 2) > + return; > + e->htmodelist |= IWINFO_HTMODE_HT20; > + capa = ie[0] | (ie[8] << 8); > + if (capa & (1 << 1)) > + { > + e->htmodelist |= IWINFO_HTMODE_HT40; > + if (e->htmodelist & IWINFO_HTMODE_VHT20) > + e->htmodelist |= IWINFO_HTMODE_VHT40; > + } > +} > +static void nl80211_parse_vht_capa(struct iwinfo_scanlist_entry *e, > +unsigned > char *ie, > +int len) > +{ > + int capa; > + if (len < 4) > + return; > + capa = ie[0] | (ie[1] << 8) | (ie[2] << 16) | (ie[3] << 24); > + > + e->htmodelist |= IWINFO_HTMODE_VHT20; > + if (e->htmodelist & IWINFO_HTMODE_HT40) > + e->htmodelist |= IWINFO_HTMODE_VHT40; > + > + switch ((capa >> 2) & 3) { > + /*case 0: neither 160 nor 80+80 */ > + case 1: > + e->htmodelist |= IWINFO_HTMODE_VHT160; > + break; > + case 2: > +
Re: [OpenWrt-Devel] [PATCH] odhcpd: allow specifying lease trigger mode
The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software.--- Begin Message --- Hi, > What usecase do you want to cover by calling the lease script every time ? I want to assign a FQDN to every device which gets an IP address from odhcpd. My lease script updates DNS records, generating MAC-based names for devices which do not provide hostnames in their DHCP requests. The missing piece of the puzzle is thus a way of triggering the lease script when an IP address is leased to a host which did not provide a hostname in its DHCP request (and when such a lease is deleted). The only way I can think of to achieve that without patching odhcpd is to resort to some sort of polling, but it feels a bit clumsy to me since an arbitrary amount of time may pass between two DHCP events and I am trying to make the relevant DNS zone match the lease database as closely as possible at any given time. -- Best regards, Michał Kępień --- End Message --- ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel