Minor code deduplication in src/sock.c
Minor code deduplication in src/sock.c for handling SABM vs SABME sequence numbers
This commit is contained in:
parent
697ade0afa
commit
56b8b90727
1 changed files with 6 additions and 4 deletions
10
src/sock.c
10
src/sock.c
|
@ -56,18 +56,20 @@ static inline size_t rx_bufsz(patty_ax25_sock *sock) {
|
||||||
return PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_rx;
|
return PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_rx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline size_t tx_slots(patty_ax25_sock *sock) {
|
||||||
|
return sock->mode == PATTY_AX25_SOCK_SABME? 128: 8;
|
||||||
|
}
|
||||||
|
|
||||||
static inline size_t tx_slot_size(patty_ax25_sock *sock) {
|
static inline size_t tx_slot_size(patty_ax25_sock *sock) {
|
||||||
return sizeof(struct slot) + PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_tx;
|
return sizeof(struct slot) + PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t tx_slots_size(patty_ax25_sock *sock) {
|
static inline size_t tx_slots_size(patty_ax25_sock *sock) {
|
||||||
size_t slots = sock->mode == PATTY_AX25_SOCK_SABME? 128: 8;
|
return tx_slots(sock) * tx_slot_size(sock);
|
||||||
|
|
||||||
return slots * tx_slot_size(sock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int tx_seq(patty_ax25_sock *sock, int seq) {
|
static inline int tx_seq(patty_ax25_sock *sock, int seq) {
|
||||||
return sock->mode == PATTY_AX25_SOCK_SABME? seq % 128: seq % 8;
|
return seq % tx_slots(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct slot *tx_slot(patty_ax25_sock *sock, int seq) {
|
static inline struct slot *tx_slot(patty_ax25_sock *sock, int seq) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue