blob: 7a1ba5bbb868622529cd52c3821c8469ea1bed11 [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 */
82
83#define X25_SMODULUS 8
84#define X25_EMODULUS 128
85
86/*
87 * X.25 Facilities constants.
88 */
89
90#define X25_FAC_CLASS_MASK 0xC0
91
92#define X25_FAC_CLASS_A 0x00
93#define X25_FAC_CLASS_B 0x40
94#define X25_FAC_CLASS_C 0x80
95#define X25_FAC_CLASS_D 0xC0
96
97#define X25_FAC_REVERSE 0x01
98#define X25_FAC_THROUGHPUT 0x02
99#define X25_FAC_PACKET_SIZE 0x42
100#define X25_FAC_WINDOW_SIZE 0x43
101
102#define X25_MAX_FAC_LEN 20 /* Plenty to spare */
103#define X25_MAX_CUD_LEN 128
104
105/**
106 * struct x25_route - x25 routing entry
107 * @node - entry in x25_list_lock
108 * @address - Start of address range
109 * @sigdigits - Number of sig digits
110 * @dev - More than one for MLP
111 * @refcnt - reference counter
112 */
113struct x25_route {
114 struct list_head node;
115 struct x25_address address;
116 unsigned int sigdigits;
117 struct net_device *dev;
118 atomic_t refcnt;
119};
120
121struct x25_neigh {
122 struct list_head node;
123 struct net_device *dev;
124 unsigned int state;
125 unsigned int extended;
126 struct sk_buff_head queue;
127 unsigned long t20;
128 struct timer_list t20timer;
129 unsigned long global_facil_mask;
130 atomic_t refcnt;
131};
132
133struct x25_sock {
134 struct sock sk;
135 struct x25_address source_addr, dest_addr;
136 struct x25_neigh *neighbour;
137 unsigned int lci;
138 unsigned char state, condition, qbitincl, intflag;
139 unsigned short vs, vr, va, vl;
140 unsigned long t2, t21, t22, t23;
141 unsigned short fraglen;
142 struct sk_buff_head ack_queue;
143 struct sk_buff_head fragment_queue;
144 struct sk_buff_head interrupt_in_queue;
145 struct sk_buff_head interrupt_out_queue;
146 struct timer_list timer;
147 struct x25_causediag causediag;
148 struct x25_facilities facilities;
149 struct x25_calluserdata calluserdata;
150 unsigned long vc_facil_mask; /* inc_call facilities mask */
151};
152
153static inline struct x25_sock *x25_sk(const struct sock *sk)
154{
155 return (struct x25_sock *)sk;
156}
157
158/* af_x25.c */
159extern int sysctl_x25_restart_request_timeout;
160extern int sysctl_x25_call_request_timeout;
161extern int sysctl_x25_reset_request_timeout;
162extern int sysctl_x25_clear_request_timeout;
163extern int sysctl_x25_ack_holdback_timeout;
164
165extern int x25_addr_ntoa(unsigned char *, struct x25_address *,
166 struct x25_address *);
167extern int x25_addr_aton(unsigned char *, struct x25_address *,
168 struct x25_address *);
169extern struct sock *x25_find_socket(unsigned int, struct x25_neigh *);
170extern void x25_destroy_socket(struct sock *);
171extern int x25_rx_call_request(struct sk_buff *, struct x25_neigh *, unsigned int);
172extern void x25_kill_by_neigh(struct x25_neigh *);
173
174/* x25_dev.c */
175extern void x25_send_frame(struct sk_buff *, struct x25_neigh *);
176extern int x25_lapb_receive_frame(struct sk_buff *, struct net_device *, struct packet_type *);
177extern void x25_establish_link(struct x25_neigh *);
178extern void x25_terminate_link(struct x25_neigh *);
179
180/* x25_facilities.c */
181extern int x25_parse_facilities(struct sk_buff *, struct x25_facilities *, unsigned long *);
182extern int x25_create_facilities(unsigned char *, struct x25_facilities *, unsigned long);
183extern int x25_negotiate_facilities(struct sk_buff *, struct sock *, struct x25_facilities *);
184extern void x25_limit_facilities(struct x25_facilities *, struct x25_neigh *);
185
186/* x25_in.c */
187extern int x25_process_rx_frame(struct sock *, struct sk_buff *);
188extern int x25_backlog_rcv(struct sock *, struct sk_buff *);
189
190/* x25_link.c */
191extern void x25_link_control(struct sk_buff *, struct x25_neigh *, unsigned short);
192extern void x25_link_device_up(struct net_device *);
193extern void x25_link_device_down(struct net_device *);
194extern void x25_link_established(struct x25_neigh *);
195extern void x25_link_terminated(struct x25_neigh *);
196extern void x25_transmit_clear_request(struct x25_neigh *, unsigned int, unsigned char);
197extern void x25_transmit_link(struct sk_buff *, struct x25_neigh *);
198extern int x25_subscr_ioctl(unsigned int, void __user *);
199extern struct x25_neigh *x25_get_neigh(struct net_device *);
200extern void x25_link_free(void);
201
202/* x25_neigh.c */
203static __inline__ void x25_neigh_hold(struct x25_neigh *nb)
204{
205 atomic_inc(&nb->refcnt);
206}
207
208static __inline__ void x25_neigh_put(struct x25_neigh *nb)
209{
210 if (atomic_dec_and_test(&nb->refcnt))
211 kfree(nb);
212}
213
214/* x25_out.c */
215extern int x25_output(struct sock *, struct sk_buff *);
216extern void x25_kick(struct sock *);
217extern void x25_enquiry_response(struct sock *);
218
219/* x25_route.c */
220extern struct x25_route *x25_get_route(struct x25_address *addr);
221extern struct net_device *x25_dev_get(char *);
222extern void x25_route_device_down(struct net_device *dev);
223extern int x25_route_ioctl(unsigned int, void __user *);
224extern void x25_route_free(void);
225
226static __inline__ void x25_route_hold(struct x25_route *rt)
227{
228 atomic_inc(&rt->refcnt);
229}
230
231static __inline__ void x25_route_put(struct x25_route *rt)
232{
233 if (atomic_dec_and_test(&rt->refcnt))
234 kfree(rt);
235}
236
237/* x25_subr.c */
238extern void x25_clear_queues(struct sock *);
239extern void x25_frames_acked(struct sock *, unsigned short);
240extern void x25_requeue_frames(struct sock *);
241extern int x25_validate_nr(struct sock *, unsigned short);
242extern void x25_write_internal(struct sock *, int);
243extern int x25_decode(struct sock *, struct sk_buff *, int *, int *, int *, int *, int *);
244extern void x25_disconnect(struct sock *, int, unsigned char, unsigned char);
245extern int x25_check_calluserdata(struct x25_calluserdata *,struct x25_calluserdata *);
246
247/* x25_timer.c */
248extern void x25_start_heartbeat(struct sock *);
249extern void x25_start_t2timer(struct sock *);
250extern void x25_start_t21timer(struct sock *);
251extern void x25_start_t22timer(struct sock *);
252extern void x25_start_t23timer(struct sock *);
253extern void x25_stop_heartbeat(struct sock *);
254extern void x25_stop_timer(struct sock *);
255extern unsigned long x25_display_timer(struct sock *);
256extern void x25_check_rbuf(struct sock *);
257
258/* sysctl_net_x25.c */
259extern void x25_register_sysctl(void);
260extern void x25_unregister_sysctl(void);
261struct x25_skb_cb {
262 unsigned flags;
263};
264#define X25_SKB_CB(s) ((struct x25_skb_cb *) ((s)->cb))
265
266extern struct hlist_head x25_list;
267extern rwlock_t x25_list_lock;
268extern struct list_head x25_route_list;
269extern rwlock_t x25_route_list_lock;
270
271extern int x25_proc_init(void);
272extern void x25_proc_exit(void);
273#endif