Import 2.3.10pre5
[davej-history.git] / net / ax25 / ax25_std_subr.c
blob1b1d1c8bb7e8fc65292d1f61faf7c7ae023ea847
1 /*
2 * AX.25 release 037
4 * This code REQUIRES 2.1.15 or higher/ NET3.038
6 * This module:
7 * This module is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
12 * Most of this code is based on the SDL diagrams published in the 7th
13 * ARRL Computer Networking Conference papers. The diagrams have mistakes
14 * in them, but are mostly correct. Before you modify the code could you
15 * read the SDL diagrams as the code is not obvious and probably very
16 * easy to break;
18 * History
19 * AX.25 036 Jonathan(G4KLX) Split from ax25_out.c.
20 * AX.25 037 Jonathan(G4KLX) New timer architecture.
23 #include <linux/config.h>
24 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
25 #include <linux/errno.h>
26 #include <linux/types.h>
27 #include <linux/socket.h>
28 #include <linux/in.h>
29 #include <linux/kernel.h>
30 #include <linux/sched.h>
31 #include <linux/timer.h>
32 #include <linux/string.h>
33 #include <linux/sockios.h>
34 #include <linux/net.h>
35 #include <net/ax25.h>
36 #include <linux/inet.h>
37 #include <linux/netdevice.h>
38 #include <linux/skbuff.h>
39 #include <net/sock.h>
40 #include <asm/uaccess.h>
41 #include <asm/system.h>
42 #include <linux/fcntl.h>
43 #include <linux/mm.h>
44 #include <linux/interrupt.h>
47 * The following routines are taken from page 170 of the 7th ARRL Computer
48 * Networking Conference paper, as is the whole state machine.
51 void ax25_std_nr_error_recovery(ax25_cb *ax25)
53 ax25_std_establish_data_link(ax25);
56 void ax25_std_establish_data_link(ax25_cb *ax25)
58 ax25->condition = 0x00;
59 ax25->n2count = 0;
61 if (ax25->modulus == AX25_MODULUS)
62 ax25_send_control(ax25, AX25_SABM, AX25_POLLON, AX25_COMMAND);
63 else
64 ax25_send_control(ax25, AX25_SABME, AX25_POLLON, AX25_COMMAND);
66 ax25_calculate_t1(ax25);
67 ax25_stop_idletimer(ax25);
68 ax25_stop_t3timer(ax25);
69 ax25_stop_t2timer(ax25);
70 ax25_start_t1timer(ax25);
73 void ax25_std_transmit_enquiry(ax25_cb *ax25)
75 if (ax25->condition & AX25_COND_OWN_RX_BUSY)
76 ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_COMMAND);
77 else
78 ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_COMMAND);
80 ax25->condition &= ~AX25_COND_ACK_PENDING;
82 ax25_calculate_t1(ax25);
83 ax25_start_t1timer(ax25);
86 void ax25_std_enquiry_response(ax25_cb *ax25)
88 if (ax25->condition & AX25_COND_OWN_RX_BUSY)
89 ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_RESPONSE);
90 else
91 ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_RESPONSE);
93 ax25->condition &= ~AX25_COND_ACK_PENDING;
96 void ax25_std_timeout_response(ax25_cb *ax25)
98 if (ax25->condition & AX25_COND_OWN_RX_BUSY)
99 ax25_send_control(ax25, AX25_RNR, AX25_POLLOFF, AX25_RESPONSE);
100 else
101 ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
103 ax25->condition &= ~AX25_COND_ACK_PENDING;
106 #endif