blob: 9baa07dc7d17e31546407e91e2875a8960861cd8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Declarations of X.25 Packet Layer type objects.
3 *
4 * History
5 * nov/17/96 Jonathan Naylor Initial version.
6 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities
7 * negotiation.
8 */
9
10#ifndef _X25_H
11#define _X25_H
12#include <linux/x25.h>
13#include <net/sock.h>
14
15#define X25_ADDR_LEN 16
16
17#define X25_MAX_L2_LEN 18 /* 802.2 LLC */
18
19#define X25_STD_MIN_LEN 3
20#define X25_EXT_MIN_LEN 4
21
22#define X25_GFI_SEQ_MASK 0x30
23#define X25_GFI_STDSEQ 0x10
24#define X25_GFI_EXTSEQ 0x20
25
26#define X25_Q_BIT 0x80
27#define X25_D_BIT 0x40
28#define X25_STD_M_BIT 0x10
29#define X25_EXT_M_BIT 0x01
30
31#define X25_CALL_REQUEST 0x0B
32#define X25_CALL_ACCEPTED 0x0F
33#define X25_CLEAR_REQUEST 0x13
34#define X25_CLEAR_CONFIRMATION 0x17
35#define X25_DATA 0x00
36#define X25_INTERRUPT 0x23
37#define X25_INTERRUPT_CONFIRMATION 0x27
38#define X25_RR 0x01
39#define X25_RNR 0x05
40#define X25_REJ 0x09
41#define X25_RESET_REQUEST 0x1B
42#define X25_RESET_CONFIRMATION 0x1F
43#define X25_REGISTRATION_REQUEST 0xF3
44#define X25_REGISTRATION_CONFIRMATION 0xF7
45#define X25_RESTART_REQUEST 0xFB
46#define X25_RESTART_CONFIRMATION 0xFF
47#define X25_DIAGNOSTIC 0xF1
48#define X25_ILLEGAL 0xFD
49
50/* Define the various conditions that may exist */
51
52#define X25_COND_ACK_PENDING 0x01
53#define X25_COND_OWN_RX_BUSY 0x02
54#define X25_COND_PEER_RX_BUSY 0x04
55
56/* Define Link State constants. */
57enum {
58 X25_STATE_0, /* Ready */
59 X25_STATE_1, /* Awaiting Call Accepted */
60 X25_STATE_2, /* Awaiting Clear Confirmation */
61 X25_STATE_3, /* Data Transfer */
62 X25_STATE_4 /* Awaiting Reset Confirmation */
63};
64
65enum {
66 X25_LINK_STATE_0,
67 X25_LINK_STATE_1,
68 X25_LINK_STATE_2,
69 X25_LINK_STATE_3
70};
71
72#define X25_DEFAULT_T20 (180 * HZ) /* Default T20 value */
73#define X25_DEFAULT_T21 (200 * HZ) /* Default T21 value */
74#define X25_DEFAULT_T22 (180 * HZ) /* Default T22 value */
75#define X25_DEFAULT_T23 (180 * HZ) /* Default T23 value */
76#define X25_DEFAULT_T2 (3 * HZ) /* Default ack holdback value */
77
78#define X25_DEFAULT_WINDOW_SIZE 2 /* Default Window Size */
79#define X25_DEFAULT_PACKET_SIZE X25_PS128 /* Default Packet Size */
80#define X25_DEFAULT_THROUGHPUT 0x0A /* Deafult Throughput */
81#define X25_DEFAULT_REVERSE 0x00 /* Default Reverse Charging */
Shaun Pereiraebc3f642005-06-22 22:16:17 -070082#define X25_DENY_ACCPT_APPRV 0x01 /* Default value */
83#define X25_ALLOW_ACCPT_APPRV 0x00 /* Control enabled */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85#define X25_SMODULUS 8
86#define X25_EMODULUS 128
87
88/*
89 * X.25 Facilities constants.
90 */
91
92#define X25_FAC_CLASS_MASK 0xC0
93
94#define X25_FAC_CLASS_A 0x00
95#define X25_FAC_CLASS_B 0x40
96#define X25_FAC_CLASS_C 0x80
97#define X25_FAC_CLASS_D 0xC0
98
Shaun Pereiraebc3f642005-06-22 22:16:17 -070099#define X25_FAC_REVERSE 0x01 /* also fast select */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#define X25_FAC_THROUGHPUT 0x02
101#define X25_FAC_PACKET_SIZE 0x42
102#define X25_FAC_WINDOW_SIZE 0x43
103
Shaun Pereiraa64b7b92006-03-22 00:01:31 -0800104#define X25_MAX_FAC_LEN 60
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#define X25_MAX_CUD_LEN 128
106
Shaun Pereiraa64b7b92006-03-22 00:01:31 -0800107#define X25_FAC_CALLING_AE 0xCB
108#define X25_FAC_CALLED_AE 0xC9
109
110#define X25_MARKER 0x00
111#define X25_DTE_SERVICES 0x0F
112#define X25_MAX_AE_LEN 40 /* Max num of semi-octets in AE - OSI Nw */
113#define X25_MAX_DTE_FACIL_LEN 21 /* Max length of DTE facility params */
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115/**
116 * struct x25_route - x25 routing entry
117 * @node - entry in x25_list_lock
118 * @address - Start of address range
119 * @sigdigits - Number of sig digits
120 * @dev - More than one for MLP
121 * @refcnt - reference counter
122 */
123struct x25_route {
124 struct list_head node;
125 struct x25_address address;
126 unsigned int sigdigits;
127 struct net_device *dev;
128 atomic_t refcnt;
129};
130
131struct x25_neigh {
132 struct list_head node;
133 struct net_device *dev;
134 unsigned int state;
135 unsigned int extended;
136 struct sk_buff_head queue;
137 unsigned long t20;
138 struct timer_list t20timer;
139 unsigned long global_facil_mask;
140 atomic_t refcnt;
141};
142
143struct x25_sock {
144 struct sock sk;
145 struct x25_address source_addr, dest_addr;
146 struct x25_neigh *neighbour;
Shaun Pereiracb65d502005-06-22 22:15:01 -0700147 unsigned int lci, cudmatchlength;
Shaun Pereiraebc3f642005-06-22 22:16:17 -0700148 unsigned char state, condition, qbitincl, intflag, accptapprv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 unsigned short vs, vr, va, vl;
150 unsigned long t2, t21, t22, t23;
151 unsigned short fraglen;
152 struct sk_buff_head ack_queue;
153 struct sk_buff_head fragment_queue;
154 struct sk_buff_head interrupt_in_queue;
155 struct sk_buff_head interrupt_out_queue;
156 struct timer_list timer;
157 struct x25_causediag causediag;
158 struct x25_facilities facilities;
Shaun Pereiraa64b7b92006-03-22 00:01:31 -0800159 struct x25_dte_facilities dte_facilities;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 struct x25_calluserdata calluserdata;
161 unsigned long vc_facil_mask; /* inc_call facilities mask */
162};
163
Andrew Hendry95a9dc42007-02-08 13:34:02 -0800164struct x25_forward {
165 struct list_head node;
166 unsigned int lci;
167 struct net_device *dev1;
168 struct net_device *dev2;
169 atomic_t refcnt;
170};
171
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172static inline struct x25_sock *x25_sk(const struct sock *sk)
173{
174 return (struct x25_sock *)sk;
175}
176
177/* af_x25.c */
178extern int sysctl_x25_restart_request_timeout;
179extern int sysctl_x25_call_request_timeout;
180extern int sysctl_x25_reset_request_timeout;
181extern int sysctl_x25_clear_request_timeout;
182extern int sysctl_x25_ack_holdback_timeout;
Andrew Hendry39e21c02007-02-08 13:34:36 -0800183extern int sysctl_x25_forward;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185extern int x25_addr_ntoa(unsigned char *, struct x25_address *,
186 struct x25_address *);
187extern int x25_addr_aton(unsigned char *, struct x25_address *,
188 struct x25_address *);
189extern struct sock *x25_find_socket(unsigned int, struct x25_neigh *);
David S. Miller14ebaf82009-06-16 05:40:30 -0700190extern void x25_destroy_socket_from_timer(struct sock *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191extern int x25_rx_call_request(struct sk_buff *, struct x25_neigh *, unsigned int);
192extern void x25_kill_by_neigh(struct x25_neigh *);
193
194/* x25_dev.c */
195extern void x25_send_frame(struct sk_buff *, struct x25_neigh *);
David S. Millerf2ccd8f2005-08-09 19:34:12 -0700196extern int x25_lapb_receive_frame(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197extern void x25_establish_link(struct x25_neigh *);
198extern void x25_terminate_link(struct x25_neigh *);
199
200/* x25_facilities.c */
Shaun Pereiraa64b7b92006-03-22 00:01:31 -0800201extern int x25_parse_facilities(struct sk_buff *, struct x25_facilities *,
202 struct x25_dte_facilities *, unsigned long *);
203extern int x25_create_facilities(unsigned char *, struct x25_facilities *,
204 struct x25_dte_facilities *, unsigned long);
205extern int x25_negotiate_facilities(struct sk_buff *, struct sock *,
206 struct x25_facilities *,
207 struct x25_dte_facilities *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208extern void x25_limit_facilities(struct x25_facilities *, struct x25_neigh *);
209
Andrew Hendry95a9dc42007-02-08 13:34:02 -0800210/* x25_forward.c */
211extern void x25_clear_forward_by_lci(unsigned int lci);
212extern void x25_clear_forward_by_dev(struct net_device *);
213extern int x25_forward_data(int, struct x25_neigh *, struct sk_buff *);
214extern int x25_forward_call(struct x25_address *, struct x25_neigh *,
215 struct sk_buff *, int);
216
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217/* x25_in.c */
218extern int x25_process_rx_frame(struct sock *, struct sk_buff *);
219extern int x25_backlog_rcv(struct sock *, struct sk_buff *);
220
221/* x25_link.c */
222extern void x25_link_control(struct sk_buff *, struct x25_neigh *, unsigned short);
223extern void x25_link_device_up(struct net_device *);
224extern void x25_link_device_down(struct net_device *);
225extern void x25_link_established(struct x25_neigh *);
226extern void x25_link_terminated(struct x25_neigh *);
227extern void x25_transmit_clear_request(struct x25_neigh *, unsigned int, unsigned char);
228extern void x25_transmit_link(struct sk_buff *, struct x25_neigh *);
229extern int x25_subscr_ioctl(unsigned int, void __user *);
230extern struct x25_neigh *x25_get_neigh(struct net_device *);
231extern void x25_link_free(void);
232
233/* x25_neigh.c */
234static __inline__ void x25_neigh_hold(struct x25_neigh *nb)
235{
236 atomic_inc(&nb->refcnt);
237}
238
239static __inline__ void x25_neigh_put(struct x25_neigh *nb)
240{
241 if (atomic_dec_and_test(&nb->refcnt))
242 kfree(nb);
243}
244
245/* x25_out.c */
246extern int x25_output(struct sock *, struct sk_buff *);
247extern void x25_kick(struct sock *);
248extern void x25_enquiry_response(struct sock *);
249
250/* x25_route.c */
251extern struct x25_route *x25_get_route(struct x25_address *addr);
252extern struct net_device *x25_dev_get(char *);
253extern void x25_route_device_down(struct net_device *dev);
254extern int x25_route_ioctl(unsigned int, void __user *);
255extern void x25_route_free(void);
256
257static __inline__ void x25_route_hold(struct x25_route *rt)
258{
259 atomic_inc(&rt->refcnt);
260}
261
262static __inline__ void x25_route_put(struct x25_route *rt)
263{
264 if (atomic_dec_and_test(&rt->refcnt))
265 kfree(rt);
266}
267
268/* x25_subr.c */
269extern void x25_clear_queues(struct sock *);
270extern void x25_frames_acked(struct sock *, unsigned short);
271extern void x25_requeue_frames(struct sock *);
272extern int x25_validate_nr(struct sock *, unsigned short);
273extern void x25_write_internal(struct sock *, int);
274extern int x25_decode(struct sock *, struct sk_buff *, int *, int *, int *, int *, int *);
275extern void x25_disconnect(struct sock *, int, unsigned char, unsigned char);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
277/* x25_timer.c */
Adrian Bunk7f18ba62007-01-03 18:48:13 -0800278extern void x25_init_timers(struct sock *sk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279extern void x25_start_heartbeat(struct sock *);
280extern void x25_start_t2timer(struct sock *);
281extern void x25_start_t21timer(struct sock *);
282extern void x25_start_t22timer(struct sock *);
283extern void x25_start_t23timer(struct sock *);
284extern void x25_stop_heartbeat(struct sock *);
285extern void x25_stop_timer(struct sock *);
286extern unsigned long x25_display_timer(struct sock *);
287extern void x25_check_rbuf(struct sock *);
288
289/* sysctl_net_x25.c */
andrew hendry2f5517a2009-11-24 15:15:26 +0000290#ifdef CONFIG_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291extern void x25_register_sysctl(void);
292extern void x25_unregister_sysctl(void);
andrew hendry2f5517a2009-11-24 15:15:26 +0000293#else
294static inline void x25_register_sysctl(void) {};
295static inline void x25_unregister_sysctl(void) {};
296#endif /* CONFIG_SYSCTL */
297
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298struct x25_skb_cb {
299 unsigned flags;
300};
301#define X25_SKB_CB(s) ((struct x25_skb_cb *) ((s)->cb))
302
303extern struct hlist_head x25_list;
304extern rwlock_t x25_list_lock;
305extern struct list_head x25_route_list;
306extern rwlock_t x25_route_list_lock;
Andrew Hendry95a9dc42007-02-08 13:34:02 -0800307extern struct list_head x25_forward_list;
308extern rwlock_t x25_forward_list_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310extern int x25_proc_init(void);
311extern void x25_proc_exit(void);
312#endif