128 lines
3.5 KiB
C
128 lines
3.5 KiB
C
#ifndef _PATTY_AX25_SOCK_H
|
|
#define _PATTY_AX25_SOCK_H
|
|
|
|
#define PATTY_AX25_SOCK_BUFSZ 328
|
|
#define PATTY_AX25_SOCK_SLOTS_SABM 8
|
|
#define PATTY_AX25_SOCK_SLOTS_SABME 128
|
|
|
|
#define PATTY_AX25_SOCK_DEFAULT_MAXLEN 256
|
|
#define PATTY_AX25_SOCK_DEFAULT_WINDOW 8
|
|
#define PATTY_AX25_SOCK_DEFAULT_SLOTS PATTY_AX25_SOCK_SLOTS_SABM
|
|
|
|
enum patty_ax25_sock_type {
|
|
PATTY_AX25_SOCK_STREAM,
|
|
PATTY_AX25_SOCK_RAW
|
|
};
|
|
|
|
enum patty_ax25_sock_status {
|
|
PATTY_AX25_SOCK_CLOSED,
|
|
PATTY_AX25_SOCK_LISTENING,
|
|
PATTY_AX25_SOCK_PENDING_ACCEPT,
|
|
PATTY_AX25_SOCK_PENDING_CONNECT,
|
|
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_opt {
|
|
PATTY_AX25_SOCK_IF
|
|
};
|
|
|
|
enum patty_ax25_sock_flags {
|
|
PATTY_AX25_SOCK_SREJ = (1 << 2),
|
|
PATTY_AX25_SOCK_MODULO_8 = (1 << 3),
|
|
PATTY_AX25_SOCK_MODULO_128 = (1 << 4),
|
|
PATTY_AX25_SOCK_TEST = (1 << 5),
|
|
PATTY_AX25_SOCK_SYNC_TX = (1 << 6),
|
|
PATTY_AX25_SOCK_SEGMENTER = (1 << 7)
|
|
};
|
|
|
|
typedef struct _patty_ax25_sock {
|
|
enum patty_ax25_proto proto;
|
|
enum patty_ax25_sock_type type;
|
|
enum patty_ax25_sock_status status;
|
|
enum patty_ax25_sock_mode mode;
|
|
|
|
time_t timer_ack,
|
|
timer_response,
|
|
timer_keepalive;
|
|
|
|
size_t n_maxlen,
|
|
n_retry,
|
|
n_window;
|
|
|
|
unsigned int seq_send,
|
|
seq_recv;
|
|
|
|
unsigned int flags;
|
|
|
|
int fd;
|
|
char path[PATTY_AX25_SOCK_PATH_SIZE];
|
|
|
|
void *rx_buf;
|
|
void *tx_slots;
|
|
|
|
patty_ax25_if *iface;
|
|
|
|
patty_ax25_addr local,
|
|
remote,
|
|
repeaters[PATTY_AX25_MAX_HOPS];
|
|
|
|
unsigned int hops;
|
|
} patty_ax25_sock;
|
|
|
|
patty_ax25_sock *patty_ax25_sock_new(enum patty_ax25_proto proto,
|
|
enum patty_ax25_sock_type type);
|
|
|
|
void patty_ax25_sock_reset(patty_ax25_sock *sock);
|
|
|
|
void patty_ax25_sock_destroy(patty_ax25_sock *sock);
|
|
|
|
int patty_ax25_sock_mode_set(patty_ax25_sock *sock,
|
|
enum patty_ax25_sock_mode mode);
|
|
|
|
char *patty_ax25_sock_pty(patty_ax25_sock *sock);
|
|
|
|
int patty_ax25_sock_bind_if(patty_ax25_sock *sock,
|
|
patty_ax25_if *iface);
|
|
|
|
void patty_ax25_sock_seq_send_incr(patty_ax25_sock *sock);
|
|
|
|
void patty_ax25_sock_seq_recv_incr(patty_ax25_sock *sock);
|
|
|
|
ssize_t patty_ax25_sock_send(patty_ax25_sock *sock,
|
|
enum patty_ax25_frame_cr cr,
|
|
uint16_t control,
|
|
void *info,
|
|
size_t infolen);
|
|
|
|
ssize_t patty_ax25_sock_resend(patty_ax25_sock *sock,
|
|
unsigned int seq);
|
|
|
|
ssize_t patty_ax25_sock_send_rr(patty_ax25_sock *sock,
|
|
enum patty_ax25_frame_cr cr);
|
|
|
|
ssize_t patty_ax25_sock_send_rnr(patty_ax25_sock *sock,
|
|
enum patty_ax25_frame_cr cr);
|
|
|
|
ssize_t patty_ax25_sock_send_rej(patty_ax25_sock *sock,
|
|
enum patty_ax25_frame_cr cr);
|
|
|
|
ssize_t patty_ax25_sock_send_srej(patty_ax25_sock *sock,
|
|
enum patty_ax25_frame_cr cr);
|
|
|
|
ssize_t patty_ax25_sock_send_sabm(patty_ax25_sock *sock, int flag);
|
|
|
|
ssize_t patty_ax25_sock_send_sabme(patty_ax25_sock *sock, int flag);
|
|
|
|
ssize_t patty_ax25_sock_send_disc(patty_ax25_sock *sock, int flag);
|
|
|
|
ssize_t patty_ax25_sock_write(patty_ax25_sock *sock,
|
|
void *buf,
|
|
size_t len);
|
|
|
|
#endif /* _PATTY_AX25_SOCK_H */
|