125 lines
2.7 KiB
C
125 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>
|
|
|
|
#include <patty/ax25/defs.h>
|
|
#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;
|
|
time_t timer_response;
|
|
time_t timer_keepalive;
|
|
|
|
int n_maxlen;
|
|
int n_retry;
|
|
int n_window;
|
|
|
|
int seq_send;
|
|
int seq_recv;
|
|
|
|
patty_ax25_if * iface;
|
|
patty_ax25_address * local;
|
|
patty_ax25_address * remote;
|
|
} patty_ax25_sock;
|
|
|
|
typedef struct _patty_ax25_event {
|
|
enum patty_ax25_event_type type;
|
|
patty_ax25_sock * sock;
|
|
} patty_ax25_event;
|
|
|
|
struct _patty_ax25 {
|
|
patty_list * ifaces;
|
|
patty_list * socks;
|
|
|
|
int unix_fdmax;
|
|
fd_set unix_fds;
|
|
fd_set unix_fds_pending_read;
|
|
fd_set unix_fds_pending_write;
|
|
fd_set unix_fds_pending_error;
|
|
|
|
patty_dict * unix_fd_lookup;
|
|
|
|
patty_dict * fd_lookup;
|
|
int fd;
|
|
int current;
|
|
};
|
|
|
|
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 */
|