aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/dccp.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r--net/dccp/dccp.h110
1 files changed, 78 insertions, 32 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 272e8584564e..68886986c8e4 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -18,15 +18,33 @@
18#include <net/tcp.h> 18#include <net/tcp.h>
19#include "ackvec.h" 19#include "ackvec.h"
20 20
21/*
22 * DCCP - specific warning and debugging macros.
23 */
24#define DCCP_WARN(fmt, a...) LIMIT_NETDEBUG(KERN_WARNING "%s: " fmt, \
25 __FUNCTION__, ##a)
26#define DCCP_CRIT(fmt, a...) printk(KERN_CRIT fmt " at %s:%d/%s()\n", ##a, \
27 __FILE__, __LINE__, __FUNCTION__)
28#define DCCP_BUG(a...) do { DCCP_CRIT("BUG: " a); dump_stack(); } while(0)
29#define DCCP_BUG_ON(cond) do { if (unlikely((cond) != 0)) \
30 DCCP_BUG("\"%s\" holds (exception!)", \
31 __stringify(cond)); \
32 } while (0)
33
34#ifdef MODULE
35#define DCCP_PRINTK(enable, fmt, args...) do { if (enable) \
36 printk(fmt, ##args); \
37 } while(0)
38#else
39#define DCCP_PRINTK(enable, fmt, args...) printk(fmt, ##args)
40#endif
41#define DCCP_PR_DEBUG(enable, fmt, a...) DCCP_PRINTK(enable, KERN_DEBUG \
42 "%s: " fmt, __FUNCTION__, ##a)
43
21#ifdef CONFIG_IP_DCCP_DEBUG 44#ifdef CONFIG_IP_DCCP_DEBUG
22extern int dccp_debug; 45extern int dccp_debug;
23 46#define dccp_pr_debug(format, a...) DCCP_PR_DEBUG(dccp_debug, format, ##a)
24#define dccp_pr_debug(format, a...) \ 47#define dccp_pr_debug_cat(format, a...) DCCP_PRINTK(dccp_debug, format, ##a)
25 do { if (dccp_debug) \
26 printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
27 } while (0)
28#define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) \
29 printk(format, ##a); } while (0)
30#else 48#else
31#define dccp_pr_debug(format, a...) 49#define dccp_pr_debug(format, a...)
32#define dccp_pr_debug_cat(format, a...) 50#define dccp_pr_debug_cat(format, a...)
@@ -35,17 +53,21 @@ extern int dccp_debug;
35extern struct inet_hashinfo dccp_hashinfo; 53extern struct inet_hashinfo dccp_hashinfo;
36 54
37extern atomic_t dccp_orphan_count; 55extern atomic_t dccp_orphan_count;
38extern int dccp_tw_count;
39extern void dccp_tw_deschedule(struct inet_timewait_sock *tw);
40 56
41extern void dccp_time_wait(struct sock *sk, int state, int timeo); 57extern void dccp_time_wait(struct sock *sk, int state, int timeo);
42 58
43/* FIXME: Right size this */ 59/*
44#define DCCP_MAX_OPT_LEN 128 60 * Set safe upper bounds for header and option length. Since Data Offset is 8
45 61 * bits (RFC 4340, sec. 5.1), the total header length can never be more than
46#define DCCP_MAX_PACKET_HDR 32 62 * 4 * 255 = 1020 bytes. The largest possible header length is 28 bytes (X=1):
47 63 * - DCCP-Response with ACK Subheader and 4 bytes of Service code OR
48#define MAX_DCCP_HEADER (DCCP_MAX_PACKET_HDR + DCCP_MAX_OPT_LEN + MAX_HEADER) 64 * - DCCP-Reset with ACK Subheader and 4 bytes of Reset Code fields
65 * Hence a safe upper bound for the maximum option length is 1020-28 = 992
66 */
67#define MAX_DCCP_SPECIFIC_HEADER (255 * sizeof(int))
68#define DCCP_MAX_PACKET_HDR 28
69#define DCCP_MAX_OPT_LEN (MAX_DCCP_SPECIFIC_HEADER - DCCP_MAX_PACKET_HDR)
70#define MAX_DCCP_HEADER (MAX_DCCP_SPECIFIC_HEADER + MAX_HEADER)
49 71
50#define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT 72#define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT
51 * state, about 60 seconds */ 73 * state, about 60 seconds */
@@ -58,6 +80,20 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo);
58 80
59#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ 81#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
60 82
83#define DCCP_XMIT_TIMEO 30000 /* Time/msecs for blocking transmit per packet */
84
85/* sysctl variables for DCCP */
86extern int sysctl_dccp_request_retries;
87extern int sysctl_dccp_retries1;
88extern int sysctl_dccp_retries2;
89extern int sysctl_dccp_feat_sequence_window;
90extern int sysctl_dccp_feat_rx_ccid;
91extern int sysctl_dccp_feat_tx_ccid;
92extern int sysctl_dccp_feat_ack_ratio;
93extern int sysctl_dccp_feat_send_ack_vector;
94extern int sysctl_dccp_feat_send_ndp_count;
95extern int sysctl_dccp_tx_qlen;
96
61/* is seq1 < seq2 ? */ 97/* is seq1 < seq2 ? */
62static inline int before48(const u64 seq1, const u64 seq2) 98static inline int before48(const u64 seq1, const u64 seq2)
63{ 99{
@@ -123,10 +159,36 @@ DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics);
123#define DCCP_ADD_STATS_USER(field, val) \ 159#define DCCP_ADD_STATS_USER(field, val) \
124 SNMP_ADD_STATS_USER(dccp_statistics, field, val) 160 SNMP_ADD_STATS_USER(dccp_statistics, field, val)
125 161
162/*
163 * Checksumming routines
164 */
165static inline int dccp_csum_coverage(const struct sk_buff *skb)
166{
167 const struct dccp_hdr* dh = dccp_hdr(skb);
168
169 if (dh->dccph_cscov == 0)
170 return skb->len;
171 return (dh->dccph_doff + dh->dccph_cscov - 1) * sizeof(u32);
172}
173
174static inline void dccp_csum_outgoing(struct sk_buff *skb)
175{
176 int cov = dccp_csum_coverage(skb);
177
178 if (cov >= skb->len)
179 dccp_hdr(skb)->dccph_cscov = 0;
180
181 skb->csum = skb_checksum(skb, 0, (cov > skb->len)? skb->len : cov, 0);
182}
183
184extern void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb);
185
126extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); 186extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
127 187
128extern void dccp_send_ack(struct sock *sk); 188extern void dccp_send_ack(struct sock *sk);
129extern void dccp_send_delayed_ack(struct sock *sk); 189extern void dccp_send_delayed_ack(struct sock *sk);
190extern void dccp_reqsk_send_ack(struct sk_buff *sk, struct request_sock *rsk);
191
130extern void dccp_send_sync(struct sock *sk, const u64 seq, 192extern void dccp_send_sync(struct sock *sk, const u64 seq,
131 const enum dccp_pkt_type pkt_type); 193 const enum dccp_pkt_type pkt_type);
132 194
@@ -147,18 +209,7 @@ extern const char *dccp_state_name(const int state);
147extern void dccp_set_state(struct sock *sk, const int state); 209extern void dccp_set_state(struct sock *sk, const int state);
148extern void dccp_done(struct sock *sk); 210extern void dccp_done(struct sock *sk);
149 211
150static inline void dccp_openreq_init(struct request_sock *req, 212extern void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb);
151 struct dccp_sock *dp,
152 struct sk_buff *skb)
153{
154 /*
155 * FIXME: fill in the other req fields from the DCCP options
156 * received
157 */
158 inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport;
159 inet_rsk(req)->acked = 0;
160 req->rcv_wnd = 0;
161}
162 213
163extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb); 214extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
164 215
@@ -217,14 +268,9 @@ extern void dccp_shutdown(struct sock *sk, int how);
217extern int inet_dccp_listen(struct socket *sock, int backlog); 268extern int inet_dccp_listen(struct socket *sock, int backlog);
218extern unsigned int dccp_poll(struct file *file, struct socket *sock, 269extern unsigned int dccp_poll(struct file *file, struct socket *sock,
219 poll_table *wait); 270 poll_table *wait);
220extern void dccp_v4_send_check(struct sock *sk, int len,
221 struct sk_buff *skb);
222extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, 271extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
223 int addr_len); 272 int addr_len);
224 273
225extern int dccp_v4_checksum(const struct sk_buff *skb,
226 const __be32 saddr, const __be32 daddr);
227
228extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); 274extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
229extern void dccp_send_close(struct sock *sk, const int active); 275extern void dccp_send_close(struct sock *sk, const int active);
230extern int dccp_invalid_packet(struct sk_buff *skb); 276extern int dccp_invalid_packet(struct sk_buff *skb);