Rework socket calls to use patty_ax25_addr
This commit is contained in:
parent
34afdba9e4
commit
548c7149fb
2 changed files with 6 additions and 18 deletions
|
@ -106,16 +106,14 @@ int patty_ax25_socket(patty_ax25 *ax25);
|
||||||
|
|
||||||
int patty_ax25_bind(patty_ax25 *ax25,
|
int patty_ax25_bind(patty_ax25 *ax25,
|
||||||
int socket,
|
int socket,
|
||||||
const char *callsign,
|
patty_ax25_addr *addr);
|
||||||
uint8_t ssid);
|
|
||||||
|
|
||||||
int patty_ax25_listen(patty_ax25 *ax25,
|
int patty_ax25_listen(patty_ax25 *ax25,
|
||||||
int socket);
|
int socket);
|
||||||
|
|
||||||
int patty_ax25_connect(patty_ax25 *ax25,
|
int patty_ax25_connect(patty_ax25 *ax25,
|
||||||
int socket,
|
int socket,
|
||||||
const char *callsign,
|
patty_ax25_addr *addr);
|
||||||
uint8_t ssid);
|
|
||||||
|
|
||||||
int patty_ax25_accept(patty_ax25 *ax25, int socket);
|
int patty_ax25_accept(patty_ax25 *ax25, int socket);
|
||||||
|
|
||||||
|
|
18
src/ax25.c
18
src/ax25.c
|
@ -294,8 +294,7 @@ error_malloc_sock:
|
||||||
|
|
||||||
int patty_ax25_bind(patty_ax25 *ax25,
|
int patty_ax25_bind(patty_ax25 *ax25,
|
||||||
int socket,
|
int socket,
|
||||||
const char *callsign,
|
patty_ax25_addr *addr) {
|
||||||
uint8_t ssid) {
|
|
||||||
patty_ax25_sock *sock;
|
patty_ax25_sock *sock;
|
||||||
|
|
||||||
if ((sock = sock_get_fd(ax25, socket)) == NULL) {
|
if ((sock = sock_get_fd(ax25, socket)) == NULL) {
|
||||||
|
@ -312,13 +311,10 @@ int patty_ax25_bind(patty_ax25 *ax25,
|
||||||
goto error_exists;
|
goto error_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (patty_ax25_pton(callsign, ssid, &sock->local) < 0) {
|
memcpy(&sock->local, addr, sizeof(*addr));
|
||||||
goto error_pton;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_pton:
|
|
||||||
error_exists:
|
error_exists:
|
||||||
error_sock_get_fd:
|
error_sock_get_fd:
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -349,8 +345,7 @@ error_sock_get_fd:
|
||||||
|
|
||||||
int patty_ax25_connect(patty_ax25 *ax25,
|
int patty_ax25_connect(patty_ax25 *ax25,
|
||||||
int socket,
|
int socket,
|
||||||
const char *callsign,
|
patty_ax25_addr *addr) {
|
||||||
uint8_t ssid) {
|
|
||||||
patty_ax25_sock *sock;
|
patty_ax25_sock *sock;
|
||||||
|
|
||||||
if ((sock = sock_get_fd(ax25, socket)) == NULL) {
|
if ((sock = sock_get_fd(ax25, socket)) == NULL) {
|
||||||
|
@ -363,15 +358,10 @@ int patty_ax25_connect(patty_ax25 *ax25,
|
||||||
goto error_exists;
|
goto error_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (patty_ax25_pton(callsign, ssid, &sock->remote) < 0) {
|
memcpy(&sock->remote, addr, sizeof(*addr));
|
||||||
errno = EINVAL;
|
|
||||||
|
|
||||||
goto error_pton;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_pton:
|
|
||||||
error_exists:
|
error_exists:
|
||||||
error_sock_get_fd:
|
error_sock_get_fd:
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue