blob: 31903a5b1211b5a49d26b12b294c382957ea4b4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef _NETWORK_H_
#define _NETWORK_H_
#include <sys/types.h>
struct nethdr {
u_int16_t flags;
u_int16_t padding;
u_int32_t seq;
};
#define NETHDR_SIZ sizeof(struct nethdr)
struct nethdr_ack {
u_int16_t flags;
u_int16_t padding;
u_int32_t seq;
u_int32_t from;
u_int32_t to;
};
#define NETHDR_ACK_SIZ sizeof(struct nethdr_ack)
enum {
NET_F_HELLO_BIT = 0,
NET_F_HELLO = (1 << NET_F_HELLO_BIT),
NET_F_RESYNC_BIT = 1,
NET_F_RESYNC = (1 << NET_F_RESYNC_BIT),
NET_F_NACK_BIT = 2,
NET_F_NACK = (1 << NET_F_NACK_BIT),
NET_F_ACK_BIT = 3,
NET_F_ACK = (1 << NET_F_ACK_BIT),
};
/* extracted from net/tcp.h */
/*
* The next routines deal with comparing 32 bit unsigned ints
* and worry about wraparound (automatic with unsigned arithmetic).
*/
static inline int before(__u32 seq1, __u32 seq2)
{
return (__s32)(seq1-seq2) < 0;
}
#define after(seq2, seq1) before(seq1, seq2)
/* is s2<=s1<=s3 ? */
static inline int between(__u32 seq1, __u32 seq2, __u32 seq3)
{
return seq3 - seq2 >= seq1 - seq2;
}
#endif
|