diff options
Diffstat (limited to 'src/libcharon/plugins/kernel_netlink')
-rw-r--r-- | src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c | 96 | ||||
-rw-r--r-- | src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c | 46 |
2 files changed, 71 insertions, 71 deletions
diff --git a/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c b/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c index 6d9d63a98..cbce0a57b 100644 --- a/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c +++ b/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c @@ -347,7 +347,7 @@ struct route_entry_t { chunk_t dst_net; /** Destination net prefixlen */ - u_int8_t prefixlen; + uint8_t prefixlen; }; /** @@ -470,7 +470,7 @@ typedef struct policy_sa_fwd_t policy_sa_fwd_t; */ struct policy_sa_t { /** Priority assigned to the policy when installed with this SA */ - u_int32_t priority; + uint32_t priority; /** Type of the policy */ policy_type_t type; @@ -546,13 +546,13 @@ typedef struct policy_entry_t policy_entry_t; struct policy_entry_t { /** Direction of this policy: in, out, forward */ - u_int8_t direction; + uint8_t direction; /** Parameters of installed policy */ struct xfrm_selector sel; /** Optional mark */ - u_int32_t mark; + uint32_t mark; /** Associated route installed for this policy */ route_entry_t *route; @@ -561,7 +561,7 @@ struct policy_entry_t { linked_list_t *used_by; /** reqid for this policy */ - u_int32_t reqid; + uint32_t reqid; }; /** @@ -606,10 +606,10 @@ static bool policy_equals(policy_entry_t *key, policy_entry_t *other_key) /** * Calculate the priority of a policy */ -static inline u_int32_t get_priority(policy_entry_t *policy, +static inline uint32_t get_priority(policy_entry_t *policy, policy_priority_t prio) { - u_int32_t priority = PRIO_BASE; + uint32_t priority = PRIO_BASE; switch (prio) { case POLICY_PRIORITY_FALLBACK: @@ -636,7 +636,7 @@ static inline u_int32_t get_priority(policy_entry_t *policy, /** * Convert the general ipsec mode to the one defined in xfrm.h */ -static u_int8_t mode2kernel(ipsec_mode_t mode) +static uint8_t mode2kernel(ipsec_mode_t mode) { switch (mode) { @@ -663,7 +663,7 @@ static void host2xfrm(host_t *host, xfrm_address_t *xfrm) /** * Convert a struct xfrm_address to a host_t */ -static host_t* xfrm2host(int family, xfrm_address_t *xfrm, u_int16_t port) +static host_t* xfrm2host(int family, xfrm_address_t *xfrm, uint16_t port) { chunk_t chunk; @@ -685,7 +685,7 @@ static host_t* xfrm2host(int family, xfrm_address_t *xfrm, u_int16_t port) * Convert a traffic selector address range to subnet and its mask. */ static void ts2subnet(traffic_selector_t* ts, - xfrm_address_t *net, u_int8_t *mask) + xfrm_address_t *net, uint8_t *mask) { host_t *net_host; chunk_t net_chunk; @@ -700,7 +700,7 @@ static void ts2subnet(traffic_selector_t* ts, * Convert a traffic selector port range to port/portmask */ static void ts2ports(traffic_selector_t* ts, - u_int16_t *port, u_int16_t *mask) + uint16_t *port, uint16_t *mask) { uint16_t from, to, bitmask; int bit; @@ -742,7 +742,7 @@ static struct xfrm_selector ts2selector(traffic_selector_t *src, traffic_selector_t *dst) { struct xfrm_selector sel; - u_int16_t port; + uint16_t port; memset(&sel, 0, sizeof(sel)); sel.family = (src->get_type(src) == TS_IPV4_ADDR_RANGE) ? AF_INET : AF_INET6; @@ -775,8 +775,8 @@ static struct xfrm_selector ts2selector(traffic_selector_t *src, static traffic_selector_t* selector2ts(struct xfrm_selector *sel, bool src) { u_char *addr; - u_int8_t prefixlen; - u_int16_t port = 0; + uint8_t prefixlen; + uint16_t port = 0; host_t *host = NULL; if (src) @@ -833,7 +833,7 @@ static void process_acquire(private_kernel_netlink_ipsec_t *this, struct rtattr *rta; size_t rtasize; traffic_selector_t *src_ts, *dst_ts; - u_int32_t reqid = 0; + uint32_t reqid = 0; int proto = 0; acquire = NLMSG_DATA(hdr); @@ -878,8 +878,8 @@ static void process_expire(private_kernel_netlink_ipsec_t *this, struct nlmsghdr *hdr) { struct xfrm_user_expire *expire; - u_int32_t spi; - u_int8_t protocol; + uint32_t spi; + uint8_t protocol; host_t *dst; expire = NLMSG_DATA(hdr); @@ -913,7 +913,7 @@ static void process_migrate(private_kernel_netlink_ipsec_t *this, host_t *local = NULL, *remote = NULL; host_t *old_src = NULL, *old_dst = NULL; host_t *new_src = NULL, *new_dst = NULL; - u_int32_t reqid = 0; + uint32_t reqid = 0; policy_dir_t dir; policy_id = NLMSG_DATA(hdr); @@ -981,7 +981,7 @@ static void process_mapping(private_kernel_netlink_ipsec_t *this, struct nlmsghdr *hdr) { struct xfrm_user_mapping *mapping; - u_int32_t spi; + uint32_t spi; mapping = NLMSG_DATA(hdr); spi = mapping->id.spi; @@ -1080,13 +1080,13 @@ METHOD(kernel_ipsec_t, get_features, kernel_feature_t, * Get an SPI for a specific protocol from the kernel. */ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this, - host_t *src, host_t *dst, u_int8_t proto, u_int32_t min, u_int32_t max, - u_int32_t *spi) + host_t *src, host_t *dst, uint8_t proto, uint32_t min, uint32_t max, + uint32_t *spi) { netlink_buf_t request; struct nlmsghdr *hdr, *out; struct xfrm_userspi_info *userspi; - u_int32_t received_spi = 0; + uint32_t received_spi = 0; size_t len; memset(&request, 0, sizeof(request)); @@ -1147,7 +1147,7 @@ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this, METHOD(kernel_ipsec_t, get_spi, status_t, private_kernel_netlink_ipsec_t *this, host_t *src, host_t *dst, - u_int8_t protocol, u_int32_t *spi) + uint8_t protocol, uint32_t *spi) { if (get_spi_internal(this, src, dst, protocol, 0xc0000000, 0xcFFFFFFF, spi) != SUCCESS) @@ -1162,9 +1162,9 @@ METHOD(kernel_ipsec_t, get_spi, status_t, METHOD(kernel_ipsec_t, get_cpi, status_t, private_kernel_netlink_ipsec_t *this, host_t *src, host_t *dst, - u_int16_t *cpi) + uint16_t *cpi) { - u_int32_t received_spi = 0; + uint32_t received_spi = 0; if (get_spi_internal(this, src, dst, IPPROTO_COMP, 0x100, 0xEFFF, &received_spi) != SUCCESS) @@ -1173,7 +1173,7 @@ METHOD(kernel_ipsec_t, get_cpi, status_t, return FAILED; } - *cpi = htons((u_int16_t)ntohl(received_spi)); + *cpi = htons((uint16_t)ntohl(received_spi)); DBG2(DBG_KNL, "got CPI %.4x", ntohs(*cpi)); return SUCCESS; @@ -1201,10 +1201,10 @@ static bool add_mark(struct nlmsghdr *hdr, int buflen, mark_t mark) METHOD(kernel_ipsec_t, add_sa, status_t, private_kernel_netlink_ipsec_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, u_int32_t replay_window, + 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, uint32_t replay_window, bool initiator, bool encap, bool esn, bool inbound, bool update, linked_list_t* src_ts, linked_list_t* dst_ts) { @@ -1212,7 +1212,7 @@ METHOD(kernel_ipsec_t, add_sa, status_t, char *alg_name; struct nlmsghdr *hdr; struct xfrm_usersa_info *sa; - u_int16_t icv_size = 64; + uint16_t icv_size = 64; ipsec_mode_t original_mode = mode; traffic_selector_t *first_src_ts, *first_dst_ts; status_t status = FAILED; @@ -1483,7 +1483,7 @@ METHOD(kernel_ipsec_t, add_sa, status_t, if (tfc && protocol == IPPROTO_ESP && mode == MODE_TUNNEL) { /* the kernel supports TFC padding only for tunnel mode ESP SAs */ - u_int32_t *tfcpad; + uint32_t *tfcpad; tfcpad = netlink_reserve(hdr, sizeof(request), XFRMA_TFCPAD, sizeof(*tfcpad)); @@ -1501,9 +1501,9 @@ METHOD(kernel_ipsec_t, add_sa, status_t, /* for ESN or larger replay windows we need the new * XFRMA_REPLAY_ESN_VAL attribute to configure a bitmap */ struct xfrm_replay_state_esn *replay; - u_int32_t bmp_size; + uint32_t bmp_size; - bmp_size = round_up(replay_window, sizeof(u_int32_t) * 8) / 8; + bmp_size = round_up(replay_window, sizeof(uint32_t) * 8) / 8; replay = netlink_reserve(hdr, sizeof(request), XFRMA_REPLAY_ESN_VAL, sizeof(*replay) + bmp_size); if (!replay) @@ -1511,7 +1511,7 @@ METHOD(kernel_ipsec_t, add_sa, status_t, goto failed; } /* bmp_len contains number uf __u32's */ - replay->bmp_len = bmp_size / sizeof(u_int32_t); + replay->bmp_len = bmp_size / sizeof(uint32_t); replay->replay_window = replay_window; DBG2(DBG_KNL, " using replay window of %u packets", replay_window); @@ -1555,10 +1555,10 @@ failed: * Allocates into one the replay state structure we get from the kernel. */ static void get_replay_state(private_kernel_netlink_ipsec_t *this, - u_int32_t spi, u_int8_t protocol, + uint32_t spi, uint8_t protocol, host_t *dst, mark_t mark, struct xfrm_replay_state_esn **replay_esn, - u_int32_t *replay_esn_len, + uint32_t *replay_esn_len, struct xfrm_replay_state **replay, struct xfrm_lifetime_cur **lifetime) { @@ -1658,8 +1658,8 @@ static void get_replay_state(private_kernel_netlink_ipsec_t *this, METHOD(kernel_ipsec_t, query_sa, status_t, private_kernel_netlink_ipsec_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) { netlink_buf_t request; struct nlmsghdr *out = NULL, *hdr; @@ -1759,7 +1759,7 @@ METHOD(kernel_ipsec_t, query_sa, status_t, METHOD(kernel_ipsec_t, del_sa, status_t, private_kernel_netlink_ipsec_t *this, host_t *src, host_t *dst, - u_int32_t spi, u_int8_t protocol, u_int16_t cpi, mark_t mark) + uint32_t spi, uint8_t protocol, uint16_t cpi, mark_t mark) { netlink_buf_t request; struct nlmsghdr *hdr; @@ -1816,8 +1816,8 @@ METHOD(kernel_ipsec_t, del_sa, status_t, } METHOD(kernel_ipsec_t, update_sa, status_t, - private_kernel_netlink_ipsec_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_kernel_netlink_ipsec_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 old_encap, bool new_encap, mark_t mark) { netlink_buf_t request; @@ -1831,7 +1831,7 @@ METHOD(kernel_ipsec_t, update_sa, status_t, struct xfrm_replay_state *replay = NULL; struct xfrm_replay_state_esn *replay_esn = NULL; struct xfrm_lifetime_cur *lifetime = NULL; - u_int32_t replay_esn_len = 0; + uint32_t replay_esn_len = 0; status_t status = FAILED; /* if IPComp is used, we first update the IPComp SA */ @@ -2032,7 +2032,7 @@ METHOD(kernel_ipsec_t, flush_sas, status_t, struct nlmsghdr *hdr; struct xfrm_usersa_flush *flush; struct { - u_int8_t proto; + uint8_t proto; char *name; } protos[] = { { IPPROTO_AH, "AH" }, @@ -2115,7 +2115,7 @@ static status_t add_policy_internal(private_kernel_netlink_ipsec_t *this, { struct xfrm_user_tmpl *tmpl; struct { - u_int8_t proto; + uint8_t proto; bool use; } protos[] = { { IPPROTO_COMP, ipsec->cfg.ipcomp.transform != IPCOMP_NONE }, @@ -2491,7 +2491,7 @@ METHOD(kernel_ipsec_t, del_policy, status_t, struct nlmsghdr *hdr; struct xfrm_userpolicy_id *policy_id; bool is_installed = TRUE; - u_int32_t priority; + uint32_t priority; ipsec_sa_t assigned_sa = { .src = src, .dst = dst, @@ -2699,7 +2699,7 @@ typedef struct { /** layer 4 protocol */ int proto; /** port number, network order */ - u_int16_t port; + uint16_t port; } bypass_t; /** @@ -2839,7 +2839,7 @@ METHOD(kernel_ipsec_t, bypass_socket, bool, } METHOD(kernel_ipsec_t, enable_udp_decap, bool, - private_kernel_netlink_ipsec_t *this, int fd, int family, u_int16_t port) + private_kernel_netlink_ipsec_t *this, int fd, int family, uint16_t port) { int type = UDP_ENCAP_ESPINUDP; diff --git a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c index f4394a14f..e297e356a 100644 --- a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c +++ b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c @@ -278,7 +278,7 @@ struct route_entry_t { chunk_t dst_net; /** Destination net prefixlen */ - u_int8_t prefixlen; + uint8_t prefixlen; }; /** @@ -513,12 +513,12 @@ struct private_kernel_netlink_net_t { /** * MTU to set on installed routes */ - u_int32_t mtu; + uint32_t mtu; /** * MSS to set on installed routes */ - u_int32_t mss; + uint32_t mss; }; /** @@ -526,7 +526,7 @@ struct private_kernel_netlink_net_t { */ static status_t manage_srcroute(private_kernel_netlink_net_t *this, int nlmsg_type, int flags, chunk_t dst_net, - u_int8_t prefixlen, host_t *gateway, + uint8_t prefixlen, host_t *gateway, host_t *src_ip, char *if_name); /** @@ -1217,7 +1217,7 @@ static void process_route(private_kernel_netlink_net_t *this, struct nlmsghdr *h struct rtmsg* msg = NLMSG_DATA(hdr); struct rtattr *rta = RTM_RTA(msg); size_t rtasize = RTM_PAYLOAD(hdr); - u_int32_t rta_oif = 0; + uint32_t rta_oif = 0; host_t *host = NULL; /* ignore routes added by us or in the local routing table (local addrs) */ @@ -1243,7 +1243,7 @@ static void process_route(private_kernel_netlink_net_t *this, struct nlmsghdr *h case RTA_OIF: if (RTA_PAYLOAD(rta) == sizeof(rta_oif)) { - rta_oif = *(u_int32_t*)RTA_DATA(rta); + rta_oif = *(uint32_t*)RTA_DATA(rta); } break; } @@ -1545,10 +1545,10 @@ typedef struct { chunk_t src; chunk_t dst; host_t *src_host; - u_int8_t dst_len; - u_int32_t table; - u_int32_t oif; - u_int32_t priority; + uint8_t dst_len; + uint32_t table; + uint32_t oif; + uint32_t priority; } rt_entry_t; /** @@ -1630,20 +1630,20 @@ static rt_entry_t *parse_route(struct nlmsghdr *hdr, rt_entry_t *route) case RTA_OIF: if (RTA_PAYLOAD(rta) == sizeof(route->oif)) { - route->oif = *(u_int32_t*)RTA_DATA(rta); + route->oif = *(uint32_t*)RTA_DATA(rta); } break; case RTA_PRIORITY: if (RTA_PAYLOAD(rta) == sizeof(route->priority)) { - route->priority = *(u_int32_t*)RTA_DATA(rta); + route->priority = *(uint32_t*)RTA_DATA(rta); } break; #ifdef HAVE_RTA_TABLE case RTA_TABLE: if (RTA_PAYLOAD(rta) == sizeof(route->table)) { - route->table = *(u_int32_t*)RTA_DATA(rta); + route->table = *(uint32_t*)RTA_DATA(rta); } break; #endif /* HAVE_RTA_TABLE*/ @@ -2144,7 +2144,7 @@ METHOD(kernel_net_t, del_ip, status_t, */ static status_t manage_srcroute(private_kernel_netlink_net_t *this, int nlmsg_type, int flags, chunk_t dst_net, - u_int8_t prefixlen, host_t *gateway, + uint8_t prefixlen, host_t *gateway, host_t *src_ip, char *if_name) { netlink_buf_t request; @@ -2160,7 +2160,7 @@ static status_t manage_srcroute(private_kernel_netlink_net_t *this, if (this->routing_table == 0 && prefixlen == 0) { chunk_t half_net; - u_int8_t half_prefixlen; + uint8_t half_prefixlen; status_t status; half_net = chunk_alloca(dst_net.len); @@ -2206,22 +2206,22 @@ static status_t manage_srcroute(private_kernel_netlink_net_t *this, if (this->mtu || this->mss) { chunk = chunk_alloca(RTA_LENGTH((sizeof(struct rtattr) + - sizeof(u_int32_t)) * 2)); + sizeof(uint32_t)) * 2)); chunk.len = 0; rta = (struct rtattr*)chunk.ptr; if (this->mtu) { rta->rta_type = RTAX_MTU; - rta->rta_len = RTA_LENGTH(sizeof(u_int32_t)); - memcpy(RTA_DATA(rta), &this->mtu, sizeof(u_int32_t)); + rta->rta_len = RTA_LENGTH(sizeof(uint32_t)); + memcpy(RTA_DATA(rta), &this->mtu, sizeof(uint32_t)); chunk.len = rta->rta_len; } if (this->mss) { rta = (struct rtattr*)(chunk.ptr + RTA_ALIGN(chunk.len)); rta->rta_type = RTAX_ADVMSS; - rta->rta_len = RTA_LENGTH(sizeof(u_int32_t)); - memcpy(RTA_DATA(rta), &this->mss, sizeof(u_int32_t)); + rta->rta_len = RTA_LENGTH(sizeof(uint32_t)); + memcpy(RTA_DATA(rta), &this->mss, sizeof(uint32_t)); chunk.len = RTA_ALIGN(chunk.len) + rta->rta_len; } netlink_add_attribute(hdr, RTA_METRICS, chunk, sizeof(request)); @@ -2231,7 +2231,7 @@ static status_t manage_srcroute(private_kernel_netlink_net_t *this, } METHOD(kernel_net_t, add_route, status_t, - private_kernel_netlink_net_t *this, chunk_t dst_net, u_int8_t prefixlen, + private_kernel_netlink_net_t *this, chunk_t dst_net, uint8_t prefixlen, host_t *gateway, host_t *src_ip, char *if_name) { status_t status; @@ -2262,7 +2262,7 @@ METHOD(kernel_net_t, add_route, status_t, } METHOD(kernel_net_t, del_route, status_t, - private_kernel_netlink_net_t *this, chunk_t dst_net, u_int8_t prefixlen, + private_kernel_netlink_net_t *this, chunk_t dst_net, uint8_t prefixlen, host_t *gateway, host_t *src_ip, char *if_name) { status_t status; @@ -2384,7 +2384,7 @@ static status_t init_address_list(private_kernel_netlink_net_t *this) * create or delete a rule to use our routing table */ static status_t manage_rule(private_kernel_netlink_net_t *this, int nlmsg_type, - int family, u_int32_t table, u_int32_t prio) + int family, uint32_t table, uint32_t prio) { netlink_buf_t request; struct nlmsghdr *hdr; |