kopia lustrzana https://github.com/cyoung/stratux
218 wiersze
20 KiB
C
218 wiersze
20 KiB
C
|
//
|
||
|
// Copyright 2015, Oliver Jowett <oliver@mutability.co.uk>
|
||
|
//
|
||
|
|
||
|
// This file is free software: you may copy, redistribute 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, or (at your
|
||
|
// option) any later version.
|
||
|
//
|
||
|
// This file 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, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <stdint.h>
|
||
|
#include <string.h>
|
||
|
#include <math.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
#include "uat.h"
|
||
|
#include "fec.h"
|
||
|
|
||
|
// Test data from DO-282B:
|
||
|
// Table 2-104 "ADS-B Message Reception - Set 1"
|
||
|
// Table 2-105 "ADS-B Message Reception - Set 2"
|
||
|
struct {
|
||
|
const char *testname;
|
||
|
const char *input;
|
||
|
int frametype;
|
||
|
const char *expected;
|
||
|
} downlink_tests[] = {
|
||
|
// Table 2-104
|
||
|
|
||
|
{ "2-104 #1", "FF8196782DD44238C1453855F89980C7524F5970940ED83AD89CE7A9BEF8761BBCD9FCC817D82E2D1ACF90CA78DA3C49", 1, "007E6987D2D74238C1453855F89980C7524F" },
|
||
|
{ "2-104 #2", "007E6987D328BDC73EBA3955F89980C7524F5970940ED83AD89CE7A9BEF8BB7B190B2EA0EACC7237B7B01B036E07EE04", -1, NULL },
|
||
|
{ "2-104 #3", "007E6987D2D74238C146C7AA07667FC7524F5970940ED83AD89CE7A9BEF8DBE78F0C386EB860D64E9BA9E06B95BEB66A", 1, "007E6987D2D74238C1453855F89980C7524F" },
|
||
|
{ "2-104 #4", "007E6987D2D74238C1453855F8998738ADB0A60F940ED83AD89CE7A9BEF8171F980B40C8B76AC0791254EE04AA73A982", 1, "007E6987D2D74238C1453855F89980C7524F" },
|
||
|
{ "2-104 #5", "007E6987D2D74238C1453855F89980C7524F597F6BF127C5E79CE7A9BEF8B22C710A46621200763F2DF70CBCBFCA1721", 1, "007E6987D2D74238C1453855F89980C7524F" },
|
||
|
{ "2-104 #6", "5A8CAA4ABC7AEE2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9DAAD75342196DEBB63CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
{ "2-104 #7", "A57355B5438412D52F6D61470CA044D556B452A7A73A5716CD1DB40964F5BA105D9DAAD75342196DEBB63CC972994DEA", -1, NULL },
|
||
|
{ "2-104 #8", "A57355B54385ED2AD0929EBBF25FBB2AA94B52A7A73A5716CD1DB40964F5BA105D9DAAD75342196DEBB63CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
{ "2-104 #9", "A57355B54385ED2AD0929EB80DA044D556B3AD5858C5A869CD1DB40964F5BA105D9DAAD75342196DEBB63CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
{ "2-104 #10", "A57355B54385ED2AD0929EB80DA044D556B452A7A73A571932E24BF69BCABA105D9DAAD75342196DEBB63CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
{ "2-104 #11", "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964EA45EFA26255C85342196DEBB63CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
{ "2-104 #12", "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9DAAE8ACBDE69214B93CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
{ "2-104 #13", "FFD7E73F83C10D2BF6B961410BEE0C2FD5A4C934E4972E7D17C8495075B2F64260211F48524C5A5590A16E3EAF4068AB", 1, "002818C07CC20D2BF6B961410BEE0C2FD5A4" },
|
||
|
{ "2-104 #14", "002818C07D3DF2D4094660410BEE0C2FD5A4C934E4972E7D17C8495075B26DD7F172B5B56FF8F49067515A8A55D64D5E", -1, NULL },
|
||
|
{ "2-104 #15", "002818C07CC20D2BF6BA9EBEF411F32FD5A4C934E4972E7D17C8495075B2C06F20916457C90BC47D261C8DEFE3ED74C5", 1, "002818C07CC20D2BF6B961410BEE0C2FD5A4" },
|
||
|
{ "2-104 #16", "002818C07CC20D2BF6B961410BEE0BD02A5B364BE4972E7D17C8495075B233CE68A8ABDCF663EAF24B3B2B1369D92C8D", 1, "002818C07CC20D2BF6B961410BEE0C2FD5A4" },
|
||
|
{ "2-104 #17", "002818C07CC20D2BF6B961410BEE0C2FD5A4C93B1B68D18228C8495075B215B194556A7E44E71C724666C96E55DEE72E", 1, "002818C07CC20D2BF6B961410BEE0C2FD5A4" },
|
||
|
{ "2-104 #18", "FF6BD35D16B72B5A4521DB1F0697464369387A5F2C8C9E435F936F4912E17BD726E20847E1E69847CE7504CFE31ACE30", 1, "00942CA2E9B42B5A4521DB1F069746436938" },
|
||
|
{ "2-104 #19", "00942CA2E84BD4A5BADEDA1F0697464369387A5F2C8C9E435F936F4912E1875A6F0477167558D0E3FCE8FC17F176AED4", -1, NULL },
|
||
|
|
||
|
{ "2-104 #20", "00942CA2E9B42B5A452224E0F968B94369387A5F2C8C9E435F936F4912E13773225FF83FE1D774B684BC1B474D55879A", 1, "00942CA2E9B42B5A4521DB1F069746436938" },
|
||
|
{ "2-104 #21", "00942CA2E9B42B5A4521DB1F069741BC96C785202C8C9E435F936F4912E189CFFBB621E21E555CCC06495B619BDA4ABC", 1, "00942CA2E9B42B5A4521DB1F069746436938" },
|
||
|
{ "2-104 #22", "00942CA2E9B42B5A4521DB1F0697464369387A50D37361BC60936F4912E1263E0AD23CEC55487CDF1D60B972DE252D81", 1, "00942CA2E9B42B5A4521DB1F069746436938" },
|
||
|
{ "2-104 #23", "29E66548CD3A0A4527AB422D6A14598C515810717B02C9C79B79F029CEEE6B4DD1E8F1F77F4CAB43AD74CBB01ECD155C", 2, "D6199AB732C5094527AB422D6A14598C515810717B02C9C79B79F029CEEE6B4DD1E8" },
|
||
|
{ "2-104 #24", "D6199AB732C4F6BAD854BDD26B14598C515810717B02C9C79B79F029CEEE6B4DD1E8F1F77F4CAB43AD74CBB01ECD155C", -1, NULL },
|
||
|
{ "2-104 #25", "D6199AB732C5094527AB422E95EBA673AEA710717B02C9C79B79F029CEEE6B4DD1E8F1F77F4CAB43AD74CBB01ECD155C", 2, "D6199AB732C5094527AB422D6A14598C515810717B02C9C79B79F029CEEE6B4DD1E8" },
|
||
|
{ "2-104 #26", "D6199AB732C5094527AB422D6A14598C515FEF8E84FD36B89B79F029CEEE6B4DD1E8F1F77F4CAB43AD74CBB01ECD155C", 2, "D6199AB732C5094527AB422D6A14598C515810717B02C9C79B79F029CEEE6B4DD1E8" },
|
||
|
{ "2-104 #27", "D6199AB732C5094527AB422D6A14598C515810717B02C9C864860FD631D16B4DD1E8F1F77F4CAB43AD74CBB01ECD155C", 2, "D6199AB732C5094527AB422D6A14598C515810717B02C9C79B79F029CEEE6B4DD1E8" },
|
||
|
{ "2-104 #28", "287F318C2A9FFF7F0784CA4036E252DEB0226A9F9E183CBB933FA68DBF5E1F018F635195DE87894F16BDA55E42A64137", -1, "D780CE73D59CFF7F0784CA4036E252DEB022" }, // basic/long mismatch
|
||
|
{ "2-104 #29", "D780CE73D4630080F87BCB4036E252DEB0226A9F9E183CBB933FA68DBF5E161C9333D935A0C83220FC2799D84A139CAB", -1, NULL },
|
||
|
{ "2-104 #30", "157A70631C57176BA3073708854B66FF4083C2AF2D96F628422CDA1A522295B85ED8C94A0DB164A4BEF4B3A402210E02", -1, NULL },
|
||
|
{ "2-104 #31", "773448BE613236BD3F0C53F45DCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE602AC8B2DDE9A4429FAAB9AFD694", 2, "88CBB7419ECD35BD3F0C53F45DCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE" },
|
||
|
{ "2-104 #32", "88CBB7419ECCCA42C0F3AC0B5CCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE602AC8B2DDE9A4429FAAB9AFD694", -1, NULL },
|
||
|
{ "2-104 #33", "88CBB7419ECD35BD3F0C53F7A235A3390F4DC0A92F6B6DF3072E0BEFFC8ADAA641EE602AC8B2DDE9A4429FAAB9AFD694", 2, "88CBB7419ECD35BD3F0C53F45DCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE" },
|
||
|
{ "2-104 #34", "88CBB7419ECD35BD3F0C53F45DCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE6015374D22165B4D9FAAB9AFD694", 2, "88CBB7419ECD35BD3F0C53F45DCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE" },
|
||
|
{ "2-104 #35", "EE62BBECF66420F249ECF8FBC08F8FB3092B6EB4C61D6C264DB6F333BEA5570E0407693351FA9161858E6460DE629EFE", 2, "119D4413099B23F249ECF8FBC08F8FB3092B6EB4C61D6C264DB6F333BEA5570E0407" },
|
||
|
{ "2-104 #36", "119D4413099ADC0DB6130704C18F8FB3092B6EB4C61D6C264DB6F333BEA5570E0407693351FA9161858E6460DE629EFE", -1, NULL },
|
||
|
{ "2-104 #37", "119D4413099B23F249ECF8F83F70704CF6D46EB4C61D6C264DB6F333BEA5570E0407693351FA9161858E6460DE629EFE", 2, "119D4413099B23F249ECF8FBC08F8FB3092B6EB4C61D6C264DB6F333BEA5570E0407" },
|
||
|
{ "2-104 #38", "119D4413099B23F249ECF8FBC08F8FB3092C914B39E293594DB6F333BEA5570E0407693351FA9161858E6460DE629EFE", 2, "119D4413099B23F249ECF8FBC08F8FB3092B6EB4C61D6C264DB6F333BEA5570E0407" },
|
||
|
{ "2-104 #39", "DF784C02075C59B503CFF562E1A553E2B54F40092EF8C22D0BFC643D3C5290867B135A1DB2EEC69474D7F594AC5738D8", -1, "20884C02075C59B503CF0A92E1A553E2B54F" }, // basic/long mismatch
|
||
|
{ "2-104 #40", "5A8355B54385ED2AD0929EB80DA044D556B452A758CA5716CD1DB40964F5BA10A26DAAD75342196DEBB63CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
|
||
|
{ "2-104 #41", "D616654732C5094527AB422D65EBA98C515810717B02C9C794860029CEEE6B4DD1E8F1F77F4CAB43AD74CBB01ECD155C", -1, NULL },
|
||
|
{ "2-104 #42", "AC8857D3318447091F3244DB71A661C7CFC7C4D859F34BD305CED0F22A0FDBE78F0C386EB860D64E9BA9E06B95BEB66A", -1, NULL },
|
||
|
{ "2-104 #43", "F8A60931105731F486BCE2B75D2EBAB00C4FBFEC1C827BEBDDF3BABC5DFC90867BECAA1DB2EEC69474D7F594AC5738D8", 1, "07560931105731F486BCE2B75D2EBA4FFC4F" },
|
||
|
{ "2-104 #44", "87AAEE174F86F7D6F81A6A5DFFE44BBE819127C89004918D683D2DD3608523EFAC727A23A788A711FCA51139D874D5C8", 2, "87AAEE174F86F7D6F8E5955DFFE44BBE816ED8C89004918D683DD22C608523EFAC72" },
|
||
|
{ "2-104 #45", "46D9B1EE2CE9216C8027CE5AE861E20BB742FF717C21B944DED0B164595D7181B14C131EA2DCCDD5B86D46824464BE9A", 2, "46D9B1EE2C16DE6C8027CE5AE89E1D0BB742FF717C21B9BB21D0B164595D7181B14C" },
|
||
|
{ "2-104 #46", "007F9667D2D74238C1453855076980C7524F5970940ED83AD89CE856BEF890867B135A1DB2EEC69474D7F594AC5738D8", -1, NULL },
|
||
|
|
||
|
// Table 2-105
|
||
|
|
||
|
{ "2-105 #1", "007E6987D2D74238C1453855F89980C7524F5970940ED83AD89CE7A9BEF890867B135A1DB2EEC69474D7F594AC5738D8", 1, "007E6987D2D74238C1453855F89980C7524F" },
|
||
|
{ "2-105 #2", "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB4096465BA105D9DAAD75342196DEBB63CC972994DEA", 2, "A57355B54385ED2AD0929EB80DA044D556B452A7A73A5716CD1DB40964F5BA105D9D" },
|
||
|
{ "2-105 #3", "002818C07CC20D2BF6B961410BEE0C2FD5B9C934E4972EED17C8495075B290867B135A1DB2EEC69474D7F594AC5738D8", 1, "002818C07CC20D2BF6B961410BEE0C2FD5A4" },
|
||
|
{ "2-105 #4", "00942CA2E9B42B5A4521DB1F0697FE4369257A5F2C8C9ED35F936F4912E190867B135A1DB2EEC69474D7F594AC5738D8", 1, "00942CA2E9B42B5A4521DB1F069746436938" },
|
||
|
{ "2-105 #5", "8B199AB732C509459FAB422D6A14598C515810717B02C9DA9B79F029CE7E6B4DD1E8F1F77F4CAB43AD74CBB01ECD155C", 2, "D6199AB732C5094527AB422D6A14598C515810717B02C9C79B79F029CEEE6B4DD1E8" },
|
||
|
{ "2-105 #6", "00879223318447F6E03244DB2CA6D93830DADB42E877E27CF095B704326590867B135A1DB2EEC69474D7F594AC5738D8", 1, "0087A823318447F6E03244DB71A6613830C7" },
|
||
|
{ "2-105 #7", "DAAAD4174F86F7D640E5955DFFE44BBE816ED86290049190683DD22C601523EFAC727A23A788A711FCA51139D874D5C8", 2, "87AAEE174F86F7D6F8E5955DFFE44BBE816ED8C89004918D683DD22C608523EFAC72" },
|
||
|
{ "2-105 #8", "1BD98BEE5D16DE6C3827CE5AE89E1D0BB742FFDB7C21B9A621D0B16459CD7181B14C131EA2DCCDD5B86D46824464BE9A", 2, "46D9B1EE2C16DE6C8027CE5AE89E1D0BB742FF717C21B9BB21D0B164595D7181B14C" },
|
||
|
{ "2-105 #9", "D780F473A49C677F0784CA406BE2EADEB03F6A9F9E183C2B9395A68DBF5E90867B135A1DB2EEC69474D7F594AC5738D8", -1, NULL },
|
||
|
{ "2-105 #10", "487A4A636D56E894E4F8C8F7844B66FF4083C2052D96F635DA2CDA1A52B295B85ED8C94A0DE064A4BEF4B3A402210E02", -1, NULL },
|
||
|
{ "2-105 #11", "88CBB7419ECD35BD3F0C53F45DCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE602AC8B2DDE9A4429FAAB9AFD694", 2, "88CBB7419ECD35BD3F0C53F45DCA5CC6F0B2C0A92F6B6DF3072E0BEFFC8ADAA641EE" },
|
||
|
{ "2-105 #12", "3DC87150293C43E1218BBBB462F06CE1ABE77693C3C24648277112B17B0EC4E774EED67F4A5C486E47E688B2FFA81FAD", 2, "60C84B50293C43E1998BBBB462F06CE1ABE77693C3C24655277112B17B9EC4E774EE" },
|
||
|
{ "2-105 #13", "E4C735D67923E302D648F20F35C66F7027697BF77AE4F6759F5106D592E19E48996C4008A98EC6178BB74D5E05380D73", 2, "B9C70FD67923E3026E48F20F35C66F7027697B5D7AE4F6689F5106D592719E48996C" },
|
||
|
{ "2-105 #14", "53A810655AA6E68A2585D51E07F01003A662B66F98020986F472BD563FD6D8CE9D354AB7E56F1871EF087F2C2DC5810F", -1, NULL },
|
||
|
{ "2-105 #15", "294B0831CCD9B59FB2DB2078C6A796AC873977A0061D2AA5FC057583D39AA1429DFBAC89A4F1A9D94D17D93FB5A982BA", 2, "294B0831CCD9B59FB2DB2078C6A796AC873977A0061D2AB8FC057583D30AA1429DFB" },
|
||
|
{ "2-105 #16", "A30D2EF671D7A56136FCAAEEFA838793C58706661638720E3E2539F280FD5B1CEC3255DB60BA866B7CD2E927188DAC0A", 2, "A30D2EF671D7A5618EFCAAEEFA838793C5870666163872133E2539F2806D5B1CEC32" },
|
||
|
{ "2-105 #17", "1E9297DE55DDFDBC646A63E90E96784012A92DCE42660EC20BC9EC886EE60DC70D7E9B3FA52D17E62E90F4C69EDA07F6", 2, "4392ADDE55DDFDBCDC6A63E90E96784012A92DCE42660EDF0BC9EC886E760DC70D7E" },
|
||
|
{ "2-105 #18", "FE767C70F15A99EE3FC77178FB1EED52BBBDBEFAB8C0F0EC0C1FB1350D363A24A24DEA5F5E955696C56858C093594BF1", 2, "A3764670805A99EE87C77178FB1EED52BBBDBE50B8C0F0F10C1FB1350DA63A24A24D" },
|
||
|
{ "2-105 #19", "62A76B1293A13428872CF1A006431013E1E25D045594026AB07440F966277040AF3B9FD2701B68113F6BCABB38B1AB7C", -1, NULL },
|
||
|
|
||
|
{ "2-105 #20", "00CB83BC39C90101CD97F84751E2D679CD3ADE7EE8D98C8824BE9F7565B690867B135A1DB2EEC69474D7F594AC5738D8", -1, NULL },
|
||
|
{ "2-105 #21", "BEF0F217696E4652DE8CB92BEC089CFA688E91363C4C627EEDC50B2B3621CD80A407357B9646CF133CDE92807BDE083A", 2, "BEF0F217696E4652DE8CB92BEC089CFA688E91363C4C627EEDC50B2B36B1CD80A407" },
|
||
|
{ "2-105 #22", "25F2846879F474085AD651F61011A07E55B92EF8412B72ED889CCBABD43BE51C2CECE97C250E4F5FAB16CEDAFA5CE238", 2, "25F2846879F474085AD651F61011A07E55B92EF8412B72F0889CCBABD4ABE51C2CEC" },
|
||
|
{ "2-105 #23", "FE8BBEFA469671700F1B9BCE491CE2E7C61DCB02668054401B2D129FBBA808A0C4F18A2B7847A35F56BFE897BFF31E71", 2, "A38B84FA46967170B71B9BCE491CE2E7C61DCBA86680545D1B2D129FBB3808A0C4F1" },
|
||
|
{ "2-105 #24", "B026C4F405E0F6DAF7EEA90134AD7F4C79CC105115F779A696B6FF79665B7D30DA7B0E12E49705C2EFBF64726AF41A65", 2, "ED26FEF474E0F6DA4FEEA90134AD7F4C79CC10FB15F779BB96B6FF7966CB7D30DA7B" },
|
||
|
{ "2-105 #25", "B2F0B85427A6B9B30ADE959C9A3597E429B4C7DB15DDD9C8E9DC9CADC4FBBDB6B7BD2446C0391DA4ACB7D62FF4DE4448", -1, NULL },
|
||
|
{ "2-105 #26", "6B9AC92CCE70667C6FD5D4B316DA46E4B5322A4B4151F651DEDBE85633E19768DE42F879B6BCB73C308D85D5E6EC2834", -1, NULL },
|
||
|
{ "2-105 #27", "07560931105731F486BCE2B75D2EBA4FFC4FBFEC1C827BEBDDF3BABC5DFC90867B135A1DB2EEC69474D7F594AC5738D8", 1, "07560931105731F486BCE2B75D2EBA4FFC4F" },
|
||
|
{ "2-105 #28", "8D264F73C42014181D475A812755061B88B784F2D7E57866DAF007EA4A420D7B5829E103C0E3DF069015893738D26FC1", 2, "8D264F73C42014181D475A812755061B88B784F2D7E57866DAF007EA4AD20D7B5829" },
|
||
|
{ "2-105 #29", "0511EE3AFD5356739D80545F1D978A8E75FFBA8D349CFBD3C19D1852B06690867B135A1DB2EEC69474D7F594AC5738D8", 1, "0511EE3AFD5356739D80545F1D978A8E75E2" },
|
||
|
{ "2-105 #30", "077B559BEFA8DA4D43A0ED6253FA096926C1EBE0899BC38D3A8415367D64756997DB0F53F54227A14229F3654F5FB489", 2, "5A7B6F9BEFA8DA4DFBA0ED6253FA096926C1EBE0899BC3903A8415367DF4756997DB" },
|
||
|
{ "2-105 #31", "14A61CC7D8766A511C98CAF387403156AFB78E35C0840FB82D6A1C4A9EEB8D3493E567AFA9EDDF7B6713935817587985", 2, "49A626C7D8766A51A498CAF387403156AFB78E9FC0840FA52D6A1C4A9E7B8D3493E5" },
|
||
|
{ "2-105 #32", "94032D84D22B86C1E1E2A18859083B9737E7F48C1F477D2951D333795CB75CA801BEFFF271349F7665D670AD62AF2FF3", 2, "C9031784A32B86C159E2A18859083B9737E7F4261F477D3451D333795C275CA801BE" },
|
||
|
{ "2-105 #33", "105B5212705BBE0DE89A8033898EFBA25AA41F9D4880BA066C874BD4AA7B90867B135A1DB2EEC69474D7F594AC5738D8", -1, NULL },
|
||
|
{ "2-105 #34", "0C646844862595EAA54DAD2F2DA5D1481D0DE3828C22F4E2A4D9D15D795D570AE9320018B985B188C1192A60300F0A37", 2, "0C646844862595EAA54DAD2F2DA5D1481D0DE3828C22F4E2A4D9D15D795D570AE932" },
|
||
|
{ "2-105 #35", "71219DC30B25D77EB24D25A1E38811FDEB9C303F0329C26F0DA358E86C327A3EAEBE2D88F3C31EC323F20D43109D7BFF", 2, "71219DC30B25D77EB24D25A1E38811FDEB9C303F0329C2720DA358E86CA27A3EAEBE" },
|
||
|
{ "2-105 #36", "20884C02075C59B503CF0A92E1A5EBE2B55240092EF8C22D0BFC643D3C5290867B135A1DB2EEC69474D7F594AC5738D8", -1, "20884C02075C59B503CF0A92E1A553E2B54F" }, // basic/long mismatch
|
||
|
{ "2-105 #37", "041FAD506C2ACF832E6E709A64393C100253641E26C3D92D0F2AA4C38AF490867B135A1DB2EEC69474D7F594AC5738D8", 1, "041F97506C2ACF832E6E709A39398410024E" },
|
||
|
{ "2-105 #38", "00117E82A1E6F9F487423BD32B0765CFC70A65332A820C1B34702487811990867B135A1DB2EEC69474D7F594AC5738D8", -1, NULL },
|
||
|
{ "2-105 #39", "7C69D795C15C7E322415505445A1588476473FF6928382FD43173F9B56A96BACBBF0B5C3868CAEB2856C8AD0E4F31A95", 2, "7C69D795C15C7E322415505445A1588476473FF6928382E043173F9B56396BACBBF0" },
|
||
|
{ "2-105 #40", "E4D3C31F1B25232D4E43F6C3F8368596C5346C919C0960B2EE40492BEEDA77934474F26191E4D8048AB87CA49EE0BE29", 2, "B9D3F91F1B25232DF643F6C3F8368596C5346C3B9C0960AFEE40492BEE4A77934474" },
|
||
|
|
||
|
{ "2-105 #41", "FE69CC228E786E996CCC8318C9C90F25C6B68F566C74316CB5FDAFCA226E7A19EA66AD963A6327B8A2F49291C22A656C", 2, "A369F622FF786E99D4CC8318C9C90F25C6B68FFC6C743171B5FDAFCA22FE7A19EA66" },
|
||
|
{ "2-105 #42", "008B74BC393401BE9D6A11D93C62435F127541E5D17C2397CCFF49EE043890867B135A1DB2EEC69474D7F594AC5738D8", -1, NULL },
|
||
|
{ "2-105 #43", "00FAE34A81BF609DACB0388BDC818EAAD028684EF3F7A68A856C9BD8CA0F90867B135A1DB2EEC69474D7F594AC5738D8", -1, NULL },
|
||
|
{ "2-105 #44", "0004E865A9FCC6E11D03557BAC9C64852F69D3174482AD9106856918E6D790867B135A1DB2EEC69474D7F594AC5738D8", 1, "0004E865A9FCC6E11D03557BAC9C64852F69" },
|
||
|
{ "2-105 #45", "B509125D72B9D0CDC67016287921F01E0DD52193C1BD8B50DD2A6BBECDEF7A50DDDC73D996CFD227032EB4A1EC746E4C", 2, "B509125D72B9D0CDC67016287921F01E0DD52193C1BD8B50DD2A6BBECD7F7A50DDDC" },
|
||
|
{ "2-105 #46", "E5A6D7BE57EBB83BFA867DA7B6978BB7161F778B63B098D72EE880885E48E6F3240528F8F1230C5537F5EA030243537A", 2, "E5A6D7BE57EBB83BFA867DA7B6978BB7161F778B63B098CA2EE880885ED8E6F32405" },
|
||
|
{ "2-105 #47", "00E7B451B11DAE9750011F73723404D39A5DE2647484ABC7890F0800969890867B135A1DB2EEC69474D7F594AC5738D8", 1, "00E7B451B11DAE9750011F737234BCD39A40" },
|
||
|
{ "2-105 #48", "FD24A99E20ECC8E347D4D46D141FCCC52A6AC35E5CE4B69338BE22E0ECB72F702E49D0EF7142D6675A4E79E2590865AF", 2, "A024939E20ECC8E3FFD4D46D141FCCC52A6AC35E5CE4B68E38BE22E0EC272F702E49" },
|
||
|
{ "2-105 #49", "1F83699AD2D74238C1453855F89980C7524F5C70390ED83AD89CE7A947F8BA105D9D83DADD3FC8DC9842693A4E9D7E63", 1, "007E6987D2D74238C1453855F89980C7524F" },
|
||
|
{ "2-105 #50", "20884C02075C59B503CFC353E1A553E2B54F4009EAF8C20E0BFC64C93C52D0AA219E83E952864A5EE34E5C06B43ED570", -1, "20884C02075C59B503CF0A92E1A553E2B54F" }, // basic/long mismatch
|
||
|
{ "2-105 #51", "1F83699AD2D74238C1453855F89980C7524F5C70390ED83AD89CE7A9BEF8BA105D9D83DADD3FC8DC9842693A4E9D7E63", 2, "097E6987D2D74238C1453855F89980C7524F5970940ED83AD89CE7A9BEF8BA105D9D" },
|
||
|
{ "2-105 #52", "20884C02075C59B503CFC392E1A553E2B54F4009EAF8C20E0BFC64C93C52D0AA219E83E952864A5EE34E5C06B43ED58B", 2, "20884C02075C59B503CF0A92E1A553E2B54F40092EF8C2BD0BFC643D3C52D6AA219E" },
|
||
|
|
||
|
{ NULL, NULL, -1, NULL }
|
||
|
};
|
||
|
|
||
|
static int hexbyte(const char *buf)
|
||
|
{
|
||
|
int i;
|
||
|
char c;
|
||
|
|
||
|
c = buf[0];
|
||
|
if (c >= '0' && c <= '9')
|
||
|
i = (c - '0');
|
||
|
else if (c >= 'a' && c <= 'f')
|
||
|
i = (c - 'a' + 10);
|
||
|
else if (c >= 'A' && c <= 'F')
|
||
|
i = (c - 'A' + 10);
|
||
|
else
|
||
|
return -1;
|
||
|
|
||
|
i <<= 4;
|
||
|
c = buf[1];
|
||
|
if (c >= '0' && c <= '9')
|
||
|
return i | (c - '0');
|
||
|
else if (c >= 'a' && c <= 'f')
|
||
|
return i | (c - 'a' + 10);
|
||
|
else if (c >= 'A' && c <= 'F')
|
||
|
return i | (c - 'A' + 10);
|
||
|
else
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
static void hex_to_bytes(const char *s, uint8_t *to)
|
||
|
{
|
||
|
for (; *s; s += 2)
|
||
|
*to++ = (uint8_t) hexbyte(s);
|
||
|
}
|
||
|
|
||
|
int main(int argc, char **argv)
|
||
|
{
|
||
|
int i;
|
||
|
uint8_t input[LONG_FRAME_BYTES];
|
||
|
uint8_t expected[LONG_FRAME_DATA_BYTES];
|
||
|
int all_ok = 1;
|
||
|
|
||
|
init_fec();
|
||
|
|
||
|
for (i = 0; downlink_tests[i].testname; ++i) {
|
||
|
int rs_errors;
|
||
|
int frametype;
|
||
|
int ok = 1;
|
||
|
|
||
|
fprintf(stderr, "%s: ", downlink_tests[i].testname);
|
||
|
|
||
|
hex_to_bytes(downlink_tests[i].input, input);
|
||
|
frametype = correct_adsb_frame(input, &rs_errors);
|
||
|
if (frametype != downlink_tests[i].frametype) {
|
||
|
fprintf(stderr, "FAIL: expected frametype %d, got frametype %d\n", downlink_tests[i].frametype, frametype);
|
||
|
ok = 0;
|
||
|
} else if (downlink_tests[i].expected) {
|
||
|
hex_to_bytes(downlink_tests[i].expected, expected);
|
||
|
if (memcmp(expected, input, (frametype == 2) ? LONG_FRAME_DATA_BYTES : SHORT_FRAME_DATA_BYTES) != 0) {
|
||
|
fprintf(stderr, "FAIL: wrong corrected output\n");
|
||
|
ok = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (ok)
|
||
|
fprintf(stderr, "PASS\n");
|
||
|
else
|
||
|
all_ok = 0;
|
||
|
}
|
||
|
|
||
|
return all_ok ? 0 : 1;
|
||
|
}
|