Use standard unsigned integer types

This commit is contained in:
Andreas Steffen
2016-03-24 18:52:48 +01:00
parent b210369314
commit b12c53ce77
584 changed files with 3430 additions and 3430 deletions
+6 -6
View File
@@ -83,7 +83,7 @@ static host_t* offset2host(pool_t *pool, int offset)
{
chunk_t addr;
host_t *host;
u_int32_t *pos;
uint32_t *pos;
if (offset > pool->size)
{
@@ -93,11 +93,11 @@ static host_t* offset2host(pool_t *pool, int offset)
addr = chunk_clone(pool->base->get_address(pool->base));
if (pool->base->get_family(pool->base) == AF_INET6)
{
pos = (u_int32_t*)(addr.ptr + 12);
pos = (uint32_t*)(addr.ptr + 12);
}
else
{
pos = (u_int32_t*)addr.ptr;
pos = (uint32_t*)addr.ptr;
}
*pos = htonl(offset + ntohl(*pos));
host = host_create_from_chunk(pool->base->get_family(pool->base), addr, 0);
@@ -111,7 +111,7 @@ static host_t* offset2host(pool_t *pool, int offset)
static int host2offset(pool_t *pool, host_t *addr)
{
chunk_t host, base;
u_int32_t hosti, basei;
uint32_t hosti, basei;
if (addr->get_family(addr) != pool->base->get_family(pool->base))
{
@@ -129,8 +129,8 @@ static int host2offset(pool_t *pool, host_t *addr)
host = chunk_skip(host, 12);
base = chunk_skip(base, 12);
}
hosti = ntohl(*(u_int32_t*)(host.ptr));
basei = ntohl(*(u_int32_t*)(base.ptr));
hosti = ntohl(*(uint32_t*)(host.ptr));
basei = ntohl(*(uint32_t*)(base.ptr));
if (hosti > basei + pool->size)
{
return -1;
+1 -1
View File
@@ -206,7 +206,7 @@ static status_t rekey_children(ike_sa_t *ike_sa)
linked_list_t *children;
struct {
protocol_id_t protocol;
u_int32_t spi;
uint32_t spi;
} *info;
children = linked_list_create();
+2 -2
View File
@@ -55,7 +55,7 @@ METHOD(listener_t, child_keys, bool,
ha_message_t *m;
chunk_t secret;
proposal_t *proposal;
u_int16_t alg, len;
uint16_t alg, len;
linked_list_t *local_ts, *remote_ts;
enumerator_t *enumerator;
traffic_selector_t *ts;
@@ -69,7 +69,7 @@ METHOD(listener_t, child_keys, bool,
m = ha_message_create(HA_CHILD_ADD);
m->add_attribute(m, HA_IKE_ID, ike_sa->get_id(ike_sa));
m->add_attribute(m, HA_INITIATOR, (u_int8_t)initiator);
m->add_attribute(m, HA_INITIATOR, (uint8_t)initiator);
m->add_attribute(m, HA_INBOUND_SPI, child_sa->get_spi(child_sa, TRUE));
m->add_attribute(m, HA_OUTBOUND_SPI, child_sa->get_spi(child_sa, FALSE));
m->add_attribute(m, HA_INBOUND_CPI, child_sa->get_cpi(child_sa, TRUE));
+10 -10
View File
@@ -131,8 +131,8 @@ static void process_ike_add(private_ha_dispatcher_t *this, ha_message_t *message
enumerator_t *enumerator;
ike_sa_t *ike_sa = NULL, *old_sa = NULL;
ike_version_t version = IKEV2;
u_int16_t encr = 0, len = 0, integ = 0, prf = 0, old_prf = PRF_UNDEFINED;
u_int16_t dh_grp = 0;
uint16_t encr = 0, len = 0, integ = 0, prf = 0, old_prf = PRF_UNDEFINED;
uint16_t dh_grp = 0;
chunk_t nonce_i = chunk_empty, nonce_r = chunk_empty;
chunk_t secret = chunk_empty, old_skd = chunk_empty;
chunk_t dh_local = chunk_empty, dh_remote = chunk_empty, psk = chunk_empty;
@@ -486,7 +486,7 @@ static void process_ike_mid(private_ha_dispatcher_t *this,
ha_message_value_t value;
enumerator_t *enumerator;
ike_sa_t *ike_sa = NULL;
u_int32_t mid = 0;
uint32_t mid = 0;
enumerator = message->create_attribute_enumerator(message);
while (enumerator->enumerate(enumerator, &attribute, &value))
@@ -652,11 +652,11 @@ static void process_child_add(private_ha_dispatcher_t *this,
child_sa_t *child_sa;
proposal_t *proposal;
bool initiator = FALSE, failed = FALSE, ok = FALSE;
u_int32_t inbound_spi = 0, outbound_spi = 0;
u_int16_t inbound_cpi = 0, outbound_cpi = 0;
u_int8_t mode = MODE_TUNNEL, ipcomp = 0;
u_int16_t encr = 0, integ = 0, len = 0, dh_grp = 0;
u_int16_t esn = NO_EXT_SEQ_NUMBERS;
uint32_t inbound_spi = 0, outbound_spi = 0;
uint16_t inbound_cpi = 0, outbound_cpi = 0;
uint8_t mode = MODE_TUNNEL, ipcomp = 0;
uint16_t encr = 0, integ = 0, len = 0, dh_grp = 0;
uint16_t esn = NO_EXT_SEQ_NUMBERS;
u_int seg_i, seg_o;
chunk_t nonce_i = chunk_empty, nonce_r = chunk_empty, secret = chunk_empty;
chunk_t encr_i, integ_i, encr_r, integ_r;
@@ -777,7 +777,7 @@ static void process_child_add(private_ha_dispatcher_t *this,
if (ike_sa->get_version(ike_sa) == IKEV1)
{
keymat_v1_t *keymat_v1 = (keymat_v1_t*)ike_sa->get_keymat(ike_sa);
u_int32_t spi_i, spi_r;
uint32_t spi_i, spi_r;
spi_i = initiator ? inbound_spi : outbound_spi;
spi_r = initiator ? outbound_spi : inbound_spi;
@@ -889,7 +889,7 @@ static void process_child_delete(private_ha_dispatcher_t *this,
enumerator_t *enumerator;
ike_sa_t *ike_sa = NULL;
child_sa_t *child_sa;
u_int32_t spi = 0;
uint32_t spi = 0;
enumerator = message->create_attribute_enumerator(message);
while (enumerator->enumerate(enumerator, &attribute, &value))
+3 -3
View File
@@ -78,7 +78,7 @@ METHOD(listener_t, ike_keys, bool,
ha_message_t *m;
chunk_t secret;
proposal_t *proposal;
u_int16_t alg, len;
uint16_t alg, len;
if (this->tunnel && this->tunnel->is_sa(this->tunnel, ike_sa))
{ /* do not sync SA between nodes */
@@ -168,7 +168,7 @@ METHOD(listener_t, ike_updown, bool,
{
enumerator_t *enumerator;
peer_cfg_t *peer_cfg;
u_int32_t extension, condition;
uint32_t extension, condition;
host_t *addr;
ike_sa_id_t *id;
identification_t *eap_id;
@@ -349,7 +349,7 @@ METHOD(listener_t, message_hook, bool,
ha_message_t *m;
notify_payload_t *notify;
chunk_t data;
u_int32_t seq;
uint32_t seq;
notify = message->get_notify(message, DPD_R_U_THERE);
if (notify)
+10 -10
View File
@@ -15,8 +15,8 @@
#include "ha_kernel.h"
typedef u_int32_t u32;
typedef u_int8_t u8;
typedef uint32_t u32;
typedef uint8_t u8;
#include <sys/utsname.h>
#include <string.h>
@@ -115,9 +115,9 @@ static jhash_version_t get_jhash_version()
/**
* jhash algorithm of two words, as used in kernel (using 0 as initval)
*/
static u_int32_t jhash(jhash_version_t version, u_int32_t a, u_int32_t b)
static uint32_t jhash(jhash_version_t version, uint32_t a, uint32_t b)
{
u_int32_t c = 0;
uint32_t c = 0;
switch (version)
{
@@ -162,7 +162,7 @@ static u_int32_t jhash(jhash_version_t version, u_int32_t a, u_int32_t b)
/**
* Segmentate a calculated hash
*/
static u_int hash2segment(private_ha_kernel_t *this, u_int64_t hash)
static u_int hash2segment(private_ha_kernel_t *this, uint64_t hash)
{
return ((hash * this->count) >> 32) + 1;
}
@@ -170,11 +170,11 @@ static u_int hash2segment(private_ha_kernel_t *this, u_int64_t hash)
/**
* Get a host as an integer for hashing
*/
static u_int32_t host2int(host_t *host)
static uint32_t host2int(host_t *host)
{
if (host->get_family(host) == AF_INET)
{
return *(u_int32_t*)host->get_address(host).ptr;
return *(uint32_t*)host->get_address(host).ptr;
}
return 0;
}
@@ -183,7 +183,7 @@ METHOD(ha_kernel_t, get_segment, u_int,
private_ha_kernel_t *this, host_t *host)
{
unsigned long hash;
u_int32_t addr;
uint32_t addr;
addr = host2int(host);
hash = jhash(this->version, ntohl(addr), 0);
@@ -192,10 +192,10 @@ METHOD(ha_kernel_t, get_segment, u_int,
}
METHOD(ha_kernel_t, get_segment_spi, u_int,
private_ha_kernel_t *this, host_t *host, u_int32_t spi)
private_ha_kernel_t *this, host_t *host, uint32_t spi)
{
unsigned long hash;
u_int32_t addr;
uint32_t addr;
addr = host2int(host);
hash = jhash(this->version, ntohl(addr), ntohl(spi));
+1 -1
View File
@@ -45,7 +45,7 @@ struct ha_kernel_t {
* @param spi SPI to include in hash
* @return segment number
*/
u_int (*get_segment_spi)(ha_kernel_t *this, host_t *host, u_int32_t spi);
u_int (*get_segment_spi)(ha_kernel_t *this, host_t *host, uint32_t spi);
/**
* Get the segment an arbitrary integer is in.
+43 -43
View File
@@ -67,10 +67,10 @@ typedef struct ike_sa_id_encoding_t ike_sa_id_encoding_t;
* Encoding if an ike_sa_id_t
*/
struct ike_sa_id_encoding_t {
u_int8_t ike_version;
u_int64_t initiator_spi;
u_int64_t responder_spi;
u_int8_t initiator;
uint8_t ike_version;
uint64_t initiator_spi;
uint64_t responder_spi;
uint8_t initiator;
} __attribute__((packed));
typedef struct identification_encoding_t identification_encoding_t;
@@ -79,8 +79,8 @@ typedef struct identification_encoding_t identification_encoding_t;
* Encoding of a identification_t
*/
struct identification_encoding_t {
u_int8_t type;
u_int8_t len;
uint8_t type;
uint8_t len;
char encoding[];
} __attribute__((packed));
@@ -90,8 +90,8 @@ typedef struct host_encoding_t host_encoding_t;
* encoding of a host_t
*/
struct host_encoding_t {
u_int16_t port;
u_int8_t family;
uint16_t port;
uint8_t family;
char encoding[];
} __attribute__((packed));
@@ -101,11 +101,11 @@ typedef struct ts_encoding_t ts_encoding_t;
* encoding of a traffic_selector_t
*/
struct ts_encoding_t {
u_int8_t type;
u_int8_t protocol;
u_int16_t from_port;
u_int16_t to_port;
u_int8_t dynamic;
uint8_t type;
uint8_t protocol;
uint16_t from_port;
uint16_t to_port;
uint8_t dynamic;
char encoding[];
} __attribute__((packed));
@@ -139,9 +139,9 @@ METHOD(ha_message_t, add_attribute, void,
size_t len;
va_list args;
check_buf(this, sizeof(u_int8_t));
check_buf(this, sizeof(uint8_t));
this->buf.ptr[this->buf.len] = attribute;
this->buf.len += sizeof(u_int8_t);
this->buf.len += sizeof(uint8_t);
va_start(args, attribute);
switch (attribute)
@@ -215,13 +215,13 @@ METHOD(ha_message_t, add_attribute, void,
this->buf.len += len;
break;
}
/* u_int8_t */
/* uint8_t */
case HA_IKE_VERSION:
case HA_INITIATOR:
case HA_IPSEC_MODE:
case HA_IPCOMP:
{
u_int8_t val;
uint8_t val;
val = va_arg(args, u_int);
check_buf(this, sizeof(val));
@@ -229,7 +229,7 @@ METHOD(ha_message_t, add_attribute, void,
this->buf.len += sizeof(val);
break;
}
/* u_int16_t */
/* uint16_t */
case HA_ALG_DH:
case HA_ALG_PRF:
case HA_ALG_OLD_PRF:
@@ -241,26 +241,26 @@ METHOD(ha_message_t, add_attribute, void,
case HA_SEGMENT:
case HA_ESN:
{
u_int16_t val;
uint16_t val;
val = va_arg(args, u_int);
check_buf(this, sizeof(val));
*(u_int16_t*)(this->buf.ptr + this->buf.len) = htons(val);
*(uint16_t*)(this->buf.ptr + this->buf.len) = htons(val);
this->buf.len += sizeof(val);
break;
}
/** u_int32_t */
/** uint32_t */
case HA_CONDITIONS:
case HA_EXTENSIONS:
case HA_INBOUND_SPI:
case HA_OUTBOUND_SPI:
case HA_MID:
{
u_int32_t val;
uint32_t val;
val = va_arg(args, u_int);
check_buf(this, sizeof(val));
*(u_int32_t*)(this->buf.ptr + this->buf.len) = htonl(val);
*(uint32_t*)(this->buf.ptr + this->buf.len) = htonl(val);
this->buf.len += sizeof(val);
break;
}
@@ -277,11 +277,11 @@ METHOD(ha_message_t, add_attribute, void,
chunk_t chunk;
chunk = va_arg(args, chunk_t);
check_buf(this, chunk.len + sizeof(u_int16_t));
*(u_int16_t*)(this->buf.ptr + this->buf.len) = htons(chunk.len);
memcpy(this->buf.ptr + this->buf.len + sizeof(u_int16_t),
check_buf(this, chunk.len + sizeof(uint16_t));
*(uint16_t*)(this->buf.ptr + this->buf.len) = htons(chunk.len);
memcpy(this->buf.ptr + this->buf.len + sizeof(uint16_t),
chunk.ptr, chunk.len);
this->buf.len += chunk.len + sizeof(u_int16_t);;
this->buf.len += chunk.len + sizeof(uint16_t);;
break;
}
/** traffic_selector_t */
@@ -309,7 +309,7 @@ METHOD(ha_message_t, add_attribute, void,
default:
{
DBG1(DBG_CFG, "unable to encode, attribute %d unknown", attribute);
this->buf.len -= sizeof(u_int8_t);
this->buf.len -= sizeof(uint8_t);
break;
}
}
@@ -435,22 +435,22 @@ METHOD(enumerator_t, attribute_enumerate, bool,
this->buf = chunk_skip(this->buf, len + 1);
return TRUE;
}
/* u_int8_t */
/* uint8_t */
case HA_IKE_VERSION:
case HA_INITIATOR:
case HA_IPSEC_MODE:
case HA_IPCOMP:
{
if (this->buf.len < sizeof(u_int8_t))
if (this->buf.len < sizeof(uint8_t))
{
return FALSE;
}
value->u8 = *(u_int8_t*)this->buf.ptr;
value->u8 = *(uint8_t*)this->buf.ptr;
*attr_out = attr;
this->buf = chunk_skip(this->buf, sizeof(u_int8_t));
this->buf = chunk_skip(this->buf, sizeof(uint8_t));
return TRUE;
}
/** u_int16_t */
/** uint16_t */
case HA_ALG_DH:
case HA_ALG_PRF:
case HA_ALG_OLD_PRF:
@@ -462,29 +462,29 @@ METHOD(enumerator_t, attribute_enumerate, bool,
case HA_SEGMENT:
case HA_ESN:
{
if (this->buf.len < sizeof(u_int16_t))
if (this->buf.len < sizeof(uint16_t))
{
return FALSE;
}
value->u16 = ntohs(*(u_int16_t*)this->buf.ptr);
value->u16 = ntohs(*(uint16_t*)this->buf.ptr);
*attr_out = attr;
this->buf = chunk_skip(this->buf, sizeof(u_int16_t));
this->buf = chunk_skip(this->buf, sizeof(uint16_t));
return TRUE;
}
/** u_int32_t */
/** uint32_t */
case HA_CONDITIONS:
case HA_EXTENSIONS:
case HA_INBOUND_SPI:
case HA_OUTBOUND_SPI:
case HA_MID:
{
if (this->buf.len < sizeof(u_int32_t))
if (this->buf.len < sizeof(uint32_t))
{
return FALSE;
}
value->u32 = ntohl(*(u_int32_t*)this->buf.ptr);
value->u32 = ntohl(*(uint32_t*)this->buf.ptr);
*attr_out = attr;
this->buf = chunk_skip(this->buf, sizeof(u_int32_t));
this->buf = chunk_skip(this->buf, sizeof(uint32_t));
return TRUE;
}
/** chunk_t */
@@ -499,12 +499,12 @@ METHOD(enumerator_t, attribute_enumerate, bool,
{
size_t len;
if (this->buf.len < sizeof(u_int16_t))
if (this->buf.len < sizeof(uint16_t))
{
return FALSE;
}
len = ntohs(*(u_int16_t*)this->buf.ptr);
this->buf = chunk_skip(this->buf, sizeof(u_int16_t));
len = ntohs(*(uint16_t*)this->buf.ptr);
this->buf = chunk_skip(this->buf, sizeof(uint16_t));
if (this->buf.len < len)
{
return FALSE;
+22 -22
View File
@@ -92,9 +92,9 @@ enum ha_message_attribute_t {
HA_REMOTE_ADDR,
/** char*, name of configuration */
HA_CONFIG_NAME,
/** u_int32_t, bitset of ike_condition_t */
/** uint32_t, bitset of ike_condition_t */
HA_CONDITIONS,
/** u_int32_t, bitset of ike_extension_t */
/** uint32_t, bitset of ike_extension_t */
HA_EXTENSIONS,
/** host_t*, local virtual IP */
HA_LOCAL_VIP,
@@ -102,7 +102,7 @@ enum ha_message_attribute_t {
HA_REMOTE_VIP,
/** host_t*, known peer addresses (used for MOBIKE) */
HA_PEER_ADDR,
/** u_int8_t, initiator of an exchange, TRUE for local */
/** uint8_t, initiator of an exchange, TRUE for local */
HA_INITIATOR,
/** chunk_t, initiators nonce */
HA_NONCE_I,
@@ -112,41 +112,41 @@ enum ha_message_attribute_t {
HA_SECRET,
/** chunk_t, SKd of old SA if rekeying */
HA_OLD_SKD,
/** u_int16_t, pseudo random function */
/** uint16_t, pseudo random function */
HA_ALG_PRF,
/** u_int16_t, old pseudo random function if rekeying */
/** uint16_t, old pseudo random function if rekeying */
HA_ALG_OLD_PRF,
/** u_int16_t, encryption algorithm */
/** uint16_t, encryption algorithm */
HA_ALG_ENCR,
/** u_int16_t, encryption key size in bytes */
/** uint16_t, encryption key size in bytes */
HA_ALG_ENCR_LEN,
/** u_int16_t, integrity protection algorithm */
/** uint16_t, integrity protection algorithm */
HA_ALG_INTEG,
/** u_int16_t, DH group */
/** uint16_t, DH group */
HA_ALG_DH,
/** u_int8_t, IPsec mode, TUNNEL|TRANSPORT|... */
/** uint8_t, IPsec mode, TUNNEL|TRANSPORT|... */
HA_IPSEC_MODE,
/** u_int8_t, IPComp protocol */
/** uint8_t, IPComp protocol */
HA_IPCOMP,
/** u_int32_t, inbound security parameter index */
/** uint32_t, inbound security parameter index */
HA_INBOUND_SPI,
/** u_int32_t, outbound security parameter index */
/** uint32_t, outbound security parameter index */
HA_OUTBOUND_SPI,
/** u_int16_t, inbound security parameter index */
/** uint16_t, inbound security parameter index */
HA_INBOUND_CPI,
/** u_int16_t, outbound security parameter index */
/** uint16_t, outbound security parameter index */
HA_OUTBOUND_CPI,
/** traffic_selector_t*, local traffic selector */
HA_LOCAL_TS,
/** traffic_selector_t*, remote traffic selector */
HA_REMOTE_TS,
/** u_int32_t, message ID */
/** uint32_t, message ID */
HA_MID,
/** u_int16_t, HA segment */
/** uint16_t, HA segment */
HA_SEGMENT,
/** u_int16_t, Extended Sequence numbers */
/** uint16_t, Extended Sequence numbers */
HA_ESN,
/** u_int8_t, IKE version */
/** uint8_t, IKE version */
HA_IKE_VERSION,
/** chunk_t, own DH public value */
HA_LOCAL_DH,
@@ -162,9 +162,9 @@ enum ha_message_attribute_t {
* Union to enumerate typed attributes in a message
*/
union ha_message_value_t {
u_int8_t u8;
u_int16_t u16;
u_int32_t u32;
uint8_t u8;
uint16_t u16;
uint32_t u32;
char *str;
chunk_t chunk;
ike_sa_id_t *ike_sa_id;
+1 -1
View File
@@ -25,7 +25,7 @@
typedef struct ha_segments_t ha_segments_t;
typedef u_int16_t segment_mask_t;
typedef uint16_t segment_mask_t;
/**
* maximum number of segments
+1 -1
View File
@@ -79,7 +79,7 @@ struct private_ha_tunnel_t {
/**
* Reqid of installed trap
*/
u_int32_t trap;
uint32_t trap;
/**
* backend for HA SA