Re: [RFC] [PATCH 1/3] adds iso3166-1 support

2006-10-25 Thread Luis R. Rodriguez

On 10/24/06, Anand Kumria <[EMAIL PROTECTED]> wrote:

On Mon, 23 Oct 2006 18:45:23 -0400, Luis R. Rodriguez wrote:

> iso3166-1
>
> ISO 3166-1, as part of the ISO 3166 standard, provides codes for the names
> of countries and dependent areas. It was first published in 1974 by
> the International Organization for Standardization (ISO) and defines three
> different codes for each area:

[snip]

+   r |= iso3166_1_add(887, "YE", "YEM",
+   "Yemen");
+   r |= iso3166_1_add(891, "CS", "SCG",
+   "Serbia and Montenegro");
+   r |= iso3166_1_add(894, "ZM", "ZMB",
+   "Zambia");


According to the ISO, at:



and



Serbia and Montenegro have been allocated new codes,
RS and ME respectively.


Will update accordingly, thanks.


Is this ISO3166 stuff supposed to track the standard?


Yes.


If so, what happens when a country splits or two join together?


We update it.


Will that require lock-step updates to user-space, or will it be insulated
by this changes?


I didn't intend on having a userspace update this as I figured these
updates are rare and could just go with a new kernel release, and as
this would currently only be used for regulatory domain control it
should't have a negative impact. If there are more modules which can
make use of this then perhaps we can consider a more robust interface.

 Luis
-
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] [PATCH 1/3] adds iso3166-1 support

2006-10-25 Thread Luis R. Rodriguez

On 10/24/06, Johannes Berg <[EMAIL PROTECTED]> wrote:

On Tue, 2006-10-24 at 11:59 -0400, Luis R. Rodriguez wrote:

> also if we index based on alpha3 we get O(1)
> access to the elements. Will make these changes.

I wouldn't do that, it's bound to make the array size explode because
there'll be one country starting with A and one starting with Z.


You are right.


Probably better to do a binary search and make sure (by hand) it's
sorted.


Will work on it when I get time, thanks.

 Luis
-
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] [PATCH 1/3] adds iso3166-1 support

2006-10-24 Thread Anand Kumria
On Mon, 23 Oct 2006 18:45:23 -0400, Luis R. Rodriguez wrote:

> iso3166-1
> 
> ISO 3166-1, as part of the ISO 3166 standard, provides codes for the names
> of countries and dependent areas. It was first published in 1974 by
> the International Organization for Standardization (ISO) and defines three
> different codes for each area:

[snip]

+   r |= iso3166_1_add(887, "YE", "YEM", 
+   "Yemen");
+   r |= iso3166_1_add(891, "CS", "SCG", 
+   "Serbia and Montenegro");
+   r |= iso3166_1_add(894, "ZM", "ZMB", 
+   "Zambia");


According to the ISO, at:



and



Serbia and Montenegro have been allocated new codes, RS and ME respectively.

Is this ISO3166 stuff supposed to track the standard? If so, what happens when 
a country splits or two join together?

Will that require lock-step updates to user-space, or will it be insulated byt 
this changes?

Regards,
Anand

-
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] [PATCH 1/3] adds iso3166-1 support

2006-10-24 Thread Johannes Berg
On Tue, 2006-10-24 at 11:59 -0400, Luis R. Rodriguez wrote:

> also if we index based on alpha3 we get O(1)
> access to the elements. Will make these changes.

I wouldn't do that, it's bound to make the array size explode because
there'll be one country starting with A and one starting with Z.
Probably better to do a binary search and make sure (by hand) it's
sorted.

johannes


signature.asc
Description: This is a digitally signed message part


Re: [RFC] [PATCH 1/3] adds iso3166-1 support

2006-10-24 Thread Luis R. Rodriguez

On 10/24/06, Johannes Berg <[EMAIL PROTECTED]> wrote:



> +static int load_iso3166_1(void) {
> +   int r = 0;
> +   r |= iso3166_1_add(4, "AF", "AFG",
> +   "Afghanistan");
[...]

Why don't you make the table a static array, then you can use ARRAY_SIZE
and get rid of the whole list_head, not have it eat up code size and
mark it as read-only static data.


This was how I had the original implementation, I moved it to linked
lists thinking we'd update it frequently but obviously that's not the
case. You are right, also if we index based on alpha3 we get O(1)
access to the elements. Will make these changes.


> +EXPORT_SYMBOL(iso3166_1_list);

Why export the list?


No good reason -- will remove this, right again.


> +EXPORT_SYMBOL(get_iso3166_1_numeric);
> +EXPORT_SYMBOL(get_iso3166_1_alpha2);
> +EXPORT_SYMBOL(get_iso3166_1_alpha3);
> +EXPORT_SYMBOL(iso3166_1_exists);

Also, please put these along with the function.


Sure.

 Luis
-
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] [PATCH 1/3] adds iso3166-1 support

2006-10-24 Thread Johannes Berg


