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 <patty/kiss.h>
|
|
|
|
#include <patty/dict.h>
|
|
|
|
|
2015-07-17 00:45:14 +00:00
|
|
|
#include <patty/ax25/macros.h>
|
2015-07-18 12:06:25 -05:00
|
|
|
#include <patty/ax25/proto.h>
|
|
|
|
#include <patty/ax25/frame.h>
|
2015-07-03 03:02:22 +00:00
|
|
|
|
2015-07-20 21:27:35 +00:00
|
|
|
#define PATTY_AX25_IF_OPT_TYPE_MASK 0x1f
|
|
|
|
|
2015-07-20 23:21:45 -05:00
|
|
|
#define PATTY_AX25_IF_OPT_TYPE(n) \
|
|
|
|
((n) & PATTY_AX25_IF_OPT_TYPE_MASK)
|
|
|
|
|
2015-07-20 21:27:35 +00:00
|
|
|
enum patty_ax25_if_type {
|
|
|
|
PATTY_AX25_IF_UNKNOWN = 0x00,
|
|
|
|
PATTY_AX25_IF_KISS_TNC_TTY = 0x01,
|
|
|
|
PATTY_AX25_IF_KISS_TNC_PORT = 0x02,
|
|
|
|
PATTY_AX25_IF_KISS_TNC_I2C = 0x04,
|
|
|
|
PATTY_AX25_IF_KISS_TNC_SPI = 0x08,
|
|
|
|
PATTY_AX25_IF_SOFT_TNC = 0x10
|
|
|
|
};
|
|
|
|
|
2015-07-20 02:22:41 -05:00
|
|
|
typedef struct _patty_ax25_stats {
|
|
|
|
size_t frame_tx;
|
|
|
|
size_t frame_rx;
|
|
|
|
size_t frame_drop;
|
|
|
|
} patty_ax25_stats;
|
|
|
|
|
|
|
|
typedef struct _patty_ax25_address patty_ax25_port;
|
|
|
|
|
|
|
|
typedef struct _patty_ax25_link {
|
|
|
|
patty_ax25_port local;
|
|
|
|
patty_ax25_port remote;
|
|
|
|
patty_ax25_stats stats;
|
|
|
|
} patty_ax25_link;
|
|
|
|
|
2015-07-20 21:27:35 +00:00
|
|
|
typedef struct _patty_ax25_if {
|
|
|
|
patty_kiss_tnc * tnc;
|
|
|
|
patty_ax25_stats stats;
|
|
|
|
patty_dict * ports;
|
|
|
|
} patty_ax25_if;
|
|
|
|
|
2015-07-20 02:22:41 -05:00
|
|
|
typedef struct _patty_ax25 {
|
2015-07-20 23:30:44 -05:00
|
|
|
patty_dict * ifaces; /* Key: AX.25 interface name */
|
|
|
|
patty_dict * ports; /* Key: Integer port descriptor */
|
|
|
|
patty_dict * links; /* Key: Integer link descriptor */
|
2015-07-20 02:22:41 -05:00
|
|
|
} patty_ax25;
|
|
|
|
|
2015-07-20 22:33:59 -05:00
|
|
|
int patty_ax25_init(patty_ax25 *ax25);
|
|
|
|
|
|
|
|
void patty_ax25_finish(patty_ax25 *ax25);
|
2015-07-20 21:27:35 +00:00
|
|
|
|
2015-07-20 23:21:45 -05:00
|
|
|
int patty_ax25_create_if(patty_ax25 *ax25, int opts, void *info);
|
2015-07-20 21:27:35 +00:00
|
|
|
|
2015-07-20 22:33:59 -05:00
|
|
|
int patty_ax25_each_if(patty_ax25 *ax25,
|
|
|
|
int (*callback)(patty_ax25_if *, void *), void *ctx);
|
|
|
|
|
2015-07-20 21:27:35 +00:00
|
|
|
int patty_ax25_get_if(patty_ax25 *ax25, const char *name);
|
|
|
|
|
|
|
|
int patty_ax25_destroy_if(patty_ax25 *ax25, int iface);
|
|
|
|
|
|
|
|
int patty_ax25_listen(patty_ax25 *ax25, int iface,
|
|
|
|
const char *callsign, int ssid);
|
|
|
|
|
|
|
|
int patty_ax25_shutdown(patty_ax25 *ax25, int port);
|
|
|
|
|
|
|
|
int patty_ax25_connect(patty_ax25 *ax25, int port,
|
|
|
|
const char *callsign, int ssid);
|
|
|
|
|
|
|
|
int patty_ax25_close(patty_ax25 *ax25, int link);
|
|
|
|
|
|
|
|
int patty_ax25_recv(patty_ax25 *ax25, int iface, patty_ax25_frame *frame);
|
|
|
|
|
|
|
|
int patty_ax25_send(patty_ax25 *ax25, int iface,
|
|
|
|
const patty_ax25_frame *frame);
|
|
|
|
|
2015-07-20 22:33:59 -05:00
|
|
|
ssize_t patty_ax25_read(patty_ax25 *ax25, int link, void *data, size_t len);
|
|
|
|
|
|
|
|
ssize_t patty_ax25_write(patty_ax25 *ax25, int link,
|
|
|
|
const void *data, size_t len);
|
|
|
|
|
2015-07-20 02:22:41 -05:00
|
|
|
#endif /* _PATTY_AX25_IF */
|