blob: 50811fe2c585b0e9fd8ffb365971229872eb353e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Ben Hutchingse0bccd32011-03-20 06:48:05 +000017#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#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
49enum {
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
Ralf Baechle82e84242006-05-03 23:28:20 -070058#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define ROSE_DEFAULT_ROUTING 1 /* Default routing flag */
Ralf Baechle82e84242006-05-03 23:28:20 -070065#define ROSE_DEFAULT_FAIL_TIMEOUT 120000 /* Time until link considered usable */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#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
90struct 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
107struct 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
116struct 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
125struct 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 */
152extern ax25_address rose_callsign;
153extern int sysctl_rose_restart_request_timeout;
154extern int sysctl_rose_call_request_timeout;
155extern int sysctl_rose_reset_request_timeout;
156extern int sysctl_rose_clear_request_timeout;
157extern int sysctl_rose_no_activity_timeout;
158extern int sysctl_rose_ack_hold_back_timeout;
159extern int sysctl_rose_routing_control;
160extern int sysctl_rose_link_fail_timeout;
161extern int sysctl_rose_maximum_vcs;
162extern int sysctl_rose_window_size;
Joe Perches54df3b92013-09-22 10:32:21 -0700163
164int rosecmp(rose_address *, rose_address *);
165int rosecmpm(rose_address *, rose_address *, unsigned short);
166char *rose2asc(char *buf, const rose_address *);
167struct sock *rose_find_socket(unsigned int, struct rose_neigh *);
168void rose_kill_by_neigh(struct rose_neigh *);
169unsigned int rose_new_lci(struct rose_neigh *);
170int rose_rx_call_request(struct sk_buff *, struct net_device *,
171 struct rose_neigh *, unsigned int);
172void rose_destroy_socket(struct sock *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174/* rose_dev.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700175void rose_setup(struct net_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
177/* rose_in.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700178int rose_process_rx_frame(struct sock *, struct sk_buff *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
180/* rose_link.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700181void rose_start_ftimer(struct rose_neigh *);
182void rose_stop_ftimer(struct rose_neigh *);
183void rose_stop_t0timer(struct rose_neigh *);
184int rose_ftimer_running(struct rose_neigh *);
185void rose_link_rx_restart(struct sk_buff *, struct rose_neigh *,
186 unsigned short);
187void rose_transmit_clear_request(struct rose_neigh *, unsigned int,
188 unsigned char, unsigned char);
189void rose_transmit_link(struct sk_buff *, struct rose_neigh *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
191/* rose_loopback.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700192void rose_loopback_init(void);
193void rose_loopback_clear(void);
194int rose_loopback_queue(struct sk_buff *, struct rose_neigh *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196/* rose_out.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700197void rose_kick(struct sock *);
198void rose_enquiry_response(struct sock *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200/* rose_route.c */
Alexey Dobriyan891e6a92007-10-07 23:44:17 -0700201extern struct rose_neigh *rose_loopback_neigh;
Arjan van de Ven54047322007-02-12 00:55:28 -0800202extern const struct file_operations rose_neigh_fops;
203extern const struct file_operations rose_nodes_fops;
204extern const struct file_operations rose_routes_fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
Joe Perches54df3b92013-09-22 10:32:21 -0700206void rose_add_loopback_neigh(void);
207int __must_check rose_add_loopback_node(rose_address *);
208void rose_del_loopback_node(rose_address *);
209void rose_rt_device_down(struct net_device *);
210void rose_link_device_down(struct net_device *);
211struct net_device *rose_dev_first(void);
212struct net_device *rose_dev_get(rose_address *);
213struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *);
214struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *,
215 unsigned char *, int);
216int rose_rt_ioctl(unsigned int, void __user *);
217void rose_link_failed(ax25_cb *, int);
218int rose_route_frame(struct sk_buff *, ax25_cb *);
219void rose_rt_free(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221/* rose_subr.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700222void rose_clear_queues(struct sock *);
223void rose_frames_acked(struct sock *, unsigned short);
224void rose_requeue_frames(struct sock *);
225int rose_validate_nr(struct sock *, unsigned short);
226void rose_write_internal(struct sock *, int);
227int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
228int rose_parse_facilities(unsigned char *, unsigned int,
229 struct rose_facilities_struct *);
230void rose_disconnect(struct sock *, int, int, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232/* rose_timer.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700233void rose_start_heartbeat(struct sock *);
234void rose_start_t1timer(struct sock *);
235void rose_start_t2timer(struct sock *);
236void rose_start_t3timer(struct sock *);
237void rose_start_hbtimer(struct sock *);
238void rose_start_idletimer(struct sock *);
239void rose_stop_heartbeat(struct sock *);
240void rose_stop_timer(struct sock *);
241void rose_stop_idletimer(struct sock *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
243/* sysctl_net_rose.c */
Joe Perches54df3b92013-09-22 10:32:21 -0700244void rose_register_sysctl(void);
245void rose_unregister_sysctl(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247#endif