> +static int load_iso3166_1(void) {
> +   int r = 0;
> +   r |= iso3166_1_add(4, "AF", "AFG", 
> +   "Afghanistan");
[...]

Why don't you make the table a static array, then you can use ARRAY_SIZE
and get rid of the whole list_head, not have it eat up code size and
mark it as read-only static data.

> +EXPORT_SYMBOL(iso3166_1_list);

Why export the list?

> +EXPORT_SYMBOL(get_iso3166_1_numeric);
> +EXPORT_SYMBOL(get_iso3166_1_alpha2);
> +EXPORT_SYMBOL(get_iso3166_1_alpha3);
> +EXPORT_SYMBOL(iso3166_1_exists);

Also, please put these along with the function.

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] [PATCH 1/3] adds iso3166-1 support

2006-10-23 Thread Luis R. Rodriguez

iso3166-1

ISO 3166-1, as part of the ISO 3166 standard, provides codes for the names
of countries and dependent areas. It was first published in 1974 by
the International Organization for Standardization (ISO) and defines three
different codes for each area:

  * ISO 3166-1 alpha-2, a two-letter system with many applications,
most notably the Internet top-level domains (ccTLD) for countries.
  * ISO 3166-1 alpha-3, a three-letter system.
  * ISO 3166-1 numeric, a three-digit numerical system, which is
  identical to that defined by the United Nations Statistical Division.

Although this would usually be only used in userspace IEEE-802.11d
has made use of ISO-3166-1 alpha 3. This mapping was added
to enhance stack support for IEEE-802.11d and 802.11 Regulatory
Domain control. ieee80211_regdomains makes use of this module
by creating a map of iso3166 alpha3 country code to stack
regulatory domain.
diff -Naurp wireless-dev-old/include/net/d80211_iso3166-1.h wireless-dev/include/net/d80211_iso3166-1.h
--- wireless-dev-old/include/net/d80211_iso3166-1.h	1969-12-31 19:00:00.0 -0500
+++ wireless-dev/include/net/d80211_iso3166-1.h	2006-10-23 14:36:20.0 -0400
@@ -0,0 +1,65 @@
+#ifndef _ISO3166_1_H
+#define _ISO3166_1_H
+/*
+ *  Copyright (C) 2006 Luis R. Rodriguez <[EMAIL PROTECTED]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/* 
+ * ISO 3166-1, as part of the ISO 3166 standard, provides codes for the names 
+ * of countries and dependent areas. It was first published in 1974 by 
+ * the International Organization for Standardization (ISO) and defines three 
+ * different codes for each area:
+ *
+ * * ISO 3166-1 alpha-2, a two-letter system with many applications, 
+ *   most notably the Internet top-level domains (ccTLD) for countries.
+ * * ISO 3166-1 alpha-3, a three-letter system.
+ * * ISO 3166-1 numeric, a three-digit numerical system, which is 
+ * identical to that defined by the United Nations Statistical Division.
+ *
+ * Although this would usually be only used in userspace IEEE-802.11d
+ * has made use of ISO-3166-1 alpha 3. This mapping was added
+ * to enhance stack support for IEEE-802.11d and 802.11 Regulatory 
+ * Domain control.
+ *
+ */
+
+#include 
+
+#define ISO3166_1_VERSION	"2006-09-18"
+#define ISOCOUNTRYSIZ2		2
+#define ISOCOUNTRYSIZ3		3
+#define ISOCOUNTRYSIZ		50
+
+struct iso3166_1_map {
+	/* ISO-3166-1 numeric */
+	u16 numeric;
+	/* ISO-3166-1 alpha 2 */
+	char alpha2[ISOCOUNTRYSIZ2];
+	/* ISO-3166-1 alpha 3 */
+	char alpha3[ISOCOUNTRYSIZ3];
+	/* Country name */
+	char country[ISOCOUNTRYSIZ];
+	struct list_head list;
+};
+
+u16 get_iso3166_1_numeric(char *);
+char * get_iso3166_1_alpha2(char *);
+char * get_iso3166_1_alpha3(int);
+char * get_iso3166_1_country(char *);
+u16 iso3166_1_exists(char *);
+
+#endif
diff -Naurp wireless-dev-old/net/d80211/iso3166-1.c wireless-dev/net/d80211/iso3166-1.c
--- wireless-dev-old/net/d80211/iso3166-1.c	1969-12-31 19:00:00.0 -0500
+++ wireless-dev/net/d80211/iso3166-1.c	2006-10-23 16:13:09.0 -0400
@@ -0,0 +1,626 @@
+/*
+ *  Copyright (C) 2006 Luis R. Rodriguez <[EMAIL PROTECTED]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include 
+#include 
+
+#define DRV_NAME"iso3166_1"
+#define DRV_DESCRIPTION "ISO 3166-1 support"
+#define DRV_VERSION ISO3166_1_VERSION
+
+MODULE_AUTHOR("Luis R. Rodriguez <[EMAIL PROTECTED]>");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_VERSION(DRV_VERSION);
+
+LIST_HEAD(iso3166_1_list);
+
+static inline void setup_iso3166_1_node(struct iso3166_1_map *, u16,
+		char *, char *, char *);
+static void unload_iso3166_1(void);
+s