blob: 555dd198aab755c9e9ef21a751992ccf653b64c7 [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;
163extern int rosecmp(rose_address *, rose_address *);
164extern int rosecmpm(rose_address *, rose_address *, unsigned short);
Ralf Baechledcf777f2009-07-26 19:11:14 -0700165extern char *rose2asc(char *buf, const rose_address *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166extern struct sock *rose_find_socket(unsigned int, struct rose_neigh *);
167extern void rose_kill_by_neigh(struct rose_neigh *);
168extern unsigned int rose_new_lci(struct rose_neigh *);
169extern int rose_rx_call_request(struct sk_buff *, struct net_device *, struct rose_neigh *, unsigned int);
170extern void rose_destroy_socket(struct sock *);
171
172/* rose_dev.c */
173extern void rose_setup(struct net_device *);
174
175/* rose_in.c */
176extern int rose_process_rx_frame(struct sock *, struct sk_buff *);
177
178/* rose_link.c */
179extern void rose_start_ftimer(struct rose_neigh *);
180extern void rose_stop_ftimer(struct rose_neigh *);
181extern void rose_stop_t0timer(struct rose_neigh *);
182extern int rose_ftimer_running(struct rose_neigh *);
183extern void rose_link_rx_restart(struct sk_buff *, struct rose_neigh *, unsigned short);
184extern void rose_transmit_clear_request(struct rose_neigh *, unsigned int, unsigned char, unsigned char);
185extern void rose_transmit_link(struct sk_buff *, struct rose_neigh *);
186
187/* rose_loopback.c */
188extern void rose_loopback_init(void);
189extern void rose_loopback_clear(void);
190extern int rose_loopback_queue(struct sk_buff *, struct rose_neigh *);
191
192/* rose_out.c */
193extern void rose_kick(struct sock *);
194extern void rose_enquiry_response(struct sock *);
195
196/* rose_route.c */
Alexey Dobriyan891e6a92007-10-07 23:44:17 -0700197extern struct rose_neigh *rose_loopback_neigh;
Arjan van de Ven54047322007-02-12 00:55:28 -0800198extern const struct file_operations rose_neigh_fops;
199extern const struct file_operations rose_nodes_fops;
200extern const struct file_operations rose_routes_fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Ralf Baechlea3d38402006-12-14 15:52:13 -0800202extern void rose_add_loopback_neigh(void);
Ralf Baechlec9266b92006-12-14 15:49:28 -0800203extern int __must_check rose_add_loopback_node(rose_address *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204extern void rose_del_loopback_node(rose_address *);
205extern void rose_rt_device_down(struct net_device *);
206extern void rose_link_device_down(struct net_device *);
207extern struct net_device *rose_dev_first(void);
208extern struct net_device *rose_dev_get(rose_address *);
209extern struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *);
Bernard Pidouxfe2c8022008-06-17 17:08:32 -0700210extern struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *, unsigned char *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211extern int rose_rt_ioctl(unsigned int, void __user *);
212extern void rose_link_failed(ax25_cb *, int);
213extern int rose_route_frame(struct sk_buff *, ax25_cb *);
214extern void rose_rt_free(void);
215
216/* rose_subr.c */
217extern void rose_clear_queues(struct sock *);
218extern void rose_frames_acked(struct sock *, unsigned short);
219extern void rose_requeue_frames(struct sock *);
220extern int rose_validate_nr(struct sock *, unsigned short);
221extern void rose_write_internal(struct sock *, int);
222extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
Ben Hutchingse0bccd32011-03-20 06:48:05 +0000223extern int rose_parse_facilities(unsigned char *, unsigned int, struct rose_facilities_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224extern void rose_disconnect(struct sock *, int, int, int);
225
226/* rose_timer.c */
227extern void rose_start_heartbeat(struct sock *);
228extern void rose_start_t1timer(struct sock *);
229extern void rose_start_t2timer(struct sock *);
230extern void rose_start_t3timer(struct sock *);
231extern void rose_start_hbtimer(struct sock *);
232extern void rose_start_idletimer(struct sock *);
233extern void rose_stop_heartbeat(struct sock *);
234extern void rose_stop_timer(struct sock *);
235extern void rose_stop_idletimer(struct sock *);
236
237/* sysctl_net_rose.c */
238extern void rose_register_sysctl(void);
239extern void rose_unregister_sysctl(void);
240
241#endif