4 * This code REQUIRES 2.1.15 or higher/ NET3.038
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.
13 * AX.25 028a Jonathan(G4KLX) New state machine based on SDL diagrams.
14 * AX.25 028b Jonathan(G4KLX) Extracted AX25 control block from the
16 * AX.25 029 Alan(GW4PTS) Switched to KA9Q constant names.
17 * AX.25 031 Joerg(DL1BKE) Added DAMA support
18 * AX.25 032 Joerg(DL1BKE) Fixed DAMA timeout bug
19 * AX.25 033 Jonathan(G4KLX) Modularisation functions.
20 * AX.25 035 Frederic(F1OAT) Support for pseudo-digipeating.
21 * AX.25 036 Jonathan(G4KLX) Split from ax25_timer.c.
22 * AX.25 037 Jonathan(G4KLX) New timer architecture.
25 #include <linux/config.h>
26 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
27 #include <linux/errno.h>
28 #include <linux/types.h>
29 #include <linux/socket.h>
31 #include <linux/kernel.h>
32 #include <linux/sched.h>
33 #include <linux/timer.h>
34 #include <linux/string.h>
35 #include <linux/sockios.h>
36 #include <linux/net.h>
38 #include <linux/inet.h>
39 #include <linux/netdevice.h>
40 #include <linux/skbuff.h>
42 #include <asm/uaccess.h>
43 #include <asm/system.h>
44 #include <linux/fcntl.h>
46 #include <linux/interrupt.h>
48 void ax25_std_heartbeat_expiry(ax25_cb
*ax25
)
50 switch (ax25
->state
) {
53 /* Magic here: If we listen() and a new link dies before it
54 is accepted() it isn't 'dead' so doesn't get removed. */
55 if (ax25
->sk
== NULL
|| ax25
->sk
->destroy
|| (ax25
->sk
->state
== TCP_LISTEN
&& ax25
->sk
->dead
)) {
56 ax25_destroy_socket(ax25
);
64 * Check the state of the receive buffer.
66 if (ax25
->sk
!= NULL
) {
67 if (atomic_read(&ax25
->sk
->rmem_alloc
) < (ax25
->sk
->rcvbuf
/ 2) &&
68 (ax25
->condition
& AX25_COND_OWN_RX_BUSY
)) {
69 ax25
->condition
&= ~AX25_COND_OWN_RX_BUSY
;
70 ax25
->condition
&= ~AX25_COND_ACK_PENDING
;
71 ax25_send_control(ax25
, AX25_RR
, AX25_POLLOFF
, AX25_RESPONSE
);
77 ax25_start_heartbeat(ax25
);
80 void ax25_std_t2timer_expiry(ax25_cb
*ax25
)
82 if (ax25
->condition
& AX25_COND_ACK_PENDING
) {
83 ax25
->condition
&= ~AX25_COND_ACK_PENDING
;
84 ax25_std_timeout_response(ax25
);
88 void ax25_std_t3timer_expiry(ax25_cb
*ax25
)
91 ax25_std_transmit_enquiry(ax25
);
92 ax25
->state
= AX25_STATE_4
;
95 void ax25_std_idletimer_expiry(ax25_cb
*ax25
)
97 ax25_clear_queues(ax25
);
100 ax25_send_control(ax25
, AX25_DISC
, AX25_POLLON
, AX25_COMMAND
);
101 ax25
->state
= AX25_STATE_2
;
103 ax25_calculate_t1(ax25
);
104 ax25_start_t1timer(ax25
);
105 ax25_stop_t2timer(ax25
);
106 ax25_stop_t3timer(ax25
);
108 if (ax25
->sk
!= NULL
) {
109 ax25
->sk
->state
= TCP_CLOSE
;
111 ax25
->sk
->shutdown
|= SEND_SHUTDOWN
;
113 ax25
->sk
->state_change(ax25
->sk
);
118 void ax25_std_t1timer_expiry(ax25_cb
*ax25
)
120 switch (ax25
->state
) {
122 if (ax25
->n2count
== ax25
->n2
) {
123 if (ax25
->modulus
== AX25_MODULUS
) {
124 ax25_disconnect(ax25
, ETIMEDOUT
);
127 ax25
->modulus
= AX25_MODULUS
;
128 ax25
->window
= ax25
->ax25_dev
->values
[AX25_VALUES_WINDOW
];
130 ax25_send_control(ax25
, AX25_SABM
, AX25_POLLON
, AX25_COMMAND
);
134 if (ax25
->modulus
== AX25_MODULUS
)
135 ax25_send_control(ax25
, AX25_SABM
, AX25_POLLON
, AX25_COMMAND
);
137 ax25_send_control(ax25
, AX25_SABME
, AX25_POLLON
, AX25_COMMAND
);
142 if (ax25
->n2count
== ax25
->n2
) {
143 ax25_send_control(ax25
, AX25_DISC
, AX25_POLLON
, AX25_COMMAND
);
144 ax25_disconnect(ax25
, ETIMEDOUT
);
148 ax25_send_control(ax25
, AX25_DISC
, AX25_POLLON
, AX25_COMMAND
);
154 ax25_std_transmit_enquiry(ax25
);
155 ax25
->state
= AX25_STATE_4
;
159 if (ax25
->n2count
== ax25
->n2
) {
160 ax25_send_control(ax25
, AX25_DM
, AX25_POLLON
, AX25_RESPONSE
);
161 ax25_disconnect(ax25
, ETIMEDOUT
);
165 ax25_std_transmit_enquiry(ax25
);
170 ax25_calculate_t1(ax25
);
171 ax25_start_t1timer(ax25
);