forked from MalcolmRobb/dump1090
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsquawk.c
490 lines (481 loc) · 23.2 KB
/
squawk.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
#include <stdlib.h>
#ifdef DEBUG
#include <stdio.h>
#endif
/*
dump1090 represent squawk codes internally in hexadecimal
but in reality it is octal. The printf is then "%04x"
but it should rather be "%04o".
If the table below should be used as octal do a: s/0x/0/g
in this source code.
*/
static const struct squawk_t {
unsigned int oct_fr;
unsigned int oct_to;
char *description;
} squawk_codes_table[] = {
{0x0000, 0x0000, "SSR data unreliable"},
{0x0001, 0x0001, "Height Monitoring Unit"},
{0x0002, 0x0002, "Ground Transponder Testing"},
{0x0003, 0x0005, "Not allocated"},
{0x0006, 0x0006, "British Transport Police ASU"},
{0x0007, 0x0007, "Off-shore Safety Area (OSA) Conspicuity"},
{0x0010, 0x0010, "Aircraft operating outside of Birmingham CAS and monitoring Birmingham Radar"},
{0x0011, 0x0011, "Solent Monitoring Code"},
{0x0012, 0x0012, "Aircraft operating outside of EGLL/EGLC/EGKK CAS and monitoring Thames/Gatwick Radar"},
{0x0013, 0x0013, "Aircraft operating outside of Luton/Stansted CAS and monitoring Luton/Essex Radar"},
{0x0014, 0x0014, "Kent Air Ambulance (HMD21)"},
{0x0015, 0x0015, "Essex Air Ambulance (HMD07)"},
{0x0016, 0x0016, "Thames Valley Air Ambulance(HMD24)"},
{0x0017, 0x0017, "Virgin HEMS (HMD27)"},
{0x0020, 0x0020, "Air Ambulance Helicopter Emergency Medivac"},
{0x0021, 0x0021, "Fixed-wing aircraft (Receiving service from a ship)"},
{0x0022, 0x0022, "Helicopter(s) (Receiving service from a ship)"},
{0x0023, 0x0023, "Aircraft engaged in actual SAR Operations"},
{0x0024, 0x0024, "Radar Flight Evaluation/Calibration"},
{0x0025, 0x0025, "Not allocated"},
{0x0026, 0x0026, "Special Tasks (Mil) - activated under Special Flight Notification (SFN)"},
{0x0027, 0x0027, "London AC (Swanwick) Ops Crossing/Joining CAS"},
{0x0030, 0x0030, "FIR Lost"},
{0x0031, 0x0031, "An aircraft receiving a radar service from Scottish D & D centre"},
{0x0032, 0x0032, "Aircraft engaged in police air support operations"},
{0x0033, 0x0033, "Aircraft Paradropping"},
{0x0034, 0x0034, "Antenna trailing/target towing"},
{0x0035, 0x0035, "Selected Flights - Helicopters"},
{0x0036, 0x0036, "Helicopter Pipeline/Powerline Inspection Flights"},
{0x0037, 0x0037, "Royal Flights - Helicopters"},
{0x0040, 0x0040, "Civil Helicopters North Sea"},
{0x0041, 0x0042, "Greater Manchester Police ASU"},
{0x0043, 0x0044, "Metropolitan Police ASU"},
{0x0045, 0x0045, "Sussex Police ASU"},
{0x0046, 0x0046, "Essex Police ASU"},
{0x0047, 0x0047, "Surrey Police ASU"},
{0x0050, 0x0050, "Chiltern Police ASU (Western Base)"},
{0x0051, 0x0051, "Chiltern Police ASU (Eastern Base)"},
{0x0052, 0x0052, "Norfolk Police ASU"},
{0x0052, 0x0052, "West Yorkshire Police ASU"},
{0x0053, 0x0053, "Suffolk Police ASU"},
{0x0053, 0x0053, "South Yorkshire Police ASU"},
{0x0054, 0x0054, "Cambridgeshire Police ASU"},
{0x0054, 0x0054, "Merseyside Police ASU"},
{0x0054, 0x0054, "South and East Wales Police ASU"},
{0x0055, 0x0055, "Cleveland Police ASU"},
{0x0055, 0x0055, "Cheshire Police ASU"},
{0x0056, 0x0056, "Northumbria Police ASU"},
{0x0056, 0x0056, "North Midlands Police ASU"},
{0x0057, 0x0057, "Strathclyde Police ASU"},
{0x0057, 0x0057, "Humberside Police ASU"},
{0x0057, 0x0057, "East Midlands Police ASU"},
{0x0060, 0x0060, "West Midlands Police ASU"},
{0x0061, 0x0061, "Lancashire Police ASU"},
{0x0061, 0x0061, "Western Counties Police ASU"},
{0x0062, 0x0077, "No 1 Air Control Centre"},
{0x0100, 0x0100, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x0101, 0x0117, "Transit (ORCAM) Brussels"},
{0x0120, 0x0137, "Transit (ORCAM) Germany"},
{0x0140, 0x0177, "Transit (ORCAM) Amsterdam"},
{0x0200, 0x0200, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x0201, 0x0213, "TC Stansted/TC Luton"},
{0x0201, 0x0217, "RAF Leuchars"},
{0x0201, 0x0257, "Ireland Domestic"},
{0x0201, 0x0257, "RNAS Yeovilton"},
{0x0220, 0x0220, "RAF Leuchars Conspicuity"},
{0x0220, 0x0237, "RAF Shawbury"},
{0x0221, 0x0247, "RAF Leuchars"},
{0x0224, 0x0243, "Anglia Radar"},
{0x0240, 0x0240, "RAF Shawbury Conspicuity"},
{0x0241, 0x0246, "RAF Shawbury"},
{0x0244, 0x0244, "North Denes Conspicuity"},
{0x0245, 0x0267, "Anglia Radar"},
{0x0247, 0x0247, "Cranfield Airport - IFR Conspicuity Purposes"},
{0x0260, 0x0260, "Liverpool Airport Conspicuity"},
{0x0260, 0x0261, "Coventry Airport Conspicuity"},
{0x0260, 0x0261, "Oil Survey Helicopters - Faeroes/Iceland Gap"},
{0x0260, 0x0267, "Westland Helicopters Yeovil"},
{0x0260, 0x0267, "RAF Northolt"},
{0x0261, 0x0267, "Liverpool Airport"},
{0x0270, 0x0277, "Superdomestic - Ireland to UK, Germany and Benelux"},
{0x0300, 0x0300, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x0301, 0x0377, "Transit (ORCAM) UK"},
{0x0400, 0x0400, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x0401, 0x0401, "RAF Leeming Conspicuity"},
{0x0401, 0x0401, "Shoreham Approach Procedural"},
{0x0401, 0x0420, "Birmingham Approach"},
{0x0401, 0x0430, "Exeter Approach"},
{0x0401, 0x0437, "Ireland Domestic"},
{0x0401, 0x0467, "RAF Lakenheath"},
{0x0402, 0x0416, "RAF Leeming"},
{0x0421, 0x0446, "Farnborough Radar/LARS"},
{0x0427, 0x0427, "RAF Leeming (Topcliffe) Conspicuity"},
{0x0430, 0x0443, "Edinburgh Approach"},
{0x0447, 0x0447, "Farnborough LARS - Blackbushe Departures"},
{0x0450, 0x0456, "Blackpool Approach"},
{0x0450, 0x0456, "Farnborough Radar/LARS"},
{0x0457, 0x0457, "Blackpool Approach (Liverpool Bay and Morecambe Bay Helicopters)"},
{0x0457, 0x0457, "Farnborough LARS - Fairoaks Departures"},
{0x0460, 0x0466, "Blackpool Approach"},
{0x0460, 0x0467, "Farnborough Radar/LARS"},
{0x0467, 0x0467, "Blackpool Approach (Liverpool Bay and Morecambe Bay Helicopters)"},
{0x0470, 0x0477, "UK Domestic"},
{0x0500, 0x0500, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x0501, 0x0577, "Transit (ORCAM) UK"},
{0x0600, 0x0600, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x0601, 0x0637, "Transit (ORCAM) Germany"},
{0x0640, 0x0677, "Transit (ORCAM) Paris"},
{0x0700, 0x0700, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x0701, 0x0777, "Transit (ORCAM) Maastricht"},
{0x1000, 0x1000, "IFR GAT flights operating in designated Mode S Airspace"},
{0x1001, 0x1077, "Transit (ORCAM) Spain"},
{0x1100, 0x1100, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x1101, 0x1137, "Transit (ORCAM) Rhein"},
{0x1140, 0x1177, "Transit (ORCAM) UK"},
{0x1177, 0x1177, "London AC (Swanwick) FIS"},
{0x1200, 0x1200, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x1201, 0x1277, "Channel Islands Domestic"},
{0x1300, 0x1300, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x1301, 0x1327, "NATO - Air Policing"},
{0x1330, 0x1357, "Transit (ORCAM) Bremen"},
{0x1360, 0x1377, "Transit (ORCAM) Munich"},
{0x1400, 0x1400, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x1401, 0x1407, "UK Domestic"},
{0x1410, 0x1437, "Superdomestic - Shannon to UK"},
{0x1440, 0x1477, "Superdomestic - Dublin to UK"},
{0x1500, 0x1577, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x1601, 0x1677, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x1701, 0x1727, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x1730, 0x1746, "Newquay Approach"},
{0x1730, 0x1756, "RAF Coningsby"},
{0x1730, 0x1767, "RAF Spadeadam"},
{0x1747, 0x1747, "Newquay Conspicuity"},
{0x1757, 0x1757, "RAF Coningsby Conspicuity"},
{0x1760, 0x1777, "RAF Coningsby"},
{0x1760, 0x1777, "RNAS Yeovilton Fighter Control"},
{0x2000, 0x2000, "Aircraft from non SSR environment or on the aerodrome surface"},
{0x2001, 0x2077, "Transit (ORCAM) Shannon"},
{0x2100, 0x2100, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x2101, 0x2177, "Transit (ORCAM) Amsterdam"},
{0x2200, 0x2200, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x2201, 0x2277, "Superdomestic UK to LF, LE, LP, GC and FA"},
{0x2300, 0x2300, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x2301, 0x2337, "Transit (ORCAM) Bordeaux"},
{0x2340, 0x2377, "Transit (ORCAM) Brest"},
{0x2400, 0x2477, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x2500, 0x2500, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x2501, 0x2577, "Transit (ORCAM) Karlsruhe"},
{0x2600, 0x2600, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x2601, 0x2620, "Aberdeen Approach"},
{0x2601, 0x2637, "RAF Cranwell"},
{0x2601, 0x2645, "MoD Boscombe Down"},
{0x2601, 0x2657, "Irish Domestic Westbound departures and Eastbound arrivals"},
{0x2621, 0x2630, "Aberdeen (Sumburgh Approach)"},
{0x2631, 0x2637, "Aberdeen (Northern North Sea Off-shore)"},
{0x2640, 0x2657, "Aberdeen (Northern North Sea Off-shore - Sumburgh Sector)"},
{0x2641, 0x2642, "RAF Cranwell - Lincolnshire AIAA"},
{0x2646, 0x2647, "MoD Boscombe Down - High Risks Trial"},
{0x2650, 0x2650, "MoD Boscombe Down Conspicuity"},
{0x2650, 0x2653, "Leeds Bradford Approach"},
{0x2651, 0x2657, "MoD Boscombe Down"},
{0x2654, 0x2654, "Leeds Bradford Conspicuity"},
{0x2655, 0x2677, "Leeds Bradford Approach"},
{0x2660, 0x2675, "Middle Wallop"},
{0x2660, 0x2677, "Aberdeen (Northern North Sea Off-shore)"},
{0x2676, 0x2677, "Middle Wallop Conspicuity"},
{0x2700, 0x2700, "NATO - CAOC 9 Exercises (activated by NOTAM)"},
{0x2701, 0x2737, "Transit (ORCAM) Shannon"},
{0x2740, 0x2777, "Transit (ORCAM) Zurich"},
{0x3000, 0x3000, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3001, 0x3077, "Transit (ORCAM) Zurich"},
{0x3100, 0x3100, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3101, 0x3127, "Transit (ORCAM) Germany"},
{0x3130, 0x3177, "Transit (ORCAM) Amsterdam"},
{0x3200, 0x3200, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3201, 0x3202, "UK Domestic (London TC (Swanwick) Special Sector Codes)"},
{0x3203, 0x3216, "UK Domestic (London AC (Swanwick) Special Sector Codes)"},
{0x3217, 0x3220, "UK Domestic"},
{0x3221, 0x3257, "Superdomestic - UK to Oceanic via Shannon/Dublin"},
{0x3260, 0x3277, "UK Domestic"},
{0x3300, 0x3300, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3301, 0x3304, "Swanwick (Military) Special Tasks"},
{0x3305, 0x3307, "London D&D Cell"},
{0x3310, 0x3367, "Swanwick (Military)"},
{0x3370, 0x3377, "UK Domestic"},
{0x3400, 0x3400, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3401, 0x3457, "Superdomestic - UK to Germany, Netherlands and Benelux"},
{0x3460, 0x3477, "Transit (ORCAM) Germany to UK"},
{0x3500, 0x3500, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3501, 0x3507, "Transit (ORCAM) Luxembourg"},
{0x3510, 0x3537, "Transit (ORCAM) Maastricht"},
{0x3540, 0x3577, "Transit (ORCAM) Berlin"},
{0x3600, 0x3600, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3601, 0x3623, "RAF Benson"},
{0x3601, 0x3632, "Scottish ATSOCA Purposes"},
{0x3601, 0x3634, "RAF Waddington"},
{0x3601, 0x3644, "Cardiff Approach"},
{0x3601, 0x3647, "Jersey Approach"},
{0x3624, 0x3624, "RAF Benson Conspicuity"},
{0x3640, 0x3645, "RAF Odiham"},
{0x3640, 0x3665, "RAF Marham"},
{0x3640, 0x3677, "Aberdeen (Northern North Sea Off-shore)"},
{0x3641, 0x3677, "BAe Warton"},
{0x3645, 0x3645, "Cardiff Approach - St Athan Conspicuity"},
{0x3646, 0x3646, "RAF Odiham Conspicuity"},
{0x3646, 0x3657, "Cardiff Approach"},
{0x3647, 0x3653, "RAF Odiham"},
{0x3660, 0x3677, "Solent Approach (Southampton)"},
{0x3666, 0x3666, "Solent Radar Conspicuity"},
{0x3666, 0x3666, "RAF Marham - Visual Recovery"},
{0x3667, 0x3667, "RAF Marham - FIS Conspicuity"},
{0x3667, 0x3677, "Solent Approach (Southampton)"},
{0x3700, 0x3700, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x3701, 0x3710, "Norwich Approach"},
{0x3701, 0x3710, "BAe Woodford"},
{0x3701, 0x3717, "Military aircraft under service from RN AEW aircraft in South West Approaches"},
{0x3701, 0x3736, "RAF Brize Norton"},
{0x3701, 0x3747, "Guernsey Approach"},
{0x3701, 0x3747, "RAF Lossiemouth"},
{0x3711, 0x3711, "Woodford Entry/Exit Lane (Woodford Inbounds and Outbounds)"},
{0x3712, 0x3712, "Woodford Entry/Exit Lane (Manchester Inbounds)"},
{0x3713, 0x3713, "Manchester VFR/SVFR (Outbounds)"},
{0x3720, 0x3720, "RAF Cottesmore Conspicuity"},
{0x3720, 0x3727, "RAF Valley"},
{0x3720, 0x3766, "Newcastle Approach"},
{0x3721, 0x3754, "RAF Cottesmore"},
{0x3730, 0x3736, "RAF Valley"},
{0x3737, 0x3737, "RAF Valley - Visual Recovery"},
{0x3737, 0x3737, "RAF Brize Norton Approach Conspicuity"},
{0x3740, 0x3745, "RAF Brize Norton"},
{0x3740, 0x3747, "RAF Valley"},
{0x3750, 0x3750, "RAF Valley - VFR VATA East"},
{0x3750, 0x3763, "Gatwick Approach (TC)"},
{0x3751, 0x3751, "RAF Valley - VFR VATA West"},
{0x3752, 0x3752, "RAF Valley - RIFA"},
{0x3753, 0x3753, "RAF Valley - Low Level Helicopters"},
{0x3754, 0x3754, "RAF Valley - Special Tasks"},
{0x3755, 0x3755, "RAF Valley"},
{0x3755, 0x3762, "RAF Wittering Approach"},
{0x3756, 0x3765, "RAF Valley - VATA IFR Traffic"},
{0x3764, 0x3767, "Gatwick Tower"},
{0x3767, 0x3767, "Redhill Approach Conspicuity"},
{0x3767, 0x3767, "Newcastle Approach Conspicuity"},
{0x3770, 0x3777, "ATSOCAS"},
{0x4000, 0x4000, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4001, 0x4077, "Transit (ORCAM) Aix-en-Provence"},
{0x4100, 0x4100, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4101, 0x4127, "Transit (ORCAM) Frankfurt"},
{0x4130, 0x4177, "Transit (ORCAM) Dusseldorf"},
{0x4200, 0x4200, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4201, 0x4214, "Heathrow Domestic"},
{0x4215, 0x4247, "Superdomestic - Shannon inbound UK"},
{0x4250, 0x4250, "Manston Conspicuity"},
{0x4250, 0x4257, "Belfast City Approach"},
{0x4250, 0x4267, "Aberdeen Approach"},
{0x4250, 0x4277, "BAe Bristol Filton"},
{0x4250, 0x4277, "Humberside Approach"},
{0x4251, 0x4267, "Manston Approach"},
{0x4300, 0x4300, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4301, 0x4307, "UK Domestic"},
{0x4310, 0x4323, "UK Domestic (Gatwick Special Sector Codes)"},
{0x4324, 0x4337, "UK Domestic (Scottish Special Sector Codes)"},
{0x4340, 0x4353, "UK Domestic (SCoACC Special Sector Codes)"},
{0x4354, 0x4377, "UK Domestic"},
{0x4400, 0x4400, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4401, 0x4427, "Superdomestic - Brussels FIR to UK FIR"},
{0x4430, 0x4477, "Superdomestic - UK to Eire and Oceanic"},
{0x4500, 0x4500, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4501, 0x4501, "Wattisham Conspicuity"},
{0x4501, 0x4515, "RAF Lyneham"},
{0x4501, 0x4520, "Prestwick Approach"},
{0x4501, 0x4547, "RAF Linton-on-Ouse"},
{0x4502, 0x4547, "Wattisham Approach"},
{0x4516, 0x4517, "RAF Lyneham Conspicuity"},
{0x4520, 0x4524, "RAF Lyneham"},
{0x4530, 0x4542, "MoD Aberporth"},
{0x4530, 0x4567, "Plymouth (Military) Radar"},
{0x4550, 0x4567, "Isle of Man"},
{0x4550, 0x4572, "East Midlands Approach"},
{0x4573, 0x4573, "East Midlands Approach Conspicuity"},
{0x4574, 0x4574, "Not allocated"},
{0x4575, 0x4575, "RAF Leeming/RAF Linton-on-Ouse"},
{0x4575, 0x4575, "Southend Airport Conspicuity"},
{0x4576, 0x4577, "RAF Colerne Conspicuity"},
{0x4576, 0x4577, "Vale of York AIAA Conspicuity"},
{0x4600, 0x4600, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4601, 0x4601, "Hawarden Conspicuity"},
{0x4601, 0x4601, "RAF Wyton QGH Approach"},
{0x4602, 0x4607, "Hawarden Approach"},
{0x4610, 0x4667, "Scottish (Military) Radar"},
{0x4670, 0x4676, "TC Stansted/TC Luton"},
{0x4670, 0x4677, "RAF Coningsby RWS"},
{0x4677, 0x4677, "Carlisle Airport Conspicuity"},
{0x4677, 0x4677, "Luton Airport Tower Conspicuity"},
{0x4700, 0x4700, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x4701, 0x4777, "Special Events (activated by NOTAM)"},
{0x5000, 0x5000, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5001, 0x5012, "TC Non-Standard Flights"},
{0x5013, 0x5017, "UK Domestic"},
{0x5020, 0x5046, "Farnborough LLARS"},
{0x5047, 0x5047, "Farnborough LLARS Conspicuity"},
{0x5050, 0x5067, "Bristol Approach"},
{0x5070, 0x5070, "Bristol VFR Conspicuity"},
{0x5071, 0x5077, "Bristol Approach"},
{0x5100, 0x5100, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5101, 0x5177, "CRC Boulmer"},
{0x5200, 0x5200, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5201, 0x5260, "Transit (ORCAM) UK"},
{0x5261, 0x5270, "Transit (ORCAM) Dublin to Europe"},
{0x5271, 0x5277, "Transit (ORCAM) Channel Islands"},
{0x5300, 0x5300, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5301, 0x5377, "Transit (ORCAM) Barcelona"},
{0x5400, 0x5400, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5401, 0x5477, "UK Domestic"},
{0x5500, 0x5500, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5501, 0x5577, "Transit (ORCAM) Barcelona"},
{0x5600, 0x5600, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5601, 0x5647, "Transit (ORCAM) Paris"},
{0x5650, 0x5657, "Transit (ORCAM) Luxembourg"},
{0x5660, 0x5677, "Transit (ORCAM) Reims"},
{0x5700, 0x5700, "NATO - Aircraft receiving a service from AEW aircraft"},
{0x5701, 0x5777, "Transit (ORCAM) Geneva"},
{0x6000, 0x6000, "NATO - CAOC 9 Exercises"},
{0x6001, 0x6007, "UK Domestic"},
{0x6010, 0x6037, "UK Domestic"},
{0x6040, 0x6077, "London (Military) Radar"},
{0x6100, 0x6100, "NATO - CAOC 9 Exercises"},
{0x6101, 0x6107, "London (Military) Radar"},
{0x6110, 0x6137, "Scottish (Military) Radar"},
{0x6140, 0x6147, "London (Military) Radar"},
{0x6151, 0x6157, "Scottish (Military) Radar"},
{0x6160, 0x6160, "Doncaster Sheffield Conspicuity"},
{0x6160, 0x6176, "Cambridge Approach"},
{0x6160, 0x6176, "Inverness Approach"},
{0x6160, 0x6177, "Plymouth (Military) Radar"},
{0x6161, 0x6167, "Doncaster Sheffield Approach"},
{0x6170, 0x6170, "Aircraft operating outside of Doncaster Sheffield Controlled Airspace Zone and Monitoring Doncaster Sheffield Radar frequency"},
{0x6171, 0x6177, "Doncaster Sheffield Approach"},
{0x6177, 0x6177, "Cambridge Conspicuity"},
{0x6177, 0x6177, "Inverness VFR Conspicuity"},
{0x6200, 0x6200, "NATO - CAOC 9 Exercises"},
{0x6201, 0x6227, "Superdomestic - Dublin inbound UK"},
{0x6230, 0x6247, "Superdomestic - UK to Scandinavia and Russia"},
{0x6250, 0x6257, "Superdomestic - UK to Amsterdam"},
{0x6260, 0x6277, "Superdomestic - Amsterdam to UK, Eire and Iceland"},
{0x6300, 0x6300, "NATO - CAOC 9 Exercises"},
{0x6301, 0x6377, "Superdomestic - UK to France"},
{0x6400, 0x6400, "NATO - CAOC 9 Exercises"},
{0x6401, 0x6457, "Swanwick (Military) Radar"},
{0x6460, 0x6477, "UK Domestic"},
{0x6500, 0x6500, "NATO - CAOC 9 Exercises"},
{0x6501, 0x6577, "CRC Scampton"},
{0x6600, 0x6600, "NATO - CAOC 9 Exercises"},
{0x6601, 0x6677, "Transit (ORCAM) Germany"},
{0x6700, 0x6700, "NATO - CAOC 9 Exercises"},
{0x6701, 0x6747, "Transit (ORCAM) Reims"},
{0x6750, 0x6777, "Transit (ORCAM) Aix-en-Provence"},
{0x7000, 0x7000, "General Conspicuity code"},
{0x7001, 0x7001, "Military Fixed-wing Low Level Conspicuity/Climbout"},
{0x7002, 0x7002, "Danger Areas General"},
{0x7003, 0x7003, "Red Arrows Transit/Display"},
{0x7004, 0x7004, "Conspicuity Aerobatics and Display"},
{0x7005, 0x7005, "High-Energy Manoeuvres"},
{0x7006, 0x7006, "Autonomous Operations within TRA and TRA (G)"},
{0x7007, 0x7007, "Open Skies Observation Aircraft"},
{0x7010, 0x7010, "Operating in Aerodrome Traffic Pattern"},
{0x7011, 0x7013, "Not allocated"},
{0x7014, 0x7027, "UK Domestic"},
{0x7030, 0x7045, "RNAS Culdrose"},
{0x7030, 0x7046, "TC Thames/TC Heathrow"},
{0x7030, 0x7047, "Aldergrove Approach"},
{0x7030, 0x7066, "Durham Tees Valley Airport"},
{0x7030, 0x7077, "Aberdeen (Northern North Sea Off-shore)"},
{0x7046, 0x7047, "RNAS Culdrose Conspicuity"},
{0x7047, 0x7047, "TC Thames (Biggin Hill Airport Conspicuity)"},
{0x7050, 0x7056, "TC Thames/TC Heathrow"},
{0x7057, 0x7057, "TC Thames (London City Airport Conspicuity)"},
{0x7050, 0x7077, "RNAS Culdrose"},
{0x7067, 0x7067, "Durham Tees Valley Airport Conspicuity"},
{0x7070, 0x7076, "TC Thames/TC Heathrow"},
{0x7077, 0x7077, "TC Thames (London Heliport Conspicuity)"},
{0x7100, 0x7100, "London Control (Swanwick) Saturation Code"},
{0x7101, 0x7177, "Transit (ORCAM) Brussels"},
{0x7200, 0x7200, "RN Ships"},
{0x7201, 0x7247, "Transit (ORCAM) Vienna"},
{0x7250, 0x7257, "UK Superdomestic for destinations in France and Barcelona FIR"},
{0x7260, 0x7267, "Superdomestic - Shannon/Dublin to France and Spain"},
{0x7270, 0x7277, "Plymouth Radar Superdomestic for destinations in UK and France"},
{0x7300, 0x7300, "Not allocated"},
{0x7301, 0x7307, "Superdomestic - Shannon Eastbound landing UK"},
{0x7310, 0x7327, "Superdomestic - UK to Netherlands"},
{0x7330, 0x7347, "Superdomestic - Netherlands to UK"},
{0x7350, 0x7350, "Norwich Approach Conspicuity"},
{0x7350, 0x7361, "MoD Ops in EG D701 (Hebrides)"},
{0x7350, 0x7365, "Manchester Approach"},
{0x7350, 0x7367, "RNAS Culdrose"},
{0x7350, 0x7376, "Bournemouth Approach/LARS"},
{0x7351, 0x7377, "Norwich Approach"},
{0x7362, 0x7362, "MoD Ops in EG D702 (Fort George)"},
{0x7363, 0x7363, "MoD Ops in EG D703 (Tain)"},
{0x7367, 0x7373, "Manchester Approach"},
{0x7374, 0x7374, "Dundee Airport Conspicuity"},
{0x7375, 0x7375, "Manchester TMA and Woodvale Local Area (Woodvale UAS Conspicuity)"},
{0x7377, 0x7377, "Bournemouth Radar Conspicuity"},
{0x7400, 0x7400, "MPA/DEFRA/Fishery Protection Conspicuity"},
{0x7401, 0x7437, "UK Domestic"},
{0x7440, 0x7477, "Superdomestic Spain and France to UK, Ireland, Iceland and North America"},
{0x7500, 0x7500, "Special Purpose Code - Hi-Jacking"},
{0x7501, 0x7537, "Transit (ORCAM) Geneva"},
{0x7540, 0x7547, "Transit (ORCAM) Bremen"},
{0x7550, 0x7577, "Transit (ORCAM) Paris"},
{0x7600, 0x7600, "Special Purpose Code - Radio Failure"},
{0x7601, 0x7607, "Superdomestic - Shannon/Dublin to Nordic States"},
{0x7610, 0x7617, "Superdomestic - Ireland to UK"},
{0x7620, 0x7657, "Superdomestic - UK to USA, Canada and Caribbean"},
{0x7660, 0x7677, "Superdomestic - UK to USA, Canada, Canaries and Caribbean"},
{0x7700, 0x7700, "Special Purpose Code - Emergency"},
{0x7701, 0x7717, "Superdomestic - UK to France and Spain"},
{0x7720, 0x7727, "Transit (ORCAM) Munich"},
{0x7730, 0x7757, "Superdomestic - Shannon Eastbound landing UK"},
{0x7760, 0x7775, "Superdomestic - UK to Channel Islands"},
{0x7776, 0x7777, "SSR Monitors"}
};
#define nr_of_squawk_codes_table (sizeof(squawk_codes_table)/sizeof(squawk_codes_table[0]))
static int
compsquawk(const void *key_p, const void *tab_p)
{
struct squawk_t *key = (struct squawk_t *) key_p;
struct squawk_t *tab = (struct squawk_t *) tab_p;
#ifdef DEBUG
printf("kFr: %04o, tFr: %04o, tTo: %04o, D: %s\n", key->oct_fr, tab->oct_fr, tab->oct_to, tab->description);
#endif
if (key->oct_fr >= tab->oct_fr && key->oct_fr <= tab->oct_to )
return 0;
if (key->oct_fr < tab->oct_fr)
return -1;
//if (key->oct_fr > tab->oct_to)
return 1;
}
char *squawkDescription(unsigned int squawk) {
if (squawk > squawk_codes_table[nr_of_squawk_codes_table-1].oct_to) {
return "Invalid squawk code. Guess which!";
} else {
struct squawk_t key, *res;
key.oct_fr = squawk;
res = bsearch(&key, &squawk_codes_table, nr_of_squawk_codes_table, sizeof(struct squawk_t), compsquawk);
return res ? res->description : "not found";
}
}
#ifdef UNIT_TEST
/* gcc -DUNIT_TEST -o squawk squawk.c && ./squawk */
#include <stdio.h>
#include <assert.h>
int main(int argc, char *argv[]) {
int d = 0x777F;
int i = 0;
printf("%3d %04o %s\n", i, d, squawkDescription(d));
while (i < nr_of_squawk_codes_table) {
d = squawk_codes_table[i].oct_fr;
printf("%3d %04x %s\n", i, d, squawkDescription(d));
++i;
}
return 0;
}
#endif