]> err.no Git - linux-2.6/blobdiff - net/dccp/dccp.h
[PATCH] do_notify_parent_cldstop() cleanup
[linux-2.6] / net / dccp / dccp.h
index fb83454102c18edafb30fd4d7fff847f256c0408..33456c0d5937c8950b1a525b7d156e63adc52077 100644 (file)
@@ -4,28 +4,29 @@
  *  net/dccp/dccp.h
  *
  *  An implementation of the DCCP protocol
- *  Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *  Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
  *
  *     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
  *     published by the Free Software Foundation.
  */
 
+#include <linux/config.h>
 #include <linux/dccp.h>
 #include <net/snmp.h>
 #include <net/sock.h>
 #include <net/tcp.h>
 
-#define DCCP_DEBUG
-
-#ifdef DCCP_DEBUG
+#ifdef CONFIG_IP_DCCP_DEBUG
 extern int dccp_debug;
 
 #define dccp_pr_debug(format, a...) \
        do { if (dccp_debug) \
                printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
        } while (0)
-#define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) printk(format, ##a); } while (0)
+#define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) \
+                                            printk(format, ##a); } while (0)
 #else
 #define dccp_pr_debug(format, a...)
 #define dccp_pr_debug_cat(format, a...)
@@ -60,19 +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);
 }
@@ -107,12 +108,14 @@ struct dccp_mib {
 } __SNMP_MIB_ALIGN__;
 
 DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics);
-#define DCCP_INC_STATS(field)          SNMP_INC_STATS(dccp_statistics, field)
-#define DCCP_INC_STATS_BH(field)       SNMP_INC_STATS_BH(dccp_statistics, field)
-#define DCCP_INC_STATS_USER(field)     SNMP_INC_STATS_USER(dccp_statistics, field)
-#define DCCP_DEC_STATS(field)          SNMP_DEC_STATS(dccp_statistics, field)
-#define DCCP_ADD_STATS_BH(field, val)  SNMP_ADD_STATS_BH(dccp_statistics, field, val)
-#define DCCP_ADD_STATS_USER(field, val)        SNMP_ADD_STATS_USER(dccp_statistics, field, val)
+#define DCCP_INC_STATS(field)      SNMP_INC_STATS(dccp_statistics, field)
+#define DCCP_INC_STATS_BH(field)    SNMP_INC_STATS_BH(dccp_statistics, field)
+#define DCCP_INC_STATS_USER(field)  SNMP_INC_STATS_USER(dccp_statistics, field)
+#define DCCP_DEC_STATS(field)      SNMP_DEC_STATS(dccp_statistics, field)
+#define DCCP_ADD_STATS_BH(field, val) \
+                       SNMP_ADD_STATS_BH(dccp_statistics, field, val)
+#define DCCP_ADD_STATS_USER(field, val)        \
+                       SNMP_ADD_STATS_USER(dccp_statistics, field, val)
 
 extern int  dccp_transmit_skb(struct sock *sk, struct sk_buff *skb);
 extern int  dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
@@ -120,7 +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, 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)
@@ -194,8 +201,6 @@ static inline void dccp_openreq_init(struct request_sock *req,
        req->rcv_wnd = 0;
 }
 
-extern void dccp_v4_send_check(struct sock *sk, struct dccp_hdr *dh, int len, 
-                              struct sk_buff *skb);
 extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
 
 extern struct sock *dccp_create_openreq_child(struct sock *sk,
@@ -227,25 +232,30 @@ extern void               dccp_close(struct sock *sk, long timeout);
 extern struct sk_buff  *dccp_make_response(struct sock *sk,
                                            struct dst_entry *dst,
                                            struct request_sock *req);
+extern struct sk_buff  *dccp_make_reset(struct sock *sk,
+                                        struct dst_entry *dst,
+                                        enum dccp_reset_codes code);
 
 extern int        dccp_connect(struct sock *sk);
 extern int        dccp_disconnect(struct sock *sk, int flags);
 extern int        dccp_getsockopt(struct sock *sk, int level, int optname,
-                                  char *optval, int *optlen);
+                                  char __user *optval, int __user *optlen);
+extern int        dccp_setsockopt(struct sock *sk, int level, int optname,
+                                  char __user *optval, int optlen);
 extern int        dccp_ioctl(struct sock *sk, int cmd, unsigned long arg);
