Just need to make a damn client/server test already
This commit is contained in:
parent
aa1ccd792a
commit
eb45bd192d
3 changed files with 46 additions and 7 deletions
|
@ -33,8 +33,11 @@ typedef struct _patty_ax25_if {
|
|||
|
||||
char name[8];
|
||||
|
||||
void *rx_buf;
|
||||
size_t rx_bufsz;
|
||||
void *rx_buf,
|
||||
*tx_buf;
|
||||
|
||||
size_t rx_bufsz,
|
||||
tx_bufsz;
|
||||
|
||||
patty_kiss_tnc *tnc;
|
||||
patty_list *addrs;
|
||||
|
|
10
src/if.c
10
src/if.c
|
@ -42,6 +42,12 @@ patty_ax25_if *patty_ax25_if_create(int opts, void *info) {
|
|||
iface->rx_bufsz = PATTY_AX25_IF_BUFSZ;
|
||||
}
|
||||
|
||||
if ((iface->tx_buf = malloc(PATTY_AX25_IF_BUFSZ)) == NULL) {
|
||||
goto error_malloc_tx_buf;
|
||||
} else {
|
||||
iface->tx_bufsz = PATTY_AX25_IF_BUFSZ;
|
||||
}
|
||||
|
||||
if ((iface->addrs = patty_list_new()) == NULL) {
|
||||
goto error_list_new;
|
||||
}
|
||||
|
@ -67,6 +73,9 @@ error_init:
|
|||
patty_list_destroy(iface->addrs);
|
||||
|
||||
error_list_new:
|
||||
free(iface->tx_buf);
|
||||
|
||||
error_malloc_tx_buf:
|
||||
free(iface->rx_buf);
|
||||
|
||||
error_malloc_rx_buf:
|
||||
|
@ -88,6 +97,7 @@ void patty_ax25_if_destroy(patty_ax25_if *iface) {
|
|||
|
||||
patty_list_destroy(iface->addrs);
|
||||
|
||||
free(iface->tx_buf);
|
||||
free(iface->rx_buf);
|
||||
free(iface);
|
||||
}
|
||||
|
|
36
src/server.c
36
src/server.c
|
@ -1000,25 +1000,51 @@ static int handle_sock(void *key,
|
|||
void *value,
|
||||
void *ctx) {
|
||||
patty_ax25_server *server = ctx;
|
||||
patty_ax25_sock *sock = value;
|
||||
int fd = (int)(key - NULL);
|
||||
patty_ax25_sock *sock = value;
|
||||
patty_ax25_route *route = sock->route;
|
||||
patty_ax25_if *iface = route->iface;
|
||||
|
||||
ssize_t readlen;
|
||||
int fd = (int)(key - NULL),
|
||||
fd_tnc = patty_kiss_tnc_fd(iface->tnc);
|
||||
|
||||
if (!FD_ISSET(fd, &server->fds_r)) {
|
||||
ssize_t len;
|
||||
|
||||
if (!FD_ISSET(fd, &server->fds_r) || !FD_ISSET(fd_tnc, &server->fds_w)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((len = read(fd, iface->tx_buf, iface->tx_bufsz)) < 0) {
|
||||
goto error_io;
|
||||
} else if (len == 0) {
|
||||
FD_CLR(fd, &server->fds_watch);
|
||||
|
||||
if (patty_dict_delete(server->socks_established,
|
||||
NULL + fd,
|
||||
sizeof(fd)) < 0) {
|
||||
goto error_dict_delete;
|
||||
}
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((len = patty_ax25_if_send(iface, iface->tx_buf, len)) < 0) {
|
||||
goto error_io;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Finish this
|
||||
*/
|
||||
|
||||
done:
|
||||
return 0;
|
||||
|
||||
error_dict_delete:
|
||||
error_io:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int handle_socks(patty_ax25_server *server) {
|
||||
return patty_dict_each(server->socks_by_fd,
|
||||
return patty_dict_each(server->socks_established,
|
||||
handle_sock,
|
||||
server);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue