xref: /openbmc/linux/include/net/rose.h (revision 2df91e39)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *	Declarations of Rose type objects.
4  *
5  *	Jonathan Naylor G4KLX	25/8/96
6  */
7 
8 #ifndef _ROSE_H
9 #define _ROSE_H
10 
11 #include <linux/rose.h>
12 #include <net/ax25.h>
13 #include <net/sock.h>
14 
15 #define	ROSE_ADDR_LEN			5
16 
17 #define	ROSE_MIN_LEN			3
18 
19 #define	ROSE_CALL_REQ_ADDR_LEN_OFF	3
20 #define	ROSE_CALL_REQ_ADDR_LEN_VAL	0xAA	/* each address is 10 digits */
21 #define	ROSE_CALL_REQ_DEST_ADDR_OFF	4
22 #define	ROSE_CALL_REQ_SRC_ADDR_OFF	9
23 #define	ROSE_CALL_REQ_FACILITIES_OFF	14
24 
25 #define	ROSE_GFI			0x10
26 #define	ROSE_Q_BIT			0x80
27 #define	ROSE_D_BIT			0x40
28 #define	ROSE_M_BIT			0x10
29 
30 #define	ROSE_CALL_REQUEST		0x0B
31 #define	ROSE_CALL_ACCEPTED		0x0F
32 #define	ROSE_CLEAR_REQUEST		0x13
33 #define	ROSE_CLEAR_CONFIRMATION		0x17
34 #define	ROSE_DATA			0x00
35 #define	ROSE_INTERRUPT			0x23
36 #define	ROSE_INTERRUPT_CONFIRMATION	0x27
37 #define	ROSE_RR				0x01
38 #define	ROSE_RNR			0x05
39 #define	ROSE_REJ			0x09
40 #define	ROSE_RESET_REQUEST		0x1B
41 #define	ROSE_RESET_CONFIRMATION		0x1F
42 #define	ROSE_REGISTRATION_REQUEST	0xF3
43 #define	ROSE_REGISTRATION_CONFIRMATION	0xF7
44 #define	ROSE_RESTART_REQUEST		0xFB
45 #define	ROSE_RESTART_CONFIRMATION	0xFF
46 #define	ROSE_DIAGNOSTIC			0xF1
47 #define	ROSE_ILLEGAL			0xFD
48 
49 /* Define Link State constants. */
50 
51 enum {
52 	ROSE_STATE_0,			/* Ready */
53 	ROSE_STATE_1,			/* Awaiting Call Accepted */
54 	ROSE_STATE_2,			/* Awaiting Clear Confirmation */
55 	ROSE_STATE_3,			/* Data Transfer */
56 	ROSE_STATE_4,			/* Awaiting Reset Confirmation */
57 	ROSE_STATE_5			/* Deferred Call Acceptance */
58 };
59 
60 #define ROSE_DEFAULT_T0			180000		/* Default T10 T20 value */
61 #define ROSE_DEFAULT_T1			200000		/* Default T11 T21 value */
62 #define ROSE_DEFAULT_T2			180000		/* Default T12 T22 value */
63 #define	ROSE_DEFAULT_T3			180000		/* Default T13 T23 value */
64 #define	ROSE_DEFAULT_HB			5000		/* Default Holdback value */
65 #define	ROSE_DEFAULT_IDLE		0		/* No Activity Timeout - none */
66 #define	ROSE_DEFAULT_ROUTING		1		/* Default routing flag */
67 #define	ROSE_DEFAULT_FAIL_TIMEOUT	120000		/* Time until link considered usable */
68 #define	ROSE_DEFAULT_MAXVC		50		/* Maximum number of VCs per neighbour */
69 #define	ROSE_DEFAULT_WINDOW_SIZE	7		/* Default window size */
70 
71 #define ROSE_MODULUS 			8
72 #define	ROSE_MAX_PACKET_SIZE		251		/* Maximum packet size */
73 
74 #define	ROSE_COND_ACK_PENDING		0x01
75 #define	ROSE_COND_PEER_RX_BUSY		0x02
76 #define	ROSE_COND_OWN_RX_BUSY		0x04
77 
78 #define	FAC_NATIONAL			0x00
79 #define	FAC_CCITT			0x0F
80 
81 #define	FAC_NATIONAL_RAND		0x7F
82 #define	FAC_NATIONAL_FLAGS		0x3F
83 #define	FAC_NATIONAL_DEST_DIGI		0xE9
84 #define	FAC_NATIONAL_SRC_DIGI		0xEB
85 #define	FAC_NATIONAL_FAIL_CALL		0xED
86 #define	FAC_NATIONAL_FAIL_ADD		0xEE
87 #define	FAC_NATIONAL_DIGIS			0xEF
88 
89 #define	FAC_CCITT_DEST_NSAP		0xC9
90 #define	FAC_CCITT_SRC_NSAP		0xCB
91 
92 struct rose_neigh {
93 	struct rose_neigh	*next;
94 	ax25_address		callsign;
95 	ax25_digi		*digipeat;
96 	ax25_cb			*ax25;
97 	struct net_device		*dev;
98 	unsigned short		count;
99 	unsigned short		use;
100 	unsigned int		number;
101 	char			restarted;
102 	char			dce_mode;
103 	char			loopback;
104 	struct sk_buff_head	queue;
105 	struct timer_list	t0timer;
106 	struct timer_list	ftimer;
107 };
108 
109 struct rose_node {
110 	struct rose_node	*next;
111 	rose_address		address;
112 	unsigned short		mask;
113 	unsigned char		count;
114 	char			loopback;
115 	struct rose_neigh	*neighbour[3];
116 };
117 
118 struct rose_route {
119 	struct rose_route	*next;
120 	unsigned int		lci1, lci2;
121 	rose_address		src_addr, dest_addr;
122 	ax25_address		src_call, dest_call;
123 	struct rose_neigh 	*neigh1, *neigh2;
124 	unsigned int		rand;
125 };
126 
127 struct rose_sock {
128 	struct sock		sock;
129 	rose_address		source_addr,   dest_addr;
130 	ax25_address		source_call,   dest_call;
131 	unsigned char		source_ndigis, dest_ndigis;
132 	ax25_address		source_digis[ROSE_MAX_DIGIS];
133 	ax25_address		dest_digis[ROSE_MAX_DIGIS];
134 	struct rose_neigh	*neighbour;
135 	struct net_device	*device;
136 	netdevice_tracker	dev_tracker;
137 	unsigned int		lci, rand;
138 	unsigned char		state, condition, qbitincl, defer;
139 	unsigned char		cause, diagnostic;
140 	unsigned short		vs, vr, va, vl;
141 	unsigned long		t1, t2, t3, hb, idle;
142 #ifdef M_BIT
143 	unsigned short		fraglen;
144 	struct sk_buff_head	frag_queue;
145 #endif
146 	struct sk_buff_head	ack_queue;
147 	struct rose_facilities_struct facilities;
148 	struct timer_list	timer;
149 	struct timer_list	idletimer;
150 };
151 
152 #define rose_sk(sk) ((struct rose_sock *)(sk))
153 
154 /* af_rose.c */
155 extern ax25_address rose_callsign;
156 extern int  sysctl_rose_restart_request_timeout;
157 extern int  sysctl_rose_call_request_timeout;
158 extern int  sysctl_rose_reset_request_timeout;
159 extern int  sysctl_rose_clear_request_timeout;
160 extern int  sysctl_rose_no_activity_timeout;
161 extern int  sysctl_rose_ack_hold_back_timeout;
162 extern int  sysctl_rose_routing_control;
163 extern int  sysctl_rose_link_fail_timeout;
164 extern int  sysctl_rose_maximum_vcs;
165 extern int  sysctl_rose_window_size;
166 
167 int rosecmp(const rose_address *, const rose_address *);
168 int rosecmpm(const rose_address *, const rose_address *, unsigned short);
169 char *rose2asc(char *buf, const rose_address *);
170 struct sock *rose_find_socket(unsigned int, struct rose_neigh *);
171 void rose_kill_by_neigh(struct rose_neigh *);
172 unsigned int rose_new_lci(struct rose_neigh *);
173 int rose_rx_call_request(struct sk_buff *, struct net_device *,
174 			 struct rose_neigh *, unsigned int);
175 void rose_destroy_socket(struct sock *);
176 
177 /* rose_dev.c */
178 void rose_setup(struct net_device *);
179 
180 /* rose_in.c */
181 int rose_process_rx_frame(struct sock *, struct sk_buff *);
182 
183 /* rose_link.c */
184 void rose_start_ftimer(struct rose_neigh *);
185 void rose_stop_ftimer(struct rose_neigh *);
186 void rose_stop_t0timer(struct rose_neigh *);
187 int rose_ftimer_running(struct rose_neigh *);
188 void rose_link_rx_restart(struct sk_buff *, struct rose_neigh *,
189 			  unsigned short);
190 void rose_transmit_clear_request(struct rose_neigh *, unsigned int,
191 				 unsigned char, unsigned char);
192 void rose_transmit_link(struct sk_buff *, struct rose_neigh *);
193 
194 /* rose_loopback.c */
195 void rose_loopback_init(void);
196 void rose_loopback_clear(void);
197 int rose_loopback_queue(struct sk_buff *, struct rose_neigh *);
198 
199 /* rose_out.c */
200 void rose_kick(struct sock *);
201 void rose_enquiry_response(struct sock *);
202 
203 /* rose_route.c */
204 extern struct rose_neigh *rose_loopback_neigh;
205 extern const struct seq_operations rose_neigh_seqops;
206 extern const struct seq_operations rose_node_seqops;
207 extern struct seq_operations rose_route_seqops;
208 
209 void rose_add_loopback_neigh(void);
210 int __must_check rose_add_loopback_node(const rose_address *);
211 void rose_del_loopback_node(const rose_address *);
212 void rose_rt_device_down(struct net_device *);
213 void rose_link_device_down(struct net_device *);
214 struct net_device *rose_dev_first(void);
215 struct net_device *rose_dev_get(rose_address *);
216 struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *);
217 struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *,
218 				  unsigned char *, int);
219 int rose_rt_ioctl(unsigned int, void __user *);
220 void rose_link_failed(ax25_cb *, int);
221 int rose_route_frame(struct sk_buff *, ax25_cb *);
222 void rose_rt_free(void);
223 
224 /* rose_subr.c */
225 void rose_clear_queues(struct sock *);
226 void rose_frames_acked(struct sock *, unsigned short);
227 void rose_requeue_frames(struct sock *);
228 int rose_validate_nr(struct sock *, unsigned short);
229 void rose_write_internal(struct sock *, int);
230 int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
231 int rose_parse_facilities(unsigned char *, unsigned int,
232 			  struct rose_facilities_struct *);
233 void rose_disconnect(struct sock *, int, int, int);
234 
235 /* rose_timer.c */
236 void rose_start_heartbeat(struct sock *);
237 void rose_start_t1timer(struct sock *);
238 void rose_start_t2timer(struct sock *);
239 void rose_start_t3timer(struct sock *);
240 void rose_start_hbtimer(struct sock *);
241 void rose_start_idletimer(struct sock *);
242 void rose_stop_heartbeat(struct sock *);
243 void rose_stop_timer(struct sock *);
244 void rose_stop_idletimer(struct sock *);
245 
246 /* sysctl_net_rose.c */
247 void rose_register_sysctl(void);
248 void rose_unregister_sysctl(void);
249 
250 #endif
251