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