1 // --------------------------------------------------------------------- 2 // ax25_decode.cxx -- AX25 Packet disassembler. 3 // 4 // This file is a proposed part of fldigi. Adapted very liberally from 5 // rtty.cxx, with many thanks to John Hansen, W2FS, who wrote 6 // 'dcc.doc' and 'dcc2.doc', GNU Octave, GNU Radio Companion, and finally 7 // Bartek Kania (bk.gnarf.org) whose 'aprs.c' expository coding style helped 8 // shape this implementation. 9 // 10 // Copyright (C) 2010, 2014 11 // Dave Freese, W1HKJ 12 // Chris Sylvain, KB3CS 13 // Robert Stiles, KK5VD 14 // 15 // fldigi is free software; you can redistribute it and/or modify 16 // it under the terms of the GNU General Public License as published by 17 // the Free Software Foundation; either version 3 of the License, or 18 // (at your option) any later version. 19 // 20 // fldigi is distributed in the hope that it will be useful, 21 // but WITHOUT ANY WARRANTY; without even the implied warranty of 22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 // GNU General Public License for more details. 24 // 25 // You should have received a copy of the GNU General Public License 26 // along with fldigi; if not, write to the 27 // 28 // Free Software Foundation, Inc. 29 // 51 Franklin Street, Fifth Floor 30 // Boston, MA 02110-1301 USA. 31 // 32 // --------------------------------------------------------------------- 33 34 #ifndef __ax25_decode__ 35 #define __ax25_decode__ 36 37 #include <iostream> 38 39 // 70 bytes addr + 256 payload + 2 FCS + 1 Control + 1 Protocol ID 40 #define MAXOCTETS 340 41 // 136 bits minimum (including start and end flags) - AX.25 v2.2 section 3.9 42 // == 15 octets. we count only one of the two flags, though. 43 #define MINOCTETS 14 44 45 enum PKT_MicE_field { 46 Null = 0x00, 47 Space = 0x20, 48 Zero = 0x30, 49 One, 50 Two, 51 Three, 52 Four, 53 Five, 54 Six, 55 Seven, 56 Eight, 57 Nine, 58 P0 = 0x40, 59 P100, 60 North = 0x50, 61 East, 62 South, 63 West, 64 Invalid = 0xFF 65 }; 66 67 struct PKT_PHG_table { 68 const char *s; 69 unsigned char l; 70 }; 71 72 //static void do_put_rx_char(unsigned char *cp); 73 static void expand_MicE(unsigned char *cpI, unsigned char *cpE); 74 static void expand_PHG(unsigned char *cpI); 75 static void expand_Cmp(unsigned char *cpI); 76 inline void put_rx_const(const char s[]); 77 void ax25_decode(unsigned char *buffer, size_t count, bool pad, bool tx_flag); 78 79 #endif /* defined(__ax25_decode__) */ 80