1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
6 #include <linux/errno.h>
7 #include <linux/types.h>
8 #include <linux/socket.h>
10 #include <linux/kernel.h>
11 #include <linux/timer.h>
12 #include <linux/string.h>
13 #include <linux/sockios.h>
14 #include <linux/net.h>
16 #include <linux/inet.h>
17 #include <linux/netdevice.h>
18 #include <linux/skbuff.h>
20 #include <linux/uaccess.h>
21 #include <linux/fcntl.h>
23 #include <linux/interrupt.h>
26 * The following routines are taken from page 170 of the 7th ARRL Computer
27 * Networking Conference paper, as is the whole state machine.
30 void ax25_std_nr_error_recovery(ax25_cb *ax25)
32 ax25_std_establish_data_link(ax25);
35 void ax25_std_establish_data_link(ax25_cb *ax25)
37 ax25->condition = 0x00;
40 if (ax25->modulus == AX25_MODULUS)
41 ax25_send_control(ax25, AX25_SABM, AX25_POLLON, AX25_COMMAND);
43 ax25_send_control(ax25, AX25_SABME, AX25_POLLON, AX25_COMMAND);
45 ax25_calculate_t1(ax25);
46 ax25_stop_idletimer(ax25);
47 ax25_stop_t3timer(ax25);
48 ax25_stop_t2timer(ax25);
49 ax25_start_t1timer(ax25);
52 void ax25_std_transmit_enquiry(ax25_cb *ax25)
54 if (ax25->condition & AX25_COND_OWN_RX_BUSY)
55 ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_COMMAND);
57 ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_COMMAND);
59 ax25->condition &= ~AX25_COND_ACK_PENDING;
61 ax25_calculate_t1(ax25);
62 ax25_start_t1timer(ax25);
65 void ax25_std_enquiry_response(ax25_cb *ax25)
67 if (ax25->condition & AX25_COND_OWN_RX_BUSY)
68 ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_RESPONSE);
70 ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_RESPONSE);
72 ax25->condition &= ~AX25_COND_ACK_PENDING;
75 void ax25_std_timeout_response(ax25_cb *ax25)
77 if (ax25->condition & AX25_COND_OWN_RX_BUSY)
78 ax25_send_control(ax25, AX25_RNR, AX25_POLLOFF, AX25_RESPONSE);
80 ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
82 ax25->condition &= ~AX25_COND_ACK_PENDING;