diff --git a/client/src/cmdlffdxb.c b/client/src/cmdlffdxb.c index 65b2efd6e..1547c743b 100644 --- a/client/src/cmdlffdxb.c +++ b/client/src/cmdlffdxb.c @@ -215,6 +215,272 @@ static int CmdFDXBdemodBI(const char *Cmd) { } */ +// For the country part: +// wget -q -O - "https://en.wikipedia.org/w/index.php?title=List_of_ISO_3166_country_codes&action=raw" | awk '/id=/{match($0, /\[\[([^\]|]*)/, a); name=a[1];getline;getline;getline;getline;getline;match($0, /numeric#([0-9]*)/, a);num=a[1]; if (num != "") {printf " { %3u, \"%s\" },\n", num, name}}' +// Beware the bottom of the list contains also Manufacturers list +const fdxbCountryMapping_t fdxbCountryMapping[] = { + { 4, "Afghanistan" }, + { 8, "Albania" }, + { 12, "Algeria" }, + { 16, "American Samoa" }, + { 20, "Andorra" }, + { 24, "Angola" }, + { 660, "Anguilla" }, + { 10, "Antarctica" }, + { 28, "Antigua and Barbuda" }, + { 32, "Argentina" }, + { 51, "Armenia" }, + { 533, "Aruba" }, + { 40, "Austria" }, + { 31, "Azerbaijan" }, + { 44, "The Bahamas" }, + { 48, "Bahrain" }, + { 50, "Bangladesh" }, + { 52, "Barbados" }, + { 112, "Belarus" }, + { 56, "Belgium" }, + { 84, "Belize" }, + { 204, "Benin" }, + { 60, "Bermuda" }, + { 64, "Bhutan" }, + { 68, "Bolivia" }, + { 535, "Bonaire" }, + { 70, "Bosnia and Herzegovina" }, + { 72, "Botswana" }, + { 74, "Bouvet Island" }, + { 76, "Brazil" }, + { 86, "British Indian Ocean Territory" }, + { 100, "Bulgaria" }, + { 854, "Burkina Faso" }, + { 132, "Cape Verde" }, + { 116, "Cambodia" }, + { 120, "Cameroon" }, + { 124, "Canada" }, + { 140, "Central African Republic" }, + { 148, "Chad" }, + { 152, "Chile" }, + { 156, "China" }, + { 170, "Colombia" }, + { 174, "Comoros" }, + { 180, "Democratic Republic of the Congo" }, + { 178, "Republic of the Congo" }, + { 184, "Cook Islands" }, + { 384, "Ivory Coast" }, + { 191, "Croatia" }, + { 192, "Cuba" }, + { 531, "Curaçao" }, + { 196, "Cyprus" }, + { 203, "Czech Republic" }, + { 262, "Djibouti" }, + { 212, "Dominica" }, + { 214, "Dominican Republic" }, + { 818, "Egypt" }, + { 222, "El Salvador" }, + { 232, "Eritrea" }, + { 233, "Estonia" }, + { 748, "Eswatini" }, + { 231, "Ethiopia" }, + { 238, "Falkland Islands" }, + { 234, "Faroe Islands" }, + { 242, "Fiji" }, + { 246, "Finland" }, + { 250, "France" }, + { 254, "French Guiana" }, + { 258, "French Polynesia" }, + { 260, "French Southern Territories" }, + { 266, "Gabon" }, + { 270, "The Gambia" }, + { 268, "Georgia (country)" }, + { 276, "Germany" }, + { 288, "Ghana" }, + { 292, "Gibraltar" }, + { 304, "Greenland" }, + { 308, "Grenada" }, + { 312, "Guadeloupe" }, + { 316, "Guam" }, + { 320, "Guatemala" }, + { 831, "Bailiwick of Guernsey" }, + { 324, "Guinea" }, + { 624, "Guinea-Bissau" }, + { 328, "Guyana" }, + { 332, "Haiti" }, + { 336, "Holy See" }, + { 340, "Honduras" }, + { 344, "Hong Kong" }, + { 348, "Hungary" }, + { 352, "Iceland" }, + { 356, "India" }, + { 360, "Indonesia" }, + { 364, "Iran (Islamic Republic of)" }, + { 368, "Iraq" }, + { 372, "Republic of Ireland" }, + { 833, "Isle of Man" }, + { 376, "Israel" }, + { 380, "Italy" }, + { 832, "Jersey" }, + { 400, "Jordan" }, + { 398, "Kazakhstan" }, + { 404, "Kenya" }, + { 296, "Kiribati" }, + { 408, "North Korea" }, + { 410, "South Korea" }, + { 414, "Kuwait" }, + { 417, "Kyrgyzstan" }, + { 418, "Laos" }, + { 428, "Latvia" }, + { 422, "Lebanon" }, + { 426, "Lesotho" }, + { 430, "Liberia" }, + { 434, "Libya" }, + { 438, "Liechtenstein" }, + { 440, "Lithuania" }, + { 442, "Luxembourg" }, + { 446, "Macau" }, + { 807, "North Macedonia" }, + { 450, "Madagascar" }, + { 454, "Malawi" }, + { 458, "Malaysia" }, + { 462, "Maldives" }, + { 466, "Mali" }, + { 470, "Malta" }, + { 584, "Marshall Islands" }, + { 474, "Martinique" }, + { 478, "Mauritania" }, + { 480, "Mauritius" }, + { 175, "Mayotte" }, + { 484, "Mexico" }, + { 583, "Federated States of Micronesia" }, + { 498, "Moldova" }, + { 492, "Monaco" }, + { 496, "Mongolia" }, + { 499, "Montenegro" }, + { 500, "Montserrat" }, + { 504, "Morocco" }, + { 508, "Mozambique" }, + { 104, "Myanmar" }, + { 516, "Namibia" }, + { 520, "Nauru" }, + { 524, "Nepal" }, + { 528, "Kingdom of the Netherlands" }, + { 540, "New Caledonia" }, + { 554, "New Zealand" }, + { 558, "Nicaragua" }, + { 562, "Niger" }, + { 566, "Nigeria" }, + { 570, "Niue" }, + { 574, "Norfolk Island" }, + { 578, "Norway" }, + { 512, "Oman" }, + { 586, "Pakistan" }, + { 585, "Palau" }, + { 275, "State of Palestine" }, + { 591, "Panama" }, + { 598, "Papua New Guinea" }, + { 600, "Paraguay" }, + { 608, "Philippines" }, + { 612, "Pitcairn Islands" }, + { 616, "Poland" }, + { 620, "Portugal" }, + { 630, "Puerto Rico" }, + { 634, "Qatar" }, + { 638, "Réunion" }, + { 642, "Romania" }, + { 643, "Russia" }, + { 646, "Rwanda" }, + { 654, "Saint Helena" }, + { 659, "Saint Kitts and Nevis" }, + { 662, "Saint Lucia" }, + { 663, "Collectivity of Saint Martin" }, + { 666, "Saint Pierre and Miquelon" }, + { 670, "Saint Vincent and the Grenadines" }, + { 882, "Samoa" }, + { 674, "San Marino" }, + { 678, "São Tomé and Príncipe" }, + { 682, "Saudi Arabia" }, + { 688, "Serbia" }, + { 690, "Seychelles" }, + { 694, "Sierra Leone" }, + { 702, "Singapore" }, + { 703, "Slovakia" }, + { 705, "Slovenia" }, + { 90, "Solomon Islands" }, + { 706, "Somalia" }, + { 710, "South Africa" }, + { 239, "South Georgia and the South Sandwich Islands" }, + { 724, "Spain" }, + { 144, "Sri Lanka" }, + { 729, "Sudan" }, + { 740, "Suriname" }, + { 744, "Svalbard" }, + { 752, "Sweden" }, + { 756, "Switzerland" }, + { 760, "Syria" }, + { 158, "Taiwan" }, + { 762, "Tajikistan" }, + { 834, "Tanzania" }, + { 764, "Thailand" }, + { 626, "East Timor" }, + { 768, "Togo" }, + { 772, "Tokelau" }, + { 776, "Tonga" }, + { 780, "Trinidad and Tobago" }, + { 788, "Tunisia" }, + { 792, "Turkey" }, + { 795, "Turkmenistan" }, + { 796, "Turks and Caicos Islands" }, + { 798, "Tuvalu" }, + { 800, "Uganda" }, + { 804, "Ukraine" }, + { 784, "United Arab Emirates" }, + { 826, "United Kingdom" }, + { 581, "United States Minor Outlying Islands" }, + { 840, "United States" }, + { 860, "Uzbekistan" }, + { 548, "Vanuatu" }, + { 704, "Vietnam" }, + { 92, "British Virgin Islands" }, + { 850, "United States Virgin Islands" }, + { 732, "Western Sahara" }, + { 887, "Yemen" }, + { 894, "Zambia" }, + { 716, "Zimbabwe" }, + + // Manufacturers list: + { 952, "JECTA" }, + { 953, "Cromasa Identificacion electronica S.A."}, + { 955, "Reseaumatique" }, + { 956, "Trovan Ltd. (ACK Reunite)" }, + { 958, "Pet ID" }, + { 959, "Global ID Technologies" }, + { 961, "Mannings I.A.I.D." }, + { 963, "Korth Eletro Mecanica LTDA" }, + { 965, "4D Technology Co. Ltd" }, + { 966, "PetCode" }, + { 967, "Rfdynamics / M4S ID in Canada" }, + { 968, "AEG / EIDAP in Canada" }, + { 972, "Planet ID" }, + { 975, "Sokymat" }, + { 977, "AVID" }, + { 978, "Ordicam" }, + { 981, "Microfindr, Datamars, Found Animals, Crystal Tag, Banfield, Bayer resQ, Peeva" }, + { 982, "24 Pet Watch (Allflex)" }, + { 985, "HomeAgain (Destron Fearing/Digital Angel)" }, + { 991, "Peeva" }, + { 999, "Test range" }, + { 0, "N/A" } // must be the last entry +}; + +static const char* mapFDBX(uint16_t countryCode) { + uint16_t i = 0; + while (fdxbCountryMapping[i].code > 0) { + if (countryCode == fdxbCountryMapping[i].code) { + return fdxbCountryMapping[i].desc; + } + i++; + } + return fdxbCountryMapping[i].desc; +} + //see ASKDemod for what args are accepted //almost the same demod as cmddata.c/CmdFDXBdemodBI int demodFDXB(bool verbose) { @@ -299,9 +565,9 @@ int demodFDXB(bool verbose) { return PM3_SUCCESS; } PrintAndLogEx(SUCCESS, "FDX-B / ISO 11784/5 Animal"); - PrintAndLogEx(SUCCESS, "Animal ID " _GREEN_("%04u-%012"PRIu64), countryCode, NationalCode); + PrintAndLogEx(SUCCESS, "Animal ID " _GREEN_("%03u-%012"PRIu64), countryCode, NationalCode); PrintAndLogEx(SUCCESS, "National Code " _GREEN_("%012" PRIu64) " (0x%" PRIX64 ")", NationalCode, NationalCode); - PrintAndLogEx(SUCCESS, "Country Code " _GREEN_("%04u"), countryCode); + PrintAndLogEx(SUCCESS, "Country Code " _GREEN_("%03u") " - %s", countryCode, mapFDBX(countryCode)); PrintAndLogEx(SUCCESS, "Reserved/RFU %u (0x%04X)", reservedCode, reservedCode); PrintAndLogEx(SUCCESS, " Animal bit set? %s", animalBit ? _YELLOW_("True") : "False"); PrintAndLogEx(SUCCESS, " Data block? %s [value 0x%X]", dataBlockBit ? _YELLOW_("True") : "False", extended); diff --git a/client/src/cmdlffdxb.h b/client/src/cmdlffdxb.h index 3667c5b67..af08ce38f 100644 --- a/client/src/cmdlffdxb.h +++ b/client/src/cmdlffdxb.h @@ -11,6 +11,11 @@ #include "common.h" +typedef struct { + uint16_t code; + const char *desc; +} fdxbCountryMapping_t; + int CmdLFFdxB(const char *Cmd); int detectFDXB(uint8_t *dest, size_t *size); int demodFDXB(bool verbose);