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
@@ -49,7 +49,7 @@ struct private_esp_context_t {
* The highest sequence number that was successfully verified
* and authenticated, or assigned in an outbound context
*/
u_int32_t last_seqno;
uint32_t last_seqno;
/**
* The bit in the window of the highest authenticated sequence number
@@ -103,7 +103,7 @@ static inline bool get_window_bit(private_esp_context_t *this, u_int index)
/**
* Returns TRUE if the supplied seqno is not already marked in the window
*/
static bool check_window(private_esp_context_t *this, u_int32_t seqno)
static bool check_window(private_esp_context_t *this, uint32_t seqno)
{
u_int offset;
@@ -113,7 +113,7 @@ static bool check_window(private_esp_context_t *this, u_int32_t seqno)
}
METHOD(esp_context_t, verify_seqno, bool,
private_esp_context_t *this, u_int32_t seqno)
private_esp_context_t *this, uint32_t seqno)
{
if (!this->inbound)
{
@@ -145,7 +145,7 @@ METHOD(esp_context_t, verify_seqno, bool,
}
METHOD(esp_context_t, set_authenticated_seqno, void,
private_esp_context_t *this, u_int32_t seqno)
private_esp_context_t *this, uint32_t seqno)
{
u_int i, shift;
@@ -173,14 +173,14 @@ METHOD(esp_context_t, set_authenticated_seqno, void,
}
}
METHOD(esp_context_t, get_seqno, u_int32_t,
METHOD(esp_context_t, get_seqno, uint32_t,
private_esp_context_t *this)
{
return this->last_seqno;
}
METHOD(esp_context_t, next_seqno, bool,
private_esp_context_t *this, u_int32_t *seqno)
private_esp_context_t *this, uint32_t *seqno)
{
if (this->inbound || this->last_seqno == UINT32_MAX)
{ /* inbound or segno would cycle */
+4 -4
View File
@@ -46,7 +46,7 @@ struct esp_context_t {
*
* @return current sequence number, in host byte order
*/
u_int32_t (*get_seqno)(esp_context_t *this);
uint32_t (*get_seqno)(esp_context_t *this);
/**
* Allocate the next outbound ESP sequence number.
@@ -54,7 +54,7 @@ struct esp_context_t {
* @param seqno the sequence number, in host byte order
* @return FALSE if the sequence number cycled or inbound context
*/
bool (*next_seqno)(esp_context_t *this, u_int32_t *seqno);
bool (*next_seqno)(esp_context_t *this, uint32_t *seqno);
/**
* Verify an ESP sequence number. Checks whether a packet with this
@@ -66,7 +66,7 @@ struct esp_context_t {
* @param seqno the sequence number to verify, in host byte order
* @return TRUE when sequence number is valid
*/
bool (*verify_seqno)(esp_context_t *this, u_int32_t seqno);
bool (*verify_seqno)(esp_context_t *this, uint32_t seqno);
/**
* Adds a sequence number that was successfully verified and
@@ -76,7 +76,7 @@ struct esp_context_t {
* @param seqno verified and authenticated seq number in host byte order
*/
void (*set_authenticated_seqno)(esp_context_t *this,
u_int32_t seqno);
uint32_t seqno);
/**
* Destroy an esp_context_t
+14 -14
View File
@@ -52,7 +52,7 @@ struct private_esp_packet_t {
/**
* Next Header info (e.g. IPPROTO_IPIP)
*/
u_int8_t next_header;
uint8_t next_header;
};
@@ -97,14 +97,14 @@ METHOD(packet_t, set_data, void,
return this->packet->set_data(this->packet, data);
}
METHOD(packet_t, get_dscp, u_int8_t,
METHOD(packet_t, get_dscp, uint8_t,
private_esp_packet_t *this)
{
return this->packet->get_dscp(this->packet);
}
METHOD(packet_t, set_dscp, void,
private_esp_packet_t *this, u_int8_t value)
private_esp_packet_t *this, uint8_t value)
{
this->packet->set_dscp(this->packet, value);
}
@@ -127,10 +127,10 @@ METHOD(packet_t, clone_, packet_t*,
}
METHOD(esp_packet_t, parse_header, bool,
private_esp_packet_t *this, u_int32_t *spi)
private_esp_packet_t *this, uint32_t *spi)
{
bio_reader_t *reader;
u_int32_t seq;
uint32_t seq;
reader = bio_reader_create(this->packet->get_data(this->packet));
if (!reader->read_uint32(reader, spi) ||
@@ -156,7 +156,7 @@ static bool check_padding(chunk_t padding)
for (i = 0; i < padding.len; ++i)
{
if (padding.ptr[i] != (u_int8_t)(i + 1))
if (padding.ptr[i] != (uint8_t)(i + 1))
{
return FALSE;
}
@@ -169,7 +169,7 @@ static bool check_padding(chunk_t padding)
*/
static bool remove_padding(private_esp_packet_t *this, chunk_t plaintext)
{
u_int8_t next_header, pad_length;
uint8_t next_header, pad_length;
chunk_t padding, payload;
bio_reader_t *reader;
@@ -211,7 +211,7 @@ METHOD(esp_packet_t, decrypt, status_t,
private_esp_packet_t *this, esp_context_t *esp_context)
{
bio_reader_t *reader;
u_int32_t spi, seq;
uint32_t spi, seq;
chunk_t data, iv, icv, aad, ciphertext, plaintext;
aead_t *aead;
@@ -272,16 +272,16 @@ static void generate_padding(chunk_t padding)
for (i = 0; i < padding.len; ++i)
{
padding.ptr[i] = (u_int8_t)(i + 1);
padding.ptr[i] = (uint8_t)(i + 1);
}
}
METHOD(esp_packet_t, encrypt, status_t,
private_esp_packet_t *this, esp_context_t *esp_context, u_int32_t spi)
private_esp_packet_t *this, esp_context_t *esp_context, uint32_t spi)
{
chunk_t iv, icv, aad, padding, payload, ciphertext;
bio_writer_t *writer;
u_int32_t next_seqno;
uint32_t next_seqno;
size_t blocksize, plainlen;
aead_t *aead;
iv_gen_t *iv_gen;
@@ -316,7 +316,7 @@ METHOD(esp_packet_t, encrypt, status_t,
plainlen += padding.len;
/* len = spi, seq, IV, plaintext, ICV */
writer = bio_writer_create(2 * sizeof(u_int32_t) + iv.len + plainlen +
writer = bio_writer_create(2 * sizeof(uint32_t) + iv.len + plainlen +
icv.len);
writer->write_uint32(writer, ntohl(spi));
writer->write_uint32(writer, next_seqno);
@@ -349,7 +349,7 @@ METHOD(esp_packet_t, encrypt, status_t,
DBG3(DBG_ESP, "ESP before encryption:\n payload = %B\n padding = %B\n "
"padding length = %hhu, next header = %hhu", &payload, &padding,
(u_int8_t)padding.len, this->next_header);
(uint8_t)padding.len, this->next_header);
/* encrypt/authenticate the content inline */
if (!aead->encrypt(aead, ciphertext, aad, iv, NULL))
@@ -368,7 +368,7 @@ METHOD(esp_packet_t, encrypt, status_t,
return SUCCESS;
}
METHOD(esp_packet_t, get_next_header, u_int8_t,
METHOD(esp_packet_t, get_next_header, uint8_t,
private_esp_packet_t *this)
{
return this->next_header;
+3 -3
View File
@@ -64,7 +64,7 @@ struct esp_packet_t {
* @return TRUE when successful, FALSE otherwise (e.g. when the
* length of the packet is invalid)
*/
bool (*parse_header)(esp_packet_t *this, u_int32_t *spi);
bool (*parse_header)(esp_packet_t *this, uint32_t *spi);
/**
* Authenticate and decrypt the packet. Also verifies the sequence number
@@ -94,7 +94,7 @@ struct esp_packet_t {
* - NOT_FOUND if no suitable IV generator provided
*/
status_t (*encrypt)(esp_packet_t *this, esp_context_t *esp_context,
u_int32_t spi);
uint32_t spi);
/**
* Get the next header field of a packet.
@@ -103,7 +103,7 @@ struct esp_packet_t {
*
* @return next header field
*/
u_int8_t (*get_next_header)(esp_packet_t *this);
uint8_t (*get_next_header)(esp_packet_t *this);
/**
* Get the plaintext payload of this packet.
+29 -29
View File
@@ -31,14 +31,14 @@
* and unfortunately Android does not define a variant with BSD names.
*/
struct tcphdr {
u_int16_t source;
u_int16_t dest;
u_int32_t seq;
u_int32_t ack_seq;
u_int16_t flags;
u_int16_t window;
u_int16_t check;
u_int16_t urg_ptr;
uint16_t source;
uint16_t dest;
uint32_t seq;
uint32_t ack_seq;
uint16_t flags;
uint16_t window;
uint16_t check;
uint16_t urg_ptr;
} __attribute__((packed));
/**
@@ -47,10 +47,10 @@ struct tcphdr {
* the BSD member names, but this is simpler and more consistent with the above.
*/
struct udphdr {
u_int16_t source;
u_int16_t dest;
u_int16_t len;
u_int16_t check;
uint16_t source;
uint16_t dest;
uint16_t len;
uint16_t check;
} __attribute__((packed));
typedef struct private_ip_packet_t private_ip_packet_t;
@@ -88,16 +88,16 @@ struct private_ip_packet_t {
/**
* IP version
*/
u_int8_t version;
uint8_t version;
/**
* Protocol|Next Header field
*/
u_int8_t next_header;
uint8_t next_header;
};
METHOD(ip_packet_t, get_version, u_int8_t,
METHOD(ip_packet_t, get_version, uint8_t,
private_ip_packet_t *this)
{
return this->version;
@@ -127,7 +127,7 @@ METHOD(ip_packet_t, get_payload, chunk_t,
return this->payload;
}
METHOD(ip_packet_t, get_next_header, u_int8_t,
METHOD(ip_packet_t, get_next_header, uint8_t,
private_ip_packet_t *this)
{
return this->next_header;
@@ -151,8 +151,8 @@ METHOD(ip_packet_t, destroy, void,
/**
* Parse transport protocol header
*/
static bool parse_transport_header(chunk_t packet, u_int8_t proto,
u_int16_t *sport, u_int16_t *dport)
static bool parse_transport_header(chunk_t packet, uint8_t proto,
uint16_t *sport, uint16_t *dport)
{
switch (proto)
{
@@ -196,8 +196,8 @@ static bool parse_transport_header(chunk_t packet, u_int8_t proto,
ip_packet_t *ip_packet_create(chunk_t packet)
{
private_ip_packet_t *this;
u_int8_t version, next_header;
u_int16_t sport = 0, dport = 0;
uint8_t version, next_header;
uint16_t sport = 0, dport = 0;
host_t *src, *dst;
chunk_t payload;
@@ -296,19 +296,19 @@ failed:
/**
* Calculate the checksum for the pseudo IP header
*/
static u_int16_t pseudo_header_checksum(host_t *src, host_t *dst,
u_int8_t proto, chunk_t payload)
static uint16_t pseudo_header_checksum(host_t *src, host_t *dst,
uint8_t proto, chunk_t payload)
{
switch (src->get_family(src))
{
case AF_INET:
{
struct __attribute__((packed)) {
u_int32_t src;
u_int32_t dst;
uint32_t src;
uint32_t dst;
u_char zero;
u_char proto;
u_int16_t len;
uint16_t len;
} pseudo = {
.proto = proto,
.len = htons(payload.len),
@@ -324,7 +324,7 @@ static u_int16_t pseudo_header_checksum(host_t *src, host_t *dst,
struct __attribute__((packed)) {
u_char src[16];
u_char dst[16];
u_int32_t len;
uint32_t len;
u_char zero[3];
u_char next_header;
} pseudo = {
@@ -344,10 +344,10 @@ static u_int16_t pseudo_header_checksum(host_t *src, host_t *dst,
/**
* Apply transport ports and calculate header checksums
*/
static void fix_transport_header(host_t *src, host_t *dst, u_int8_t proto,
static void fix_transport_header(host_t *src, host_t *dst, uint8_t proto,
chunk_t payload)
{
u_int16_t sum = 0, sport, dport;
uint16_t sum = 0, sport, dport;
sport = src->get_port(src);
dport = dst->get_port(dst);
@@ -407,7 +407,7 @@ static void fix_transport_header(host_t *src, host_t *dst, u_int8_t proto,
* Described in header.
*/
ip_packet_t *ip_packet_create_from_data(host_t *src, host_t *dst,
u_int8_t next_header, chunk_t data)
uint8_t next_header, chunk_t data)
{
chunk_t packet;
int family;
+3 -3
View File
@@ -37,7 +37,7 @@ struct ip_packet_t {
*
* @return ip version
*/
u_int8_t (*get_version)(ip_packet_t *this);
uint8_t (*get_version)(ip_packet_t *this);
/**
* Get the source address of this packet
@@ -58,7 +58,7 @@ struct ip_packet_t {
*
* @return protocol|next header field
*/
u_int8_t (*get_next_header)(ip_packet_t *this);
uint8_t (*get_next_header)(ip_packet_t *this);
/**
* Get the complete IP packet (including the header)
@@ -113,7 +113,7 @@ ip_packet_t *ip_packet_create(chunk_t packet);
* @return ip_packet_t instance, or NULL if invalid
*/
ip_packet_t *ip_packet_create_from_data(host_t *src, host_t *dst,
u_int8_t next_header, chunk_t data);
uint8_t next_header, chunk_t data);
/**
* Encode a UDP packet from the given data.
+1 -1
View File
@@ -40,7 +40,7 @@ struct ipsec_event_listener_t {
* @param dst destination address of expired SA
* @param hard TRUE if this is a hard expire, FALSE otherwise
*/
void (*expire)(u_int8_t protocol, u_int32_t spi, host_t *dst, bool hard);
void (*expire)(uint8_t protocol, uint32_t spi, host_t *dst, bool hard);
};
#endif /** IPSEC_EVENT_LISTENER_H_ @}*/
+3 -3
View File
@@ -67,12 +67,12 @@ typedef struct {
/**
* Protocol of the SA
*/
u_int8_t protocol;
uint8_t protocol;
/**
* SPI of the SA, if any
*/
u_int32_t spi;
uint32_t spi;
/**
* SA destination address
@@ -135,7 +135,7 @@ static job_requeue_t handle_events(private_ipsec_event_relay_t *this)
}
METHOD(ipsec_event_relay_t, expire, void,
private_ipsec_event_relay_t *this, u_int8_t protocol, u_int32_t spi,
private_ipsec_event_relay_t *this, uint8_t protocol, uint32_t spi,
host_t *dst, bool hard)
{
ipsec_event_t *event;
+1 -1
View File
@@ -43,7 +43,7 @@ struct ipsec_event_relay_t {
* @param dst destination address of expired SA
* @param hard TRUE for a hard expire, FALSE otherwise
*/
void (*expire)(ipsec_event_relay_t *this, u_int8_t protocol, u_int32_t spi,
void (*expire)(ipsec_event_relay_t *this, uint8_t protocol, uint32_t spi,
host_t *dst, bool hard);
/**
+4 -4
View File
@@ -54,7 +54,7 @@ struct private_ipsec_policy_t {
/**
* If any of the two TS has a protocol selector we cache it here
*/
u_int8_t protocol;
uint8_t protocol;
/**
* Traffic direction
@@ -90,7 +90,7 @@ struct private_ipsec_policy_t {
METHOD(ipsec_policy_t, match, bool,
private_ipsec_policy_t *this, traffic_selector_t *src_ts,
traffic_selector_t *dst_ts, policy_dir_t direction, u_int32_t reqid,
traffic_selector_t *dst_ts, policy_dir_t direction, uint32_t reqid,
mark_t mark, policy_priority_t priority)
{
return (this->direction == direction &&
@@ -104,7 +104,7 @@ METHOD(ipsec_policy_t, match, bool,
METHOD(ipsec_policy_t, match_packet, bool,
private_ipsec_policy_t *this, ip_packet_t *packet)
{
u_int8_t proto = packet->get_next_header(packet);
uint8_t proto = packet->get_next_header(packet);
host_t *src = packet->get_source(packet),
*dst = packet->get_destination(packet);
@@ -125,7 +125,7 @@ METHOD(ipsec_policy_t, get_destination_ts, traffic_selector_t*,
return this->dst_ts;
}
METHOD(ipsec_policy_t, get_reqid, u_int32_t,
METHOD(ipsec_policy_t, get_reqid, uint32_t,
private_ipsec_policy_t *this)
{
return this->sa.reqid;
+2 -2
View File
@@ -77,7 +77,7 @@ struct ipsec_policy_t {
*
* @return the reqid
*/
u_int32_t (*get_reqid)(ipsec_policy_t *this);
uint32_t (*get_reqid)(ipsec_policy_t *this);
/**
* Get another reference to this policy
@@ -99,7 +99,7 @@ struct ipsec_policy_t {
*/
bool (*match)(ipsec_policy_t *this, traffic_selector_t *src_ts,
traffic_selector_t *dst_ts, policy_dir_t direction,
u_int32_t reqid, mark_t mark, policy_priority_t priority);
uint32_t reqid, mark_t mark, policy_priority_t priority);
/**
* Check if this policy matches the given IP packet
+7 -7
View File
@@ -57,7 +57,7 @@ typedef struct {
/**
* Priority used to sort policies
*/
u_int32_t priority;
uint32_t priority;
/**
* The policy
@@ -70,13 +70,13 @@ typedef struct {
* Calculate the pseudo-priority to sort policies. This is the same algorithm
* used by the NETLINK kernel interface (i.e. high priority -> low value).
*/
static u_int32_t calculate_priority(policy_priority_t policy_priority,
static uint32_t calculate_priority(policy_priority_t policy_priority,
traffic_selector_t *src,
traffic_selector_t *dst)
{
u_int32_t priority = PRIO_BASE;
u_int16_t port;
u_int8_t mask, proto;
uint32_t priority = PRIO_BASE;
uint16_t port;
uint8_t mask, proto;
host_t *net;
switch (policy_priority)
@@ -182,7 +182,7 @@ METHOD(ipsec_policy_mgr_t, del_policy, status_t,
{
enumerator_t *enumerator;
ipsec_policy_entry_t *current, *found = NULL;
u_int32_t priority;
uint32_t priority;
if (type != POLICY_IPSEC || direction == POLICY_FWD)
{ /* we ignore these policies as we currently have no use for them */
@@ -235,7 +235,7 @@ METHOD(ipsec_policy_mgr_t, flush_policies, status_t,
METHOD(ipsec_policy_mgr_t, find_by_packet, ipsec_policy_t*,
private_ipsec_policy_mgr_t *this, ip_packet_t *packet, bool inbound,
u_int32_t reqid)
uint32_t reqid)
{
enumerator_t *enumerator;
ipsec_policy_entry_t *current;
+1 -1
View File
@@ -105,7 +105,7 @@ struct ipsec_policy_mgr_t {
*/
ipsec_policy_t *(*find_by_packet)(ipsec_policy_mgr_t *this,
ip_packet_t *packet, bool inbound,
u_int32_t reqid);
uint32_t reqid);
/**
* Destroy an ipsec_policy_mgr_t
+2 -2
View File
@@ -93,8 +93,8 @@ static job_requeue_t process_inbound(private_ipsec_processor_t *this)
esp_packet_t *packet;
ip_packet_t *ip_packet;
ipsec_sa_t *sa;
u_int8_t next_header;
u_int32_t spi, reqid;
uint8_t next_header;
uint32_t spi, reqid;
packet = (esp_packet_t*)this->inbound_queue->dequeue(this->inbound_queue);
+18 -18
View File
@@ -36,7 +36,7 @@ struct private_ipsec_sa_t {
/**
* SPI of this SA
*/
u_int32_t spi;
uint32_t spi;
/**
* Source address
@@ -51,12 +51,12 @@ struct private_ipsec_sa_t {
/**
* Protocol
*/
u_int8_t protocol;
uint8_t protocol;
/**
* Reqid of this SA
*/
u_int32_t reqid;
uint32_t reqid;
/**
* Lifetime configuration
@@ -90,9 +90,9 @@ struct private_ipsec_sa_t {
/** last time of use */
time_t time;
/** number of packets processed */
u_int64_t packets;
uint64_t packets;
/** number of bytes processed */
u_int64_t bytes;
uint64_t bytes;
} use;
/**
@@ -132,19 +132,19 @@ METHOD(ipsec_sa_t, set_destination, void,
this->dst = addr->clone(addr);
}
METHOD(ipsec_sa_t, get_spi, u_int32_t,
METHOD(ipsec_sa_t, get_spi, uint32_t,
private_ipsec_sa_t *this)
{
return this->spi;
}
METHOD(ipsec_sa_t, get_reqid, u_int32_t,
METHOD(ipsec_sa_t, get_reqid, uint32_t,
private_ipsec_sa_t *this)
{
return this->reqid;
}
METHOD(ipsec_sa_t, get_protocol, u_int8_t,
METHOD(ipsec_sa_t, get_protocol, uint8_t,
private_ipsec_sa_t *this)
{
return this->protocol;
@@ -169,7 +169,7 @@ METHOD(ipsec_sa_t, get_esp_context, esp_context_t*,
}
METHOD(ipsec_sa_t, get_usestats, void,
private_ipsec_sa_t *this, u_int64_t *bytes, u_int64_t *packets,
private_ipsec_sa_t *this, uint64_t *bytes, uint64_t *packets,
time_t *time)
{
if (bytes)
@@ -210,7 +210,7 @@ METHOD(ipsec_sa_t, expire, void,
}
METHOD(ipsec_sa_t, update_usestats, void,
private_ipsec_sa_t *this, u_int32_t bytes)
private_ipsec_sa_t *this, uint32_t bytes)
{
this->use.time = time_monotonic(NULL);
this->use.packets++;
@@ -239,21 +239,21 @@ METHOD(ipsec_sa_t, update_usestats, void,
}
METHOD(ipsec_sa_t, match_by_spi_dst, bool,
private_ipsec_sa_t *this, u_int32_t spi, host_t *dst)
private_ipsec_sa_t *this, uint32_t spi, host_t *dst)
{
return this->spi == spi && this->dst->ip_equals(this->dst, dst) &&
!this->hard_expired;
}
METHOD(ipsec_sa_t, match_by_spi_src_dst, bool,
private_ipsec_sa_t *this, u_int32_t spi, host_t *src, host_t *dst)
private_ipsec_sa_t *this, uint32_t spi, host_t *src, host_t *dst)
{
return this->spi == spi && this->src->ip_equals(this->src, src) &&
this->dst->ip_equals(this->dst, dst);
}
METHOD(ipsec_sa_t, match_by_reqid, bool,
private_ipsec_sa_t *this, u_int32_t reqid, bool inbound)
private_ipsec_sa_t *this, uint32_t reqid, bool inbound)
{
return this->reqid == reqid && this->inbound == inbound &&
!this->hard_expired;
@@ -271,11 +271,11 @@ METHOD(ipsec_sa_t, destroy, void,
/**
* Described in header.
*/
ipsec_sa_t *ipsec_sa_create(u_int32_t spi, host_t *src, host_t *dst,
u_int8_t protocol, u_int32_t reqid, mark_t mark, u_int32_t tfc,
lifetime_cfg_t *lifetime, u_int16_t enc_alg, chunk_t enc_key,
u_int16_t int_alg, chunk_t int_key, ipsec_mode_t mode,
u_int16_t ipcomp, u_int16_t cpi, bool encap, bool esn, bool inbound)
ipsec_sa_t *ipsec_sa_create(uint32_t spi, host_t *src, host_t *dst,
uint8_t protocol, uint32_t reqid, mark_t mark, uint32_t tfc,
lifetime_cfg_t *lifetime, uint16_t enc_alg, chunk_t enc_key,
uint16_t int_alg, chunk_t int_key, ipsec_mode_t mode,
uint16_t ipcomp, uint16_t cpi, bool encap, bool esn, bool inbound)
{
private_ipsec_sa_t *this;
+14 -14
View File
@@ -70,21 +70,21 @@ struct ipsec_sa_t {
*
* @return SPI of this SA
*/
u_int32_t (*get_spi)(ipsec_sa_t *this);
uint32_t (*get_spi)(ipsec_sa_t *this);
/**
* Get the reqid of this SA
*
* @return reqid of this SA
*/
u_int32_t (*get_reqid)(ipsec_sa_t *this);
uint32_t (*get_reqid)(ipsec_sa_t *this);
/**
* Get the protocol (e.g. IPPROTO_ESP) of this SA
*
* @return protocol of this SA
*/
u_int8_t (*get_protocol)(ipsec_sa_t *this);
uint8_t (*get_protocol)(ipsec_sa_t *this);
/**
* Returns whether this SA is inbound or outbound
@@ -116,7 +116,7 @@ struct ipsec_sa_t {
* @param packets receives number of processed packets, or NULL
* @param time receives last use time of this SA, or NULL
*/
void (*get_usestats)(ipsec_sa_t *this, u_int64_t *bytes, u_int64_t *packets,
void (*get_usestats)(ipsec_sa_t *this, uint64_t *bytes, uint64_t *packets,
time_t *time);
/**
@@ -124,7 +124,7 @@ struct ipsec_sa_t {
*
* @param bytes length of packet processed
*/
void (*update_usestats)(ipsec_sa_t *this, u_int32_t bytes);
void (*update_usestats)(ipsec_sa_t *this, uint32_t bytes);
/**
* Expire this SA, soft or hard.
@@ -145,7 +145,7 @@ struct ipsec_sa_t {
* @param dst destination address
* @return TRUE if this SA matches all parameters, FALSE otherwise
*/
bool (*match_by_spi_dst)(ipsec_sa_t *this, u_int32_t spi, host_t *dst);
bool (*match_by_spi_dst)(ipsec_sa_t *this, uint32_t spi, host_t *dst);
/**
* Check if this SA matches all given parameters
@@ -155,7 +155,7 @@ struct ipsec_sa_t {
* @param dst destination address
* @return TRUE if this SA matches all parameters, FALSE otherwise
*/
bool (*match_by_spi_src_dst)(ipsec_sa_t *this, u_int32_t spi, host_t *src,
bool (*match_by_spi_src_dst)(ipsec_sa_t *this, uint32_t spi, host_t *src,
host_t *dst);
/**
@@ -167,7 +167,7 @@ struct ipsec_sa_t {
* @param inbound TRUE for inbound SA, FALSE for outbound
* @return TRUE if this SA matches all parameters, FALSE otherwise
*/
bool (*match_by_reqid)(ipsec_sa_t *this, u_int32_t reqid, bool inbound);
bool (*match_by_reqid)(ipsec_sa_t *this, uint32_t reqid, bool inbound);
/**
* Destroy an ipsec_sa_t
@@ -199,12 +199,12 @@ struct ipsec_sa_t {
* @param inbound TRUE if this is an inbound SA, FALSE otherwise
* @return the IPsec SA, or NULL if the creation failed
*/
ipsec_sa_t *ipsec_sa_create(u_int32_t spi, host_t *src, host_t *dst,
u_int8_t protocol, u_int32_t reqid, mark_t mark,
u_int32_t tfc, lifetime_cfg_t *lifetime,
u_int16_t enc_alg, chunk_t enc_key,
u_int16_t int_alg, chunk_t int_key,
ipsec_mode_t mode, u_int16_t ipcomp, u_int16_t cpi,
ipsec_sa_t *ipsec_sa_create(uint32_t spi, host_t *src, host_t *dst,
uint8_t protocol, uint32_t reqid, mark_t mark,
uint32_t tfc, lifetime_cfg_t *lifetime,
uint16_t enc_alg, chunk_t enc_key,
uint16_t int_alg, chunk_t int_key,
ipsec_mode_t mode, uint16_t ipcomp, uint16_t cpi,
bool encap, bool esn, bool inbound);
#endif /** IPSEC_SA_H_ @}*/
+31 -31
View File
@@ -109,19 +109,19 @@ typedef struct {
/**
* 0 if this is a hard expire, otherwise the offset in s (soft->hard)
*/
u_int32_t hard_offset;
uint32_t hard_offset;
} ipsec_sa_expired_t;
/*
* Used for the hash table of allocated SPIs
*/
static bool spi_equals(u_int32_t *spi, u_int32_t *other_spi)
static bool spi_equals(uint32_t *spi, uint32_t *other_spi)
{
return *spi == *other_spi;
}
static u_int spi_hash(u_int32_t *spi)
static u_int spi_hash(uint32_t *spi)
{
return chunk_hash(chunk_from_thing(*spi));
}
@@ -237,26 +237,26 @@ static bool match_entry_by_sa_ptr(ipsec_sa_entry_t *item, ipsec_sa_t *sa)
return item->sa == sa;
}
static bool match_entry_by_spi_inbound(ipsec_sa_entry_t *item, u_int32_t *spi,
static bool match_entry_by_spi_inbound(ipsec_sa_entry_t *item, uint32_t *spi,
bool *inbound)
{
return item->sa->get_spi(item->sa) == *spi &&
item->sa->is_inbound(item->sa) == *inbound;
}
static bool match_entry_by_spi_src_dst(ipsec_sa_entry_t *item, u_int32_t *spi,
static bool match_entry_by_spi_src_dst(ipsec_sa_entry_t *item, uint32_t *spi,
host_t *src, host_t *dst)
{
return item->sa->match_by_spi_src_dst(item->sa, *spi, src, dst);
}
static bool match_entry_by_reqid_inbound(ipsec_sa_entry_t *item,
u_int32_t *reqid, bool *inbound)
uint32_t *reqid, bool *inbound)
{
return item->sa->match_by_reqid(item->sa, *reqid, *inbound);
}
static bool match_entry_by_spi_dst(ipsec_sa_entry_t *item, u_int32_t *spi,
static bool match_entry_by_spi_dst(ipsec_sa_entry_t *item, uint32_t *spi,
host_t *dst)
{
return item->sa->match_by_spi_dst(item->sa, *spi, dst);
@@ -299,7 +299,7 @@ static job_requeue_t sa_expired(ipsec_sa_expired_t *expired)
if (this->sas->find_first(this->sas, (void*)match_entry_by_ptr,
NULL, expired->entry) == SUCCESS)
{
u_int32_t hard_offset;
uint32_t hard_offset;
hard_offset = expired->hard_offset;
expired->entry->sa->expire(expired->entry->sa, hard_offset == 0);
@@ -328,7 +328,7 @@ static void schedule_expiration(private_ipsec_sa_mgr_t *this,
lifetime_cfg_t *lifetime = entry->sa->get_lifetime(entry->sa);
ipsec_sa_expired_t *expired;
callback_job_t *job;
u_int32_t timeout;
uint32_t timeout;
if (!lifetime->time.life)
{ /* no expiration at all */
@@ -362,7 +362,7 @@ static void schedule_expiration(private_ipsec_sa_mgr_t *this,
static void flush_allocated_spis(private_ipsec_sa_mgr_t *this)
{
enumerator_t *enumerator;
u_int32_t *current;
uint32_t *current;
DBG2(DBG_ESP, "flushing allocated SPIs");
enumerator = this->allocated_spis->create_enumerator(this->allocated_spis);
@@ -378,9 +378,9 @@ static void flush_allocated_spis(private_ipsec_sa_mgr_t *this)
/**
* Pre-allocate an SPI for an inbound SA
*/
static bool allocate_spi(private_ipsec_sa_mgr_t *this, u_int32_t spi)
static bool allocate_spi(private_ipsec_sa_mgr_t *this, uint32_t spi)
{
u_int32_t *spi_alloc;
uint32_t *spi_alloc;
if (this->allocated_spis->get(this->allocated_spis, &spi) ||
this->sas->find_first(this->sas, (void*)match_entry_by_spi_inbound,
@@ -388,17 +388,17 @@ static bool allocate_spi(private_ipsec_sa_mgr_t *this, u_int32_t spi)
{
return FALSE;
}
spi_alloc = malloc_thing(u_int32_t);
spi_alloc = malloc_thing(uint32_t);
*spi_alloc = spi;
this->allocated_spis->put(this->allocated_spis, spi_alloc, spi_alloc);
return TRUE;
}
METHOD(ipsec_sa_mgr_t, get_spi, status_t,
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst, u_int8_t protocol,
u_int32_t *spi)
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst, uint8_t protocol,
uint32_t *spi)
{
u_int32_t spi_new;
uint32_t spi_new;
this->mutex->lock(this->mutex);
if (!this->rng)
@@ -415,7 +415,7 @@ METHOD(ipsec_sa_mgr_t, get_spi, status_t,
do
{
if (!this->rng->get_bytes(this->rng, sizeof(spi_new),
(u_int8_t*)&spi_new))
(uint8_t*)&spi_new))
{
this->mutex->unlock(this->mutex);
DBG1(DBG_ESP, "failed to allocate SPI");
@@ -435,11 +435,11 @@ METHOD(ipsec_sa_mgr_t, get_spi, status_t,
}
METHOD(ipsec_sa_mgr_t, add_sa, status_t,
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst, u_int32_t spi,
u_int8_t protocol, u_int32_t reqid, mark_t mark, u_int32_t tfc,
lifetime_cfg_t *lifetime, u_int16_t enc_alg, chunk_t enc_key,
u_int16_t int_alg, chunk_t int_key, ipsec_mode_t mode, u_int16_t ipcomp,
u_int16_t cpi, bool initiator, bool encap, bool esn, bool inbound,
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst, uint32_t spi,
uint8_t protocol, uint32_t reqid, mark_t mark, uint32_t tfc,
lifetime_cfg_t *lifetime, uint16_t enc_alg, chunk_t enc_key,
uint16_t int_alg, chunk_t int_key, ipsec_mode_t mode, uint16_t ipcomp,
uint16_t cpi, bool initiator, bool encap, bool esn, bool inbound,
bool update)
{
ipsec_sa_entry_t *entry;
@@ -465,7 +465,7 @@ METHOD(ipsec_sa_mgr_t, add_sa, status_t,
if (update)
{ /* remove any pre-allocated SPIs */
u_int32_t *spi_alloc;
uint32_t *spi_alloc;
spi_alloc = this->allocated_spis->remove(this->allocated_spis, &spi);
free(spi_alloc);
@@ -489,8 +489,8 @@ METHOD(ipsec_sa_mgr_t, add_sa, status_t,
}
METHOD(ipsec_sa_mgr_t, update_sa, status_t,
private_ipsec_sa_mgr_t *this, u_int32_t spi, u_int8_t protocol,
u_int16_t cpi, host_t *src, host_t *dst, host_t *new_src, host_t *new_dst,
private_ipsec_sa_mgr_t *this, uint32_t spi, uint8_t protocol,
uint16_t cpi, host_t *src, host_t *dst, host_t *new_src, host_t *new_dst,
bool encap, bool new_encap, mark_t mark)
{
ipsec_sa_entry_t *entry = NULL;
@@ -528,8 +528,8 @@ METHOD(ipsec_sa_mgr_t, update_sa, status_t,
METHOD(ipsec_sa_mgr_t, query_sa, status_t,
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst,
u_int32_t spi, u_int8_t protocol, mark_t mark,
u_int64_t *bytes, u_int64_t *packets, time_t *time)
uint32_t spi, uint8_t protocol, mark_t mark,
uint64_t *bytes, uint64_t *packets, time_t *time)
{
ipsec_sa_entry_t *entry = NULL;
@@ -549,8 +549,8 @@ METHOD(ipsec_sa_mgr_t, query_sa, status_t,
}
METHOD(ipsec_sa_mgr_t, del_sa, status_t,
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst, u_int32_t spi,
u_int8_t protocol, u_int16_t cpi, mark_t mark)
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst, uint32_t spi,
uint8_t protocol, uint16_t cpi, mark_t mark)
{
ipsec_sa_entry_t *current, *found = NULL;
enumerator_t *enumerator;
@@ -583,7 +583,7 @@ METHOD(ipsec_sa_mgr_t, del_sa, status_t,
}
METHOD(ipsec_sa_mgr_t, checkout_by_reqid, ipsec_sa_t*,
private_ipsec_sa_mgr_t *this, u_int32_t reqid, bool inbound)
private_ipsec_sa_mgr_t *this, uint32_t reqid, bool inbound)
{
ipsec_sa_entry_t *entry;
ipsec_sa_t *sa = NULL;
@@ -600,7 +600,7 @@ METHOD(ipsec_sa_mgr_t, checkout_by_reqid, ipsec_sa_t*,
}
METHOD(ipsec_sa_mgr_t, checkout_by_spi, ipsec_sa_t*,
private_ipsec_sa_mgr_t *this, u_int32_t spi, host_t *dst)
private_ipsec_sa_mgr_t *this, uint32_t spi, host_t *dst)
{
ipsec_sa_entry_t *entry;
ipsec_sa_t *sa = NULL;
+12 -12
View File
@@ -49,7 +49,7 @@ struct ipsec_sa_mgr_t {
* @return SUCCESS of operation successful
*/
status_t (*get_spi)(ipsec_sa_mgr_t *this, host_t *src, host_t *dst,
u_int8_t protocol, u_int32_t *spi);
uint8_t protocol, uint32_t *spi);
/**
* Add a new SA
@@ -77,11 +77,11 @@ struct ipsec_sa_mgr_t {
* @return SUCCESS if operation completed
*/
status_t (*add_sa)(ipsec_sa_mgr_t *this, host_t *src, host_t *dst,
u_int32_t spi, u_int8_t protocol, u_int32_t reqid,
mark_t mark, u_int32_t tfc, lifetime_cfg_t *lifetime,
u_int16_t enc_alg, chunk_t enc_key, u_int16_t int_alg,
chunk_t int_key, ipsec_mode_t mode, u_int16_t ipcomp,
u_int16_t cpi, bool initiator, bool encap, bool esn,
uint32_t spi, uint8_t protocol, uint32_t reqid,
mark_t mark, uint32_t tfc, lifetime_cfg_t *lifetime,
uint16_t enc_alg, chunk_t enc_key, uint16_t int_alg,
chunk_t int_key, ipsec_mode_t mode, uint16_t ipcomp,
uint16_t cpi, bool initiator, bool encap, bool esn,
bool inbound, bool update);
/**
@@ -100,7 +100,7 @@ struct ipsec_sa_mgr_t {
* @return SUCCESS if operation completed
*/
status_t (*update_sa)(ipsec_sa_mgr_t *this,
u_int32_t spi, u_int8_t protocol, u_int16_t cpi,
uint32_t spi, uint8_t protocol, uint16_t cpi,
host_t *src, host_t *dst,
host_t *new_src, host_t *new_dst,
bool encap, bool new_encap, mark_t mark);
@@ -119,8 +119,8 @@ struct ipsec_sa_mgr_t {
* @return SUCCESS if operation completed
*/
status_t (*query_sa)(ipsec_sa_mgr_t *this, host_t *src, host_t *dst,
u_int32_t spi, u_int8_t protocol, mark_t mark,
u_int64_t *bytes, u_int64_t *packets, time_t *time);
uint32_t spi, uint8_t protocol, mark_t mark,
uint64_t *bytes, uint64_t *packets, time_t *time);
/**
* Delete a previously added SA
@@ -134,7 +134,7 @@ struct ipsec_sa_mgr_t {
* @return SUCCESS if operation completed
*/
status_t (*del_sa)(ipsec_sa_mgr_t *this, host_t *src, host_t *dst,
u_int32_t spi, u_int8_t protocol, u_int16_t cpi,
uint32_t spi, uint8_t protocol, uint16_t cpi,
mark_t mark);
/**
@@ -159,7 +159,7 @@ struct ipsec_sa_mgr_t {
* @param dst destination address (e.g. of an inbound packet)
* @return the matching IPsec SA, or NULL if none is found
*/
ipsec_sa_t *(*checkout_by_spi)(ipsec_sa_mgr_t *this, u_int32_t spi,
ipsec_sa_t *(*checkout_by_spi)(ipsec_sa_mgr_t *this, uint32_t spi,
host_t *dst);
/**
@@ -177,7 +177,7 @@ struct ipsec_sa_mgr_t {
* @param inbound TRUE for an inbound SA, FALSE for an outbound SA
* @return the matching IPsec SA, or NULL if none is found
*/
ipsec_sa_t *(*checkout_by_reqid)(ipsec_sa_mgr_t *this, u_int32_t reqid,
ipsec_sa_t *(*checkout_by_reqid)(ipsec_sa_mgr_t *this, uint32_t reqid,
bool inbound);
/**
+3 -3
View File
@@ -27,7 +27,7 @@ METHOD(aead_t, get_iv_gen, iv_gen_t*,
}
METHOD(iv_gen_t, get_iv, bool,
iv_gen_t *this, u_int64_t seq, size_t size, u_int8_t *buffer)
iv_gen_t *this, uint64_t seq, size_t size, uint8_t *buffer)
{
if (size != 8)
{
@@ -38,7 +38,7 @@ METHOD(iv_gen_t, get_iv, bool,
}
METHOD(iv_gen_t, allocate_iv, bool,
iv_gen_t *this, u_int64_t seq, size_t size, chunk_t *chunk)
iv_gen_t *this, uint64_t seq, size_t size, chunk_t *chunk)
{
if (size != 8)
{
@@ -58,7 +58,7 @@ START_TEST(test_chapoly)
esp_packet_t *esp;
esp_context_t *ctx;
chunk_t data, exp;
u_int32_t seq = 0;
uint32_t seq = 0;
icmp = ip_packet_create(chunk_clone(chunk_from_chars(
0x45,0x00,0x00,0x54,0xa6,0xf2,0x00,0x00,