Linux Audio

Check our new training course

Loading...
v3.1
 
 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/timer.h>
15#include <linux/string.h>
16#include <linux/sockios.h>
17#include <linux/net.h>
18#include <net/ax25.h>
19#include <linux/inet.h>
20#include <linux/netdevice.h>
21#include <linux/skbuff.h>
22#include <net/sock.h>
23#include <asm/uaccess.h>
24#include <asm/system.h>
25#include <linux/fcntl.h>
26#include <linux/mm.h>
27#include <linux/interrupt.h>
28
29/*
30 * The following routines are taken from page 170 of the 7th ARRL Computer
31 * Networking Conference paper, as is the whole state machine.
32 */
33
34void ax25_std_nr_error_recovery(ax25_cb *ax25)
35{
36	ax25_std_establish_data_link(ax25);
37}
38
39void ax25_std_establish_data_link(ax25_cb *ax25)
40{
41	ax25->condition = 0x00;
42	ax25->n2count   = 0;
43
44	if (ax25->modulus == AX25_MODULUS)
45		ax25_send_control(ax25, AX25_SABM, AX25_POLLON, AX25_COMMAND);
46	else
47		ax25_send_control(ax25, AX25_SABME, AX25_POLLON, AX25_COMMAND);
48
49	ax25_calculate_t1(ax25);
50	ax25_stop_idletimer(ax25);
51	ax25_stop_t3timer(ax25);
52	ax25_stop_t2timer(ax25);
53	ax25_start_t1timer(ax25);
54}
55
56void ax25_std_transmit_enquiry(ax25_cb *ax25)
57{
58	if (ax25->condition & AX25_COND_OWN_RX_BUSY)
59		ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_COMMAND);
60	else
61		ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_COMMAND);
62
63	ax25->condition &= ~AX25_COND_ACK_PENDING;
64
65	ax25_calculate_t1(ax25);
66	ax25_start_t1timer(ax25);
67}
68
69void ax25_std_enquiry_response(ax25_cb *ax25)
70{
71	if (ax25->condition & AX25_COND_OWN_RX_BUSY)
72		ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_RESPONSE);
73	else
74		ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_RESPONSE);
75
76	ax25->condition &= ~AX25_COND_ACK_PENDING;
77}
78
79void ax25_std_timeout_response(ax25_cb *ax25)
80{
81	if (ax25->condition & AX25_COND_OWN_RX_BUSY)
82		ax25_send_control(ax25, AX25_RNR, AX25_POLLOFF, AX25_RESPONSE);
83	else
84		ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
85
86	ax25->condition &= ~AX25_COND_ACK_PENDING;
87}
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 
 
 
 
 3 *
 4 * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
 5 */
 6#include <linux/errno.h>
 7#include <linux/types.h>
 8#include <linux/socket.h>
 9#include <linux/in.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>
15#include <net/ax25.h>
16#include <linux/inet.h>
17#include <linux/netdevice.h>
18#include <linux/skbuff.h>
19#include <net/sock.h>
20#include <linux/uaccess.h>
 
21#include <linux/fcntl.h>
22#include <linux/mm.h>
23#include <linux/interrupt.h>
24
25/*
26 * The following routines are taken from page 170 of the 7th ARRL Computer
27 * Networking Conference paper, as is the whole state machine.
28 */
29
30void ax25_std_nr_error_recovery(ax25_cb *ax25)
31{
32	ax25_std_establish_data_link(ax25);
33}
34
35void ax25_std_establish_data_link(ax25_cb *ax25)
36{
37	ax25->condition = 0x00;
38	ax25->n2count   = 0;
39
40	if (ax25->modulus == AX25_MODULUS)
41		ax25_send_control(ax25, AX25_SABM, AX25_POLLON, AX25_COMMAND);
42	else
43		ax25_send_control(ax25, AX25_SABME, AX25_POLLON, AX25_COMMAND);
44
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);
50}
51
52void ax25_std_transmit_enquiry(ax25_cb *ax25)
53{
54	if (ax25->condition & AX25_COND_OWN_RX_BUSY)
55		ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_COMMAND);
56	else
57		ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_COMMAND);
58
59	ax25->condition &= ~AX25_COND_ACK_PENDING;
60
61	ax25_calculate_t1(ax25);
62	ax25_start_t1timer(ax25);
63}
64
65void ax25_std_enquiry_response(ax25_cb *ax25)
66{
67	if (ax25->condition & AX25_COND_OWN_RX_BUSY)
68		ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_RESPONSE);
69	else
70		ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_RESPONSE);
71
72	ax25->condition &= ~AX25_COND_ACK_PENDING;
73}
74
75void ax25_std_timeout_response(ax25_cb *ax25)
76{
77	if (ax25->condition & AX25_COND_OWN_RX_BUSY)
78		ax25_send_control(ax25, AX25_RNR, AX25_POLLOFF, AX25_RESPONSE);
79	else
80		ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
81
82	ax25->condition &= ~AX25_COND_ACK_PENDING;
83}