X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Fdccp%2Fdccp.h;h=33456c0d5937c8950b1a525b7d156e63adc52077;hb=ef88b7dba2b47c70037a34a599d383462bb74bd3;hp=148e8a65a10c09e6c5f1aaaa4a6835e8fccfe6f7;hpb=a1d3a35518779df0579dd9de0121354b49c68ddc;p=linux-2.6 diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 148e8a65a1..33456c0d59 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -4,7 +4,8 @@ * net/dccp/dccp.h * * An implementation of the DCCP protocol - * Arnaldo Carvalho de Melo + * Copyright (c) 2005 Arnaldo Carvalho de Melo + * Copyright (c) 2005 Ian McDonald * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as @@ -60,20 +61,19 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); extern struct proto dccp_v4_prot; /* is seq1 < seq2 ? */ -static inline const int before48(const u64 seq1, const u64 seq2) +static inline int before48(const u64 seq1, const u64 seq2) { - return (const s64)((seq1 << 16) - (seq2 << 16)) < 0; + return (s64)((seq1 << 16) - (seq2 << 16)) < 0; } /* is seq1 > seq2 ? */ -static inline const int after48(const u64 seq1, const u64 seq2) +static inline int after48(const u64 seq1, const u64 seq2) { - return (const s64)((seq2 << 16) - (seq1 << 16)) < 0; + return (s64)((seq2 << 16) - (seq1 << 16)) < 0; } /* is seq2 <= seq1 <= seq3 ? */ -static inline const int between48(const u64 seq1, const u64 seq2, - const u64 seq3) +static inline int between48(const u64 seq1, const u64 seq2, const u64 seq3) { return (seq3 << 16) - (seq2 << 16) >= (seq1 << 16) - (seq2 << 16); } @@ -123,10 +123,11 @@ extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); extern int dccp_send_response(struct sock *sk); extern void dccp_send_ack(struct sock *sk); extern void dccp_send_delayed_ack(struct sock *sk); -extern void dccp_send_sync(struct sock *sk, u64 seq); +extern void dccp_send_sync(struct sock *sk, const u64 seq, + const enum dccp_pkt_type pkt_type); -extern int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, - const int len); +extern int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, long *timeo); +extern void dccp_write_space(struct sock *sk); extern void dccp_init_xmit_timers(struct sock *sk); static inline void dccp_clear_xmit_timers(struct sock *sk) @@ -254,7 +255,7 @@ extern int dccp_v4_checksum(const struct sk_buff *skb, extern int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code); -extern void dccp_send_close(struct sock *sk); +extern void dccp_send_close(struct sock *sk, const int active); struct dccp_skb_cb { __u8 dccpd_type; @@ -339,13 +340,11 @@ static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, static inline void dccp_update_gsr(struct sock *sk, u64 seq) { struct dccp_sock *dp = dccp_sk(sk); - u64 tmp_gsr; - dccp_set_seqno(&tmp_gsr, + dp->dccps_gsr = seq; + dccp_set_seqno(&dp->dccps_swl, (dp->dccps_gsr + 1 - (dp->dccps_options.dccpo_sequence_window / 4))); - dp->dccps_gsr = seq; - dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr)); dccp_set_seqno(&dp->dccps_swh, (dp->dccps_gsr + (3 * dp->dccps_options.dccpo_sequence_window) / 4)); @@ -354,19 +353,19 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq) static inline void dccp_update_gss(struct sock *sk, u64 seq) { struct dccp_sock *dp = dccp_sk(sk); - u64 tmp_gss; - dccp_set_seqno(&tmp_gss, + dp->dccps_awh = dp->dccps_gss = seq; + dccp_set_seqno(&dp->dccps_awl, (dp->dccps_gss - dp->dccps_options.dccpo_sequence_window + 1)); - dp->dccps_awl = max48(tmp_gss, dp->dccps_iss); - dp->dccps_awh = dp->dccps_gss = seq; } extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb); extern void dccp_insert_option_elapsed_time(struct sock *sk, struct sk_buff *skb, u32 elapsed_time); +extern void dccp_insert_option_timestamp(struct sock *sk, + struct sk_buff *skb); extern void dccp_insert_option(struct sock *sk, struct sk_buff *skb, unsigned char option, const void *value, unsigned char len); @@ -404,6 +403,7 @@ extern struct socket *dccp_ctl_socket; * @dccpap_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. * * @dccpap_buf_len - circular buffer length + * @dccpap_time - the time in usecs * @dccpap_buf - circular buffer of acknowledgeable packets */ struct dccp_ackpkts { @@ -416,7 +416,7 @@ struct dccp_ackpkts { unsigned int dccpap_buf_vector_len; unsigned int dccpap_ack_vector_len; unsigned int dccpap_buf_len; - unsigned long dccpap_time; + struct timeval dccpap_time; u8 dccpap_buf_nonce; u8 dccpap_ack_nonce; u8 dccpap_buf[0]; @@ -430,6 +430,55 @@ extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state); extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk, u64 ackno); +static inline suseconds_t timeval_usecs(const struct timeval *tv) +{ + return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; +} + +static inline suseconds_t timeval_delta(const struct timeval *large, + const struct timeval *small) +{ + time_t secs = large->tv_sec - small->tv_sec; + suseconds_t usecs = large->tv_usec - small->tv_usec; + + if (usecs < 0) { + secs--; + usecs += USEC_PER_SEC; + } + return secs * USEC_PER_SEC + usecs; +} + +static inline void timeval_add_usecs(struct timeval *tv, + const suseconds_t usecs) +{ + tv->tv_usec += usecs; + while (tv->tv_usec >= USEC_PER_SEC) { + tv->tv_sec++; + tv->tv_usec -= USEC_PER_SEC; + } +} + +static inline void timeval_sub_usecs(struct timeval *tv, + const suseconds_t usecs) +{ + tv->tv_usec -= usecs; + while (tv->tv_usec < 0) { + tv->tv_sec--; + tv->tv_usec += USEC_PER_SEC; + } +} + +/* + * Returns the difference in usecs between timeval + * passed in and current time + */ +static inline suseconds_t timeval_now_delta(const struct timeval *tv) +{ + struct timeval now; + do_gettimeofday(&now); + return timeval_delta(&now, tv); +} + #ifdef CONFIG_IP_DCCP_DEBUG extern void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len);