2 * Declarations of X.25 Packet Layer type objects.
5 * nov/17/96 Jonathan Naylor Initial version.
6 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities
12 #include <linux/x25.h>
15 #define X25_ADDR_LEN 16
17 #define X25_MAX_L2_LEN 18 /* 802.2 LLC */
19 #define X25_STD_MIN_LEN 3
20 #define X25_EXT_MIN_LEN 4
22 #define X25_GFI_SEQ_MASK 0x30
23 #define X25_GFI_STDSEQ 0x10
24 #define X25_GFI_EXTSEQ 0x20
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
31 #define X25_CALL_REQUEST 0x0B
32 #define X25_CALL_ACCEPTED 0x0F
33 #define X25_CLEAR_REQUEST 0x13
34 #define X25_CLEAR_CONFIRMATION 0x17
36 #define X25_INTERRUPT 0x23
37 #define X25_INTERRUPT_CONFIRMATION 0x27
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
50 /* Define the various conditions that may exist */
52 #define X25_COND_ACK_PENDING 0x01
53 #define X25_COND_OWN_RX_BUSY 0x02
54 #define X25_COND_PEER_RX_BUSY 0x04
56 /* Define Link State constants. */
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 */
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 */
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 #define X25_DENY_ACCPT_APPRV 0x01 /* Default value */
83 #define X25_ALLOW_ACCPT_APPRV 0x00 /* Control enabled */
85 #define X25_SMODULUS 8
86 #define X25_EMODULUS 128
89 * X.25 Facilities constants.
92 #define X25_FAC_CLASS_MASK 0xC0
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
99 #define X25_FAC_REVERSE 0x01 /* also fast select */
100 #define X25_FAC_THROUGHPUT 0x02
101 #define X25_FAC_PACKET_SIZE 0x42
102 #define X25_FAC_WINDOW_SIZE 0x43
104 #define X25_MAX_FAC_LEN 20 /* Plenty to spare */
105 #define X25_MAX_CUD_LEN 128
108 * struct x25_route - x25 routing entry
109 * @node - entry in x25_list_lock
110 * @address - Start of address range
111 * @sigdigits - Number of sig digits
112 * @dev - More than one for MLP
113 * @refcnt - reference counter
116 struct list_head node
;
117 struct x25_address address
;
118 unsigned int sigdigits
;
119 struct net_device
*dev
;
124 struct list_head node
;
125 struct net_device
*dev
;
127 unsigned int extended
;
128 struct sk_buff_head queue
;
130 struct timer_list t20timer
;
131 unsigned long global_facil_mask
;
137 struct x25_address source_addr
, dest_addr
;
138 struct x25_neigh
*neighbour
;
139 unsigned int lci
, cudmatchlength
;
140 unsigned char state
, condition
, qbitincl
, intflag
, accptapprv
;
141 unsigned short vs
, vr
, va
, vl
;
142 unsigned long t2
, t21
, t22
, t23
;
143 unsigned short fraglen
;
144 struct sk_buff_head ack_queue
;
145 struct sk_buff_head fragment_queue
;
146 struct sk_buff_head interrupt_in_queue
;
147 struct sk_buff_head interrupt_out_queue
;
148 struct timer_list timer
;
149 struct x25_causediag causediag
;
150 struct x25_facilities facilities
;
151 struct x25_calluserdata calluserdata
;
152 unsigned long vc_facil_mask
; /* inc_call facilities mask */
155 static inline struct x25_sock
*x25_sk(const struct sock
*sk
)
157 return (struct x25_sock
*)sk
;
161 extern int sysctl_x25_restart_request_timeout
;
162 extern int sysctl_x25_call_request_timeout
;
163 extern int sysctl_x25_reset_request_timeout
;
164 extern int sysctl_x25_clear_request_timeout
;
165 extern int sysctl_x25_ack_holdback_timeout
;
167 extern int x25_addr_ntoa(unsigned char *, struct x25_address
*,
168 struct x25_address
*);
169 extern int x25_addr_aton(unsigned char *, struct x25_address
*,
170 struct x25_address
*);
171 extern struct sock
*x25_find_socket(unsigned int, struct x25_neigh
*);
172 extern void x25_destroy_socket(struct sock
*);
173 extern int x25_rx_call_request(struct sk_buff
*, struct x25_neigh
*, unsigned int);
174 extern void x25_kill_by_neigh(struct x25_neigh
*);
177 extern void x25_send_frame(struct sk_buff
*, struct x25_neigh
*);
178 extern int x25_lapb_receive_frame(struct sk_buff
*, struct net_device
*, struct packet_type
*, struct net_device
*);
179 extern void x25_establish_link(struct x25_neigh
*);
180 extern void x25_terminate_link(struct x25_neigh
*);
182 /* x25_facilities.c */
183 extern int x25_parse_facilities(struct sk_buff
*, struct x25_facilities
*, unsigned long *);
184 extern int x25_create_facilities(unsigned char *, struct x25_facilities
*, unsigned long);
185 extern int x25_negotiate_facilities(struct sk_buff
*, struct sock
*, struct x25_facilities
*);
186 extern void x25_limit_facilities(struct x25_facilities
*, struct x25_neigh
*);
189 extern int x25_process_rx_frame(struct sock
*, struct sk_buff
*);
190 extern int x25_backlog_rcv(struct sock
*, struct sk_buff
*);
193 extern void x25_link_control(struct sk_buff
*, struct x25_neigh
*, unsigned short);
194 extern void x25_link_device_up(struct net_device
*);
195 extern void x25_link_device_down(struct net_device
*);
196 extern void x25_link_established(struct x25_neigh
*);
197 extern void x25_link_terminated(struct x25_neigh
*);
198 extern void x25_transmit_clear_request(struct x25_neigh
*, unsigned int, unsigned char);
199 extern void x25_transmit_link(struct sk_buff
*, struct x25_neigh
*);
200 extern int x25_subscr_ioctl(unsigned int, void __user
*);
201 extern struct x25_neigh
*x25_get_neigh(struct net_device
*);
202 extern void x25_link_free(void);
205 static __inline__
void x25_neigh_hold(struct x25_neigh
*nb
)
207 atomic_inc(&nb
->refcnt
);
210 static __inline__
void x25_neigh_put(struct x25_neigh
*nb
)
212 if (atomic_dec_and_test(&nb
->refcnt
))
217 extern int x25_output(struct sock
*, struct sk_buff
*);
218 extern void x25_kick(struct sock
*);
219 extern void x25_enquiry_response(struct sock
*);
222 extern struct x25_route
*x25_get_route(struct x25_address
*addr
);
223 extern struct net_device
*x25_dev_get(char *);
224 extern void x25_route_device_down(struct net_device
*dev
);
225 extern int x25_route_ioctl(unsigned int, void __user
*);
226 extern void x25_route_free(void);
228 static __inline__
void x25_route_hold(struct x25_route
*rt
)
230 atomic_inc(&rt
->refcnt
);
233 static __inline__
void x25_route_put(struct x25_route
*rt
)
235 if (atomic_dec_and_test(&rt
->refcnt
))
240 extern void x25_clear_queues(struct sock
*);
241 extern void x25_frames_acked(struct sock
*, unsigned short);
242 extern void x25_requeue_frames(struct sock
*);
243 extern int x25_validate_nr(struct sock
*, unsigned short);
244 extern void x25_write_internal(struct sock
*, int);
245 extern int x25_decode(struct sock
*, struct sk_buff
*, int *, int *, int *, int *, int *);
246 extern void x25_disconnect(struct sock
*, int, unsigned char, unsigned char);
249 extern void x25_start_heartbeat(struct sock
*);
250 extern void x25_start_t2timer(struct sock
*);
251 extern void x25_start_t21timer(struct sock
*);
252 extern void x25_start_t22timer(struct sock
*);
253 extern void x25_start_t23timer(struct sock
*);
254 extern void x25_stop_heartbeat(struct sock
*);
255 extern void x25_stop_timer(struct sock
*);
256 extern unsigned long x25_display_timer(struct sock
*);
257 extern void x25_check_rbuf(struct sock
*);
259 /* sysctl_net_x25.c */
260 extern void x25_register_sysctl(void);
261 extern void x25_unregister_sysctl(void);
265 #define X25_SKB_CB(s) ((struct x25_skb_cb *) ((s)->cb))
267 extern struct hlist_head x25_list
;
268 extern rwlock_t x25_list_lock
;
269 extern struct list_head x25_route_list
;
270 extern rwlock_t x25_route_list_lock
;
272 extern int x25_proc_init(void);
273 extern void x25_proc_exit(void);