[AX.25]: Fix unchecked rose_add_loopback_neigh uses
[linux-2.6.22.y-op.git] / include / net / rose.h
blob4c05a88b921b6d32fc8bc1e5431897e260c43ef0
1 /*
2 * Declarations of Rose type objects.
4 * Jonathan Naylor G4KLX 25/8/96
5 */
7 #ifndef _ROSE_H
8 #define _ROSE_H
10 #include <linux/rose.h>
11 #include <net/sock.h>
13 #define ROSE_ADDR_LEN 5
15 #define ROSE_MIN_LEN 3
17 #define ROSE_GFI 0x10
18 #define ROSE_Q_BIT 0x80
19 #define ROSE_D_BIT 0x40
20 #define ROSE_M_BIT 0x10
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
41 /* Define Link State constants. */
43 enum {
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 */
52 #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 */
58 #define ROSE_DEFAULT_ROUTING 1 /* Default routing flag */
59 #define ROSE_DEFAULT_FAIL_TIMEOUT 120000 /* Time until link considered usable */
60 #define ROSE_DEFAULT_MAXVC 50 /* Maximum number of VCs per neighbour */
61 #define ROSE_DEFAULT_WINDOW_SIZE 7 /* Default window size */
63 #define ROSE_MODULUS 8
64 #define ROSE_MAX_PACKET_SIZE 251 /* Maximum packet size */
66 #define ROSE_COND_ACK_PENDING 0x01
67 #define ROSE_COND_PEER_RX_BUSY 0x02
68 #define ROSE_COND_OWN_RX_BUSY 0x04
70 #define FAC_NATIONAL 0x00
71 #define FAC_CCITT 0x0F
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
81 #define FAC_CCITT_DEST_NSAP 0xC9
82 #define FAC_CCITT_SRC_NSAP 0xCB
84 struct 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;
101 struct 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];
110 struct 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;
119 struct 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;
143 #define rose_sk(sk) ((struct rose_sock *)(sk))
145 /* af_rose.c */
146 extern ax25_address rose_callsign;
147 extern int sysctl_rose_restart_request_timeout;
148 extern int sysctl_rose_call_request_timeout;
149 extern int sysctl_rose_reset_request_timeout;
150 extern int sysctl_rose_clear_request_timeout;
151 extern int sysctl_rose_no_activity_timeout;
152 extern int sysctl_rose_ack_hold_back_timeout;
153 extern int sysctl_rose_routing_control;
154 extern int sysctl_rose_link_fail_timeout;
155 extern int sysctl_rose_maximum_vcs;
156 extern int sysctl_rose_window_size;
157 extern int rosecmp(rose_address *, rose_address *);
158 extern int rosecmpm(rose_address *, rose_address *, unsigned short);
159 extern const char *rose2asc(const rose_address *);
160 extern struct sock *rose_find_socket(unsigned int, struct rose_neigh *);
161 extern void rose_kill_by_neigh(struct rose_neigh *);
162 extern unsigned int rose_new_lci(struct rose_neigh *);
163 extern int rose_rx_call_request(struct sk_buff *, struct net_device *, struct rose_neigh *, unsigned int);
164 extern void rose_destroy_socket(struct sock *);
166 /* rose_dev.c */
167 extern void rose_setup(struct net_device *);
169 /* rose_in.c */
170 extern int rose_process_rx_frame(struct sock *, struct sk_buff *);
172 /* rose_link.c */
173 extern void rose_start_ftimer(struct rose_neigh *);
174 extern void rose_stop_ftimer(struct rose_neigh *);
175 extern void rose_stop_t0timer(struct rose_neigh *);
176 extern int rose_ftimer_running(struct rose_neigh *);
177 extern void rose_link_rx_restart(struct sk_buff *, struct rose_neigh *, unsigned short);
178 extern void rose_transmit_clear_request(struct rose_neigh *, unsigned int, unsigned char, unsigned char);
179 extern void rose_transmit_link(struct sk_buff *, struct rose_neigh *);
181 /* rose_loopback.c */
182 extern void rose_loopback_init(void);
183 extern void rose_loopback_clear(void);
184 extern int rose_loopback_queue(struct sk_buff *, struct rose_neigh *);
186 /* rose_out.c */
187 extern void rose_kick(struct sock *);
188 extern void rose_enquiry_response(struct sock *);
190 /* rose_route.c */
191 extern struct rose_neigh rose_loopback_neigh;
192 extern struct file_operations rose_neigh_fops;
193 extern struct file_operations rose_nodes_fops;
194 extern struct file_operations rose_routes_fops;
196 extern void rose_add_loopback_neigh(void);
197 extern int __must_check rose_add_loopback_node(rose_address *);
198 extern void rose_del_loopback_node(rose_address *);
199 extern void rose_rt_device_down(struct net_device *);
200 extern void rose_link_device_down(struct net_device *);
201 extern struct net_device *rose_dev_first(void);
202 extern struct net_device *rose_dev_get(rose_address *);
203 extern struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *);
204 extern struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *, unsigned char *);
205 extern int rose_rt_ioctl(unsigned int, void __user *);
206 extern void rose_link_failed(ax25_cb *, int);
207 extern int rose_route_frame(struct sk_buff *, ax25_cb *);
208 extern void rose_rt_free(void);
210 /* rose_subr.c */
211 extern void rose_clear_queues(struct sock *);
212 extern void rose_frames_acked(struct sock *, unsigned short);
213 extern void rose_requeue_frames(struct sock *);
214 extern int rose_validate_nr(struct sock *, unsigned short);
215 extern void rose_write_internal(struct sock *, int);
216 extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
217 extern int rose_parse_facilities(unsigned char *, struct rose_facilities_struct *);
218 extern void rose_disconnect(struct sock *, int, int, int);
220 /* rose_timer.c */
221 extern void rose_start_heartbeat(struct sock *);
222 extern void rose_start_t1timer(struct sock *);
223 extern void rose_start_t2timer(struct sock *);
224 extern void rose_start_t3timer(struct sock *);
225 extern void rose_start_hbtimer(struct sock *);
226 extern void rose_start_idletimer(struct sock *);
227 extern void rose_stop_heartbeat(struct sock *);
228 extern void rose_stop_timer(struct sock *);
229 extern void rose_stop_idletimer(struct sock *);
231 /* sysctl_net_rose.c */
232 extern void rose_register_sysctl(void);
233 extern void rose_unregister_sysctl(void);
235 #endif