Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *
0004  * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
0005  */
0006 #include <linux/errno.h>
0007 #include <linux/types.h>
0008 #include <linux/socket.h>
0009 #include <linux/in.h>
0010 #include <linux/kernel.h>
0011 #include <linux/timer.h>
0012 #include <linux/string.h>
0013 #include <linux/sockios.h>
0014 #include <linux/net.h>
0015 #include <net/ax25.h>
0016 #include <linux/inet.h>
0017 #include <linux/netdevice.h>
0018 #include <linux/skbuff.h>
0019 #include <net/sock.h>
0020 #include <linux/uaccess.h>
0021 #include <linux/fcntl.h>
0022 #include <linux/mm.h>
0023 #include <linux/interrupt.h>
0024 
0025 /*
0026  * The following routines are taken from page 170 of the 7th ARRL Computer
0027  * Networking Conference paper, as is the whole state machine.
0028  */
0029 
0030 void ax25_std_nr_error_recovery(ax25_cb *ax25)
0031 {
0032     ax25_std_establish_data_link(ax25);
0033 }
0034 
0035 void ax25_std_establish_data_link(ax25_cb *ax25)
0036 {
0037     ax25->condition = 0x00;
0038     ax25->n2count   = 0;
0039 
0040     if (ax25->modulus == AX25_MODULUS)
0041         ax25_send_control(ax25, AX25_SABM, AX25_POLLON, AX25_COMMAND);
0042     else
0043         ax25_send_control(ax25, AX25_SABME, AX25_POLLON, AX25_COMMAND);
0044 
0045     ax25_calculate_t1(ax25);
0046     ax25_stop_idletimer(ax25);
0047     ax25_stop_t3timer(ax25);
0048     ax25_stop_t2timer(ax25);
0049     ax25_start_t1timer(ax25);
0050 }
0051 
0052 void ax25_std_transmit_enquiry(ax25_cb *ax25)
0053 {
0054     if (ax25->condition & AX25_COND_OWN_RX_BUSY)
0055         ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_COMMAND);
0056     else
0057         ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_COMMAND);
0058 
0059     ax25->condition &= ~AX25_COND_ACK_PENDING;
0060 
0061     ax25_calculate_t1(ax25);
0062     ax25_start_t1timer(ax25);
0063 }
0064 
0065 void ax25_std_enquiry_response(ax25_cb *ax25)
0066 {
0067     if (ax25->condition & AX25_COND_OWN_RX_BUSY)
0068         ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_RESPONSE);
0069     else
0070         ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_RESPONSE);
0071 
0072     ax25->condition &= ~AX25_COND_ACK_PENDING;
0073 }
0074 
0075 void ax25_std_timeout_response(ax25_cb *ax25)
0076 {
0077     if (ax25->condition & AX25_COND_OWN_RX_BUSY)
0078         ax25_send_control(ax25, AX25_RNR, AX25_POLLOFF, AX25_RESPONSE);
0079     else
0080         ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
0081 
0082     ax25->condition &= ~AX25_COND_ACK_PENDING;
0083 }