148 lines
3.3 KiB
C
148 lines
3.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>
|
|
|
|
#pragma pack(push)
|
|
#pragma pack(1)
|
|
|
|
typedef struct _patty_ax25_addr {
|
|
char callsign[6];
|
|
uint8_t ssid;
|
|
} patty_ax25_addr;
|
|
|
|
#pragma pack(pop)
|
|
|
|
typedef struct _patty_ax25 patty_ax25;
|
|
typedef struct _patty_ax25_if patty_ax25_if;
|
|
|
|
#include <patty/ax25/macros.h>
|
|
#include <patty/ax25/proto.h>
|
|
#include <patty/ax25/frame.h>
|
|
#include <patty/ax25/if.h>
|
|
|
|
#define PATTY_AX25_ADDRESS_SIZE 7
|
|
#define PATTY_AX25_CALLSIGN_LEN 6
|
|
|
|
enum patty_ax25_sock_status {
|
|
PATTY_AX25_SOCK_CLOSED,
|
|
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;
|
|
|
|
int fd;
|
|
|
|
patty_ax25_if *iface;
|
|
|
|
patty_ax25_addr local,
|
|
remote,
|
|
repeaters[PATTY_AX25_MAX_HOPS];
|
|
|
|
unsigned int hops;
|
|
} patty_ax25_sock;
|
|
|
|
typedef struct _patty_ax25 {
|
|
patty_list *ifaces;
|
|
|
|
patty_dict *socks,
|
|
*socks_by_addrpair;
|
|
|
|
int fd,
|
|
fdmax;
|
|
|
|
fd_set fds,
|
|
fds_r,
|
|
fds_w;
|
|
} patty_ax25;
|
|
|
|
int patty_ax25_init(patty_ax25 *ax25);
|
|
|
|
void patty_ax25_stop(patty_ax25 *ax25);
|
|
|
|
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);
|
|
|
|
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,
|
|
patty_ax25_addr *addr);
|
|
|
|
int patty_ax25_listen(patty_ax25 *ax25,
|
|
int socket);
|
|
|
|
int patty_ax25_accept(patty_ax25 *ax25,
|
|
int socket);
|
|
|
|
int patty_ax25_connect(patty_ax25 *ax25,
|
|
int socket,
|
|
patty_ax25_addr *addr);
|
|
|
|
int patty_ax25_close(patty_ax25 *ax25, int socket);
|
|
|
|
/*int patty_ax25_next_event(patty_ax25 *ax25,
|
|
patty_ax25_event *ev);*/
|
|
|
|
ssize_t patty_ax25_sendto(patty_ax25 *ax25,
|
|
int socket,
|
|
const void *buf,
|
|
size_t len,
|
|
patty_ax25_addr *addr);
|
|
|
|
int patty_ax25_recvfrom(patty_ax25 *ax25,
|
|
int socket,
|
|
void *buf,
|
|
size_t len,
|
|
patty_ax25_addr *addr);
|
|
|
|
ssize_t patty_ax25_read(patty_ax25 *ax25,
|
|
int socket,
|
|
void *buf,
|
|
size_t len);
|
|
|
|
ssize_t patty_ax25_write(patty_ax25 *ax25,
|
|
int socket,
|
|
const void *buf,
|
|
size_t len);
|
|
|
|
#endif /* _PATTY_AX25_H */
|