mirror of
https://agent.ghink.cloud/wb2osz/direwolf
synced 2025-04-08 15:48:35 +00:00
Changes to be committed: new file: .gitattributes new file: .gitignore new file: APRStt-Implementation-Notes.pdf new file: CHANGES.txt new file: LICENSE-dire-wolf.txt new file: LICENSE-other.txt new file: Makefile.linux new file: Makefile.win new file: Quick-Start-Guide-Windows.pdf new file: Raspberry-Pi-APRS.pdf new file: User-Guide.pdf new file: aclients.c new file: aprs_tt.c new file: aprs_tt.h new file: atest.c new file: audio.c new file: audio.h new file: audio_win.c new file: ax25_pad.c new file: ax25_pad.h new file: beacon.c new file: beacon.h new file: config.c new file: config.h new file: decode_aprs.c new file: decode_aprs.h new file: dedupe.c new file: dedupe.h new file: demod.c new file: demod.h new file: demod_9600.c new file: demod_9600.h new file: demod_afsk.c new file: demod_afsk.h new file: digipeater.c new file: digipeater.h new file: direwolf.c new file: direwolf.conf new file: direwolf.desktop new file: direwolf.h new file: dsp.c new file: dsp.h new file: dtmf.c new file: dtmf.h new file: dw-icon.ico new file: dw-icon.png new file: dw-icon.rc new file: dw-start.sh new file: dwgps.c new file: dwgps.h new file: encode_aprs.c new file: encode_aprs.h new file: fcs_calc.c new file: fcs_calc.h new file: fsk_demod_agc.h new file: fsk_demod_state.h new file: fsk_filters.h new file: fsk_gen_filter.h new file: gen_packets.c new file: gen_tone.c new file: gen_tone.h new file: hdlc_rec.c new file: hdlc_rec.h new file: hdlc_rec2.c new file: hdlc_rec2.h new file: hdlc_send.c new file: hdlc_send.h new file: igate.c new file: igate.h new file: kiss.c new file: kiss.h new file: kiss_frame.c new file: kiss_frame.h new file: kissnet.c new file: kissnet.h new file: latlong.c new file: latlong.h new file: ll2utm.c new file: misc/README-dire-wolf.txt new file: misc/strcasestr.c new file: misc/strsep.c new file: misc/strtok_r.c new file: morse.c new file: multi_modem.c new file: multi_modem.h new file: ptt.c new file: ptt.h new file: pttest.c new file: rdq.c new file: rdq.h new file: redecode.c new file: redecode.h new file: regex/COPYING new file: regex/INSTALL new file: regex/LICENSES new file: regex/NEWS new file: regex/README new file: regex/README-dire-wolf.txt new file: regex/re_comp.h new file: regex/regcomp.c new file: regex/regex.c new file: regex/regex.h new file: regex/regex_internal.c new file: regex/regex_internal.h new file: regex/regexec.c new file: rrbb.c new file: rrbb.h new file: server.c new file: server.h new file: symbols-new.txt new file: symbols.c new file: symbols.h new file: symbolsX.txt new file: textcolor.c new file: textcolor.h new file: tocalls.txt new file: tq.c new file: tq.h new file: tt_text.c new file: tt_text.h new file: tt_user.c new file: tt_user.h new file: tune.h new file: udp_test.c new file: utm/LatLong-UTMconversion.c new file: utm/LatLong-UTMconversion.h new file: utm/README.txt new file: utm/SwissGrid.cpp new file: utm/UTMConversions.cpp new file: utm/constants.h new file: utm2ll.c new file: version.h new file: xmit.c new file: xmit.h
299 lines
7.3 KiB
C
299 lines
7.3 KiB
C
/*-------------------------------------------------------------------
|
|
*
|
|
* Name: ax25_pad.h
|
|
*
|
|
* Purpose: Header file for using ax25_pad.c
|
|
*
|
|
*------------------------------------------------------------------*/
|
|
|
|
#ifndef AX25_PAD_H
|
|
#define AX25_PAD_H 1
|
|
|
|
|
|
#define AX25_MAX_REPEATERS 8
|
|
#define AX25_MIN_ADDRS 2 /* Destinatin & Source. */
|
|
#define AX25_MAX_ADDRS 10 /* Destination, Source, 8 digipeaters. */
|
|
|
|
#define AX25_DESTINATION 0 /* Address positions in frame. */
|
|
#define AX25_SOURCE 1
|
|
#define AX25_REPEATER_1 2
|
|
#define AX25_REPEATER_2 3
|
|
#define AX25_REPEATER_3 4
|
|
#define AX25_REPEATER_4 5
|
|
#define AX25_REPEATER_5 6
|
|
#define AX25_REPEATER_6 7
|
|
#define AX25_REPEATER_7 8
|
|
#define AX25_REPEATER_8 9
|
|
|
|
#define AX25_MAX_ADDR_LEN 12 /* In theory, you would expect the maximum length */
|
|
/* to be 6 letters, dash, 2 digits, and nul for a */
|
|
/* total of 10. However, object labels can be 10 */
|
|
/* characters so throw in a couple extra bytes */
|
|
/* to be safe. */
|
|
|
|
#define AX25_MIN_INFO_LEN 0 /* Previously 1 when considering only APRS. */
|
|
|
|
#define AX25_MAX_INFO_LEN 2048 /* Maximum size for APRS. */
|
|
/* AX.25 starts out with 256 as the default max */
|
|
/* length but the end stations can negotiate */
|
|
/* something different. */
|
|
/* version 0.8: Change from 256 to 2028 to */
|
|
/* handle the larger paclen for Linux AX25. */
|
|
|
|
/* These don't include the 2 bytes for the */
|
|
/* HDLC frame FCS. */
|
|
|
|
/*
|
|
* Previously, for APRS only.
|
|
* #define AX25_MIN_PACKET_LEN ( 2 * 7 + 2 + AX25_MIN_INFO_LEN)
|
|
* #define AX25_MAX_PACKET_LEN ( AX25_MAX_ADDRS * 7 + 2 + AX25_MAX_INFO_LEN)
|
|
*/
|
|
|
|
/* the more general case. */
|
|
|
|
#define AX25_MIN_PACKET_LEN ( 2 * 7 + 1 )
|
|
|
|
#define AX25_MAX_PACKET_LEN ( AX25_MAX_ADDRS * 7 + 2 + 3 + AX25_MAX_INFO_LEN)
|
|
|
|
|
|
/*
|
|
* packet_t is a pointer to a packet object.
|
|
*
|
|
* The actual implementation is not visible outside ax25_pad.c.
|
|
*/
|
|
|
|
#define AX25_UI_FRAME 3 /* Control field value. */
|
|
#define AX25_NO_LAYER_3 0xf0 /* protocol ID */
|
|
|
|
|
|
|
|
#ifdef AX25_PAD_C /* Keep this hidden - implementation could change. */
|
|
|
|
struct packet_s {
|
|
|
|
int magic1; /* for error checking. */
|
|
|
|
#define MAGIC 0x41583235
|
|
|
|
struct packet_s *nextp; /* Pointer to next in queue. */
|
|
|
|
int num_addr; /* Number of elements used in two below. */
|
|
/* Range of 0 .. AX25_MAX_ADDRS. */
|
|
|
|
char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN];
|
|
/* Contains the address without the ssid. */
|
|
/* Why is it larger than 7? */
|
|
/* Messages from an IGate server can have longer */
|
|
/* addresses after qAC. Up to 9 observed so far. */
|
|
|
|
/* usual human readable form. e.g. WB20SZ-15 */
|
|
|
|
unsigned char ssid_etc[AX25_MAX_ADDRS]; /* SSID octet from each address. */
|
|
|
|
/*
|
|
* Bits: H R R SSID 0
|
|
*
|
|
* H for digipeaters set to 0 intially.
|
|
* Changed to 1 when position has been used.
|
|
*
|
|
* for source & destination it is called
|
|
* command/response and is normally 1.
|
|
*
|
|
* R R Reserved. Normally set to 1 1.
|
|
*
|
|
* SSID Substation ID. Range of 0 - 15.
|
|
*
|
|
* 0 Usually 0 but 1 for last address.
|
|
*/
|
|
|
|
#define SSID_H_MASK 0x80
|
|
#define SSID_H_SHIFT 7
|
|
|
|
#define SSID_RR_MASK 0x60
|
|
#define SSID_RR_SHIFT 5
|
|
|
|
#define SSID_SSID_MASK 0x1e
|
|
#define SSID_SSID_SHIFT 1
|
|
|
|
#define SSID_LAST_MASK 0x01
|
|
|
|
|
|
int the_rest_len; /* Frame length minus the address part. */
|
|
|
|
unsigned char the_rest[2 + 3 + AX25_MAX_INFO_LEN + 1];
|
|
/* The rest after removing the addresses. */
|
|
/* Includes control, protocol ID, Information, */
|
|
/* and throw in one more for a character */
|
|
/* string nul terminator. */
|
|
|
|
int magic2; /* Will get stomped on if above overflows. */
|
|
};
|
|
|
|
|
|
|
|
|
|
#else /* Public view. */
|
|
|
|
struct packet_s {
|
|
int secret;
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
typedef struct packet_s *packet_t;
|
|
|
|
|
|
|
|
#ifdef AX25_PAD_C /* Keep this hidden - implementation could change. */
|
|
|
|
/*
|
|
* APRS always has one control octet of 0x03 but the more
|
|
* general AX.25 case is one or two control bytes depending on
|
|
* "modulo 128 operation" is in effect. Unfortunately, it seems
|
|
* this can be determined only by examining the XID frames and
|
|
* keeping this information for each connection.
|
|
* We can assume 1 for our purposes.
|
|
*/
|
|
|
|
static inline int ax25_get_control_offset (packet_t this_p)
|
|
{
|
|
return (0);
|
|
}
|
|
|
|
static inline int ax25_get_num_control (packet_t this_p)
|
|
{
|
|
return (1);
|
|
}
|
|
|
|
|
|
/*
|
|
* APRS always has one protocol octet of 0xF0 meaning no level 3
|
|
* protocol but the more general case is 0, 1 or 2 protocol ID octets.
|
|
*/
|
|
|
|
static inline int ax25_get_pid_offset (packet_t this_p)
|
|
{
|
|
return (ax25_get_num_control(this_p));
|
|
}
|
|
|
|
static int ax25_get_num_pid (packet_t this_p)
|
|
{
|
|
int c;
|
|
int pid;
|
|
|
|
c = this_p->the_rest[ax25_get_control_offset(this_p)];
|
|
|
|
if ( (c & 0x01) == 0 || /* I xxxx xxx0 */
|
|
c == 0x03 || c == 0x13) { /* UI 000x 0011 */
|
|
|
|
pid = this_p->the_rest[ax25_get_pid_offset(this_p)];
|
|
if (pid == 0xff) {
|
|
return (2); /* pid 1111 1111 means another follows. */
|
|
}
|
|
return (1);
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
|
|
/*
|
|
* APRS always has an Information field with at least one octet for the
|
|
* Data Type Indicator. AX.25 has this for only 5 frame types depending
|
|
* on the control field.
|
|
* xxxx xxx0 I
|
|
* 000x 0011 UI
|
|
* 101x 1111 XID
|
|
* 111x 0011 TEST
|
|
* 100x 0111 FRMR
|
|
*/
|
|
|
|
static inline int ax25_get_info_offset (packet_t this_p)
|
|
{
|
|
return (ax25_get_num_control(this_p) + ax25_get_num_pid(this_p));
|
|
}
|
|
|
|
static int ax25_get_num_info (packet_t this_p)
|
|
{
|
|
int len;
|
|
|
|
len = this_p->the_rest_len - ax25_get_num_control(this_p) - ax25_get_num_pid(this_p);
|
|
if (len < 0) {
|
|
len = 0; /* print error? */
|
|
}
|
|
return (len);
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//static packet_t ax25_new (void);
|
|
|
|
extern void ax25_delete (packet_t pp);
|
|
|
|
extern void ax25_clear (packet_t pp);
|
|
|
|
extern packet_t ax25_from_text (char *, int strict);
|
|
|
|
extern packet_t ax25_from_frame (unsigned char *data, int len, int alevel);
|
|
|
|
extern packet_t ax25_dup (packet_t copy_from);
|
|
|
|
extern int ax25_parse_addr (char *in_addr, int strict, char *out_addr, int *out_ssid, int *out_heard);
|
|
|
|
extern packet_t ax25_unwrap_third_party (packet_t from_pp);
|
|
|
|
extern void ax25_set_addr (packet_t pp, int, char *);
|
|
extern void ax25_insert_addr (packet_t this_p, int n, char *ad);
|
|
extern void ax25_remove_addr (packet_t this_p, int n);
|
|
|
|
extern int ax25_get_num_addr (packet_t pp);
|
|
extern int ax25_get_num_repeaters (packet_t this_p);
|
|
|
|
extern void ax25_get_addr_with_ssid (packet_t pp, int n, char *);
|
|
|
|
extern int ax25_get_ssid (packet_t pp, int n);
|
|
extern void ax25_set_ssid (packet_t this_p, int n, int ssid);
|
|
|
|
extern int ax25_get_h (packet_t pp, int n);
|
|
|
|
extern void ax25_set_h (packet_t pp, int n);
|
|
|
|
extern int ax25_get_heard(packet_t this_p);
|
|
|
|
extern int ax25_get_first_not_repeated(packet_t pp);
|
|
|
|
extern int ax25_get_info (packet_t pp, unsigned char **paddr);
|
|
|
|
extern void ax25_set_nextp (packet_t this_p, packet_t next_p);
|
|
|
|
extern int ax25_get_dti (packet_t this_p);
|
|
|
|
extern packet_t ax25_get_nextp (packet_t this_p);
|
|
|
|
extern void ax25_format_addrs (packet_t pp, char *);
|
|
|
|
extern int ax25_pack (packet_t pp, unsigned char result[AX25_MAX_PACKET_LEN]);
|
|
|
|
extern int ax25_is_aprs (packet_t pp);
|
|
|
|
extern int ax25_get_control (packet_t this_p);
|
|
|
|
extern int ax25_get_pid (packet_t this_p);
|
|
|
|
extern unsigned short ax25_dedupe_crc (packet_t pp);
|
|
|
|
extern unsigned short ax25_m_m_crc (packet_t pp);
|
|
|
|
extern void ax25_safe_print (char *, int, int ascii_only);
|
|
|
|
|
|
#endif /* AX25_PAD_H */
|
|
|
|
/* end ax25_pad.h */
|
|
|
|
|