Use standard unsigned integer types
This commit is contained in:
@@ -52,7 +52,7 @@ struct private_traffic_selector_t {
|
||||
/**
|
||||
* IP protocol (UDP, TCP, ICMP, ...)
|
||||
*/
|
||||
u_int8_t protocol;
|
||||
uint8_t protocol;
|
||||
|
||||
/**
|
||||
* narrow this traffic selector to hosts external ip
|
||||
@@ -63,7 +63,7 @@ struct private_traffic_selector_t {
|
||||
/**
|
||||
* subnet size in CIDR notation, 255 means a non-subnet address range
|
||||
*/
|
||||
u_int8_t netbits;
|
||||
uint8_t netbits;
|
||||
|
||||
/**
|
||||
* begin of address range, network order
|
||||
@@ -72,9 +72,9 @@ struct private_traffic_selector_t {
|
||||
/** dummy char for common address manipulation */
|
||||
char from[0];
|
||||
/** IPv4 address */
|
||||
u_int32_t from4[1];
|
||||
uint32_t from4[1];
|
||||
/** IPv6 address */
|
||||
u_int32_t from6[4];
|
||||
uint32_t from6[4];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -84,30 +84,30 @@ struct private_traffic_selector_t {
|
||||
/** dummy char for common address manipulation */
|
||||
char to[0];
|
||||
/** IPv4 address */
|
||||
u_int32_t to4[1];
|
||||
uint32_t to4[1];
|
||||
/** IPv6 address */
|
||||
u_int32_t to6[4];
|
||||
uint32_t to6[4];
|
||||
};
|
||||
|
||||
/**
|
||||
* begin of port range
|
||||
*/
|
||||
u_int16_t from_port;
|
||||
uint16_t from_port;
|
||||
|
||||
/**
|
||||
* end of port range
|
||||
*/
|
||||
u_int16_t to_port;
|
||||
uint16_t to_port;
|
||||
};
|
||||
|
||||
/**
|
||||
* calculate the "to"-address for the "from" address and a subnet size
|
||||
*/
|
||||
static void calc_range(private_traffic_selector_t *this, u_int8_t netbits)
|
||||
static void calc_range(private_traffic_selector_t *this, uint8_t netbits)
|
||||
{
|
||||
size_t len;
|
||||
int bytes, bits;
|
||||
u_int8_t mask;
|
||||
uint8_t mask;
|
||||
|
||||
this->netbits = netbits;
|
||||
|
||||
@@ -126,10 +126,10 @@ static void calc_range(private_traffic_selector_t *this, u_int8_t netbits)
|
||||
/**
|
||||
* calculate the subnet size from the "to" and "from" addresses
|
||||
*/
|
||||
static u_int8_t calc_netbits(private_traffic_selector_t *this)
|
||||
static uint8_t calc_netbits(private_traffic_selector_t *this)
|
||||
{
|
||||
int byte, bit;
|
||||
u_int8_t netbits;
|
||||
uint8_t netbits;
|
||||
size_t size = (this->type == TS_IPV4_ADDR_RANGE) ? 4 : 16;
|
||||
bool prefix = TRUE;
|
||||
|
||||
@@ -144,7 +144,7 @@ static u_int8_t calc_netbits(private_traffic_selector_t *this)
|
||||
{
|
||||
for (bit = 7; bit >= 0; bit--)
|
||||
{
|
||||
u_int8_t bitmask = 1 << bit;
|
||||
uint8_t bitmask = 1 << bit;
|
||||
|
||||
if (prefix)
|
||||
{
|
||||
@@ -173,8 +173,8 @@ static u_int8_t calc_netbits(private_traffic_selector_t *this)
|
||||
/**
|
||||
* internal generic constructor
|
||||
*/
|
||||
static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol,
|
||||
ts_type_t type, u_int16_t from_port, u_int16_t to_port);
|
||||
static private_traffic_selector_t *traffic_selector_create(uint8_t protocol,
|
||||
ts_type_t type, uint16_t from_port, uint16_t to_port);
|
||||
|
||||
/**
|
||||
* Check if TS contains "opaque" ports
|
||||
@@ -195,9 +195,9 @@ static bool is_any(private_traffic_selector_t *this)
|
||||
/**
|
||||
* Print ICMP/ICMPv6 type and code
|
||||
*/
|
||||
static int print_icmp(printf_hook_data_t *data, u_int16_t port)
|
||||
static int print_icmp(printf_hook_data_t *data, uint16_t port)
|
||||
{
|
||||
u_int8_t type, code;
|
||||
uint8_t type, code;
|
||||
|
||||
type = traffic_selector_icmp_type(port);
|
||||
code = traffic_selector_icmp_code(port);
|
||||
@@ -222,7 +222,7 @@ int traffic_selector_printf_hook(printf_hook_data_t *data,
|
||||
char *serv_proto = NULL, *sep = "";
|
||||
bool has_proto, has_ports;
|
||||
size_t written = 0;
|
||||
u_int32_t from[4], to[4];
|
||||
uint32_t from[4], to[4];
|
||||
|
||||
if (this == NULL)
|
||||
{
|
||||
@@ -361,9 +361,9 @@ METHOD(traffic_selector_t, get_subset, traffic_selector_t*,
|
||||
private_traffic_selector_t *this, traffic_selector_t *other_public)
|
||||
{
|
||||
private_traffic_selector_t *other, *subset;
|
||||
u_int16_t from_port, to_port;
|
||||
uint16_t from_port, to_port;
|
||||
u_char *from, *to;
|
||||
u_int8_t protocol;
|
||||
uint8_t protocol;
|
||||
size_t size;
|
||||
|
||||
other = (private_traffic_selector_t*)other_public;
|
||||
@@ -481,13 +481,13 @@ METHOD(traffic_selector_t, get_to_address, chunk_t,
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(traffic_selector_t, get_from_port, u_int16_t,
|
||||
METHOD(traffic_selector_t, get_from_port, uint16_t,
|
||||
private_traffic_selector_t *this)
|
||||
{
|
||||
return this->from_port;
|
||||
}
|
||||
|
||||
METHOD(traffic_selector_t, get_to_port, u_int16_t,
|
||||
METHOD(traffic_selector_t, get_to_port, uint16_t,
|
||||
private_traffic_selector_t *this)
|
||||
{
|
||||
return this->to_port;
|
||||
@@ -499,7 +499,7 @@ METHOD(traffic_selector_t, get_type, ts_type_t,
|
||||
return this->type;
|
||||
}
|
||||
|
||||
METHOD(traffic_selector_t, get_protocol, u_int8_t,
|
||||
METHOD(traffic_selector_t, get_protocol, uint8_t,
|
||||
private_traffic_selector_t *this)
|
||||
{
|
||||
return this->protocol;
|
||||
@@ -610,14 +610,14 @@ METHOD(traffic_selector_t, includes, bool,
|
||||
}
|
||||
|
||||
METHOD(traffic_selector_t, to_subnet, bool,
|
||||
private_traffic_selector_t *this, host_t **net, u_int8_t *mask)
|
||||
private_traffic_selector_t *this, host_t **net, uint8_t *mask)
|
||||
{
|
||||
/* there is no way to do this cleanly, as the address range may
|
||||
* be anything else but a subnet. We use from_addr as subnet
|
||||
* and try to calculate a usable subnet mask.
|
||||
*/
|
||||
int family, non_zero_bytes;
|
||||
u_int16_t port = 0;
|
||||
uint16_t port = 0;
|
||||
chunk_t net_chunk;
|
||||
|
||||
*mask = (this->netbits == NON_SUBNET_ADDRESS_RANGE) ? calc_netbits(this)
|
||||
@@ -777,10 +777,10 @@ int traffic_selector_cmp(traffic_selector_t *a_pub, traffic_selector_t *b_pub,
|
||||
/*
|
||||
* see header
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_bytes(u_int8_t protocol,
|
||||
traffic_selector_t *traffic_selector_create_from_bytes(uint8_t protocol,
|
||||
ts_type_t type,
|
||||
chunk_t from, u_int16_t from_port,
|
||||
chunk_t to, u_int16_t to_port)
|
||||
chunk_t from, uint16_t from_port,
|
||||
chunk_t to, uint16_t to_port)
|
||||
{
|
||||
private_traffic_selector_t *this = traffic_selector_create(protocol, type,
|
||||
from_port, to_port);
|
||||
@@ -843,7 +843,7 @@ traffic_selector_t *traffic_selector_create_from_rfc3779_format(ts_type_t type,
|
||||
}
|
||||
if (to.len > 1)
|
||||
{
|
||||
u_int8_t mask = to.ptr[0] ? (1 << to.ptr[0]) - 1 : 0;
|
||||
uint8_t mask = to.ptr[0] ? (1 << to.ptr[0]) - 1 : 0;
|
||||
|
||||
memcpy(this->to, to.ptr+1, to.len-1);
|
||||
this->to[to.len-2] |= mask;
|
||||
@@ -856,8 +856,8 @@ traffic_selector_t *traffic_selector_create_from_rfc3779_format(ts_type_t type,
|
||||
* see header
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_subnet(host_t *net,
|
||||
u_int8_t netbits, u_int8_t protocol,
|
||||
u_int16_t from_port, u_int16_t to_port)
|
||||
uint8_t netbits, uint8_t protocol,
|
||||
uint16_t from_port, uint16_t to_port)
|
||||
{
|
||||
private_traffic_selector_t *this;
|
||||
chunk_t from;
|
||||
@@ -890,9 +890,9 @@ traffic_selector_t *traffic_selector_create_from_subnet(host_t *net,
|
||||
* see header
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_string(
|
||||
u_int8_t protocol, ts_type_t type,
|
||||
char *from_addr, u_int16_t from_port,
|
||||
char *to_addr, u_int16_t to_port)
|
||||
uint8_t protocol, ts_type_t type,
|
||||
char *from_addr, uint16_t from_port,
|
||||
char *to_addr, uint16_t to_port)
|
||||
{
|
||||
private_traffic_selector_t *this;
|
||||
int family;
|
||||
@@ -926,8 +926,8 @@ traffic_selector_t *traffic_selector_create_from_string(
|
||||
* see header
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_cidr(
|
||||
char *string, u_int8_t protocol,
|
||||
u_int16_t from_port, u_int16_t to_port)
|
||||
char *string, uint8_t protocol,
|
||||
uint16_t from_port, uint16_t to_port)
|
||||
{
|
||||
host_t *net;
|
||||
int bits;
|
||||
@@ -944,8 +944,8 @@ traffic_selector_t *traffic_selector_create_from_cidr(
|
||||
/*
|
||||
* see header
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_dynamic(u_int8_t protocol,
|
||||
u_int16_t from_port, u_int16_t to_port)
|
||||
traffic_selector_t *traffic_selector_create_dynamic(uint8_t protocol,
|
||||
uint16_t from_port, uint16_t to_port)
|
||||
{
|
||||
private_traffic_selector_t *this = traffic_selector_create(
|
||||
protocol, TS_IPV4_ADDR_RANGE, from_port, to_port);
|
||||
@@ -961,8 +961,8 @@ traffic_selector_t *traffic_selector_create_dynamic(u_int8_t protocol,
|
||||
/*
|
||||
* see declaration
|
||||
*/
|
||||
static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol,
|
||||
ts_type_t type, u_int16_t from_port, u_int16_t to_port)
|
||||
static private_traffic_selector_t *traffic_selector_create(uint8_t protocol,
|
||||
ts_type_t type, uint16_t from_port, uint16_t to_port)
|
||||
{
|
||||
private_traffic_selector_t *this;
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ struct traffic_selector_t {
|
||||
*
|
||||
* @return port
|
||||
*/
|
||||
u_int16_t (*get_from_port) (traffic_selector_t *this);
|
||||
uint16_t (*get_from_port) (traffic_selector_t *this);
|
||||
|
||||
/**
|
||||
* Get ending port of this ts.
|
||||
@@ -136,7 +136,7 @@ struct traffic_selector_t {
|
||||
*
|
||||
* @return port
|
||||
*/
|
||||
u_int16_t (*get_to_port) (traffic_selector_t *this);
|
||||
uint16_t (*get_to_port) (traffic_selector_t *this);
|
||||
|
||||
/**
|
||||
* Get the type of the traffic selector.
|
||||
@@ -150,7 +150,7 @@ struct traffic_selector_t {
|
||||
*
|
||||
* @return protocol id
|
||||
*/
|
||||
u_int8_t (*get_protocol) (traffic_selector_t *this);
|
||||
uint8_t (*get_protocol) (traffic_selector_t *this);
|
||||
|
||||
/**
|
||||
* Check if the traffic selector is for a single host.
|
||||
@@ -218,7 +218,7 @@ struct traffic_selector_t {
|
||||
* @param mask converted net mask
|
||||
* @return TRUE if traffic selector matches exactly to the subnet
|
||||
*/
|
||||
bool (*to_subnet) (traffic_selector_t *this, host_t **net, u_int8_t *mask);
|
||||
bool (*to_subnet) (traffic_selector_t *this, host_t **net, uint8_t *mask);
|
||||
|
||||
/**
|
||||
* Create a hash value for the traffic selector.
|
||||
@@ -240,7 +240,7 @@ struct traffic_selector_t {
|
||||
* @param port port number in host order
|
||||
* @return ICMP/ICMPv6 message type
|
||||
*/
|
||||
static inline u_int8_t traffic_selector_icmp_type(u_int16_t port)
|
||||
static inline uint8_t traffic_selector_icmp_type(uint16_t port)
|
||||
{
|
||||
return port >> 8;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ static inline u_int8_t traffic_selector_icmp_type(u_int16_t port)
|
||||
* @param port port number in host order
|
||||
* @return ICMP/ICMPv6 message code
|
||||
*/
|
||||
static inline u_int8_t traffic_selector_icmp_code(u_int16_t port)
|
||||
static inline uint8_t traffic_selector_icmp_code(uint16_t port)
|
||||
{
|
||||
return port & 0xff;
|
||||
}
|
||||
@@ -286,9 +286,9 @@ int traffic_selector_cmp(traffic_selector_t *a, traffic_selector_t *b,
|
||||
* - NULL if invalid address strings/protocol
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_string(
|
||||
u_int8_t protocol, ts_type_t type,
|
||||
char *from_addr, u_int16_t from_port,
|
||||
char *to_addr, u_int16_t to_port);
|
||||
uint8_t protocol, ts_type_t type,
|
||||
char *from_addr, uint16_t from_port,
|
||||
char *to_addr, uint16_t to_port);
|
||||
|
||||
|
||||
|
||||
@@ -307,8 +307,8 @@ traffic_selector_t *traffic_selector_create_from_string(
|
||||
* @return traffic selector, NULL if string invalid
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_cidr(
|
||||
char *string, u_int8_t protocol,
|
||||
u_int16_t from_port, u_int16_t to_port);
|
||||
char *string, uint8_t protocol,
|
||||
uint16_t from_port, uint16_t to_port);
|
||||
|
||||
/**
|
||||
* Create a new traffic selector using data read from the net.
|
||||
@@ -331,9 +331,9 @@ traffic_selector_t *traffic_selector_create_from_cidr(
|
||||
* @return traffic_selector_t object
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_bytes(
|
||||
u_int8_t protocol, ts_type_t type,
|
||||
chunk_t from_address, u_int16_t from_port,
|
||||
chunk_t to_address, u_int16_t to_port);
|
||||
uint8_t protocol, ts_type_t type,
|
||||
chunk_t from_address, uint16_t from_port,
|
||||
chunk_t to_address, uint16_t to_port);
|
||||
|
||||
/**
|
||||
* Create a new traffic selector using the RFC 3779 ASN.1 min/max address format
|
||||
@@ -370,8 +370,8 @@ traffic_selector_t *traffic_selector_create_from_rfc3779_format(ts_type_t type,
|
||||
* - NULL if address family of net not supported
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_from_subnet(
|
||||
host_t *net, u_int8_t netbits, u_int8_t protocol,
|
||||
u_int16_t from_port, u_int16_t to_port);
|
||||
host_t *net, uint8_t netbits, uint8_t protocol,
|
||||
uint16_t from_port, uint16_t to_port);
|
||||
|
||||
/**
|
||||
* Create a traffic selector for host-to-host cases.
|
||||
@@ -392,8 +392,8 @@ traffic_selector_t *traffic_selector_create_from_subnet(
|
||||
* - traffic_selector_t object
|
||||
* - NULL if type not supported
|
||||
*/
|
||||
traffic_selector_t *traffic_selector_create_dynamic(u_int8_t protocol,
|
||||
u_int16_t from_port, u_int16_t to_port);
|
||||
traffic_selector_t *traffic_selector_create_dynamic(uint8_t protocol,
|
||||
uint16_t from_port, uint16_t to_port);
|
||||
|
||||
/**
|
||||
* printf hook function for traffic_selector_t.
|
||||
|
||||
Reference in New Issue
Block a user