patty/include/patty/ax25.h

142 lines
3.9 KiB
C
Raw Normal View History

2015-07-03 03:02:22 +00:00
#ifndef _PATTY_AX25_H
#define _PATTY_AX25_H
2015-07-20 02:22:41 -05:00
#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
2015-07-20 02:22:41 -05:00
2015-07-23 23:55:44 +00:00
#include <patty/list.h>
2015-07-20 02:22:41 -05:00
#include <patty/dict.h>
#define PATTY_AX25_CALLSTRLEN 6
#define PATTY_AX25_ADDRSTRLEN (PATTY_AX25_CALLSTRLEN + 3)
2020-06-16 18:48:29 -04:00
#define PATTY_AX25_IF_NAME_SIZE 8
#define PATTY_AX25_MAX_HOPS 8
2020-06-16 18:48:29 -04:00
#define PATTY_AX25_SOCK_PATH_SIZE 256
enum patty_ax25_version {
PATTY_AX25_OLD,
PATTY_AX25_2_0,
PATTY_AX25_2_2
};
enum patty_ax25_proto {
PATTY_AX25_PROTO_UNKNOWN = 0x00,
PATTY_AX25_PROTO_ISO_8208 = 0x01,
PATTY_AX25_PROTO_TCP_VJ_COMPR = 0x06,
PATTY_AX25_PROTO_TCP_VJ = 0x07,
PATTY_AX25_PROTO_FRAGMENT = 0x08,
PATTY_AX25_PROTO_TEXNET = 0xc3,
PATTY_AX25_PROTO_LQP = 0xc4,
PATTY_AX25_PROTO_APPLETALK = 0xca,
PATTY_AX25_PROTO_APPLETALK_ARP = 0xcb,
PATTY_AX25_PROTO_INET = 0xcc,
PATTY_AX25_PROTO_INET_ARP = 0xcd,
PATTY_AX25_PROTO_FLEXNET = 0xce,
PATTY_AX25_PROTO_NETROM = 0xcf,
PATTY_AX25_PROTO_NONE = 0xf0,
PATTY_AX25_PROTO_ESCAPE = 0xff
};
2020-06-07 02:46:12 -04:00
#pragma pack(push)
#pragma pack(1)
typedef struct _patty_ax25_addr {
char callsign[PATTY_AX25_CALLSTRLEN];
2020-06-07 02:46:12 -04:00
uint8_t ssid;
} patty_ax25_addr;
#pragma pack(pop)
enum patty_ax25_param_type {
PATTY_AX25_PARAM_CLASSES = 2,
PATTY_AX25_PARAM_HDLC = 3,
PATTY_AX25_PARAM_INFO_TX = 5,
PATTY_AX25_PARAM_INFO_RX = 6,
PATTY_AX25_PARAM_WINDOW_TX = 7,
PATTY_AX25_PARAM_WINDOW_RX = 8,
PATTY_AX25_PARAM_ACK = 9,
PATTY_AX25_PARAM_RETRY = 10
};
/*
* Note: These values are byte swapped from their listed order as per
* AX.25 v2.2 Section 4.3.37 "Exchange Identification (XID) Frame"; bits 0-7
* are in the first byte, 8-15 in the second, and 16-23 in the third.
* The bit positions are shown in their original order (plus one) in the
* aforementioned figure in the AX.25 v2.2 spec.
*/
enum patty_ax25_param_classes {
PATTY_AX25_PARAM_CLASSES_ABM = (1 << 0) << 8,
PATTY_AX25_PARAM_CLASSES_HALF_DUPLEX = (1 << 5) << 8,
PATTY_AX25_PARAM_CLASSES_FULL_DUPLEX = (1 << 6) << 8
};
enum patty_ax25_param_hdlc {
PATTY_AX25_PARAM_HDLC_REJ = (1 << 1) << 16,
PATTY_AX25_PARAM_HDLC_SREJ = (1 << 2) << 16,
PATTY_AX25_PARAM_HDLC_XADDR = (1 << 7) << 16,
PATTY_AX25_PARAM_HDLC_MODULO_8 = (1 << 10),
PATTY_AX25_PARAM_HDLC_MODULO_128 = (1 << 11),
PATTY_AX25_PARAM_HDLC_TEST = (1 << 13),
PATTY_AX25_PARAM_HDLC_FCS_16 = (1 << 15),
PATTY_AX25_PARAM_HDLC_SYNC_TX = (1 << 17) >> 16,
PATTY_AX25_PARAM_HDLC_SREJ_MULTI = (1 << 21) >> 16
};
typedef struct _patty_ax25_params {
uint32_t flags;
uint32_t classes,
hdlc;
size_t info_tx,
info_rx,
window_tx,
window_rx,
ack,
retry;
} patty_ax25_params;
2020-06-07 02:46:12 -04:00
typedef struct _patty_ax25_if patty_ax25_if;
#include <patty/client.h>
2015-07-18 12:06:25 -05:00
#include <patty/ax25/frame.h>
2015-07-24 22:28:39 +00:00
#include <patty/ax25/if.h>
Implement patty_ax25_if_driver Changes: * Implement patty_ax25_if_driver type, providing a vtable with pointers to methods implementing an AX.25 interface PHY * Implement patty_ax25_if_name() to return a pointer to the name string of an AX.25 interface * Decouple patty_kiss_tnc from src/if.c using patty_ax25_if_driver * Remove port input/output arguments from patty_kiss_tnc_send() and patty_kiss_tnc_recv(), respectively; use 0 as the default, but keep the port argument in patty_kiss_frame_send() * Implement patty_ax25_if_fd() to return file descriptor backing a PHY; use this rather than patty_kiss_tnc_fd() in src/server.c to further decouple interfaces from their implementation * Remove 'enum patty_ax25_if_type' type; refactor constructor patty_ax25_if_new() to no longer take this as an argument, but rather a patty_ax25_if_driver to use to instantiate the PHY with the information pointer passed * Break out patty_kiss_tnc code from src/kiss.c into src/tnc.c, leaving only patty_kiss_frame_send() in the original; this is needed to prevent a cyclic dependency within patty_ax25_sock and other areas * Rename patty_bin_if_config() to patty_bin_if_create(); a separate patty_bin_if_config() will likely be created later as necessary to change an existing interface * Split PHY-specific interface configuration code into separate delegates in bin/if.c * Implement usage of patty_error to better capture internal error states not currently representable with semantic error numbers while configuring and instantiating PHYs * Pass patty_error object to patty_bin_kiss_config() to receive detailed error information
2020-09-13 16:56:10 -04:00
#include <patty/kiss/tnc.h>
#include <patty/ax25/aprs_is.h>
2020-06-18 18:50:24 -04:00
#include <patty/ax25/route.h>
#include <patty/ax25/sock.h>
#include <patty/ax25/server.h>
#define PATTY_AX25_ADDR_CHAR_VALID(c) \
((c >= 0x20 && c <= 0x7e))
#define PATTY_AX25_ADDR_OCTET_LAST(c) \
((c & 0x01) == 0x01)
#define PATTY_AX25_ADDR_SSID_NUMBER(c) \
((c & 0x1e) >> 1)
#define PATTY_AX25_ADDR_SSID_C(c) \
((c & 0x80) == 0x80)
#define PATTY_AX25_ADDR_SSID_REPEATED(c) \
((c & 0x80) == 0x80)
2020-06-07 02:46:12 -04:00
int patty_ax25_pton(const char *callsign,
patty_ax25_addr *addr);
int patty_ax25_ntop(const patty_ax25_addr *addr,
char *dest,
size_t len);
2020-06-25 20:37:12 -04:00
void patty_ax25_addr_hash(uint32_t *hash,
const patty_ax25_addr *addr);
size_t patty_ax25_addr_copy(void *buf,
patty_ax25_addr *addr,
uint8_t ssid_flags);
2015-07-24 21:07:03 -05:00
#endif /* _PATTY_AX25_H */