Re: [RFC 3/3] cfg80211 thoughts on configuration

2006-09-20 Thread Thomas Graf
* Johannes Berg [EMAIL PROTECTED] 2006-09-14 12:53
 This is some preliminary code how I'm currently thinking (and that might
 change radically :) ) configuration might look like.
 
 It uses the patch I previously posted to make genetlink attributes
 custom-definable.
 
 --- wireless-dev.orig/include/linux/nl80211.h 2006-09-13 22:06:10.539647141 
 +0200
 +++ wireless-dev/include/linux/nl80211.h  2006-09-13 22:06:11.919647141 
 +0200
 @@ -45,6 +45,47 @@ enum {
   /* get list of all interfaces belonging to a wiphy */
   NL80211_CMD_NEW_INTERFACES,
  
 + /* configure device */
 + NL80211_CMD_CONFIGURE,
 +
 + /* request configuration */
 + NL80211_CMD_GET_CONFIG,
 +
 + /* configuration sent from kernel */
 + NL80211_CMD_CONFIGURATION,

I think I brought this up already, it's a lot easier to understand
things if you keep it symmetric, i.e. NL80211_CMD_GET_CONFIG triggers
sending a NL80211_CMD_NEW_CONFIG.

 +static int check_information_element(struct nlattr *nla)
 +{
 + int len = nla_len(nla);
 + u8 *data = nla_data(nla);
 + int elementlen;
 +
 + while (len = 2) {
 + /* 1 byte ID, 1 byte len, `len' bytes data */
 + elementlen = *(data+1) + 2;
 + data += elementlen;
 + len -= elementlen;
 + }
 + return len ? -EINVAL : 0;
 +}
 +
  static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
   [NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
   [NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
 @@ -33,6 +49,17 @@ static struct nla_policy nl80211_policy[
.len = NL80211_MAX_FRAME_LEN },
   [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
   [NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
 + [NL80211_ATTR_NETWORK_ID] = { .type = NLA_U16 },
 + [NL80211_ATTR_CHANNEL] = { .type = NLA_U32 },
 + [NL80211_ATTR_RX_SENSITIVITY] = { .type = NLA_U32 },
 + [NL80211_ATTR_BSSID] = { .len = 6 },
 + [NL80211_ATTR_SSID] = { .type = NLA_STRING, .len = 32 },
 + [NL80211_ATTR_TRANSMIT_POWER] = { .type = NLA_U32 },
 + [NL80211_ATTR_FRAG_THRESHOLD] = { .type = NLA_U32 },
 + [NL80211_ATTR_INFORMATION_ELEMENT] = { .type = NLA_CUSTOM_CHECK,
 +.check = 
 check_information_element },

Just use a nested attribute here, this new array format you introduce
having 1 byte ID, 1 byte len is equivalent to using a set of nested
attributes with nla_type=id, nla_len=len.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 3/3] cfg80211 thoughts on configuration

2006-09-20 Thread Johannes Berg
On Wed, 2006-09-20 at 08:33 +0200, Thomas Graf wrote:

 I think I brought this up already, it's a lot easier to understand
 things if you keep it symmetric, i.e. NL80211_CMD_GET_CONFIG triggers
 sending a NL80211_CMD_NEW_CONFIG.

Yes, I think you did :) I'll do that as soon as I get around to
reworking it (hoping for more comments...)

 Just use a nested attribute here, this new array format you introduce
 having 1 byte ID, 1 byte len is equivalent to using a set of nested
 attributes with nla_type=id, nla_len=len.

No, it is only validated, it is then supposed to be copied verbatim into
some 802.11 frames. I thought validating it would be a good idea to not
send out totally bogus frames, but I didn't want to have to mangle it in
the kernel.

johannes
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 3/3] cfg80211 thoughts on configuration

2006-09-20 Thread Thomas Graf
* Johannes Berg [EMAIL PROTECTED] 2006-09-20 09:03
  Just use a nested attribute here, this new array format you introduce
  having 1 byte ID, 1 byte len is equivalent to using a set of nested
  attributes with nla_type=id, nla_len=len.
 
 No, it is only validated, it is then supposed to be copied verbatim into
 some 802.11 frames. I thought validating it would be a good idea to not
 send out totally bogus frames, but I didn't want to have to mangle it in
 the kernel.

I see, fair enough, wasn't able to get that from your code.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 3/3] cfg80211 thoughts on configuration

2006-09-14 Thread Johannes Berg
This is some preliminary code how I'm currently thinking (and that might
change radically :) ) configuration might look like.

It uses the patch I previously posted to make genetlink attributes
custom-definable.

