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.000000000 -0500 +++ wireless-dev/include/net/d80211_iso3166-1.h 2006-10-23 14:36:20.000000000 -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 <linux/list.h> + +#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.000000000 -0500 +++ wireless-dev/net/d80211/iso3166-1.c 2006-10-23 16:13:09.000000000 -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 <linux/module.h> +#include <net/d80211_iso3166-1.h> + +#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); +static int load_iso3166_1(void); +static int iso3166_1_add(u16, char *, char *, char *); + +static inline void setup_iso3166_1_node(struct iso3166_1_map *iso, u16 numeric, + char *alpha2, char *alpha3, char *country) +{ + iso->numeric = numeric; + strcpy(iso->alpha2, alpha2); + strcpy(iso->alpha3, alpha3); + strcpy(iso->country, country); +} + + +static int iso3166_1_add(u16 numeric, char *alpha2, char *alpha3, char *country) +{ + struct iso3166_1_map *iso; + iso = kmalloc(sizeof(struct iso3166_1_map), GFP_KERNEL); + if (iso == NULL) + return -ENOMEM; + setup_iso3166_1_node(iso, numeric, alpha2, alpha3, country); + list_add_rcu(&iso->list, &iso3166_1_list); + return 0; +} + +static void unload_iso3166_1(void) +{ + struct iso3166_1_map *iso, *tmp; + list_for_each_entry_safe(iso, tmp, &iso3166_1_list, list) { + list_del(&iso->list); + kfree(iso); + } + list_del(&iso3166_1_list); +} +static int load_iso3166_1(void) { + int r = 0; + r |= iso3166_1_add(4, "AF", "AFG", + "Afghanistan"); + r |= iso3166_1_add(8, "AL", "ALB", + "Albania"); + r |= iso3166_1_add(10, "AQ", "ATA", + "Antarctica"); + r |= iso3166_1_add(12, "DZ", "DZA", + "Algeria"); + r |= iso3166_1_add(16, "AS", "ASM", + "American Samoa"); + r |= iso3166_1_add(20, "AD", "AND", + "Andorra"); + r |= iso3166_1_add(24, "AO", "AGO", + "Angola"); + r |= iso3166_1_add(28, "AG", "ATG", + "Antigua and Barbuda"); + r |= iso3166_1_add(31, "AZ", "AZE", + "Azerbaijan"); + r |= iso3166_1_add(32, "AR", "ARG", + "Argentina"); + r |= iso3166_1_add(36, "AU", "AUS", + "Australia"); + r |= iso3166_1_add(40, "AT", "AUT", + "Austria"); + r |= iso3166_1_add(44, "BS", "BHS", + "Bahamas"); + r |= iso3166_1_add(48, "BH", "BHR", + "Bahrain"); + r |= iso3166_1_add(50, "BD", "BGD", + "Bangladesh"); + r |= iso3166_1_add(51, "AM", "ARM", + "Armenia"); + r |= iso3166_1_add(52, "BB", "BRB", + "Barbados"); + r |= iso3166_1_add(56, "BE", "BEL", + "Belgium"); + r |= iso3166_1_add(60, "BM", "BMU", + "Bermuda"); + r |= iso3166_1_add(64, "BT", "BTN", + "Bhutan"); + r |= iso3166_1_add(68, "BO", "BOL", + "Bolivia"); + r |= iso3166_1_add(70, "BA", "BIH", + "Bosnia and Herzegovina"); + r |= iso3166_1_add(72, "BW", "BWA", + "Botswana"); + r |= iso3166_1_add(74, "BV", "BVT", + "Bouvet Island"); + r |= iso3166_1_add(76, "BR", "BRA", + "Brazil"); + r |= iso3166_1_add(84, "BZ", "BLZ", + "Belize"); + r |= iso3166_1_add(86, "IO", "IOT", + "British Indian Ocean Territory"); + r |= iso3166_1_add(90, "SB", "SLB", + "Solomon Islands"); + r |= iso3166_1_add(92, "VG", "VGB", + "Virgin Islands, British"); + r |= iso3166_1_add(96, "BN", "BRN", + "Brunei Darussalam"); + r |= iso3166_1_add(100, "BG", "BGR", + "Bulgaria"); + r |= iso3166_1_add(104, "MM", "MMR", + "Myanmar"); + r |= iso3166_1_add(108, "BI", "BDI", + "Burundi"); + r |= iso3166_1_add(112, "BY", "BLR", + "Belarus"); + r |= iso3166_1_add(116, "KH", "KHM", + "Cambodia"); + r |= iso3166_1_add(120, "CM", "CMR", + "Cameroon"); + r |= iso3166_1_add(124, "CA", "CAN", + "Canada"); + r |= iso3166_1_add(132, "CV", "CPV", + "Cape Verde"); + r |= iso3166_1_add(136, "KY", "CYM", + "Cayman Islands"); + r |= iso3166_1_add(140, "CF", "CAF", + "Central African Republic"); + r |= iso3166_1_add(144, "LK", "LKA", + "Sri Lanka"); + r |= iso3166_1_add(148, "TD", "TCD", + "Chad"); + r |= iso3166_1_add(152, "CL", "CHL", + "Chile"); + r |= iso3166_1_add(156, "CN", "CHN", + "China"); + r |= iso3166_1_add(158, "TW", "TWN", + "Taiwan, Province of China"); + r |= iso3166_1_add(162, "CX", "CXR", + "Christmas Island"); + r |= iso3166_1_add(166, "CC", "CCK", + "Cocos (Keeling) Islands"); + r |= iso3166_1_add(170, "CO", "COL", + "Colombia"); + r |= iso3166_1_add(174, "KM", "COM", + "Comoros"); + r |= iso3166_1_add(175, "YT", "MYT", + "Mayotte"); + r |= iso3166_1_add(178, "CG", "COG", + "Congo"); + r |= iso3166_1_add(180, "CD", "COD", + "Congo, the Democratic Republic of the"); + r |= iso3166_1_add(184, "CK", "COK", + "Cook Islands"); + r |= iso3166_1_add(188, "CR", "CRI", + "Costa Rica"); + r |= iso3166_1_add(191, "HR", "HRV", + "Croatia"); + r |= iso3166_1_add(192, "CU", "CUB", + "Cuba"); + r |= iso3166_1_add(196, "CY", "CYP", + "Cyprus"); + r |= iso3166_1_add(203, "CZ", "CZE", + "Czech Republic"); + r |= iso3166_1_add(204, "BJ", "BEN", + "Benin"); + r |= iso3166_1_add(208, "DK", "DNK", + "Denmark"); + r |= iso3166_1_add(212, "DM", "DMA", + "Dominica"); + r |= iso3166_1_add(214, "DO", "DOM", + "Dominican Republic"); + r |= iso3166_1_add(218, "EC", "ECU", + "Ecuador"); + r |= iso3166_1_add(222, "SV", "SLV", + "El Salvador"); + r |= iso3166_1_add(226, "GQ", "GNQ", + "Equatorial Guinea"); + r |= iso3166_1_add(231, "ET", "ETH", + "Ethiopia"); + r |= iso3166_1_add(232, "ER", "ERI", + "Eritrea"); + r |= iso3166_1_add(233, "EE", "EST", + "Estonia"); + r |= iso3166_1_add(234, "FO", "FRO", + "Faroe Islands"); + r |= iso3166_1_add(238, "FK", "FLK", + "Falkland Islands (Malvinas)"); + r |= iso3166_1_add(239, "GS", "SGS", + "South Georgia and the South Sandwich Islands"); + r |= iso3166_1_add(242, "FJ", "FJI", + "Fiji"); + r |= iso3166_1_add(246, "FI", "FIN", + "Finland"); + r |= iso3166_1_add(248, "AX", "ALA", + "à land Islands"); + r |= iso3166_1_add(250, "FR", "FRA", + "France"); + r |= iso3166_1_add(254, "GF", "GUF", + "French Guiana"); + r |= iso3166_1_add(258, "PF", "PYF", + "French Polynesia"); + r |= iso3166_1_add(260, "TF", "ATF", + "French Southern Territories"); + r |= iso3166_1_add(262, "DJ", "DJI", + "Djibouti"); + r |= iso3166_1_add(266, "GA", "GAB", + "Gabon"); + r |= iso3166_1_add(268, "GE", "GEO", + "Georgia"); + r |= iso3166_1_add(270, "GM", "GMB", + "Gambia"); + r |= iso3166_1_add(275, "PS", "PSE", + "Palestinian Territory, Occupied"); + r |= iso3166_1_add(276, "DE", "DEU", + "Germany"); + r |= iso3166_1_add(288, "GH", "GHA", + "Ghana"); + r |= iso3166_1_add(292, "GI", "GIB", + "Gibraltar"); + r |= iso3166_1_add(296, "KI", "KIR", + "Kiribati"); + r |= iso3166_1_add(300, "GR", "GRC", + "Greece"); + r |= iso3166_1_add(304, "GL", "GRL", + "Greenland"); + r |= iso3166_1_add(308, "GD", "GRD", + "Grenada"); + r |= iso3166_1_add(312, "GP", "GLP", + "Guadeloupe"); + r |= iso3166_1_add(316, "GU", "GUM", + "Guam"); + r |= iso3166_1_add(320, "GT", "GTM", + "Guatemala"); + r |= iso3166_1_add(324, "GN", "GIN", + "Guinea"); + r |= iso3166_1_add(328, "GY", "GUY", + "Guyana"); + r |= iso3166_1_add(332, "HT", "HTI", + "Haiti"); + r |= iso3166_1_add(334, "HM", "HMD", + "Heard Island and McDonald Islands"); + r |= iso3166_1_add(336, "VA", "VAT", + "Holy See (Vatican City State)"); + r |= iso3166_1_add(340, "HN", "HND", + "Honduras"); + r |= iso3166_1_add(344, "HK", "HKG", + "Hong Kong"); + r |= iso3166_1_add(348, "HU", "HUN", + "Hungary"); + r |= iso3166_1_add(352, "IS", "ISL", + "Iceland"); + r |= iso3166_1_add(356, "IN", "IND", + "India"); + r |= iso3166_1_add(360, "ID", "IDN", + "Indonesia"); + r |= iso3166_1_add(364, "IR", "IRN", + "Iran, Islamic Republic of"); + r |= iso3166_1_add(368, "IQ", "IRQ", + "Iraq"); + r |= iso3166_1_add(372, "IE", "IRL", + "Ireland"); + r |= iso3166_1_add(376, "IL", "ISR", + "Israel"); + r |= iso3166_1_add(380, "IT", "ITA", + "Italy"); + r |= iso3166_1_add(384, "CI", "CIV", + "Côte d'Ivoire"); + r |= iso3166_1_add(388, "JM", "JAM", + "Jamaica"); + r |= iso3166_1_add(392, "JP", "JPN", + "Japan"); + r |= iso3166_1_add(398, "KZ", "KAZ", + "Kazakhstan"); + r |= iso3166_1_add(400, "JO", "JOR", + "Jordan"); + r |= iso3166_1_add(404, "KE", "KEN", + "Kenya"); + r |= iso3166_1_add(408, "KP", "PRK", + "Korea, Democratic People's Republic of"); + r |= iso3166_1_add(410, "KR", "KOR", + "Korea, Republic of"); + r |= iso3166_1_add(414, "KW", "KWT", + "Kuwait"); + r |= iso3166_1_add(417, "KG", "KGZ", + "Kyrgyzstan"); + r |= iso3166_1_add(418, "LA", "LAO", + "Lao People's Democratic Republic"); + r |= iso3166_1_add(422, "LB", "LBN", + "Lebanon"); + r |= iso3166_1_add(426, "LS", "LSO", + "Lesotho"); + r |= iso3166_1_add(428, "LV", "LVA", + "Latvia"); + r |= iso3166_1_add(430, "LR", "LBR", + "Liberia"); + r |= iso3166_1_add(434, "LY", "LBY", + "Libyan Arab Jamahiriya"); + r |= iso3166_1_add(438, "LI", "LIE", + "Liechtenstein"); + r |= iso3166_1_add(440, "LT", "LTU", + "Lithuania"); + r |= iso3166_1_add(442, "LU", "LUX", + "Luxembourg"); + r |= iso3166_1_add(446, "MO", "MAC", + "Macao"); + r |= iso3166_1_add(450, "MG", "MDG", + "Madagascar"); + r |= iso3166_1_add(454, "MW", "MWI", + "Malawi"); + r |= iso3166_1_add(458, "MY", "MYS", + "Malaysia"); + r |= iso3166_1_add(462, "MV", "MDV", + "Maldives"); + r |= iso3166_1_add(466, "ML", "MLI", + "Mali"); + r |= iso3166_1_add(470, "MT", "MLT", + "Malta"); + r |= iso3166_1_add(474, "MQ", "MTQ", + "Martinique"); + r |= iso3166_1_add(478, "MR", "MRT", + "Mauritania"); + r |= iso3166_1_add(480, "MU", "MUS", + "Mauritius"); + r |= iso3166_1_add(484, "MX", "MEX", + "Mexico"); + r |= iso3166_1_add(492, "MC", "MCO", + "Monaco"); + r |= iso3166_1_add(496, "MN", "MNG", + "Mongolia"); + r |= iso3166_1_add(498, "MD", "MDA", + "Moldova, Republic of"); + r |= iso3166_1_add(500, "MS", "MSR", + "Montserrat"); + r |= iso3166_1_add(504, "MA", "MAR", + "Morocco"); + r |= iso3166_1_add(508, "MZ", "MOZ", + "Mozambique"); + r |= iso3166_1_add(512, "OM", "OMN", + "Oman"); + r |= iso3166_1_add(516, "NA", "NAM", + "Namibia"); + r |= iso3166_1_add(520, "NR", "NRU", + "Nauru"); + r |= iso3166_1_add(524, "NP", "NPL", + "Nepal"); + r |= iso3166_1_add(528, "NL", "NLD", + "Netherlands"); + r |= iso3166_1_add(530, "AN", "ANT", + "Netherlands Antilles"); + r |= iso3166_1_add(533, "AW", "ABW", + "Aruba"); + r |= iso3166_1_add(540, "NC", "NCL", + "New Caledonia"); + r |= iso3166_1_add(548, "VU", "VUT", + "Vanuatu"); + r |= iso3166_1_add(554, "NZ", "NZL", + "New Zealand"); + r |= iso3166_1_add(558, "NI", "NIC", + "Nicaragua"); + r |= iso3166_1_add(562, "NE", "NER", + "Niger"); + r |= iso3166_1_add(566, "NG", "NGA", + "Nigeria"); + r |= iso3166_1_add(570, "NU", "NIU", + "Niue"); + r |= iso3166_1_add(574, "NF", "NFK", + "Norfolk Island"); + r |= iso3166_1_add(578, "NO", "NOR", + "Norway"); + r |= iso3166_1_add(580, "MP", "MNP", + "Northern Mariana Islands"); + r |= iso3166_1_add(581, "UM", "UMI", + "United States Minor Outlying Islands"); + r |= iso3166_1_add(583, "FM", "FSM", + "Micronesia, Federated States of"); + r |= iso3166_1_add(584, "MH", "MHL", + "Marshall Islands"); + r |= iso3166_1_add(585, "PW", "PLW", + "Palau"); + r |= iso3166_1_add(586, "PK", "PAK", + "Pakistan"); + r |= iso3166_1_add(591, "PA", "PAN", + "Panama"); + r |= iso3166_1_add(598, "PG", "PNG", + "Papua New Guinea"); + r |= iso3166_1_add(600, "PY", "PRY", + "Paraguay"); + r |= iso3166_1_add(604, "PE", "PER", + "Peru"); + r |= iso3166_1_add(608, "PH", "PHL", + "Philippines"); + r |= iso3166_1_add(612, "PN", "PCN", + "Pitcairn"); + r |= iso3166_1_add(616, "PL", "POL", + "Poland"); + r |= iso3166_1_add(620, "PT", "PRT", + "Portugal"); + r |= iso3166_1_add(624, "GW", "GNB", + "Guinea-Bissau"); + r |= iso3166_1_add(626, "TL", "TLS", + "Timor-Leste"); + r |= iso3166_1_add(630, "PR", "PRI", + "Puerto Rico"); + r |= iso3166_1_add(634, "QA", "QAT", + "Qatar"); + r |= iso3166_1_add(638, "RE", "REU", + "Réunion"); + r |= iso3166_1_add(642, "RO", "ROU", + "Romania"); + r |= iso3166_1_add(643, "RU", "RUS", + "Russian Federation"); + r |= iso3166_1_add(646, "RW", "RWA", + "Rwanda"); + r |= iso3166_1_add(654, "SH", "SHN", + "Saint Helena"); + r |= iso3166_1_add(659, "KN", "KNA", + "Saint Kitts and Nevis"); + r |= iso3166_1_add(660, "AI", "AIA", + "Anguilla"); + r |= iso3166_1_add(662, "LC", "LCA", + "Saint Lucia"); + r |= iso3166_1_add(666, "PM", "SPM", + "Saint Pierre and Miquelon"); + r |= iso3166_1_add(670, "VC", "VCT", + "Saint Vincent and the Grenadines"); + r |= iso3166_1_add(674, "SM", "SMR", + "San Marino"); + r |= iso3166_1_add(678, "ST", "STP", + "Sao Tome and Principe"); + r |= iso3166_1_add(682, "SA", "SAU", + "Saudi Arabia"); + r |= iso3166_1_add(686, "SN", "SEN", + "Senegal"); + r |= iso3166_1_add(690, "SC", "SYC", + "Seychelles"); + r |= iso3166_1_add(694, "SL", "SLE", + "Sierra Leone"); + r |= iso3166_1_add(702, "SG", "SGP", + "Singapore"); + r |= iso3166_1_add(703, "SK", "SVK", + "Slovakia"); + r |= iso3166_1_add(704, "VN", "VNM", + "Viet Nam"); + r |= iso3166_1_add(705, "SI", "SVN", + "Slovenia"); + r |= iso3166_1_add(706, "SO", "SOM", + "Somalia"); + r |= iso3166_1_add(710, "ZA", "ZAF", + "South Africa"); + r |= iso3166_1_add(716, "ZW", "ZWE", + "Zimbabwe"); + r |= iso3166_1_add(724, "ES", "ESP", + "Spain"); + r |= iso3166_1_add(732, "EH", "ESH", + "Western Sahara"); + r |= iso3166_1_add(736, "SD", "SDN", + "Sudan"); + r |= iso3166_1_add(740, "SR", "SUR", + "Suriname"); + r |= iso3166_1_add(744, "SJ", "SJM", + "Svalbard and Jan Mayen"); + r |= iso3166_1_add(748, "SZ", "SWZ", + "Swaziland"); + r |= iso3166_1_add(752, "SE", "SWE", + "Sweden"); + r |= iso3166_1_add(756, "CH", "CHE", + "Switzerland"); + r |= iso3166_1_add(760, "SY", "SYR", + "Syrian Arab Republic"); + r |= iso3166_1_add(762, "TJ", "TJK", + "Tajikistan"); + r |= iso3166_1_add(764, "TH", "THA", + "Thailand"); + r |= iso3166_1_add(768, "TG", "TGO", + "Togo"); + r |= iso3166_1_add(772, "TK", "TKL", + "Tokelau"); + r |= iso3166_1_add(776, "TO", "TON", + "Tonga"); + r |= iso3166_1_add(780, "TT", "TTO", + "Trinidad and Tobago"); + r |= iso3166_1_add(784, "AE", "ARE", + "United Arab Emirates"); + r |= iso3166_1_add(788, "TN", "TUN", + "Tunisia"); + r |= iso3166_1_add(792, "TR", "TUR", + "Turkey"); + r |= iso3166_1_add(795, "TM", "TKM", + "Turkmenistan"); + r |= iso3166_1_add(796, "TC", "TCA", + "Turks and Caicos Islands"); + r |= iso3166_1_add(798, "TV", "TUV", + "Tuvalu"); + r |= iso3166_1_add(800, "UG", "UGA", + "Uganda"); + r |= iso3166_1_add(804, "UA", "UKR", + "Ukraine"); + r |= iso3166_1_add(807, "MK", "MKD", + "Macedonia, the former Yugoslav Republic of"); + r |= iso3166_1_add(818, "EG", "EGY", + "Egypt"); + r |= iso3166_1_add(826, "GB", "GBR", + "United Kingdom"); + r |= iso3166_1_add(831, "GG", "GGY", + "Guernsey"); + r |= iso3166_1_add(832, "JE", "JEY", + "Jersey"); + r |= iso3166_1_add(833, "IM", "IMN", + "Isle of Man"); + r |= iso3166_1_add(834, "TZ", "TZA", + "Tanzania, United Republic of"); + r |= iso3166_1_add(840, "US", "USA", + "United States"); + r |= iso3166_1_add(850, "VI", "VIR", + "Virgin Islands, U.S."); + r |= iso3166_1_add(854, "BF", "BFA", + "Burkina Faso"); + r |= iso3166_1_add(858, "UY", "URY", + "Uruguay"); + r |= iso3166_1_add(860, "UZ", "UZB", + "Uzbekistan"); + r |= iso3166_1_add(862, "VE", "VEN", + "Venezuela"); + r |= iso3166_1_add(876, "WF", "WLF", + "Wallis and Futuna"); + r |= iso3166_1_add(882, "WS", "WSM", + "Samoa"); + 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"); + return r; +} + +static int iso3166_1_init(void) +{ + int r = load_iso3166_1(); + if(r) { + printk("%s: load failed\n", DRV_NAME); + return r; + } + printk("%s: %s loaded, last updated %s\n", + DRV_NAME, DRV_DESCRIPTION, DRV_VERSION); + return r; +} + +static void iso3166_1_exit(void) +{ + unload_iso3166_1(); + printk("%s: unloaded\n", DRV_NAME); + return; +} + +u16 get_iso3166_1_numeric(char *alpha3) +{ + struct iso3166_1_map *iso; + list_for_each_entry(iso, &iso3166_1_list, list) + if(strcmp(iso->alpha3, alpha3) == 0) + return iso->numeric; + return -ENODATA; +} + +char * get_iso3166_1_alpha2(char *alpha3) +{ + struct iso3166_1_map *iso; + list_for_each_entry(iso, &iso3166_1_list, list) + if(strcmp(iso->alpha3, alpha3) == 0) + return iso->alpha2; + return NULL; +} + +char * get_iso3166_1_alpha3(int numeric) +{ + struct iso3166_1_map *iso; + list_for_each_entry(iso, &iso3166_1_list, list) + if (iso->numeric == numeric) + return iso->alpha3; + return NULL; +} + +char * get_iso3166_1_country(char *alpha3) +{ + struct iso3166_1_map *iso; + list_for_each_entry(iso, &iso3166_1_list, list) + if(strcmp(iso->alpha3, alpha3) == 0) + return iso->country; + return NULL; +} + +u16 iso3166_1_exists(char *alpha3) +{ + return get_iso3166_1_numeric(alpha3); +} + +module_init(iso3166_1_init); +module_exit(iso3166_1_exit); +EXPORT_SYMBOL(iso3166_1_list); +EXPORT_SYMBOL(get_iso3166_1_numeric); +EXPORT_SYMBOL(get_iso3166_1_alpha2); +EXPORT_SYMBOL(get_iso3166_1_alpha3); +EXPORT_SYMBOL(iso3166_1_exists);