diff options
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r-- | net/dccp/dccp.h | 133 |
1 files changed, 43 insertions, 90 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 93f26dd6e6cb..1fe509148689 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -59,8 +59,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); | |||
59 | 59 | ||
60 | #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ | 60 | #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ |
61 | 61 | ||
62 | extern struct proto dccp_prot; | ||
63 | |||
64 | /* is seq1 < seq2 ? */ | 62 | /* is seq1 < seq2 ? */ |
65 | static inline int before48(const u64 seq1, const u64 seq2) | 63 | static inline int before48(const u64 seq1, const u64 seq2) |
66 | { | 64 | { |
@@ -120,7 +118,6 @@ DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics); | |||
120 | 118 | ||
121 | extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); | 119 | extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); |
122 | 120 | ||
123 | extern int dccp_send_response(struct sock *sk); | ||
124 | extern void dccp_send_ack(struct sock *sk); | 121 | extern void dccp_send_ack(struct sock *sk); |
125 | extern void dccp_send_delayed_ack(struct sock *sk); | 122 | extern void dccp_send_delayed_ack(struct sock *sk); |
126 | extern void dccp_send_sync(struct sock *sk, const u64 seq, | 123 | extern void dccp_send_sync(struct sock *sk, const u64 seq, |
@@ -140,53 +137,8 @@ extern unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu); | |||
140 | extern const char *dccp_packet_name(const int type); | 137 | extern const char *dccp_packet_name(const int type); |
141 | extern const char *dccp_state_name(const int state); | 138 | extern const char *dccp_state_name(const int state); |
142 | 139 | ||
143 | static inline void dccp_set_state(struct sock *sk, const int state) | 140 | extern void dccp_set_state(struct sock *sk, const int state); |
144 | { | 141 | extern void dccp_done(struct sock *sk); |
145 | const int oldstate = sk->sk_state; | ||
146 | |||
147 | dccp_pr_debug("%s(%p) %-10.10s -> %s\n", | ||
148 | dccp_role(sk), sk, | ||
149 | dccp_state_name(oldstate), dccp_state_name(state)); | ||
150 | WARN_ON(state == oldstate); | ||
151 | |||
152 | switch (state) { | ||
153 | case DCCP_OPEN: | ||
154 | if (oldstate != DCCP_OPEN) | ||
155 | DCCP_INC_STATS(DCCP_MIB_CURRESTAB); | ||
156 | break; | ||
157 | |||
158 | case DCCP_CLOSED: | ||
159 | if (oldstate == DCCP_CLOSING || oldstate == DCCP_OPEN) | ||
160 | DCCP_INC_STATS(DCCP_MIB_ESTABRESETS); | ||
161 | |||
162 | sk->sk_prot->unhash(sk); | ||
163 | if (inet_csk(sk)->icsk_bind_hash != NULL && | ||
164 | !(sk->sk_userlocks & SOCK_BINDPORT_LOCK)) | ||
165 | inet_put_port(&dccp_hashinfo, sk); | ||
166 | /* fall through */ | ||
167 | default: | ||
168 | if (oldstate == DCCP_OPEN) | ||
169 | DCCP_DEC_STATS(DCCP_MIB_CURRESTAB); | ||
170 | } | ||
171 | |||
172 | /* Change state AFTER socket is unhashed to avoid closed | ||
173 | * socket sitting in hash tables. | ||
174 | */ | ||
175 | sk->sk_state = state; | ||
176 | } | ||
177 | |||
178 | static inline void dccp_done(struct sock *sk) | ||
179 | { | ||
180 | dccp_set_state(sk, DCCP_CLOSED); | ||
181 | dccp_clear_xmit_timers(sk); | ||
182 | |||
183 | sk->sk_shutdown = SHUTDOWN_MASK; | ||
184 | |||
185 | if (!sock_flag(sk, SOCK_DEAD)) | ||
186 | sk->sk_state_change(sk); | ||
187 | else | ||
188 | inet_csk_destroy_sock(sk); | ||
189 | } | ||
190 | 142 | ||
191 | static inline void dccp_openreq_init(struct request_sock *req, | 143 | static inline void dccp_openreq_init(struct request_sock *req, |
192 | struct dccp_sock *dp, | 144 | struct dccp_sock *dp, |
@@ -209,10 +161,6 @@ extern struct sock *dccp_create_openreq_child(struct sock *sk, | |||
209 | 161 | ||
210 | extern int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb); | 162 | extern int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb); |
211 | 163 | ||
212 | extern void dccp_v4_err(struct sk_buff *skb, u32); | ||
213 | |||
214 | extern int dccp_v4_rcv(struct sk_buff *skb); | ||
215 | |||
216 | extern struct sock *dccp_v4_request_recv_sock(struct sock *sk, | 164 | extern struct sock *dccp_v4_request_recv_sock(struct sock *sk, |
217 | struct sk_buff *skb, | 165 | struct sk_buff *skb, |
218 | struct request_sock *req, | 166 | struct request_sock *req, |
@@ -228,24 +176,30 @@ extern int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
228 | extern int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, | 176 | extern int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, |
229 | const struct dccp_hdr *dh, const unsigned len); | 177 | const struct dccp_hdr *dh, const unsigned len); |
230 | 178 | ||
231 | extern int dccp_v4_init_sock(struct sock *sk); | 179 | extern int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized); |
232 | extern int dccp_v4_destroy_sock(struct sock *sk); | 180 | extern int dccp_destroy_sock(struct sock *sk); |
233 | 181 | ||
234 | extern void dccp_close(struct sock *sk, long timeout); | 182 | extern void dccp_close(struct sock *sk, long timeout); |
235 | extern struct sk_buff *dccp_make_response(struct sock *sk, | 183 | extern struct sk_buff *dccp_make_response(struct sock *sk, |
236 | struct dst_entry *dst, | 184 | struct dst_entry *dst, |
237 | struct request_sock *req); | 185 | struct request_sock *req); |
238 | extern struct sk_buff *dccp_make_reset(struct sock *sk, | ||
239 | struct dst_entry *dst, | ||
240 | enum dccp_reset_codes code); | ||
241 | 186 | ||
242 | extern int dccp_connect(struct sock *sk); | 187 | extern int dccp_connect(struct sock *sk); |
243 | extern int dccp_disconnect(struct sock *sk, int flags); | 188 | extern int dccp_disconnect(struct sock *sk, int flags); |
189 | extern void dccp_hash(struct sock *sk); | ||
244 | extern void dccp_unhash(struct sock *sk); | 190 | extern void dccp_unhash(struct sock *sk); |
245 | extern int dccp_getsockopt(struct sock *sk, int level, int optname, | 191 | extern int dccp_getsockopt(struct sock *sk, int level, int optname, |
246 | char __user *optval, int __user *optlen); | 192 | char __user *optval, int __user *optlen); |
247 | extern int dccp_setsockopt(struct sock *sk, int level, int optname, | 193 | extern int dccp_setsockopt(struct sock *sk, int level, int optname, |
248 | char __user *optval, int optlen); | 194 | char __user *optval, int optlen); |
195 | #ifdef CONFIG_COMPAT | ||
196 | extern int compat_dccp_getsockopt(struct sock *sk, | ||
197 | int level, int optname, | ||
198 | char __user *optval, int __user *optlen); | ||
199 | extern int compat_dccp_setsockopt(struct sock *sk, | ||
200 | int level, int optname, | ||
201 | char __user *optval, int optlen); | ||
202 | #endif | ||
249 | extern int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); | 203 | extern int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); |
250 | extern int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, | 204 | extern int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, |
251 | struct msghdr *msg, size_t size); | 205 | struct msghdr *msg, size_t size); |
@@ -262,15 +216,14 @@ extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, | |||
262 | int addr_len); | 216 | int addr_len); |
263 | 217 | ||
264 | extern int dccp_v4_checksum(const struct sk_buff *skb, | 218 | extern int dccp_v4_checksum(const struct sk_buff *skb, |
265 | const u32 saddr, const u32 daddr); | 219 | const __be32 saddr, const __be32 daddr); |
266 | 220 | ||
267 | extern int dccp_v4_send_reset(struct sock *sk, | 221 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); |
268 | enum dccp_reset_codes code); | ||
269 | extern void dccp_send_close(struct sock *sk, const int active); | 222 | extern void dccp_send_close(struct sock *sk, const int active); |
270 | extern int dccp_invalid_packet(struct sk_buff *skb); | 223 | extern int dccp_invalid_packet(struct sk_buff *skb); |
271 | 224 | ||
272 | static inline int dccp_bad_service_code(const struct sock *sk, | 225 | static inline int dccp_bad_service_code(const struct sock *sk, |
273 | const __u32 service) | 226 | const __be32 service) |
274 | { | 227 | { |
275 | const struct dccp_sock *dp = dccp_sk(sk); | 228 | const struct dccp_sock *dp = dccp_sk(sk); |
276 | 229 | ||
@@ -334,41 +287,29 @@ static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) | |||
334 | { | 287 | { |
335 | struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh + | 288 | struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh + |
336 | sizeof(*dh)); | 289 | sizeof(*dh)); |
337 | 290 | dh->dccph_seq2 = 0; | |
338 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 291 | dh->dccph_seq = htons((gss >> 32) & 0xfffff); |
339 | dh->dccph_seq = htonl((gss >> 32)) >> 8; | ||
340 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
341 | dh->dccph_seq = htonl((gss >> 32)); | ||
342 | #else | ||
343 | #error "Adjust your <asm/byteorder.h> defines" | ||
344 | #endif | ||
345 | dhx->dccph_seq_low = htonl(gss & 0xffffffff); | 292 | dhx->dccph_seq_low = htonl(gss & 0xffffffff); |
346 | } | 293 | } |
347 | 294 | ||
348 | static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, | 295 | static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, |
349 | const u64 gsr) | 296 | const u64 gsr) |
350 | { | 297 | { |
351 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 298 | dhack->dccph_reserved1 = 0; |
352 | dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8; | 299 | dhack->dccph_ack_nr_high = htons(gsr >> 32); |
353 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
354 | dhack->dccph_ack_nr_high = htonl((gsr >> 32)); | ||
355 | #else | ||
356 | #error "Adjust your <asm/byteorder.h> defines" | ||
357 | #endif | ||
358 | dhack->dccph_ack_nr_low = htonl(gsr & 0xffffffff); | 300 | dhack->dccph_ack_nr_low = htonl(gsr & 0xffffffff); |
359 | } | 301 | } |
360 | 302 | ||
361 | static inline void dccp_update_gsr(struct sock *sk, u64 seq) | 303 | static inline void dccp_update_gsr(struct sock *sk, u64 seq) |
362 | { | 304 | { |
363 | struct dccp_sock *dp = dccp_sk(sk); | 305 | struct dccp_sock *dp = dccp_sk(sk); |
306 | const struct dccp_minisock *dmsk = dccp_msk(sk); | ||
364 | 307 | ||
365 | dp->dccps_gsr = seq; | 308 | dp->dccps_gsr = seq; |
366 | dccp_set_seqno(&dp->dccps_swl, | 309 | dccp_set_seqno(&dp->dccps_swl, |
367 | (dp->dccps_gsr + 1 - | 310 | dp->dccps_gsr + 1 - (dmsk->dccpms_sequence_window / 4)); |
368 | (dp->dccps_options.dccpo_sequence_window / 4))); | ||
369 | dccp_set_seqno(&dp->dccps_swh, | 311 | dccp_set_seqno(&dp->dccps_swh, |
370 | (dp->dccps_gsr + | 312 | dp->dccps_gsr + (3 * dmsk->dccpms_sequence_window) / 4); |
371 | (3 * dp->dccps_options.dccpo_sequence_window) / 4)); | ||
372 | } | 313 | } |
373 | 314 | ||
374 | static inline void dccp_update_gss(struct sock *sk, u64 seq) | 315 | static inline void dccp_update_gss(struct sock *sk, u64 seq) |
@@ -378,7 +319,7 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq) | |||
378 | dp->dccps_awh = dp->dccps_gss = seq; | 319 | dp->dccps_awh = dp->dccps_gss = seq; |
379 | dccp_set_seqno(&dp->dccps_awl, | 320 | dccp_set_seqno(&dp->dccps_awl, |
380 | (dp->dccps_gss - | 321 | (dp->dccps_gss - |
381 | dp->dccps_options.dccpo_sequence_window + 1)); | 322 | dccp_msk(sk)->dccpms_sequence_window + 1)); |
382 | } | 323 | } |
383 | 324 | ||
384 | static inline int dccp_ack_pending(const struct sock *sk) | 325 | static inline int dccp_ack_pending(const struct sock *sk) |
@@ -386,24 +327,22 @@ static inline int dccp_ack_pending(const struct sock *sk) | |||
386 | const struct dccp_sock *dp = dccp_sk(sk); | 327 | const struct dccp_sock *dp = dccp_sk(sk); |
387 | return dp->dccps_timestamp_echo != 0 || | 328 | return dp->dccps_timestamp_echo != 0 || |
388 | #ifdef CONFIG_IP_DCCP_ACKVEC | 329 | #ifdef CONFIG_IP_DCCP_ACKVEC |
389 | (dp->dccps_options.dccpo_send_ack_vector && | 330 | (dccp_msk(sk)->dccpms_send_ack_vector && |
390 | dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) || | 331 | dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) || |
391 | #endif | 332 | #endif |
392 | inet_csk_ack_scheduled(sk); | 333 | inet_csk_ack_scheduled(sk); |
393 | } | 334 | } |
394 | 335 | ||
395 | extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb); | 336 | extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb); |
396 | extern void dccp_insert_option_elapsed_time(struct sock *sk, | 337 | extern int dccp_insert_option_elapsed_time(struct sock *sk, |
397 | struct sk_buff *skb, | 338 | struct sk_buff *skb, |
398 | u32 elapsed_time); | 339 | u32 elapsed_time); |
399 | extern void dccp_insert_option_timestamp(struct sock *sk, | 340 | extern int dccp_insert_option_timestamp(struct sock *sk, |
400 | struct sk_buff *skb); | 341 | struct sk_buff *skb); |
401 | extern void dccp_insert_option(struct sock *sk, struct sk_buff *skb, | 342 | extern int dccp_insert_option(struct sock *sk, struct sk_buff *skb, |
402 | unsigned char option, | 343 | unsigned char option, |
403 | const void *value, unsigned char len); | 344 | const void *value, unsigned char len); |
404 | 345 | ||
405 | extern struct socket *dccp_ctl_socket; | ||
406 | |||
407 | extern void dccp_timestamp(const struct sock *sk, struct timeval *tv); | 346 | extern void dccp_timestamp(const struct sock *sk, struct timeval *tv); |
408 | 347 | ||
409 | static inline suseconds_t timeval_usecs(const struct timeval *tv) | 348 | static inline suseconds_t timeval_usecs(const struct timeval *tv) |
@@ -444,4 +383,18 @@ static inline void timeval_sub_usecs(struct timeval *tv, | |||
444 | } | 383 | } |
445 | } | 384 | } |
446 | 385 | ||
386 | #ifdef CONFIG_SYSCTL | ||
387 | extern int dccp_sysctl_init(void); | ||
388 | extern void dccp_sysctl_exit(void); | ||
389 | #else | ||
390 | static inline int dccp_sysctl_init(void) | ||
391 | { | ||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | static inline void dccp_sysctl_exit(void) | ||
396 | { | ||
397 | } | ||
398 | #endif | ||
399 | |||
447 | #endif /* _DCCP_H */ | 400 | #endif /* _DCCP_H */ |