126 lines
2.7 KiB
C
126 lines
2.7 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>
|
|
|
|
typedef struct _patty_ax25 patty_ax25;
|
|
|
|
#include <patty/ax25/macros.h>
|
|
#include <patty/ax25/proto.h>
|
|
#include <patty/ax25/address.h>
|
|
#include <patty/ax25/frame.h>
|
|
#include <patty/ax25/if.h>
|
|
|
|
#define PATTY_AX25_EVENT_QUEUE_SIZE 32
|
|
|
|
enum patty_ax25_event_type {
|
|
PATTY_AX25_EVENT_UNKNOWN,
|
|
PATTY_AX25_EVENT_RECV,
|
|
PATTY_AX25_EVENT_SEND,
|
|
PATTY_AX25_EVENT_READ,
|
|
PATTY_AX25_EVENT_WRITE,
|
|
PATTY_AX25_EVENT_ERROR
|
|
};
|
|
|
|
enum patty_ax25_sock_status {
|
|
PATTY_AX25_SOCK_OPEN,
|
|
PATTY_AX25_SOCK_LISTENING,
|
|
PATTY_AX25_SOCK_ESTABLISHED
|
|
};
|
|
|
|
enum patty_ax25_sock_mode {
|
|
PATTY_AX25_SOCK_DM,
|
|
PATTY_AX25_SOCK_SABM,
|
|
PATTY_AX25_SOCK_SABME
|
|
};
|
|
|
|
enum patty_ax25_sock_opts {
|
|
PATTY_AX25_SOCK_NONBLOCK = 1 << 0
|
|
};
|
|
|
|
typedef struct _patty_ax25_sock {
|
|
enum patty_ax25_sock_status status;
|
|
enum patty_ax25_sock_mode mode;
|
|
enum patty_ax25_sock_opts opts;
|
|
|
|
time_t timer_ack,
|
|
timer_response,
|
|
timer_keepalive;
|
|
|
|
unsigned int n_maxlen,
|
|
n_retry,
|
|
n_window;
|
|
|
|
unsigned int seq_send,
|
|
seq_recv;
|
|
|
|
patty_ax25_if *iface;
|
|
|
|
patty_ax25_address *local,
|
|
*remote;
|
|
} patty_ax25_sock;
|
|
|
|
typedef struct _patty_ax25_event {
|
|
enum patty_ax25_event_type type;
|
|
patty_ax25_sock * sock;
|
|
} patty_ax25_event;
|
|
|
|
typedef struct _patty_ax25 {
|
|
patty_list *ifaces,
|
|
*socks;
|
|
|
|
int fd,
|
|
current,
|
|
fdmax;
|
|
|
|
fd_set fds,
|
|
fds_pending_read,
|
|
fds_pending_write,
|
|
fds_pending_error;
|
|
|
|
patty_dict * fd_lookup;
|
|
} patty_ax25;
|
|
|
|
int patty_ax25_init(patty_ax25 *ax25);
|
|
|
|
void patty_ax25_stop(patty_ax25 *ax25);
|
|
|
|
int patty_ax25_open(patty_ax25 *ax25, const char *ifname);
|
|
|
|
int patty_ax25_socket(patty_ax25 *ax25);
|
|
|
|
int patty_ax25_bind(patty_ax25 *ax25,
|
|
int socket, const char *callsign, int ssid);
|
|
|
|
int patty_ax25_listen(patty_ax25 *ax25,
|
|
int socket, const char *callsign, int ssid);
|
|
|
|
int patty_ax25_connect(patty_ax25 *ax25,
|
|
int socket, const char *callsign, int ssid);
|
|
|
|
int patty_ax25_accept(patty_ax25 *ax25,
|
|
int socket);
|
|
|
|
int patty_ax25_close(patty_ax25 *ax25, int fd);
|
|
|
|
int patty_ax25_next_event(patty_ax25 *ax25,
|
|
patty_ax25_event *ev);
|
|
|
|
int patty_ax25_recv(patty_ax25 *ax25,
|
|
int fd, patty_ax25_frame *frame);
|
|
|
|
int patty_ax25_send(patty_ax25 *ax25,
|
|
int fd, patty_ax25_frame *frame);
|
|
|
|
ssize_t patty_ax25_read(patty_ax25 *ax25,
|
|
int fd, void *data, size_t len);
|
|
|
|
ssize_t patty_ax25_write(patty_ax25 *ax25,
|
|
int fd, const void *data, size_t len);
|
|
|
|
#endif /* _PATTY_AX25_H */
|