Add SOCK_PARAMS to patty_client_setsockopt()
Add SOCK_PARAMS to patty_client_setsockopt() to allow for setting (presently) the MTU and TX window of a given socket to accommodate the needs of specific remote stations
This commit is contained in:
parent
4d47b62f5f
commit
eb071de230
4 changed files with 36 additions and 0 deletions
|
@ -64,6 +64,7 @@ enum patty_ax25_sock_flow {
|
|||
};
|
||||
|
||||
enum patty_ax25_sock_opt {
|
||||
PATTY_AX25_SOCK_PARAMS,
|
||||
PATTY_AX25_SOCK_IF
|
||||
};
|
||||
|
||||
|
@ -127,6 +128,10 @@ void patty_ax25_sock_init(patty_ax25_sock *sock);
|
|||
|
||||
void patty_ax25_sock_reset(patty_ax25_sock *sock);
|
||||
|
||||
void patty_ax25_sock_mtu_set(patty_ax25_sock *sock, size_t mtu);
|
||||
|
||||
void patty_ax25_sock_window_set(patty_ax25_sock *sock, size_t window);
|
||||
|
||||
void patty_ax25_sock_params_upgrade(patty_ax25_sock *sock);
|
||||
|
||||
void patty_ax25_sock_params_max(patty_ax25_sock *sock);
|
||||
|
|
|
@ -56,6 +56,11 @@ typedef struct _patty_client_setsockopt_request {
|
|||
size_t len;
|
||||
} patty_client_setsockopt_request;
|
||||
|
||||
typedef struct _patty_client_setsockopt_params {
|
||||
size_t mtu,
|
||||
window;
|
||||
} patty_client_setsockopt_params;
|
||||
|
||||
typedef struct _patty_client_setsockopt_if {
|
||||
char name[8];
|
||||
int status;
|
||||
|
|
18
src/server.c
18
src/server.c
|
@ -590,6 +590,23 @@ static int server_setsockopt(patty_ax25_server *server,
|
|||
}
|
||||
|
||||
switch (request.opt) {
|
||||
case PATTY_AX25_SOCK_PARAMS: {
|
||||
patty_client_setsockopt_params data;
|
||||
|
||||
if (read(client, &data, request.len) < 0) {
|
||||
goto error_read;
|
||||
}
|
||||
|
||||
if (data.mtu) patty_ax25_sock_mtu_set(sock, data.mtu);
|
||||
if (data.window) patty_ax25_sock_window_set(sock, data.window);
|
||||
|
||||
if (patty_ax25_sock_realloc_bufs(sock) < 0) {
|
||||
goto error_realloc_bufs;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PATTY_AX25_SOCK_IF: {
|
||||
patty_client_setsockopt_if data;
|
||||
patty_ax25_if *iface;
|
||||
|
@ -639,6 +656,7 @@ error_invalid_type:
|
|||
error_invalid_opt:
|
||||
return write(client, &response, sizeof(response));
|
||||
|
||||
error_realloc_bufs:
|
||||
error_read:
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -227,6 +227,14 @@ void patty_ax25_sock_reset(patty_ax25_sock *sock) {
|
|||
patty_timer_clear(&sock->timer_t3);
|
||||
}
|
||||
|
||||
void patty_ax25_sock_mtu_set(patty_ax25_sock *sock, size_t mtu) {
|
||||
sock->n_maxlen_tx = mtu;
|
||||
}
|
||||
|
||||
void patty_ax25_sock_window_set(patty_ax25_sock *sock, size_t window) {
|
||||
sock->n_window_tx = window;
|
||||
}
|
||||
|
||||
void patty_ax25_sock_params_upgrade(patty_ax25_sock *sock) {
|
||||
if (sock->version >= PATTY_AX25_2_2) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue