0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _X25_H
0012 #define _X25_H
0013 #include <linux/x25.h>
0014 #include <linux/slab.h>
0015 #include <linux/refcount.h>
0016 #include <net/sock.h>
0017
0018 #define X25_ADDR_LEN 16
0019
0020 #define X25_MAX_L2_LEN 18
0021
0022 #define X25_STD_MIN_LEN 3
0023 #define X25_EXT_MIN_LEN 4
0024
0025 #define X25_GFI_SEQ_MASK 0x30
0026 #define X25_GFI_STDSEQ 0x10
0027 #define X25_GFI_EXTSEQ 0x20
0028
0029 #define X25_Q_BIT 0x80
0030 #define X25_D_BIT 0x40
0031 #define X25_STD_M_BIT 0x10
0032 #define X25_EXT_M_BIT 0x01
0033
0034 #define X25_CALL_REQUEST 0x0B
0035 #define X25_CALL_ACCEPTED 0x0F
0036 #define X25_CLEAR_REQUEST 0x13
0037 #define X25_CLEAR_CONFIRMATION 0x17
0038 #define X25_DATA 0x00
0039 #define X25_INTERRUPT 0x23
0040 #define X25_INTERRUPT_CONFIRMATION 0x27
0041 #define X25_RR 0x01
0042 #define X25_RNR 0x05
0043 #define X25_REJ 0x09
0044 #define X25_RESET_REQUEST 0x1B
0045 #define X25_RESET_CONFIRMATION 0x1F
0046 #define X25_REGISTRATION_REQUEST 0xF3
0047 #define X25_REGISTRATION_CONFIRMATION 0xF7
0048 #define X25_RESTART_REQUEST 0xFB
0049 #define X25_RESTART_CONFIRMATION 0xFF
0050 #define X25_DIAGNOSTIC 0xF1
0051 #define X25_ILLEGAL 0xFD
0052
0053
0054
0055 #define X25_COND_ACK_PENDING 0x01
0056 #define X25_COND_OWN_RX_BUSY 0x02
0057 #define X25_COND_PEER_RX_BUSY 0x04
0058
0059
0060 enum {
0061 X25_STATE_0,
0062 X25_STATE_1,
0063 X25_STATE_2,
0064 X25_STATE_3,
0065 X25_STATE_4,
0066 X25_STATE_5
0067 };
0068
0069 enum {
0070 X25_LINK_STATE_0,
0071 X25_LINK_STATE_1,
0072 X25_LINK_STATE_2,
0073 X25_LINK_STATE_3
0074 };
0075
0076 #define X25_DEFAULT_T20 (180 * HZ)
0077 #define X25_DEFAULT_T21 (200 * HZ)
0078 #define X25_DEFAULT_T22 (180 * HZ)
0079 #define X25_DEFAULT_T23 (180 * HZ)
0080 #define X25_DEFAULT_T2 (3 * HZ)
0081
0082 #define X25_DEFAULT_WINDOW_SIZE 2
0083 #define X25_DEFAULT_PACKET_SIZE X25_PS128
0084 #define X25_DEFAULT_THROUGHPUT 0x0A
0085 #define X25_DEFAULT_REVERSE 0x00
0086
0087 #define X25_SMODULUS 8
0088 #define X25_EMODULUS 128
0089
0090
0091
0092
0093
0094 #define X25_FAC_CLASS_MASK 0xC0
0095
0096 #define X25_FAC_CLASS_A 0x00
0097 #define X25_FAC_CLASS_B 0x40
0098 #define X25_FAC_CLASS_C 0x80
0099 #define X25_FAC_CLASS_D 0xC0
0100
0101 #define X25_FAC_REVERSE 0x01
0102 #define X25_FAC_THROUGHPUT 0x02
0103 #define X25_FAC_PACKET_SIZE 0x42
0104 #define X25_FAC_WINDOW_SIZE 0x43
0105
0106 #define X25_MAX_FAC_LEN 60
0107 #define X25_MAX_CUD_LEN 128
0108
0109 #define X25_FAC_CALLING_AE 0xCB
0110 #define X25_FAC_CALLED_AE 0xC9
0111
0112 #define X25_MARKER 0x00
0113 #define X25_DTE_SERVICES 0x0F
0114 #define X25_MAX_AE_LEN 40
0115 #define X25_MAX_DTE_FACIL_LEN 21
0116
0117
0118 #define X25_Q_BIT_FLAG 0
0119 #define X25_INTERRUPT_FLAG 1
0120 #define X25_ACCPT_APPRV_FLAG 2
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130 struct x25_route {
0131 struct list_head node;
0132 struct x25_address address;
0133 unsigned int sigdigits;
0134 struct net_device *dev;
0135 refcount_t refcnt;
0136 };
0137
0138 struct x25_neigh {
0139 struct list_head node;
0140 struct net_device *dev;
0141 unsigned int state;
0142 unsigned int extended;
0143 struct sk_buff_head queue;
0144 unsigned long t20;
0145 struct timer_list t20timer;
0146 unsigned long global_facil_mask;
0147 refcount_t refcnt;
0148 };
0149
0150 struct x25_sock {
0151 struct sock sk;
0152 struct x25_address source_addr, dest_addr;
0153 struct x25_neigh *neighbour;
0154 unsigned int lci, cudmatchlength;
0155 unsigned char state, condition;
0156 unsigned short vs, vr, va, vl;
0157 unsigned long t2, t21, t22, t23;
0158 unsigned short fraglen;
0159 unsigned long flags;
0160 struct sk_buff_head ack_queue;
0161 struct sk_buff_head fragment_queue;
0162 struct sk_buff_head interrupt_in_queue;
0163 struct sk_buff_head interrupt_out_queue;
0164 struct timer_list timer;
0165 struct x25_causediag causediag;
0166 struct x25_facilities facilities;
0167 struct x25_dte_facilities dte_facilities;
0168 struct x25_calluserdata calluserdata;
0169 unsigned long vc_facil_mask;
0170 };
0171
0172 struct x25_forward {
0173 struct list_head node;
0174 unsigned int lci;
0175 struct net_device *dev1;
0176 struct net_device *dev2;
0177 atomic_t refcnt;
0178 };
0179
0180 static inline struct x25_sock *x25_sk(const struct sock *sk)
0181 {
0182 return (struct x25_sock *)sk;
0183 }
0184
0185
0186 extern int sysctl_x25_restart_request_timeout;
0187 extern int sysctl_x25_call_request_timeout;
0188 extern int sysctl_x25_reset_request_timeout;
0189 extern int sysctl_x25_clear_request_timeout;
0190 extern int sysctl_x25_ack_holdback_timeout;
0191 extern int sysctl_x25_forward;
0192
0193 int x25_parse_address_block(struct sk_buff *skb,
0194 struct x25_address *called_addr,
0195 struct x25_address *calling_addr);
0196
0197 int x25_addr_ntoa(unsigned char *, struct x25_address *, struct x25_address *);
0198 int x25_addr_aton(unsigned char *, struct x25_address *, struct x25_address *);
0199 struct sock *x25_find_socket(unsigned int, struct x25_neigh *);
0200 void x25_destroy_socket_from_timer(struct sock *);
0201 int x25_rx_call_request(struct sk_buff *, struct x25_neigh *, unsigned int);
0202 void x25_kill_by_neigh(struct x25_neigh *);
0203
0204
0205 void x25_send_frame(struct sk_buff *, struct x25_neigh *);
0206 int x25_lapb_receive_frame(struct sk_buff *, struct net_device *,
0207 struct packet_type *, struct net_device *);
0208 void x25_establish_link(struct x25_neigh *);
0209 void x25_terminate_link(struct x25_neigh *);
0210
0211
0212 int x25_parse_facilities(struct sk_buff *, struct x25_facilities *,
0213 struct x25_dte_facilities *, unsigned long *);
0214 int x25_create_facilities(unsigned char *, struct x25_facilities *,
0215 struct x25_dte_facilities *, unsigned long);
0216 int x25_negotiate_facilities(struct sk_buff *, struct sock *,
0217 struct x25_facilities *,
0218 struct x25_dte_facilities *);
0219 void x25_limit_facilities(struct x25_facilities *, struct x25_neigh *);
0220
0221
0222 void x25_clear_forward_by_lci(unsigned int lci);
0223 void x25_clear_forward_by_dev(struct net_device *);
0224 int x25_forward_data(int, struct x25_neigh *, struct sk_buff *);
0225 int x25_forward_call(struct x25_address *, struct x25_neigh *, struct sk_buff *,
0226 int);
0227
0228
0229 int x25_process_rx_frame(struct sock *, struct sk_buff *);
0230 int x25_backlog_rcv(struct sock *, struct sk_buff *);
0231
0232
0233 void x25_link_control(struct sk_buff *, struct x25_neigh *, unsigned short);
0234 void x25_link_device_up(struct net_device *);
0235 void x25_link_device_down(struct net_device *);
0236 void x25_link_established(struct x25_neigh *);
0237 void x25_link_terminated(struct x25_neigh *);
0238 void x25_transmit_clear_request(struct x25_neigh *, unsigned int,
0239 unsigned char);
0240 void x25_transmit_link(struct sk_buff *, struct x25_neigh *);
0241 int x25_subscr_ioctl(unsigned int, void __user *);
0242 struct x25_neigh *x25_get_neigh(struct net_device *);
0243 void x25_link_free(void);
0244
0245
0246 static __inline__ void x25_neigh_hold(struct x25_neigh *nb)
0247 {
0248 refcount_inc(&nb->refcnt);
0249 }
0250
0251 static __inline__ void x25_neigh_put(struct x25_neigh *nb)
0252 {
0253 if (refcount_dec_and_test(&nb->refcnt))
0254 kfree(nb);
0255 }
0256
0257
0258 int x25_output(struct sock *, struct sk_buff *);
0259 void x25_kick(struct sock *);
0260 void x25_enquiry_response(struct sock *);
0261
0262
0263 struct x25_route *x25_get_route(struct x25_address *addr);
0264 struct net_device *x25_dev_get(char *);
0265 void x25_route_device_down(struct net_device *dev);
0266 int x25_route_ioctl(unsigned int, void __user *);
0267 void x25_route_free(void);
0268
0269 static __inline__ void x25_route_hold(struct x25_route *rt)
0270 {
0271 refcount_inc(&rt->refcnt);
0272 }
0273
0274 static __inline__ void x25_route_put(struct x25_route *rt)
0275 {
0276 if (refcount_dec_and_test(&rt->refcnt))
0277 kfree(rt);
0278 }
0279
0280
0281 void x25_clear_queues(struct sock *);
0282 void x25_frames_acked(struct sock *, unsigned short);
0283 void x25_requeue_frames(struct sock *);
0284 int x25_validate_nr(struct sock *, unsigned short);
0285 void x25_write_internal(struct sock *, int);
0286 int x25_decode(struct sock *, struct sk_buff *, int *, int *, int *, int *,
0287 int *);
0288 void x25_disconnect(struct sock *, int, unsigned char, unsigned char);
0289
0290
0291 void x25_init_timers(struct sock *sk);
0292 void x25_start_heartbeat(struct sock *);
0293 void x25_start_t2timer(struct sock *);
0294 void x25_start_t21timer(struct sock *);
0295 void x25_start_t22timer(struct sock *);
0296 void x25_start_t23timer(struct sock *);
0297 void x25_stop_heartbeat(struct sock *);
0298 void x25_stop_timer(struct sock *);
0299 unsigned long x25_display_timer(struct sock *);
0300 void x25_check_rbuf(struct sock *);
0301
0302
0303 #ifdef CONFIG_SYSCTL
0304 int x25_register_sysctl(void);
0305 void x25_unregister_sysctl(void);
0306 #else
0307 static inline int x25_register_sysctl(void) { return 0; };
0308 static inline void x25_unregister_sysctl(void) {};
0309 #endif
0310
0311 struct x25_skb_cb {
0312 unsigned int flags;
0313 };
0314 #define X25_SKB_CB(s) ((struct x25_skb_cb *) ((s)->cb))
0315
0316 extern struct hlist_head x25_list;
0317 extern rwlock_t x25_list_lock;
0318 extern struct list_head x25_route_list;
0319 extern rwlock_t x25_route_list_lock;
0320 extern struct list_head x25_forward_list;
0321 extern rwlock_t x25_forward_list_lock;
0322 extern struct list_head x25_neigh_list;
0323 extern rwlock_t x25_neigh_list_lock;
0324
0325 int x25_proc_init(void);
0326 void x25_proc_exit(void);
0327 #endif