^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright Darryl Miles G7LED (dlm@g7led.demon.co.uk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sockios.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <net/ax25.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/inet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <net/netrom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * This is where all NET/ROM frames pass, except for IP-over-NET/ROM which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * cannot be fragmented in this manner.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) void nr_output(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct sk_buff *skbn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned char transport[NR_TRANSPORT_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int err, frontlen, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if (skb->len - NR_TRANSPORT_LEN > NR_MAX_PACKET_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* Save a copy of the Transport Header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) skb_copy_from_linear_data(skb, transport, NR_TRANSPORT_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) skb_pull(skb, NR_TRANSPORT_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) frontlen = skb_headroom(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) while (skb->len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if ((skbn = sock_alloc_send_skb(sk, frontlen + NR_MAX_PACKET_SIZE, 0, &err)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) skb_reserve(skbn, frontlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) len = (NR_MAX_PACKET_SIZE > skb->len) ? skb->len : NR_MAX_PACKET_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Copy the user data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) skb_copy_from_linear_data(skb, skb_put(skbn, len), len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) skb_pull(skb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* Duplicate the Transport Header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) skb_push(skbn, NR_TRANSPORT_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) skb_copy_to_linear_data(skbn, transport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) NR_TRANSPORT_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (skb->len > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) skbn->data[4] |= NR_MORE_FLAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) skb_queue_tail(&sk->sk_write_queue, skbn); /* Throw it on the queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) skb_queue_tail(&sk->sk_write_queue, skb); /* Throw it on the queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) nr_kick(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * This procedure is passed a buffer descriptor for an iframe. It builds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * the rest of the control part of the frame and then writes it out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static void nr_send_iframe(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (skb == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) skb->data[2] = nr->vs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) skb->data[3] = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (nr->condition & NR_COND_OWN_RX_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) skb->data[4] |= NR_CHOKE_FLAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) nr_start_idletimer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) nr_transmit_buffer(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) void nr_send_nak_frame(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct sk_buff *skb, *skbn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if ((skb = skb_peek(&nr->ack_queue)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) skbn->data[2] = nr->va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) skbn->data[3] = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (nr->condition & NR_COND_OWN_RX_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) skbn->data[4] |= NR_CHOKE_FLAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) nr_transmit_buffer(sk, skbn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) nr->condition &= ~NR_COND_ACK_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) nr->vl = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) nr_stop_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) void nr_kick(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct sk_buff *skb, *skbn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned short start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (nr->state != NR_STATE_3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (nr->condition & NR_COND_PEER_RX_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (!skb_peek(&sk->sk_write_queue))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) start = (skb_peek(&nr->ack_queue) == NULL) ? nr->va : nr->vs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) end = (nr->va + nr->window) % NR_MODULUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (start == end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) nr->vs = start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * Transmit data until either we're out of data to send or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * the window is full.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * Dequeue the frame and copy it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) skb = skb_dequeue(&sk->sk_write_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) skb_queue_head(&sk->sk_write_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) skb_set_owner_w(skbn, sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * Transmit the frame copy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) nr_send_iframe(sk, skbn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) nr->vs = (nr->vs + 1) % NR_MODULUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * Requeue the original data frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) skb_queue_tail(&nr->ack_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) } while (nr->vs != end &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) (skb = skb_dequeue(&sk->sk_write_queue)) != NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) nr->vl = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) nr->condition &= ~NR_COND_ACK_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (!nr_t1timer_running(sk))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) nr_start_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) unsigned char *dptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * Add the protocol byte and network header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) dptr = skb_push(skb, NR_NETWORK_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) memcpy(dptr, &nr->source_addr, AX25_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) dptr[6] &= ~AX25_CBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) dptr[6] &= ~AX25_EBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) dptr[6] |= AX25_SSSID_SPARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) dptr += AX25_ADDR_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) memcpy(dptr, &nr->dest_addr, AX25_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) dptr[6] &= ~AX25_CBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) dptr[6] |= AX25_EBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) dptr[6] |= AX25_SSSID_SPARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) dptr += AX25_ADDR_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) *dptr++ = sysctl_netrom_network_ttl_initialiser;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (!nr_route_frame(skb, NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) nr_disconnect(sk, ENETUNREACH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * The following routines are taken from page 170 of the 7th ARRL Computer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * Networking Conference paper, as is the whole state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) void nr_establish_data_link(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) nr->condition = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) nr->n2count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) nr_write_internal(sk, NR_CONNREQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) nr_stop_t2timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) nr_stop_t4timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) nr_stop_idletimer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) nr_start_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * Never send a NAK when we are CHOKEd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void nr_enquiry_response(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) int frametype = NR_INFOACK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) if (nr->condition & NR_COND_OWN_RX_BUSY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) frametype |= NR_CHOKE_FLAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if (skb_peek(&nr->reseq_queue) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) frametype |= NR_NAK_FLAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) nr_write_internal(sk, frametype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) nr->vl = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) nr->condition &= ~NR_COND_ACK_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) void nr_check_iframes_acked(struct sock *sk, unsigned short nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct nr_sock *nrom = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) if (nrom->vs == nr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) nr_frames_acked(sk, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) nr_stop_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) nrom->n2count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (nrom->va != nr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) nr_frames_acked(sk, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) nr_start_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }