This source file includes following definitions.
- dn_before
- dn_after
- dn_equal
- dn_before_or_equal
- seq_add
- seq_next
- sendack
- dn_congested
1
2 #ifndef _NET_DN_NSP_H
3 #define _NET_DN_NSP_H
4
5
6
7
8
9
10 void dn_nsp_send_data_ack(struct sock *sk);
11 void dn_nsp_send_oth_ack(struct sock *sk);
12 void dn_send_conn_ack(struct sock *sk);
13 void dn_send_conn_conf(struct sock *sk, gfp_t gfp);
14 void dn_nsp_send_disc(struct sock *sk, unsigned char type,
15 unsigned short reason, gfp_t gfp);
16 void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type,
17 unsigned short reason);
18 void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval);
19 void dn_nsp_send_conninit(struct sock *sk, unsigned char flags);
20
21 void dn_nsp_output(struct sock *sk);
22 int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb,
23 struct sk_buff_head *q, unsigned short acknum);
24 void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, gfp_t gfp,
25 int oob);
26 unsigned long dn_nsp_persist(struct sock *sk);
27 int dn_nsp_xmit_timeout(struct sock *sk);
28
29 int dn_nsp_rx(struct sk_buff *);
30 int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
31
32 struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
33 struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock,
34 long timeo, int *err);
35
36 #define NSP_REASON_OK 0
37 #define NSP_REASON_NR 1
38 #define NSP_REASON_UN 2
39 #define NSP_REASON_SD 3
40 #define NSP_REASON_ID 4
41 #define NSP_REASON_ER 5
42 #define NSP_REASON_OB 6
43 #define NSP_REASON_US 7
44 #define NSP_REASON_TP 8
45 #define NSP_REASON_EA 9
46 #define NSP_REASON_IF 10
47 #define NSP_REASON_LS 11
48 #define NSP_REASON_LL 32
49 #define NSP_REASON_LE 33
50 #define NSP_REASON_UR 34
51 #define NSP_REASON_UA 36
52 #define NSP_REASON_TM 38
53 #define NSP_REASON_NU 39
54 #define NSP_REASON_NL 41
55 #define NSP_REASON_DC 42
56 #define NSP_REASON_IO 43
57
58 #define NSP_DISCINIT 0x38
59 #define NSP_DISCCONF 0x48
60
61
62
63
64
65
66
67 struct nsp_data_seg_msg {
68 __u8 msgflg;
69 __le16 dstaddr;
70 __le16 srcaddr;
71 } __packed;
72
73 struct nsp_data_opt_msg {
74 __le16 acknum;
75 __le16 segnum;
76 __le16 lsflgs;
77 } __packed;
78
79 struct nsp_data_opt_msg1 {
80 __le16 acknum;
81 __le16 segnum;
82 } __packed;
83
84
85
86 struct nsp_data_ack_msg {
87 __u8 msgflg;
88 __le16 dstaddr;
89 __le16 srcaddr;
90 __le16 acknum;
91 } __packed;
92
93
94 struct nsp_conn_ack_msg {
95 __u8 msgflg;
96 __le16 dstaddr;
97 } __packed;
98
99
100
101 struct nsp_conn_init_msg {
102 __u8 msgflg;
103 #define NSP_CI 0x18
104 #define NSP_RCI 0x68
105 __le16 dstaddr;
106 __le16 srcaddr;
107 __u8 services;
108 #define NSP_FC_NONE 0x00
109 #define NSP_FC_SRC 0x04
110 #define NSP_FC_SCMC 0x08
111 #define NSP_FC_MASK 0x0c
112 __u8 info;
113 __le16 segsize;
114 } __packed;
115
116
117 struct nsp_disconn_init_msg {
118 __u8 msgflg;
119 __le16 dstaddr;
120 __le16 srcaddr;
121 __le16 reason;
122 } __packed;
123
124
125
126 struct srcobj_fmt {
127 __u8 format;
128 __u8 task;
129 __le16 grpcode;
130 __le16 usrcode;
131 __u8 dlen;
132 } __packed;
133
134
135
136
137
138
139 static __inline__ int dn_before(__u16 seq1, __u16 seq2)
140 {
141 seq1 &= 0x0fff;
142 seq2 &= 0x0fff;
143
144 return (int)((seq1 - seq2) & 0x0fff) > 2048;
145 }
146
147
148 static __inline__ int dn_after(__u16 seq1, __u16 seq2)
149 {
150 seq1 &= 0x0fff;
151 seq2 &= 0x0fff;
152
153 return (int)((seq2 - seq1) & 0x0fff) > 2048;
154 }
155
156 static __inline__ int dn_equal(__u16 seq1, __u16 seq2)
157 {
158 return ((seq1 ^ seq2) & 0x0fff) == 0;
159 }
160
161 static __inline__ int dn_before_or_equal(__u16 seq1, __u16 seq2)
162 {
163 return (dn_before(seq1, seq2) || dn_equal(seq1, seq2));
164 }
165
166 static __inline__ void seq_add(__u16 *seq, __u16 off)
167 {
168 (*seq) += off;
169 (*seq) &= 0x0fff;
170 }
171
172 static __inline__ int seq_next(__u16 seq1, __u16 seq2)
173 {
174 return dn_equal(seq1 + 1, seq2);
175 }
176
177
178
179
180 static __inline__ int sendack(__u16 seq)
181 {
182 return (int)((seq & 0x1000) ? 0 : 1);
183 }
184
185
186
187
188 static __inline__ int dn_congested(struct sock *sk)
189 {
190 return atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1);
191 }
192
193 #define DN_MAX_NSP_DATA_HEADER (11)
194
195 #endif