diff options
Diffstat (limited to 'net/ax25/ax25_std_subr.c')
-rw-r--r-- | net/ax25/ax25_std_subr.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/net/ax25/ax25_std_subr.c b/net/ax25/ax25_std_subr.c new file mode 100644 index 000000000000..2b3c801ae486 --- /dev/null +++ b/net/ax25/ax25_std_subr.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation; either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk) | ||
8 | */ | ||
9 | #include <linux/errno.h> | ||
10 | #include <linux/types.h> | ||
11 | #include <linux/socket.h> | ||
12 | #include <linux/in.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/timer.h> | ||
16 | #include <linux/string.h> | ||
17 | #include <linux/sockios.h> | ||
18 | #include <linux/net.h> | ||
19 | #include <net/ax25.h> | ||
20 | #include <linux/inet.h> | ||
21 | #include <linux/netdevice.h> | ||
22 | #include <linux/skbuff.h> | ||
23 | #include <net/sock.h> | ||
24 | #include <asm/uaccess.h> | ||
25 | #include <asm/system.h> | ||
26 | #include <linux/fcntl.h> | ||
27 | #include <linux/mm.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | |||
30 | /* | ||
31 | * The following routines are taken from page 170 of the 7th ARRL Computer | ||
32 | * Networking Conference paper, as is the whole state machine. | ||
33 | */ | ||
34 | |||
35 | void ax25_std_nr_error_recovery(ax25_cb *ax25) | ||
36 | { | ||
37 | ax25_std_establish_data_link(ax25); | ||
38 | } | ||
39 | |||
40 | void ax25_std_establish_data_link(ax25_cb *ax25) | ||
41 | { | ||
42 | ax25->condition = 0x00; | ||
43 | ax25->n2count = 0; | ||
44 | |||
45 | if (ax25->modulus == AX25_MODULUS) | ||
46 | ax25_send_control(ax25, AX25_SABM, AX25_POLLON, AX25_COMMAND); | ||
47 | else | ||
48 | ax25_send_control(ax25, AX25_SABME, AX25_POLLON, AX25_COMMAND); | ||
49 | |||
50 | ax25_calculate_t1(ax25); | ||
51 | ax25_stop_idletimer(ax25); | ||
52 | ax25_stop_t3timer(ax25); | ||
53 | ax25_stop_t2timer(ax25); | ||
54 | ax25_start_t1timer(ax25); | ||
55 | } | ||
56 | |||
57 | void ax25_std_transmit_enquiry(ax25_cb *ax25) | ||
58 | { | ||
59 | if (ax25->condition & AX25_COND_OWN_RX_BUSY) | ||
60 | ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_COMMAND); | ||
61 | else | ||
62 | ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_COMMAND); | ||
63 | |||
64 | ax25->condition &= ~AX25_COND_ACK_PENDING; | ||
65 | |||
66 | ax25_calculate_t1(ax25); | ||
67 | ax25_start_t1timer(ax25); | ||
68 | } | ||
69 | |||
70 | void ax25_std_enquiry_response(ax25_cb *ax25) | ||
71 | { | ||
72 | if (ax25->condition & AX25_COND_OWN_RX_BUSY) | ||
73 | ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_RESPONSE); | ||
74 | else | ||
75 | ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_RESPONSE); | ||
76 | |||
77 | ax25->condition &= ~AX25_COND_ACK_PENDING; | ||
78 | } | ||
79 | |||
80 | void ax25_std_timeout_response(ax25_cb *ax25) | ||
81 | { | ||
82 | if (ax25->condition & AX25_COND_OWN_RX_BUSY) | ||
83 | ax25_send_control(ax25, AX25_RNR, AX25_POLLOFF, AX25_RESPONSE); | ||
84 | else | ||
85 | ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE); | ||
86 | |||
87 | ax25->condition &= ~AX25_COND_ACK_PENDING; | ||
88 | } | ||