patty/include/patty/ax25.h
XANTRONIX Development 79d1393e74 Implement patty_ax25_addr_copy()
Implement patty_ax25_addr_copy() as a means to copy a patty_ax25_addr
object from one location in memory to another, ensuring that the SSID
field only contains at minimum the station identifier (0-15) and the
reserved bits 0x60
2024-03-01 00:20:46 -05:00

91 lines
2.3 KiB
C

#ifndef _PATTY_AX25_H
#define _PATTY_AX25_H
#include <stdint.h>
#include <sys/types.h>
#include <patty/kiss.h>
#include <patty/list.h>
#include <patty/dict.h>
#define PATTY_AX25_ADDR_SIZE 7
#define PATTY_AX25_CALLSIGN_LEN 6
#define PATTY_AX25_IF_NAME_SIZE 8
#define PATTY_AX25_MAX_HOPS 8
#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
};
#pragma pack(push)
#pragma pack(1)
typedef struct _patty_ax25_addr {
char callsign[PATTY_AX25_CALLSIGN_LEN];
uint8_t ssid;
} patty_ax25_addr;
#pragma pack(pop)
typedef struct _patty_ax25_if patty_ax25_if;
#include <patty/ax25/frame.h>
#include <patty/ax25/call.h>
#include <patty/ax25/if.h>
#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)
int patty_ax25_pton(const char *callsign,
uint8_t ssid,
patty_ax25_addr *addr);
int patty_ax25_ntop(const patty_ax25_addr *addr,
char *dest,
uint8_t *ssid,
size_t len);
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);
#endif /* _PATTY_AX25_H */