^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) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/sockios.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <net/ax25.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/inet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <net/tcp_states.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 routine purges all of the queues of frames.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void nr_clear_queues(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) skb_queue_purge(&sk->sk_write_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) skb_queue_purge(&nr->ack_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) skb_queue_purge(&nr->reseq_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) skb_queue_purge(&nr->frag_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * This routine purges the input queue of those frames that have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * acknowledged. This replaces the boxes labelled "V(a) <- N(r)" on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * SDL diagram.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) void nr_frames_acked(struct sock *sk, unsigned short nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct nr_sock *nrom = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * Remove all the ack-ed frames from the ack queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) if (nrom->va != nr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) while (skb_peek(&nrom->ack_queue) != NULL && nrom->va != nr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) skb = skb_dequeue(&nrom->ack_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) nrom->va = (nrom->va + 1) % NR_MODULUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Requeue all the un-ack-ed frames on the output queue to be picked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * up by nr_kick called from the timer. This arrangement handles the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * possibility of an empty output queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) void nr_requeue_frames(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct sk_buff *skb, *skb_prev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) while ((skb = skb_dequeue(&nr_sk(sk)->ack_queue)) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (skb_prev == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) skb_queue_head(&sk->sk_write_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) skb_append(skb_prev, skb, &sk->sk_write_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) skb_prev = skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * Validate that the value of nr is between va and vs. Return true or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * false for testing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int nr_validate_nr(struct sock *sk, unsigned short nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct nr_sock *nrom = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) unsigned short vc = nrom->va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) while (vc != nrom->vs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (nr == vc) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) vc = (vc + 1) % NR_MODULUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return nr == nrom->vs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * Check that ns is within the receive window.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int nr_in_rx_window(struct sock *sk, unsigned short ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) unsigned short vc = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) unsigned short vt = (nr->vl + nr->window) % NR_MODULUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) while (vc != vt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) if (ns == vc) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) vc = (vc + 1) % NR_MODULUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * This routine is called when the HDLC layer internally generates a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * control frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) void nr_write_internal(struct sock *sk, int frametype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) unsigned char *dptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) int len, timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) len = NR_NETWORK_LEN + NR_TRANSPORT_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) switch (frametype & 0x0F) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) case NR_CONNREQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) len += 17;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) case NR_CONNACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) len += (nr->bpqext) ? 2 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) case NR_DISCREQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) case NR_DISCACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) case NR_INFOACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) printk(KERN_ERR "NET/ROM: nr_write_internal - invalid frame type %d\n", frametype);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * Space for AX.25 and NET/ROM network header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) skb_reserve(skb, NR_NETWORK_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) dptr = skb_put(skb, skb_tailroom(skb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) switch (frametype & 0x0F) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) case NR_CONNREQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) timeout = nr->t1 / HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) *dptr++ = nr->my_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) *dptr++ = nr->my_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) *dptr++ = frametype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) *dptr++ = nr->window;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) memcpy(dptr, &nr->user_addr, AX25_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) dptr[6] &= ~AX25_CBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) dptr[6] &= ~AX25_EBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) dptr[6] |= AX25_SSSID_SPARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) dptr += AX25_ADDR_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) memcpy(dptr, &nr->source_addr, AX25_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) dptr[6] &= ~AX25_CBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) dptr[6] &= ~AX25_EBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) dptr[6] |= AX25_SSSID_SPARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) dptr += AX25_ADDR_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) *dptr++ = timeout % 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) *dptr++ = timeout / 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) case NR_CONNACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) *dptr++ = nr->your_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) *dptr++ = nr->your_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) *dptr++ = nr->my_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) *dptr++ = nr->my_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) *dptr++ = frametype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) *dptr++ = nr->window;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (nr->bpqext) *dptr++ = sysctl_netrom_network_ttl_initialiser;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) case NR_DISCREQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) case NR_DISCACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) *dptr++ = nr->your_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) *dptr++ = nr->your_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) *dptr++ = frametype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) case NR_INFOACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) *dptr++ = nr->your_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) *dptr++ = nr->your_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) *dptr++ = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) *dptr++ = frametype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) nr_transmit_buffer(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * This routine is called to send an error reply.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) void __nr_transmit_reply(struct sk_buff *skb, int mine, unsigned char cmdflags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct sk_buff *skbn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) unsigned char *dptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) len = NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if ((skbn = alloc_skb(len, GFP_ATOMIC)) == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) skb_reserve(skbn, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) dptr = skb_put(skbn, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) skb_copy_from_linear_data_offset(skb, 7, dptr, AX25_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) dptr[6] &= ~AX25_CBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) dptr[6] &= ~AX25_EBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) dptr[6] |= AX25_SSSID_SPARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) dptr += AX25_ADDR_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) skb_copy_from_linear_data(skb, dptr, AX25_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) dptr[6] &= ~AX25_CBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) dptr[6] |= AX25_EBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) dptr[6] |= AX25_SSSID_SPARE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) dptr += AX25_ADDR_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) *dptr++ = sysctl_netrom_network_ttl_initialiser;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (mine) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) *dptr++ = skb->data[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) *dptr++ = skb->data[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *dptr++ = skb->data[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) *dptr++ = skb->data[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) *dptr++ = cmdflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) *dptr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (!nr_route_frame(skbn, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) kfree_skb(skbn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) void nr_disconnect(struct sock *sk, int reason)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) nr_stop_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) nr_stop_t2timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) nr_stop_t4timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) nr_stop_idletimer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) nr_clear_queues(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) nr_sk(sk)->state = NR_STATE_0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) sk->sk_state = TCP_CLOSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) sk->sk_err = reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) sk->sk_shutdown |= SEND_SHUTDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (!sock_flag(sk, SOCK_DEAD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) sk->sk_state_change(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) sock_set_flag(sk, SOCK_DEAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }