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>
|
2020-07-25 01:54:59 -04:00
|
|
|
#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>
|
|
|
|
|
2020-09-18 14:33:16 -05:00
|
|
|
#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
|
2020-07-10 00:01:50 -04:00
|
|
|
#define PATTY_AX25_MAX_HOPS 8
|
2020-06-16 18:48:29 -04:00
|
|
|
#define PATTY_AX25_SOCK_PATH_SIZE 256
|
|
|
|
|
2020-07-10 00:01:50 -04:00
|
|
|
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 {
|
2020-09-18 14:33:16 -05:00
|
|
|
char callsign[PATTY_AX25_CALLSTRLEN];
|
2020-06-07 02:46:12 -04:00
|
|
|
uint8_t ssid;
|
|
|
|
} patty_ax25_addr;
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2020-07-17 22:57:23 -04:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2020-08-03 02:54:49 -04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2020-07-17 22:57:23 -04:00
|
|
|
enum patty_ax25_param_classes {
|
2020-08-03 02:54:49 -04:00
|
|
|
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
|
2020-07-17 22:57:23 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum patty_ax25_param_hdlc {
|
2020-08-03 02:54:49 -04:00
|
|
|
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
|
2020-07-17 22:57:23 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _patty_ax25_params {
|
2020-07-18 15:03:52 -04:00
|
|
|
uint32_t flags;
|
2020-07-17 22:57:23 -04:00
|
|
|
|
|
|
|
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;
|
2020-05-27 22:03:42 -04:00
|
|
|
|
Implement new patty client code
Implement new patty client code, replacing src/call.c with src/client.c
providing clients with an interface dealing with file descriptors valid
in their process space; this also obviates the need to open a Unix
domain socket to a patty server explicitly, and helps keep track of
sockets opened on the server, locally
Changes:
* Implement patty_client_new() to handle opening the server Unix
domain socket, and to allocate a dict for mapping server-side
sockets with current process file descriptors
* Reimplement all server calls in src/call.c around the new
patty_client type; calls which result in the creation of a
Unix98 PTY by the patty server now handle opening the local PTY
and setting the file descriptor to raw mode. Furthermore, these
calls deal exclusively in terms of current process file
descriptors
* Refactor src/server.c to use the new patty_client type and calls
* Refactor examples/client.c, examples/server.c, examples/ax25dump.c
to use the new patty_client type and calls
* Fix a bug in src/server.c, respond_accept() wherein a 0, rather
than the file descriptor of the socket, is sent to the client as a
return value
2020-08-01 20:21:01 -04:00
|
|
|
#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>
|
2020-09-13 16:56:10 -04:00
|
|
|
#include <patty/kiss/tnc.h>
|
2020-09-14 00:24:59 -04:00
|
|
|
#include <patty/ax25/aprs_is.h>
|
2020-06-18 18:50:24 -04:00
|
|
|
#include <patty/ax25/route.h>
|
2020-06-20 02:25:26 -04:00
|
|
|
#include <patty/ax25/sock.h>
|
2020-06-25 23:36:13 -04:00
|
|
|
#include <patty/ax25/server.h>
|
2015-08-09 09:50:12 -05:00
|
|
|
|
2020-07-10 00:01:50 -04:00
|
|
|
#define PATTY_AX25_ADDR_CHAR_VALID(c) \
|
2020-07-10 15:58:35 -04:00
|
|
|
((c >= 0x20 && c <= 0x7e))
|
2020-07-10 00:01:50 -04:00
|
|
|
|
|
|
|
#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);
|
|
|
|
|
2020-07-14 17:02:17 -04:00
|
|
|
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 */
|