summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-09-12 17:49:51 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-09-12 17:51:02 +0200
commitef7737c5da9e770463a33d46316986cd37298e4a (patch)
treeb28923c74d66b3607e5809894e06ea4f307a0b54
parente0d0d1858cbe351718c530df062645faf60f6a17 (diff)
csum: Use ISO C fixed width types
Use the ISO C fixed width types from stdint.h instead of the self-defined Linux types. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--csum.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/csum.h b/csum.h
index cf4599a..ab549f8 100644
--- a/csum.h
+++ b/csum.h
@@ -39,7 +39,7 @@ static inline uint16_t csum_expected(uint16_t sum, uint16_t computed_sum)
/* Taken and modified from tcpdump, Copyright belongs to them! */
struct cksum_vec {
- const u8 *ptr;
+ const uint8_t *ptr;
int len;
};
@@ -55,30 +55,30 @@ struct cksum_vec {
ADDCARRY(sum); \
} while (0)
-static inline u16 __in_cksum(const struct cksum_vec *vec, int veclen)
+static inline uint16_t __in_cksum(const struct cksum_vec *vec, int veclen)
{
- const u16 *w;
+ const uint16_t *w;
int sum = 0, mlen = 0;
int byte_swapped = 0;
union {
- u8 c[2];
- u16 s;
+ uint8_t c[2];
+ uint16_t s;
} s_util;
union {
- u16 s[2];
- u32 l;
+ uint16_t s[2];
+ uint32_t l;
} l_util;
for (; veclen != 0; vec++, veclen--) {
if (vec->len == 0)
continue;
- w = (const u16 *) (void *) vec->ptr;
+ w = (const uint16_t *) (void *) vec->ptr;
if (mlen == -1) {
- s_util.c[1] = *(const u8 *) w;
+ s_util.c[1] = *(const uint8_t *) w;
sum += s_util.s;
- w = (const u16 *) (void *) ((const u8 *) w + 1);
+ w = (const uint16_t *) (void *) ((const uint8_t *) w + 1);
mlen = vec->len - 1;
} else
mlen = vec->len;
@@ -86,8 +86,8 @@ static inline u16 __in_cksum(const struct cksum_vec *vec, int veclen)
if ((1 & (unsigned long) w) && (mlen > 0)) {
REDUCE;
sum <<= 8;
- s_util.c[0] = *(const u8 *) w;
- w = (const u16 *) (void *) ((const u8 *) w + 1);
+ s_util.c[0] = *(const uint8_t *) w;
+ w = (const uint16_t *) (void *) ((const uint8_t *) w + 1);
mlen--;
byte_swapped = 1;
}
@@ -124,13 +124,13 @@ static inline u16 __in_cksum(const struct cksum_vec *vec, int veclen)
byte_swapped = 0;
if (mlen == -1) {
- s_util.c[1] = *(const u8 *) w;
+ s_util.c[1] = *(const uint8_t *) w;
sum += s_util.s;
mlen = 0;
} else
mlen = -1;
} else if (mlen == -1)
- s_util.c[0] = *(const u8 *) w;
+ s_util.c[0] = *(const uint8_t *) w;
}
if (mlen == -1) {
@@ -143,16 +143,16 @@ static inline u16 __in_cksum(const struct cksum_vec *vec, int veclen)
return (~sum & 0xffff);
}
-static inline u16 p4_csum(const struct ip *ip, const u8 *data, u16 len,
- u8 next_proto)
+static inline uint16_t p4_csum(const struct ip *ip, const uint8_t *data,
+ uint16_t len, uint8_t next_proto)
{
struct cksum_vec vec[2];
struct pseudo_hdr {
- u32 src;
- u32 dst;
- u8 mbz;
- u8 proto;
- u16 len;
+ uint32_t src;
+ uint32_t dst;
+ uint8_t mbz;
+ uint8_t proto;
+ uint16_t len;
} ph;
memset(&ph, 0, sizeof(ph));
@@ -162,7 +162,7 @@ static inline u16 p4_csum(const struct ip *ip, const u8 *data, u16 len,
ph.src = ip->ip_src.s_addr;
ph.dst = ip->ip_dst.s_addr;
- vec[0].ptr = (const u8 *) (void *) &ph;
+ vec[0].ptr = (const uint8_t *) (void *) &ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;