]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * Declarations of X.25 Packet Layer type objects. | |
4 | * | |
5 | * History | |
6 | * nov/17/96 Jonathan Naylor Initial version. | |
7 | * mar/20/00 Daniela Squassoni Disabling/enabling of facilities | |
8 | * negotiation. | |
9 | */ | |
10 | ||
11 | #ifndef _X25_H | |
12 | #define _X25_H | |
13 | #include <linux/x25.h> | |
5a0e3ad6 | 14 | #include <linux/slab.h> |
5f9ccf6f | 15 | #include <linux/refcount.h> |
1da177e4 LT |
16 | #include <net/sock.h> |
17 | ||
18 | #define X25_ADDR_LEN 16 | |
19 | ||
20 | #define X25_MAX_L2_LEN 18 /* 802.2 LLC */ | |
21 | ||
22 | #define X25_STD_MIN_LEN 3 | |
23 | #define X25_EXT_MIN_LEN 4 | |
24 | ||
25 | #define X25_GFI_SEQ_MASK 0x30 | |
26 | #define X25_GFI_STDSEQ 0x10 | |
27 | #define X25_GFI_EXTSEQ 0x20 | |
28 | ||
29 | #define X25_Q_BIT 0x80 | |
30 | #define X25_D_BIT 0x40 | |
31 | #define X25_STD_M_BIT 0x10 | |
32 | #define X25_EXT_M_BIT 0x01 | |
33 | ||
34 | #define X25_CALL_REQUEST 0x0B | |
35 | #define X25_CALL_ACCEPTED 0x0F | |
36 | #define X25_CLEAR_REQUEST 0x13 | |
37 | #define X25_CLEAR_CONFIRMATION 0x17 | |
38 | #define X25_DATA 0x00 | |
39 | #define X25_INTERRUPT 0x23 | |
40 | #define X25_INTERRUPT_CONFIRMATION 0x27 | |
41 | #define X25_RR 0x01 | |
42 | #define X25_RNR 0x05 | |
43 | #define X25_REJ 0x09 | |
44 | #define X25_RESET_REQUEST 0x1B | |
45 | #define X25_RESET_CONFIRMATION 0x1F | |
46 | #define X25_REGISTRATION_REQUEST 0xF3 | |
47 | #define X25_REGISTRATION_CONFIRMATION 0xF7 | |
48 | #define X25_RESTART_REQUEST 0xFB | |
49 | #define X25_RESTART_CONFIRMATION 0xFF | |
50 | #define X25_DIAGNOSTIC 0xF1 | |
51 | #define X25_ILLEGAL 0xFD | |
52 | ||
53 | /* Define the various conditions that may exist */ | |
54 | ||
55 | #define X25_COND_ACK_PENDING 0x01 | |
56 | #define X25_COND_OWN_RX_BUSY 0x02 | |
57 | #define X25_COND_PEER_RX_BUSY 0x04 | |
58 | ||
59 | /* Define Link State constants. */ | |
60 | enum { | |
61 | X25_STATE_0, /* Ready */ | |
62 | X25_STATE_1, /* Awaiting Call Accepted */ | |
63 | X25_STATE_2, /* Awaiting Clear Confirmation */ | |
64 | X25_STATE_3, /* Data Transfer */ | |
f8fc57e8 MS |
65 | X25_STATE_4, /* Awaiting Reset Confirmation */ |
66 | X25_STATE_5 /* Call Accepted / Call Connected pending */ | |
1da177e4 LT |
67 | }; |
68 | ||
69 | enum { | |
70 | X25_LINK_STATE_0, | |
71 | X25_LINK_STATE_1, | |
72 | X25_LINK_STATE_2, | |
73 | X25_LINK_STATE_3 | |
74 | }; | |
75 | ||
76 | #define X25_DEFAULT_T20 (180 * HZ) /* Default T20 value */ | |
77 | #define X25_DEFAULT_T21 (200 * HZ) /* Default T21 value */ | |
78 | #define X25_DEFAULT_T22 (180 * HZ) /* Default T22 value */ | |
79 | #define X25_DEFAULT_T23 (180 * HZ) /* Default T23 value */ | |
80 | #define X25_DEFAULT_T2 (3 * HZ) /* Default ack holdback value */ | |
81 | ||
82 | #define X25_DEFAULT_WINDOW_SIZE 2 /* Default Window Size */ | |
83 | #define X25_DEFAULT_PACKET_SIZE X25_PS128 /* Default Packet Size */ | |
84 | #define X25_DEFAULT_THROUGHPUT 0x0A /* Deafult Throughput */ | |
85 | #define X25_DEFAULT_REVERSE 0x00 /* Default Reverse Charging */ | |
86 | ||
87 | #define X25_SMODULUS 8 | |
88 | #define X25_EMODULUS 128 | |
89 | ||
90 | /* | |
91 | * X.25 Facilities constants. | |
92 | */ | |
93 | ||
94 | #define X25_FAC_CLASS_MASK 0xC0 | |
95 | ||
96 | #define X25_FAC_CLASS_A 0x00 | |
97 | #define X25_FAC_CLASS_B 0x40 | |
98 | #define X25_FAC_CLASS_C 0x80 | |
99 | #define X25_FAC_CLASS_D 0xC0 | |
100 | ||
ebc3f64b | 101 | #define X25_FAC_REVERSE 0x01 /* also fast select */ |
1da177e4 LT |
102 | #define X25_FAC_THROUGHPUT 0x02 |
103 | #define X25_FAC_PACKET_SIZE 0x42 | |
104 | #define X25_FAC_WINDOW_SIZE 0x43 | |
105 | ||
a64b7b93 | 106 | #define X25_MAX_FAC_LEN 60 |
1da177e4 LT |
107 | #define X25_MAX_CUD_LEN 128 |
108 | ||
a64b7b93 SP |
109 | #define X25_FAC_CALLING_AE 0xCB |
110 | #define X25_FAC_CALLED_AE 0xC9 | |
111 | ||
112 | #define X25_MARKER 0x00 | |
113 | #define X25_DTE_SERVICES 0x0F | |
114 | #define X25_MAX_AE_LEN 40 /* Max num of semi-octets in AE - OSI Nw */ | |
115 | #define X25_MAX_DTE_FACIL_LEN 21 /* Max length of DTE facility params */ | |
116 | ||
cb863ffd | 117 | /* Bitset in x25_sock->flags for misc flags */ |
118 | #define X25_Q_BIT_FLAG 0 | |
b7792e34 | 119 | #define X25_INTERRUPT_FLAG 1 |
37cda787 | 120 | #define X25_ACCPT_APPRV_FLAG 2 |
cb863ffd | 121 | |
1da177e4 LT |
122 | /** |
123 | * struct x25_route - x25 routing entry | |
124 | * @node - entry in x25_list_lock | |
125 | * @address - Start of address range | |
126 | * @sigdigits - Number of sig digits | |
127 | * @dev - More than one for MLP | |
128 | * @refcnt - reference counter | |
129 | */ | |
130 | struct x25_route { | |
131 | struct list_head node; | |
132 | struct x25_address address; | |
133 | unsigned int sigdigits; | |
134 | struct net_device *dev; | |
5f9ccf6f | 135 | refcount_t refcnt; |
1da177e4 LT |
136 | }; |
137 | ||
138 | struct x25_neigh { | |
139 | struct list_head node; | |
140 | struct net_device *dev; | |
141 | unsigned int state; | |
142 | unsigned int extended; | |
143 | struct sk_buff_head queue; | |
144 | unsigned long t20; | |
145 | struct timer_list t20timer; | |
146 | unsigned long global_facil_mask; | |
5534a51a | 147 | refcount_t refcnt; |
1da177e4 LT |
148 | }; |
149 | ||
150 | struct x25_sock { | |
151 | struct sock sk; | |
152 | struct x25_address source_addr, dest_addr; | |
153 | struct x25_neigh *neighbour; | |
cb65d506 | 154 | unsigned int lci, cudmatchlength; |
37cda787 | 155 | unsigned char state, condition; |
1da177e4 LT |
156 | unsigned short vs, vr, va, vl; |
157 | unsigned long t2, t21, t22, t23; | |
158 | unsigned short fraglen; | |
cb863ffd | 159 | unsigned long flags; |
1da177e4 LT |
160 | struct sk_buff_head ack_queue; |
161 | struct sk_buff_head fragment_queue; | |
162 | struct sk_buff_head interrupt_in_queue; | |
163 | struct sk_buff_head interrupt_out_queue; | |
164 | struct timer_list timer; | |
165 | struct x25_causediag causediag; | |
166 | struct x25_facilities facilities; | |
a64b7b93 | 167 | struct x25_dte_facilities dte_facilities; |
1da177e4 LT |
168 | struct x25_calluserdata calluserdata; |
169 | unsigned long vc_facil_mask; /* inc_call facilities mask */ | |
170 | }; | |
171 | ||
95a9dc43 AH |
172 | struct x25_forward { |
173 | struct list_head node; | |
174 | unsigned int lci; | |
175 | struct net_device *dev1; | |
176 | struct net_device *dev2; | |
177 | atomic_t refcnt; | |
178 | }; | |
179 | ||
1da177e4 LT |
180 | static inline struct x25_sock *x25_sk(const struct sock *sk) |
181 | { | |
182 | return (struct x25_sock *)sk; | |
183 | } | |
184 | ||
185 | /* af_x25.c */ | |
186 | extern int sysctl_x25_restart_request_timeout; | |
187 | extern int sysctl_x25_call_request_timeout; | |
188 | extern int sysctl_x25_reset_request_timeout; | |
189 | extern int sysctl_x25_clear_request_timeout; | |
190 | extern int sysctl_x25_ack_holdback_timeout; | |
39e21c0d | 191 | extern int sysctl_x25_forward; |
1da177e4 | 192 | |
5db50ee6 JP |
193 | int x25_parse_address_block(struct sk_buff *skb, |
194 | struct x25_address *called_addr, | |
195 | struct x25_address *calling_addr); | |
196 | ||
197 | int x25_addr_ntoa(unsigned char *, struct x25_address *, struct x25_address *); | |
198 | int x25_addr_aton(unsigned char *, struct x25_address *, struct x25_address *); | |
199 | struct sock *x25_find_socket(unsigned int, struct x25_neigh *); | |
200 | void x25_destroy_socket_from_timer(struct sock *); | |
201 | int x25_rx_call_request(struct sk_buff *, struct x25_neigh *, unsigned int); | |
202 | void x25_kill_by_neigh(struct x25_neigh *); | |
1da177e4 LT |
203 | |
204 | /* x25_dev.c */ | |
5db50ee6 JP |
205 | void x25_send_frame(struct sk_buff *, struct x25_neigh *); |
206 | int x25_lapb_receive_frame(struct sk_buff *, struct net_device *, | |
207 | struct packet_type *, struct net_device *); | |
208 | void x25_establish_link(struct x25_neigh *); | |
209 | void x25_terminate_link(struct x25_neigh *); | |
1da177e4 LT |
210 | |
211 | /* x25_facilities.c */ | |
5db50ee6 JP |
212 | int x25_parse_facilities(struct sk_buff *, struct x25_facilities *, |
213 | struct x25_dte_facilities *, unsigned long *); | |
214 | int x25_create_facilities(unsigned char *, struct x25_facilities *, | |
215 | struct x25_dte_facilities *, unsigned long); | |
216 | int x25_negotiate_facilities(struct sk_buff *, struct sock *, | |
217 | struct x25_facilities *, | |
218 | struct x25_dte_facilities *); | |
219 | void x25_limit_facilities(struct x25_facilities *, struct x25_neigh *); | |
1da177e4 | 220 | |
95a9dc43 | 221 | /* x25_forward.c */ |
5db50ee6 JP |
222 | void x25_clear_forward_by_lci(unsigned int lci); |
223 | void x25_clear_forward_by_dev(struct net_device *); | |
224 | int x25_forward_data(int, struct x25_neigh *, struct sk_buff *); | |
225 | int x25_forward_call(struct x25_address *, struct x25_neigh *, struct sk_buff *, | |
226 | int); | |
95a9dc43 | 227 | |
1da177e4 | 228 | /* x25_in.c */ |
5db50ee6 JP |
229 | int x25_process_rx_frame(struct sock *, struct sk_buff *); |
230 | int x25_backlog_rcv(struct sock *, struct sk_buff *); | |
1da177e4 LT |
231 | |
232 | /* x25_link.c */ | |
5db50ee6 JP |
233 | void x25_link_control(struct sk_buff *, struct x25_neigh *, unsigned short); |
234 | void x25_link_device_up(struct net_device *); | |
235 | void x25_link_device_down(struct net_device *); | |
236 | void x25_link_established(struct x25_neigh *); | |
237 | void x25_link_terminated(struct x25_neigh *); | |
238 | void x25_transmit_clear_request(struct x25_neigh *, unsigned int, | |
239 | unsigned char); | |
240 | void x25_transmit_link(struct sk_buff *, struct x25_neigh *); | |
241 | int x25_subscr_ioctl(unsigned int, void __user *); | |
242 | struct x25_neigh *x25_get_neigh(struct net_device *); | |
243 | void x25_link_free(void); | |
1da177e4 LT |
244 | |
245 | /* x25_neigh.c */ | |
246 | static __inline__ void x25_neigh_hold(struct x25_neigh *nb) | |
247 | { | |
5534a51a | 248 | refcount_inc(&nb->refcnt); |
1da177e4 LT |
249 | } |
250 | ||
251 | static __inline__ void x25_neigh_put(struct x25_neigh *nb) | |
252 | { | |
5534a51a | 253 | if (refcount_dec_and_test(&nb->refcnt)) |
1da177e4 LT |
254 | kfree(nb); |
255 | } | |
256 | ||
257 | /* x25_out.c */ | |
5db50ee6 JP |
258 | int x25_output(struct sock *, struct sk_buff *); |
259 | void x25_kick(struct sock *); | |
260 | void x25_enquiry_response(struct sock *); | |
1da177e4 LT |
261 | |
262 | /* x25_route.c */ | |
5db50ee6 JP |
263 | struct x25_route *x25_get_route(struct x25_address *addr); |
264 | struct net_device *x25_dev_get(char *); | |
265 | void x25_route_device_down(struct net_device *dev); | |
266 | int x25_route_ioctl(unsigned int, void __user *); | |
267 | void x25_route_free(void); | |
1da177e4 LT |
268 | |
269 | static __inline__ void x25_route_hold(struct x25_route *rt) | |
270 | { | |
5f9ccf6f | 271 | refcount_inc(&rt->refcnt); |
1da177e4 LT |
272 | } |
273 | ||
274 | static __inline__ void x25_route_put(struct x25_route *rt) | |
275 | { | |
5f9ccf6f | 276 | if (refcount_dec_and_test(&rt->refcnt)) |
1da177e4 LT |
277 | kfree(rt); |
278 | } | |
279 | ||
280 | /* x25_subr.c */ | |
5db50ee6 JP |
281 | void x25_clear_queues(struct sock *); |
282 | void x25_frames_acked(struct sock *, unsigned short); | |
283 | void x25_requeue_frames(struct sock *); | |
284 | int x25_validate_nr(struct sock *, unsigned short); | |
285 | void x25_write_internal(struct sock *, int); | |
286 | int x25_decode(struct sock *, struct sk_buff *, int *, int *, int *, int *, | |
287 | int *); | |
288 | void x25_disconnect(struct sock *, int, unsigned char, unsigned char); | |
1da177e4 LT |
289 | |
290 | /* x25_timer.c */ | |
5db50ee6 JP |
291 | void x25_init_timers(struct sock *sk); |
292 | void x25_start_heartbeat(struct sock *); | |
293 | void x25_start_t2timer(struct sock *); | |
294 | void x25_start_t21timer(struct sock *); | |
295 | void x25_start_t22timer(struct sock *); | |
296 | void x25_start_t23timer(struct sock *); | |
297 | void x25_stop_heartbeat(struct sock *); | |
298 | void x25_stop_timer(struct sock *); | |
299 | unsigned long x25_display_timer(struct sock *); | |
300 | void x25_check_rbuf(struct sock *); | |
1da177e4 LT |
301 | |
302 | /* sysctl_net_x25.c */ | |
2f5517ae | 303 | #ifdef CONFIG_SYSCTL |
64df6d52 | 304 | int x25_register_sysctl(void); |
5db50ee6 | 305 | void x25_unregister_sysctl(void); |
2f5517ae | 306 | #else |
64df6d52 | 307 | static inline int x25_register_sysctl(void) { return 0; }; |
2f5517ae | 308 | static inline void x25_unregister_sysctl(void) {}; |
309 | #endif /* CONFIG_SYSCTL */ | |
310 | ||
1da177e4 | 311 | struct x25_skb_cb { |
95c96174 | 312 | unsigned int flags; |
1da177e4 LT |
313 | }; |
314 | #define X25_SKB_CB(s) ((struct x25_skb_cb *) ((s)->cb)) | |
315 | ||
316 | extern struct hlist_head x25_list; | |
317 | extern rwlock_t x25_list_lock; | |
318 | extern struct list_head x25_route_list; | |
319 | extern rwlock_t x25_route_list_lock; | |
95a9dc43 AH |
320 | extern struct list_head x25_forward_list; |
321 | extern rwlock_t x25_forward_list_lock; | |
5595a1a5 | 322 | extern struct list_head x25_neigh_list; |
323 | extern rwlock_t x25_neigh_list_lock; | |
1da177e4 | 324 | |
5db50ee6 JP |
325 | int x25_proc_init(void); |
326 | void x25_proc_exit(void); | |
1da177e4 | 327 | #endif |