Implement patty_ax25_sock_send_xid()
Implement patty_ax25_sock_send_xid() to send the current socket parameters to a remote peer
This commit is contained in:
parent
92ff180d57
commit
e95994bf19
2 changed files with 59 additions and 0 deletions
|
@ -121,6 +121,8 @@ ssize_t patty_ax25_sock_send_sabme(patty_ax25_sock *sock, int pf);
|
||||||
|
|
||||||
ssize_t patty_ax25_sock_send_disc(patty_ax25_sock *sock, int pf);
|
ssize_t patty_ax25_sock_send_disc(patty_ax25_sock *sock, int pf);
|
||||||
|
|
||||||
|
ssize_t patty_ax25_sock_send_xid(patty_ax25_sock *sock);
|
||||||
|
|
||||||
ssize_t patty_ax25_sock_write(patty_ax25_sock *sock,
|
ssize_t patty_ax25_sock_write(patty_ax25_sock *sock,
|
||||||
void *buf,
|
void *buf,
|
||||||
size_t len);
|
size_t len);
|
||||||
|
|
57
src/sock.c
57
src/sock.c
|
@ -377,6 +377,63 @@ ssize_t patty_ax25_sock_send_disc(patty_ax25_sock *sock, int pf) {
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t patty_ax25_sock_send_xid(patty_ax25_sock *sock) {
|
||||||
|
patty_ax25_params params;
|
||||||
|
ssize_t encoded;
|
||||||
|
|
||||||
|
if (sock->remote.callsign[0] == '\0') {
|
||||||
|
goto error_nopeer;
|
||||||
|
}
|
||||||
|
|
||||||
|
params.flags = PATTY_AX25_PARAM_CLASSES
|
||||||
|
| PATTY_AX25_PARAM_HDLC
|
||||||
|
| PATTY_AX25_PARAM_INFO_TX
|
||||||
|
| PATTY_AX25_PARAM_INFO_RX
|
||||||
|
| PATTY_AX25_PARAM_WINDOW_TX
|
||||||
|
| PATTY_AX25_PARAM_WINDOW_RX
|
||||||
|
| PATTY_AX25_PARAM_ACK
|
||||||
|
| PATTY_AX25_PARAM_RETRY;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: This value needs to come from the interface this socket is bound
|
||||||
|
* to
|
||||||
|
*/
|
||||||
|
params.classes = PATTY_AX25_PARAM_CLASSES_ABM
|
||||||
|
| PATTY_AX25_PARAM_CLASSES_HALF_DUPLEX;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: These flags should be part of each sock object
|
||||||
|
*/
|
||||||
|
params.hdlc = PATTY_AX25_PARAM_HDLC_REJ
|
||||||
|
| PATTY_AX25_PARAM_HDLC_SREJ
|
||||||
|
| PATTY_AX25_PARAM_HDLC_XADDR
|
||||||
|
| PATTY_AX25_PARAM_HDLC_MODULO_128
|
||||||
|
| PATTY_AX25_PARAM_HDLC_SYNC_TX;
|
||||||
|
|
||||||
|
params.info_tx = sock->n_maxlen_tx;
|
||||||
|
params.info_rx = sock->n_maxlen_rx;
|
||||||
|
params.window_tx = sock->n_window_tx;
|
||||||
|
params.window_rx = sock->n_window_rx;
|
||||||
|
params.ack = sock->n_ack;
|
||||||
|
params.retry = sock->n_retry;
|
||||||
|
|
||||||
|
if ((encoded = patty_ax25_frame_encode_xid(¶ms,
|
||||||
|
sock->buf,
|
||||||
|
sock->n_maxlen_tx)) < 0) {
|
||||||
|
goto error_frame_encode_xid;
|
||||||
|
}
|
||||||
|
|
||||||
|
return patty_ax25_sock_send(sock,
|
||||||
|
PATTY_AX25_FRAME_COMMAND,
|
||||||
|
control_u(PATTY_AX25_FRAME_XID, 0),
|
||||||
|
sock->buf,
|
||||||
|
encoded);
|
||||||
|
|
||||||
|
error_nopeer:
|
||||||
|
error_frame_encode_xid:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t patty_ax25_sock_write(patty_ax25_sock *sock,
|
ssize_t patty_ax25_sock_write(patty_ax25_sock *sock,
|
||||||
void *buf,
|
void *buf,
|
||||||
size_t len) {
|
size_t len) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue