• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 extern int  rosecmp(rose_address *, rose_address *);
164 extern int  rosecmpm(rose_address *, rose_address *, unsigned short);
165 extern char *rose2asc(char *buf, const rose_address *);
166 extern struct sock *rose_find_socket(unsigned int, struct rose_neigh *);
167 extern void rose_kill_by_neigh(struct rose_neigh *);
168 extern unsigned int rose_new_lci(struct rose_neigh *);
169 extern int  rose_rx_call_request(struct sk_buff *, struct net_device *, struct rose_neigh *, unsigned int);
170 extern void rose_destroy_socket(struct sock *);
171 
172 /* rose_dev.c */
173 extern void  rose_setup(struct net_device *);
174 
175 /* rose_in.c */
176 extern int  rose_process_rx_frame(struct sock *, struct sk_buff *);
177 
178 /* rose_link.c */
179 extern void rose_start_ftimer(struct rose_neigh *);
180 extern void rose_stop_ftimer(struct rose_neigh *);
181 extern void rose_stop_t0timer(struct rose_neigh *);
182 extern int  rose_ftimer_running(struct rose_neigh *);
183 extern void rose_link_rx_restart(struct sk_buff *, struct rose_neigh *, unsigned short);
184 extern void rose_transmit_clear_request(struct rose_neigh *, unsigned int, unsigned char, unsigned char);
185 extern void rose_transmit_link(struct sk_buff *, struct rose_neigh *);
186 
187 /* rose_loopback.c */
188 extern void rose_loopback_init(void);
189 extern void rose_loopback_clear(void);
190 extern int  rose_loopback_queue(struct sk_buff *, struct rose_neigh *);
191 
192 /* rose_out.c */
193 extern void rose_kick(struct sock *);
194 extern void rose_enquiry_response(struct sock *);
195 
196 /* rose_route.c */
197 extern struct rose_neigh *rose_loopback_neigh;
198 extern const struct file_operations rose_neigh_fops;
199 extern const struct file_operations rose_nodes_fops;
200 extern const struct file_operations rose_routes_fops;
201 
202 extern void rose_add_loopback_neigh(void);
203 extern int __must_check rose_add_loopback_node(rose_address *);
204 extern void rose_del_loopback_node(rose_address *);
205 extern void rose_rt_device_down(struct net_device *);
206 extern void rose_link_device_down(struct net_device *);
207 extern struct net_device *rose_dev_first(void);
208 extern struct net_device *rose_dev_get(rose_address *);
209 extern struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *);
210 extern struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *, unsigned char *, int);
211 extern int  rose_rt_ioctl(unsigned int, void __user *);
212 extern void rose_link_failed(ax25_cb *, int);
213 extern int  rose_route_frame(struct sk_buff *, ax25_cb *);
214 extern void rose_rt_free(void);
215 
216 /* rose_subr.c */
217 extern void rose_clear_queues(struct sock *);
218 extern void rose_frames_acked(struct sock *, unsigned short);
219 extern void rose_requeue_frames(struct sock *);
220 extern int  rose_validate_nr(struct sock *, unsigned short);
221 extern void rose_write_internal(struct sock *, int);
222 extern int  rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
223 extern int  rose_parse_facilities(unsigned char *, unsigned int, struct rose_facilities_struct *);
224 extern void rose_disconnect(struct sock *, int, int, int);
225 
226 /* rose_timer.c */
227 extern void rose_start_heartbeat(struct sock *);
228 extern void rose_start_t1timer(struct sock *);
229 extern void rose_start_t2timer(struct sock *);
230 extern void rose_start_t3timer(struct sock *);
231 extern void rose_start_hbtimer(struct sock *);
232 extern void rose_start_idletimer(struct sock *);
233 extern void rose_stop_heartbeat(struct sock *);
234 extern void rose_stop_timer(struct sock *);
235 extern void rose_stop_idletimer(struct sock *);
236 
237 /* sysctl_net_rose.c */
238 extern void rose_register_sysctl(void);
239 extern void rose_unregister_sysctl(void);
240 
241 #endif
242