-extern int        dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-                               size_t size);
+extern int        dccp_sendmsg(struct kiocb *iocb, struct sock *sk,
+                               struct msghdr *msg, size_t size);
 extern int        dccp_recvmsg(struct kiocb *iocb, struct sock *sk,
                                struct msghdr *msg, size_t len, int nonblock,
                                int flags, int *addr_len);
-extern int        dccp_setsockopt(struct sock *sk, int level, int optname,
-                                  char *optval, int optlen);
 extern void       dccp_shutdown(struct sock *sk, int how);
 
-extern int        dccp_v4_checksum(struct sk_buff *skb);
+extern int        dccp_v4_checksum(const struct sk_buff *skb,
+                                   const u32 saddr, const u32 daddr);
 
-extern int        dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code);
-extern void       dccp_send_close(struct sock *sk);
+extern int        dccp_v4_send_reset(struct sock *sk,
+                                     enum dccp_reset_codes code);
+extern void       dccp_send_close(struct sock *sk, const int active);
 
 struct dccp_skb_cb {
        __u8 dccpd_type;
@@ -301,7 +311,8 @@ static inline void dccp_inc_seqno(u64 *seqno)
 
 static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss)
 {
-       struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh + sizeof(*dh));
+       struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh +
+                                                          sizeof(*dh));
 
 #if defined(__LITTLE_ENDIAN_BITFIELD)
        dh->dccph_seq      = htonl((gss >> 32)) >> 8;
@@ -313,7 +324,8 @@ static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss)
        dhx->dccph_seq_low = htonl(gss & 0xffffffff);
 }
 
-static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, const u64 gsr)
+static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack,
+                                   const u64 gsr)
 {
 #if defined(__LITTLE_ENDIAN_BITFIELD)
        dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8;
@@ -328,29 +340,32 @@ static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, const u64 g
 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 + 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_swl,
+                      (dp->dccps_gsr + 1 -
+                       (dp->dccps_options.dccpo_sequence_window / 4)));
        dccp_set_seqno(&dp->dccps_swh,
-                      dp->dccps_gsr + (3 * dp->dccps_options.dccpo_sequence_window) / 4);
+                      (dp->dccps_gsr +
+                       (3 * dp->dccps_options.dccpo_sequence_window) / 4));
 }
 
 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_gss - dp->dccps_options.dccpo_sequence_window + 1);
-       dp->dccps_awl = max48(tmp_gss, dp->dccps_iss);
        dp->dccps_awh = dp->dccps_gss = seq;
+       dccp_set_seqno(&dp->dccps_awl,
+                      (dp->dccps_gss -
+                       dp->dccps_options.dccpo_sequence_window + 1));
 }
 
 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);
@@ -371,19 +386,24 @@ extern struct socket *dccp_ctl_socket;
  *
  * @dccpap_buf_head - circular buffer head
  * @dccpap_buf_tail - circular buffer tail
- * @dccpap_buf_ackno - ack # of the most recent packet acknoldgeable in the buffer (i.e. %dccpap_buf_head)
- * @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked by the buffer with State 0
+ * @dccpap_buf_ackno - ack # of the most recent packet acknowledgeable in the
+ *                    buffer (i.e. %dccpap_buf_head)
+ * @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
+ *                    by the buffer with State 0
  *
  * Additionally, the HC-Receiver must keep some information about the
  * Ack Vectors it has recently sent. For each packet sent carrying an
  * Ack Vector, it remembers four variables:
  *
- * @dccpap_ack_seqno - the Sequence Number used for the packet (HC-Receiver seqno)
+ * @dccpap_ack_seqno - the Sequence Number used for the packet
+ *                    (HC-Receiver seqno)
  * @dccpap_ack_ptr - the value of buf_head at the time of acknowledgement.
- * @dccpap_ack_ackno - the Acknowledgement Number used for the packet (HC-Sender seqno)
+ * @dccpap_ack_ackno - the Acknowledgement Number used for the packet
+ *                    (HC-Sender seqno)
  * @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 {
@@ -396,19 +416,70 @@ 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];
 };
 
-extern struct dccp_ackpkts *dccp_ackpkts_alloc(unsigned int len, int priority);
+extern struct dccp_ackpkts *
+               dccp_ackpkts_alloc(unsigned int len,
+                                 const unsigned int __nocast priority);
 extern void dccp_ackpkts_free(struct dccp_ackpkts *ap);
 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);
 
-#ifdef DCCP_DEBUG
+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);
 extern void dccp_ackpkts_print(const struct dccp_ackpkts *ap);