diff options
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r-- | net/dccp/dccp.h | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index e33a9edb4036..a2c20a265b25 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -92,6 +92,32 @@ extern int sysctl_dccp_feat_send_ack_vector; | |||
92 | extern int sysctl_dccp_feat_send_ndp_count; | 92 | extern int sysctl_dccp_feat_send_ndp_count; |
93 | extern int sysctl_dccp_tx_qlen; | 93 | extern int sysctl_dccp_tx_qlen; |
94 | 94 | ||
95 | /* | ||
96 | * 48-bit sequence number arithmetic (signed and unsigned) | ||
97 | */ | ||
98 | #define INT48_MIN 0x800000000000LL /* 2^47 */ | ||
99 | #define UINT48_MAX 0xFFFFFFFFFFFFLL /* 2^48 - 1 */ | ||
100 | #define COMPLEMENT48(x) (0x1000000000000LL - (x)) /* 2^48 - x */ | ||
101 | #define TO_SIGNED48(x) (((x) < INT48_MIN)? (x) : -COMPLEMENT48( (x))) | ||
102 | #define TO_UNSIGNED48(x) (((x) >= 0)? (x) : COMPLEMENT48(-(x))) | ||
103 | #define ADD48(a, b) (((a) + (b)) & UINT48_MAX) | ||
104 | #define SUB48(a, b) ADD48((a), COMPLEMENT48(b)) | ||
105 | |||
106 | static inline void dccp_set_seqno(u64 *seqno, u64 value) | ||
107 | { | ||
108 | *seqno = value & UINT48_MAX; | ||
109 | } | ||
110 | |||
111 | static inline void dccp_inc_seqno(u64 *seqno) | ||
112 | { | ||
113 | *seqno = ADD48(*seqno, 1); | ||
114 | } | ||
115 | |||
116 | static inline u64 dccp_delta_seqno(u64 seqno1, u64 seqno2) | ||
117 | { | ||
118 | return ((seqno2 << 16) - (seqno1 << 16)) >> 16; | ||
119 | } | ||
120 | |||
95 | /* is seq1 < seq2 ? */ | 121 | /* is seq1 < seq2 ? */ |
96 | static inline int before48(const u64 seq1, const u64 seq2) | 122 | static inline int before48(const u64 seq1, const u64 seq2) |
97 | { | 123 | { |
@@ -313,26 +339,7 @@ static inline int dccp_packet_without_ack(const struct sk_buff *skb) | |||
313 | return type == DCCP_PKT_DATA || type == DCCP_PKT_REQUEST; | 339 | return type == DCCP_PKT_DATA || type == DCCP_PKT_REQUEST; |
314 | } | 340 | } |
315 | 341 | ||
316 | #define DCCP_MAX_SEQNO ((((u64)1) << 48) - 1) | 342 | #define DCCP_PKT_WITHOUT_ACK_SEQ (UINT48_MAX << 2) |
317 | #define DCCP_PKT_WITHOUT_ACK_SEQ (DCCP_MAX_SEQNO << 2) | ||
318 | |||
319 | static inline void dccp_set_seqno(u64 *seqno, u64 value) | ||
320 | { | ||
321 | if (value > DCCP_MAX_SEQNO) | ||
322 | value -= DCCP_MAX_SEQNO + 1; | ||
323 | *seqno = value; | ||
324 | } | ||
325 | |||
326 | static inline u64 dccp_delta_seqno(u64 seqno1, u64 seqno2) | ||
327 | { | ||
328 | return ((seqno2 << 16) - (seqno1 << 16)) >> 16; | ||
329 | } | ||
330 | |||
331 | static inline void dccp_inc_seqno(u64 *seqno) | ||
332 | { | ||
333 | if (++*seqno > DCCP_MAX_SEQNO) | ||
334 | *seqno = 0; | ||
335 | } | ||
336 | 343 | ||
337 | static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) | 344 | static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) |
338 | { | 345 | { |