dccp.h (21f130a2370ba837cdfc5204ebe52e7c664fec3d) dccp.h (ae31c3399d17b1f7bc1742724f70476b5417744f)
1#ifndef _DCCP_H
2#define _DCCP_H
3/*
4 * net/dccp/dccp.h
5 *
6 * An implementation of the DCCP protocol
7 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
8 * Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/config.h>
16#include <linux/dccp.h>
17#include <net/snmp.h>
18#include <net/sock.h>
19#include <net/tcp.h>
1#ifndef _DCCP_H
2#define _DCCP_H
3/*
4 * net/dccp/dccp.h
5 *
6 * An implementation of the DCCP protocol
7 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
8 * Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/config.h>
16#include <linux/dccp.h>
17#include <net/snmp.h>
18#include <net/sock.h>
19#include <net/tcp.h>
20#include "ackvec.h"
20
21#ifdef CONFIG_IP_DCCP_DEBUG
22extern int dccp_debug;
23
24#define dccp_pr_debug(format, a...) \
25 do { if (dccp_debug) \
26 printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
27 } while (0)

--- 325 unchanged lines hidden (view full) ---

353{
354 struct dccp_sock *dp = dccp_sk(sk);
355
356 dp->dccps_awh = dp->dccps_gss = seq;
357 dccp_set_seqno(&dp->dccps_awl,
358 (dp->dccps_gss -
359 dp->dccps_options.dccpo_sequence_window + 1));
360}
21
22#ifdef CONFIG_IP_DCCP_DEBUG
23extern int dccp_debug;
24
25#define dccp_pr_debug(format, a...) \
26 do { if (dccp_debug) \
27 printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
28 } while (0)

--- 325 unchanged lines hidden (view full) ---

354{
355 struct dccp_sock *dp = dccp_sk(sk);
356
357 dp->dccps_awh = dp->dccps_gss = seq;
358 dccp_set_seqno(&dp->dccps_awl,
359 (dp->dccps_gss -
360 dp->dccps_options.dccpo_sequence_window + 1));
361}
362
363static inline int dccp_ack_pending(const struct sock *sk)
364{
365 const struct dccp_sock *dp = dccp_sk(sk);
366 return dp->dccps_timestamp_echo != 0 ||
367#ifdef CONFIG_IP_DCCP_ACKVEC
368 (dp->dccps_options.dccpo_send_ack_vector &&
369 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) ||
370#endif
371 inet_csk_ack_scheduled(sk);
372}
361
362extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb);
363extern void dccp_insert_option_elapsed_time(struct sock *sk,
364 struct sk_buff *skb,
365 u32 elapsed_time);
366extern void dccp_insert_option_timestamp(struct sock *sk,
367 struct sk_buff *skb);
368extern void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
369 unsigned char option,
370 const void *value, unsigned char len);
371
372extern struct socket *dccp_ctl_socket;
373
373
374extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb);
375extern void dccp_insert_option_elapsed_time(struct sock *sk,
376 struct sk_buff *skb,
377 u32 elapsed_time);
378extern void dccp_insert_option_timestamp(struct sock *sk,
379 struct sk_buff *skb);
380extern void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
381 unsigned char option,
382 const void *value, unsigned char len);
383
384extern struct socket *dccp_ctl_socket;
385
374#define DCCP_ACKPKTS_STATE_RECEIVED 0
375#define DCCP_ACKPKTS_STATE_ECN_MARKED (1 << 6)
376#define DCCP_ACKPKTS_STATE_NOT_RECEIVED (3 << 6)
377
378#define DCCP_ACKPKTS_STATE_MASK 0xC0 /* 11000000 */
379#define DCCP_ACKPKTS_LEN_MASK 0x3F /* 00111111 */
380
381/** struct dccp_ackpkts - acknowledgeable packets
382 *
383 * This data structure is the one defined in the DCCP draft
384 * Appendix A.
385 *
386 * @dccpap_buf_head - circular buffer head
387 * @dccpap_buf_tail - circular buffer tail
388 * @dccpap_buf_ackno - ack # of the most recent packet acknowledgeable in the
389 * buffer (i.e. %dccpap_buf_head)
390 * @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
391 * by the buffer with State 0
392 *
393 * Additionally, the HC-Receiver must keep some information about the
394 * Ack Vectors it has recently sent. For each packet sent carrying an
395 * Ack Vector, it remembers four variables:
396 *
397 * @dccpap_ack_seqno - the Sequence Number used for the packet
398 * (HC-Receiver seqno)
399 * @dccpap_ack_ptr - the value of buf_head at the time of acknowledgement.
400 * @dccpap_ack_ackno - the Acknowledgement Number used for the packet
401 * (HC-Sender seqno)
402 * @dccpap_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
403 *
404 * @dccpap_buf_len - circular buffer length
405 * @dccpap_time - the time in usecs
406 * @dccpap_buf - circular buffer of acknowledgeable packets
407 */
408struct dccp_ackpkts {
409 unsigned int dccpap_buf_head;
410 unsigned int dccpap_buf_tail;
411 u64 dccpap_buf_ackno;
412 u64 dccpap_ack_seqno;
413 u64 dccpap_ack_ackno;
414 unsigned int dccpap_ack_ptr;
415 unsigned int dccpap_buf_vector_len;
416 unsigned int dccpap_ack_vector_len;
417 unsigned int dccpap_buf_len;
418 struct timeval dccpap_time;
419 u8 dccpap_buf_nonce;
420 u8 dccpap_ack_nonce;
421 u8 dccpap_buf[0];
422};
423
424extern struct dccp_ackpkts *
425 dccp_ackpkts_alloc(unsigned int len,
426 const unsigned int __nocast priority);
427extern void dccp_ackpkts_free(struct dccp_ackpkts *ap);
428extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk,
429 u64 ackno, u8 state);
430extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap,
431 struct sock *sk, u64 ackno);
432
433extern void dccp_timestamp(const struct sock *sk, struct timeval *tv);
434
435static inline suseconds_t timeval_usecs(const struct timeval *tv)
436{
437 return tv->tv_sec * USEC_PER_SEC + tv->tv_usec;
438}
439
440static inline suseconds_t timeval_delta(const struct timeval *large,

--- 24 unchanged lines hidden (view full) ---

465{
466 tv->tv_usec -= usecs;
467 while (tv->tv_usec < 0) {
468 tv->tv_sec--;
469 tv->tv_usec += USEC_PER_SEC;
470 }
471}
472
386extern void dccp_timestamp(const struct sock *sk, struct timeval *tv);
387
388static inline suseconds_t timeval_usecs(const struct timeval *tv)
389{
390 return tv->tv_sec * USEC_PER_SEC + tv->tv_usec;
391}
392
393static inline suseconds_t timeval_delta(const struct timeval *large,

--- 24 unchanged lines hidden (view full) ---

418{
419 tv->tv_usec -= usecs;
420 while (tv->tv_usec < 0) {
421 tv->tv_sec--;
422 tv->tv_usec += USEC_PER_SEC;
423 }
424}
425
473#ifdef CONFIG_IP_DCCP_DEBUG
474extern void dccp_ackvector_print(const u64 ackno,
475 const unsigned char *vector, int len);
476extern void dccp_ackpkts_print(const struct dccp_ackpkts *ap);
477#else
478static inline void dccp_ackvector_print(const u64 ackno,
479 const unsigned char *vector,
480 int len) { }
481static inline void dccp_ackpkts_print(const struct dccp_ackpkts *ap) { }
482#endif
483
484#endif /* _DCCP_H */
426#endif /* _DCCP_H */