--- wireless-dev.orig/include/linux/nl80211.h   2006-09-13 22:06:10.539647141 
+0200
+++ wireless-dev/include/linux/nl80211.h2006-09-13 22:06:11.919647141 
+0200
@@ -45,6 +45,47 @@ enum {
/* get list of all interfaces belonging to a wiphy */
NL80211_CMD_NEW_INTERFACES,
 
+   /* configure device */
+   NL80211_CMD_CONFIGURE,
+
+   /* request configuration */
+   NL80211_CMD_GET_CONFIG,
+
+   /* configuration sent from kernel */
+   NL80211_CMD_CONFIGURATION,
+
+   /* initiate scan */
+   NL80211_CMD_INITIATE_SCAN,
+
+   /* scan result (kernel - userspace) */
+   NL80211_CMD_SCAN_RESULT,
+
+   /* change roaming control */
+   NL80211_CMD_SET_ROAMING_CONTROL,
+
+   /* get roaming control setting */
+   NL80211_CMD_GET_ROAMING_CONTROL,
+
+   /* set access point BSSID for userspace roaming */
+   NL80211_CMD_SET_BSSID,
+
+   /* get current association information, if not associated then
+* the BSSID attribute is not present in response */
+   NL80211_CMD_GET_ASSOCIATION,
+
+   /* association notification/response to GET_BSSID */
+   NL80211_CMD_ASSOCIATION_CHANGED,
+
+   /* disassociate from current AP */
+   NL80211_CMD_DISASSOCIATE,
+
+   /* deauth from current AP */
+   NL80211_CMD_DEAUTH,
+
+   /* re-associate with current settings
+* (SSID and BSSID if roaming control in userspace) */
+   NL80211_CMD_REASSOCIATE,
+
/* add commands here */
 
/* used to define NL80211_CMD_MAX below */
@@ -88,6 +129,36 @@ enum {
/* wiphy list */
NL80211_ATTR_WIPHY_LIST,
 
+   /* attributes used for configuration */
+   /* network ID (pre 802.11 HW) */
+   NL80211_ATTR_NETWORK_ID,
+
+   /* channel, 1-14 are B/G */
+   NL80211_ATTR_CHANNEL,
+
+   /* receiver sensitivity in dBm */
+   NL80211_ATTR_RX_SENSITIVITY,
+
+   /* BSSID to associate to, only used when roaming control
+* is in userspace */
+   NL80211_ATTR_BSSID,
+
+   /* SSID of ESS to associate to */
+   NL80211_ATTR_SSID,
+
+   /* transmit power in mW */
+   NL80211_ATTR_TRANSMIT_POWER,
+
+   /* fragmentation threshold in bytes */
+   NL80211_ATTR_FRAG_THRESHOLD,
+
+   /* one or more information elements */
+   NL80211_ATTR_INFORMATION_ELEMENT,
+
+   NL80211_ATTR_ROAMING_CONTROL,
+
+   NL80211_ATTR_SCAN_TYPE,
+
/* add attributes here */
 
/* used to define NL80211_ATTR_MAX below */
@@ -134,4 +205,13 @@ enum {
 };
 #define NL80211_IFTYPE_MAX (__NL80211_IFTYPE_AFTER_LAST - 1)
 
+enum {
+   NL80211_ROAMING_CONTROL_KERNEL,
+   NL80211_ROAMING_CONTROL_USERSPACE,
+
+   /* keep last */
+   __NL80211_ROAMING_CONTROL_AFTER_LAST
+};
+#define NL80211_ROAMING_CONTROL_MAX (__NL80211_ROAMING_CONTROL_AFTER_LAST-1)
+
 #endif /* __LINUX_NL80211_H */
--- wireless-dev.orig/include/net/cfg80211.h2006-09-13 22:06:10.539647141 
+0200
+++ wireless-dev/include/net/cfg80211.h 2006-09-13 22:06:11.919647141 +0200
@@ -14,6 +14,30 @@
  */
 
 /**
+ * struct cfg80211_config - description of a configuration (request)
+ */
+struct cfg80211_config {
+   /* first fields with 'internal' validity */
+
+   /* SSID to use, valid if not NULL. change forces reassociation */
+   u8 *ssid;
+
+   /* now fields with explicit validity */
+#define CFG80211_CFG_VALID_NWID(10)
+#define CFG80211_CFG_VALID_RX_SENSITIVITY  (11)
+#define CFG80211_CFG_VALID_TRANSMIT_POWER  (12)
+#define CFG80211_CFG_VALID_FRAG_THRESHOLD  (13)
+#define CFG80211_CFG_VALID_CHANNEL (14)
+   unsigned int valid;
+
+   u16 network_id;
+   s32 rx_sensitivity;
+   u32 transmit_power;
+   u32 fragmentation_threshold;
+   u32 channel;
+};
+
+/**
  * struct cfg80211_ops - backend description for wireless configuration
  *
  * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -35,6 +59,26 @@
  * @add_virtual_intf: create a new virtual interface with the given name
  *
  * @del_virtual_intf: remove the virtual interface determined by ifindex.
+ *
+ * @configure: configure the given interface as requested in the config struct.
+ *must not ignore any configuration item, if something is
+ *is requested that cannot be fulfilled return an error
+ *
+ * @get_config: fill the given config structure with the current configuration
+ *
+ * @reassociate: reassociate with current settings (SSID, BSSID if
+ *  userspace roaming is enabled)
+ *
+ * @disassociate: disassociate from current AP
+ *
+ * @deauth: deauth from current AP
+ *
+ * @initiate_scan: ...
+ *
+ * @set_roaming: set who gets to control roaming
+ *
+ *