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