From patchwork Wed Nov 11 12:22:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 59322 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nABCMgKp020402 for ; Wed, 11 Nov 2009 12:22:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750997AbZKKMWU (ORCPT ); Wed, 11 Nov 2009 07:22:20 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750824AbZKKMWU (ORCPT ); Wed, 11 Nov 2009 07:22:20 -0500 Received: from nbd.name ([88.198.39.176]:42168 "EHLO ds10.mine.nu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755263AbZKKMWT (ORCPT ); Wed, 11 Nov 2009 07:22:19 -0500 Received: from p5ddc7c19.dip.t-dialin.net ([93.220.124.25] helo=pi.lan) by ds10.mine.nu with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1N8CHI-00033T-8w; Wed, 11 Nov 2009 13:26:24 +0100 Message-ID: <4AFAAC7F.8000903@openwrt.org> Date: Wed, 11 Nov 2009 13:22:23 +0100 From: Felix Fietkau User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: linux-wireless CC: Johannes Berg Subject: [PATCH] iw: add a command for moving a STA into an AP VLAN X-Enigmail-Version: 0.96.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org --- a/station.c +++ b/station.c @@ -196,7 +196,7 @@ COMMAND(station, del, "", NL80211_CMD_DEL_STATION, 0, CIB_NETDEV, handle_station_get, "Remove the given station entry (use with caution!)"); -static int handle_station_set(struct nl80211_state *state, +static int handle_station_set_plink(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg, int argc, char **argv) @@ -241,9 +241,56 @@ static int handle_station_set(struct nl8 return -ENOBUFS; } COMMAND(station, set, " plink_action ", - NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set, + NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink, "Set mesh peer link action for this station (peer)."); +static int handle_station_set_vlan(struct nl80211_state *state, + struct nl_cb *cb, + struct nl_msg *msg, + int argc, char **argv) +{ + unsigned char mac_addr[ETH_ALEN]; + unsigned long sta_vlan = 0; + char *err = NULL; + + if (argc < 3) + return 1; + + if (mac_addr_a2n(mac_addr, argv[0])) { + fprintf(stderr, "invalid mac address\n"); + return 2; + } + argc--; + argv++; + + if (strcmp("vlan", argv[0]) != 0) + return 1; + argc--; + argv++; + + sta_vlan = strtoul(argv[0], &err, 0); + if (err && *err) { + fprintf(stderr, "invalid vlan id\n"); + return 2; + } + argc--; + argv++; + + if (argc) + return 1; + + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); + NLA_PUT_U32(msg, NL80211_ATTR_STA_VLAN, sta_vlan); + + return 0; + nla_put_failure: + return -ENOBUFS; +} +COMMAND(station, set, " vlan ", + NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_vlan, + "Set an AP VLAN for this station."); + + static int handle_station_dump(struct nl80211_state *state, struct nl_cb *cb, struct nl_msg *msg,