0001
0002 #ifndef _LAPB_H
0003 #define _LAPB_H
0004 #include <linux/lapb.h>
0005 #include <linux/refcount.h>
0006
0007 #define LAPB_HEADER_LEN 20
0008
0009 #define LAPB_ACK_PENDING_CONDITION 0x01
0010 #define LAPB_REJECT_CONDITION 0x02
0011 #define LAPB_PEER_RX_BUSY_CONDITION 0x04
0012
0013
0014 #define LAPB_I 0x00
0015 #define LAPB_S 0x01
0016 #define LAPB_U 0x03
0017
0018 #define LAPB_RR 0x01
0019 #define LAPB_RNR 0x05
0020 #define LAPB_REJ 0x09
0021
0022 #define LAPB_SABM 0x2F
0023 #define LAPB_SABME 0x6F
0024 #define LAPB_DISC 0x43
0025 #define LAPB_DM 0x0F
0026 #define LAPB_UA 0x63
0027 #define LAPB_FRMR 0x87
0028
0029 #define LAPB_ILLEGAL 0x100
0030
0031 #define LAPB_SPF 0x10
0032 #define LAPB_EPF 0x01
0033
0034 #define LAPB_FRMR_W 0x01
0035 #define LAPB_FRMR_X 0x02
0036 #define LAPB_FRMR_Y 0x04
0037 #define LAPB_FRMR_Z 0x08
0038
0039 #define LAPB_POLLOFF 0
0040 #define LAPB_POLLON 1
0041
0042
0043 #define LAPB_COMMAND 1
0044 #define LAPB_RESPONSE 2
0045
0046 #define LAPB_ADDR_A 0x03
0047 #define LAPB_ADDR_B 0x01
0048 #define LAPB_ADDR_C 0x0F
0049 #define LAPB_ADDR_D 0x07
0050
0051
0052 enum {
0053 LAPB_STATE_0,
0054 LAPB_STATE_1,
0055 LAPB_STATE_2,
0056 LAPB_STATE_3,
0057 LAPB_STATE_4
0058 };
0059
0060 #define LAPB_DEFAULT_MODE (LAPB_STANDARD | LAPB_SLP | LAPB_DTE)
0061 #define LAPB_DEFAULT_WINDOW 7
0062 #define LAPB_DEFAULT_T1 (5 * HZ)
0063 #define LAPB_DEFAULT_T2 (1 * HZ)
0064 #define LAPB_DEFAULT_N2 20
0065
0066 #define LAPB_SMODULUS 8
0067 #define LAPB_EMODULUS 128
0068
0069
0070
0071
0072 struct lapb_frame {
0073 unsigned short type;
0074 unsigned short nr, ns;
0075 unsigned char cr;
0076 unsigned char pf;
0077 unsigned char control[2];
0078 };
0079
0080
0081
0082
0083 struct lapb_cb {
0084 struct list_head node;
0085 struct net_device *dev;
0086
0087
0088 unsigned int mode;
0089 unsigned char state;
0090 unsigned short vs, vr, va;
0091 unsigned char condition;
0092 unsigned short n2, n2count;
0093 unsigned short t1, t2;
0094 struct timer_list t1timer, t2timer;
0095 bool t1timer_running, t2timer_running;
0096
0097
0098 struct sk_buff_head write_queue;
0099 struct sk_buff_head ack_queue;
0100 unsigned char window;
0101 const struct lapb_register_struct *callbacks;
0102
0103
0104 struct lapb_frame frmr_data;
0105 unsigned char frmr_type;
0106
0107 spinlock_t lock;
0108 refcount_t refcnt;
0109 };
0110
0111
0112 void lapb_connect_confirmation(struct lapb_cb *lapb, int);
0113 void lapb_connect_indication(struct lapb_cb *lapb, int);
0114 void lapb_disconnect_confirmation(struct lapb_cb *lapb, int);
0115 void lapb_disconnect_indication(struct lapb_cb *lapb, int);
0116 int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *);
0117 int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *);
0118
0119
0120 void lapb_data_input(struct lapb_cb *lapb, struct sk_buff *);
0121
0122
0123 void lapb_kick(struct lapb_cb *lapb);
0124 void lapb_transmit_buffer(struct lapb_cb *lapb, struct sk_buff *, int);
0125 void lapb_establish_data_link(struct lapb_cb *lapb);
0126 void lapb_enquiry_response(struct lapb_cb *lapb);
0127 void lapb_timeout_response(struct lapb_cb *lapb);
0128 void lapb_check_iframes_acked(struct lapb_cb *lapb, unsigned short);
0129 void lapb_check_need_response(struct lapb_cb *lapb, int, int);
0130
0131
0132 void lapb_clear_queues(struct lapb_cb *lapb);
0133 void lapb_frames_acked(struct lapb_cb *lapb, unsigned short);
0134 void lapb_requeue_frames(struct lapb_cb *lapb);
0135 int lapb_validate_nr(struct lapb_cb *lapb, unsigned short);
0136 int lapb_decode(struct lapb_cb *lapb, struct sk_buff *, struct lapb_frame *);
0137 void lapb_send_control(struct lapb_cb *lapb, int, int, int);
0138 void lapb_transmit_frmr(struct lapb_cb *lapb);
0139
0140
0141 void lapb_start_t1timer(struct lapb_cb *lapb);
0142 void lapb_start_t2timer(struct lapb_cb *lapb);
0143 void lapb_stop_t1timer(struct lapb_cb *lapb);
0144 void lapb_stop_t2timer(struct lapb_cb *lapb);
0145 int lapb_t1timer_running(struct lapb_cb *lapb);
0146
0147
0148
0149
0150
0151
0152
0153
0154 #define LAPB_DEBUG 0
0155
0156 #define lapb_dbg(level, fmt, ...) \
0157 do { \
0158 if (level < LAPB_DEBUG) \
0159 pr_debug(fmt, ##__VA_ARGS__); \
0160 } while (0)
0161
0162 #endif