got rid of deprecated create_iterator_locked()
This commit is contained in:
@@ -1623,7 +1623,7 @@ static status_t del_policy(private_kernel_netlink_ipsec_t *this,
|
|||||||
unsigned char request[NETLINK_BUFFER_SIZE];
|
unsigned char request[NETLINK_BUFFER_SIZE];
|
||||||
struct nlmsghdr *hdr;
|
struct nlmsghdr *hdr;
|
||||||
struct xfrm_userpolicy_id *policy_id;
|
struct xfrm_userpolicy_id *policy_id;
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
|
|
||||||
DBG2(DBG_KNL, "deleting policy %R === %R %N", src_ts, dst_ts,
|
DBG2(DBG_KNL, "deleting policy %R === %R %N", src_ts, dst_ts,
|
||||||
policy_dir_names, direction);
|
policy_dir_names, direction);
|
||||||
@@ -1634,8 +1634,9 @@ static status_t del_policy(private_kernel_netlink_ipsec_t *this,
|
|||||||
policy.direction = direction;
|
policy.direction = direction;
|
||||||
|
|
||||||
/* find the policy */
|
/* find the policy */
|
||||||
iterator = this->policies->create_iterator_locked(this->policies, &this->mutex);
|
pthread_mutex_lock(&this->mutex);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
enumerator = this->policies->create_enumerator(this->policies);
|
||||||
|
while (enumerator->enumerate(enumerator, ¤t))
|
||||||
{
|
{
|
||||||
if (memeq(¤t->sel, &policy.sel, sizeof(struct xfrm_selector)) &&
|
if (memeq(¤t->sel, &policy.sel, sizeof(struct xfrm_selector)) &&
|
||||||
policy.direction == current->direction)
|
policy.direction == current->direction)
|
||||||
@@ -1645,15 +1646,17 @@ static status_t del_policy(private_kernel_netlink_ipsec_t *this,
|
|||||||
{
|
{
|
||||||
/* is used by more SAs, keep in kernel */
|
/* is used by more SAs, keep in kernel */
|
||||||
DBG2(DBG_KNL, "policy still used by another CHILD_SA, not removed");
|
DBG2(DBG_KNL, "policy still used by another CHILD_SA, not removed");
|
||||||
iterator->destroy(iterator);
|
pthread_mutex_unlock(&this->mutex);
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
/* remove if last reference */
|
/* remove if last reference */
|
||||||
iterator->remove(iterator);
|
this->policies->remove_at(this->policies, enumerator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
pthread_mutex_unlock(&this->mutex);
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
if (!to_delete)
|
if (!to_delete)
|
||||||
{
|
{
|
||||||
DBG1(DBG_KNL, "deleting policy %R === %R %N failed, not found", src_ts,
|
DBG1(DBG_KNL, "deleting policy %R === %R %N failed, not found", src_ts,
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ static void process_link(private_kernel_netlink_net_t *this,
|
|||||||
struct ifinfomsg* msg = (struct ifinfomsg*)(NLMSG_DATA(hdr));
|
struct ifinfomsg* msg = (struct ifinfomsg*)(NLMSG_DATA(hdr));
|
||||||
struct rtattr *rta = IFLA_RTA(msg);
|
struct rtattr *rta = IFLA_RTA(msg);
|
||||||
size_t rtasize = IFLA_PAYLOAD (hdr);
|
size_t rtasize = IFLA_PAYLOAD (hdr);
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
iface_entry_t *current, *entry = NULL;
|
iface_entry_t *current, *entry = NULL;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
bool update = FALSE;
|
bool update = FALSE;
|
||||||
@@ -253,6 +253,7 @@ static void process_link(private_kernel_netlink_net_t *this,
|
|||||||
name = "(unknown)";
|
name = "(unknown)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&this->mutex);
|
||||||
switch (hdr->nlmsg_type)
|
switch (hdr->nlmsg_type)
|
||||||
{
|
{
|
||||||
case RTM_NEWLINK:
|
case RTM_NEWLINK:
|
||||||
@@ -261,9 +262,8 @@ static void process_link(private_kernel_netlink_net_t *this,
|
|||||||
{ /* ignore loopback interfaces */
|
{ /* ignore loopback interfaces */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iterator = this->ifaces->create_iterator_locked(this->ifaces,
|
enumerator = this->ifaces->create_enumerator(this->ifaces);
|
||||||
&this->mutex);
|
while (enumerator->enumerate(enumerator, ¤t))
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
|
||||||
{
|
{
|
||||||
if (current->ifindex == msg->ifi_index)
|
if (current->ifindex == msg->ifi_index)
|
||||||
{
|
{
|
||||||
@@ -271,6 +271,7 @@ static void process_link(private_kernel_netlink_net_t *this,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
{
|
{
|
||||||
entry = malloc_thing(iface_entry_t);
|
entry = malloc_thing(iface_entry_t);
|
||||||
@@ -295,14 +296,12 @@ static void process_link(private_kernel_netlink_net_t *this,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry->flags = msg->ifi_flags;
|
entry->flags = msg->ifi_flags;
|
||||||
iterator->destroy(iterator);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RTM_DELLINK:
|
case RTM_DELLINK:
|
||||||
{
|
{
|
||||||
iterator = this->ifaces->create_iterator_locked(this->ifaces,
|
enumerator = this->ifaces->create_enumerator(this->ifaces);
|
||||||
&this->mutex);
|
while (enumerator->enumerate(enumerator, ¤t))
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
|
||||||
{
|
{
|
||||||
if (current->ifindex == msg->ifi_index)
|
if (current->ifindex == msg->ifi_index)
|
||||||
{
|
{
|
||||||
@@ -312,10 +311,11 @@ static void process_link(private_kernel_netlink_net_t *this,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
|
|
||||||
/* send an update to all IKE_SAs */
|
/* send an update to all IKE_SAs */
|
||||||
if (update && event)
|
if (update && event)
|
||||||
@@ -334,7 +334,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
|
|||||||
struct rtattr *rta = IFA_RTA(msg);
|
struct rtattr *rta = IFA_RTA(msg);
|
||||||
size_t rtasize = IFA_PAYLOAD (hdr);
|
size_t rtasize = IFA_PAYLOAD (hdr);
|
||||||
host_t *host = NULL;
|
host_t *host = NULL;
|
||||||
iterator_t *ifaces, *addrs;
|
enumerator_t *ifaces, *addrs;
|
||||||
iface_entry_t *iface;
|
iface_entry_t *iface;
|
||||||
addr_entry_t *addr;
|
addr_entry_t *addr;
|
||||||
chunk_t local = chunk_empty, address = chunk_empty;
|
chunk_t local = chunk_empty, address = chunk_empty;
|
||||||
@@ -373,20 +373,21 @@ static void process_addr(private_kernel_netlink_net_t *this,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifaces = this->ifaces->create_iterator_locked(this->ifaces, &this->mutex);
|
pthread_mutex_lock(&this->mutex);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
|
while (ifaces->enumerate(ifaces, &iface))
|
||||||
{
|
{
|
||||||
if (iface->ifindex == msg->ifa_index)
|
if (iface->ifindex == msg->ifa_index)
|
||||||
{
|
{
|
||||||
addrs = iface->addrs->create_iterator(iface->addrs, TRUE);
|
addrs = iface->addrs->create_enumerator(iface->addrs);
|
||||||
while (addrs->iterate(addrs, (void**)&addr))
|
while (addrs->enumerate(addrs, &addr))
|
||||||
{
|
{
|
||||||
if (host->ip_equals(host, addr->ip))
|
if (host->ip_equals(host, addr->ip))
|
||||||
{
|
{
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
if (hdr->nlmsg_type == RTM_DELADDR)
|
if (hdr->nlmsg_type == RTM_DELADDR)
|
||||||
{
|
{
|
||||||
addrs->remove(addrs);
|
iface->addrs->remove_at(iface->addrs, addrs);
|
||||||
if (!addr->virtual)
|
if (!addr->virtual)
|
||||||
{
|
{
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
@@ -430,6 +431,7 @@ static void process_addr(private_kernel_netlink_net_t *this,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
host->destroy(host);
|
host->destroy(host);
|
||||||
|
|
||||||
/* send an update to all IKE_SAs */
|
/* send an update to all IKE_SAs */
|
||||||
@@ -624,18 +626,19 @@ static enumerator_t *create_address_enumerator(private_kernel_netlink_net_t *thi
|
|||||||
*/
|
*/
|
||||||
static char *get_interface_name(private_kernel_netlink_net_t *this, host_t* ip)
|
static char *get_interface_name(private_kernel_netlink_net_t *this, host_t* ip)
|
||||||
{
|
{
|
||||||
iterator_t *ifaces, *addrs;
|
enumerator_t *ifaces, *addrs;
|
||||||
iface_entry_t *iface;
|
iface_entry_t *iface;
|
||||||
addr_entry_t *addr;
|
addr_entry_t *addr;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
|
||||||
DBG2(DBG_KNL, "getting interface name for %H", ip);
|
DBG2(DBG_KNL, "getting interface name for %H", ip);
|
||||||
|
|
||||||
ifaces = this->ifaces->create_iterator_locked(this->ifaces, &this->mutex);
|
pthread_mutex_lock(&this->mutex);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
|
while (ifaces->enumerate(ifaces, &iface))
|
||||||
{
|
{
|
||||||
addrs = iface->addrs->create_iterator(iface->addrs, TRUE);
|
addrs = iface->addrs->create_enumerator(iface->addrs);
|
||||||
while (addrs->iterate(addrs, (void**)&addr))
|
while (addrs->enumerate(addrs, &addr))
|
||||||
{
|
{
|
||||||
if (ip->ip_equals(ip, addr->ip))
|
if (ip->ip_equals(ip, addr->ip))
|
||||||
{
|
{
|
||||||
@@ -650,6 +653,7 @@ static char *get_interface_name(private_kernel_netlink_net_t *this, host_t* ip)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
@@ -667,14 +671,15 @@ static char *get_interface_name(private_kernel_netlink_net_t *this, host_t* ip)
|
|||||||
*/
|
*/
|
||||||
static int get_interface_index(private_kernel_netlink_net_t *this, char* name)
|
static int get_interface_index(private_kernel_netlink_net_t *this, char* name)
|
||||||
{
|
{
|
||||||
iterator_t *ifaces;
|
enumerator_t *ifaces;
|
||||||
iface_entry_t *iface;
|
iface_entry_t *iface;
|
||||||
int ifindex = 0;
|
int ifindex = 0;
|
||||||
|
|
||||||
DBG2(DBG_KNL, "getting iface index for %s", name);
|
DBG2(DBG_KNL, "getting iface index for %s", name);
|
||||||
|
|
||||||
ifaces = this->ifaces->create_iterator_locked(this->ifaces, &this->mutex);
|
pthread_mutex_lock(&this->mutex);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
|
while (ifaces->enumerate(ifaces, &iface))
|
||||||
{
|
{
|
||||||
if (streq(name, iface->ifname))
|
if (streq(name, iface->ifname))
|
||||||
{
|
{
|
||||||
@@ -683,6 +688,7 @@ static int get_interface_index(private_kernel_netlink_net_t *this, char* name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
|
|
||||||
if (ifindex == 0)
|
if (ifindex == 0)
|
||||||
{
|
{
|
||||||
@@ -815,7 +821,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
|
|||||||
&& (msg->rtm_dst_len == 0 || /* default route */
|
&& (msg->rtm_dst_len == 0 || /* default route */
|
||||||
(rta_dst.ptr && addr_in_subnet(chunk, rta_dst, msg->rtm_dst_len))))
|
(rta_dst.ptr && addr_in_subnet(chunk, rta_dst, msg->rtm_dst_len))))
|
||||||
{
|
{
|
||||||
iterator_t *ifaces, *addrs;
|
enumerator_t *ifaces, *addrs;
|
||||||
iface_entry_t *iface;
|
iface_entry_t *iface;
|
||||||
addr_entry_t *addr;
|
addr_entry_t *addr;
|
||||||
|
|
||||||
@@ -840,15 +846,14 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no source addr, get one from the interfaces */
|
/* no source addr, get one from the interfaces */
|
||||||
ifaces = this->ifaces->create_iterator_locked(
|
pthread_mutex_lock(&this->mutex);
|
||||||
this->ifaces, &this->mutex);
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
while (ifaces->enumerate(ifaces, &iface))
|
||||||
{
|
{
|
||||||
if (iface->ifindex == rta_oif)
|
if (iface->ifindex == rta_oif)
|
||||||
{
|
{
|
||||||
addrs = iface->addrs->create_iterator(
|
addrs = iface->addrs->create_enumerator(iface->addrs);
|
||||||
iface->addrs, TRUE);
|
while (addrs->enumerate(addrs, &addr))
|
||||||
while (addrs->iterate(addrs, (void**)&addr))
|
|
||||||
{
|
{
|
||||||
chunk_t ip = addr->ip->get_address(addr->ip);
|
chunk_t ip = addr->ip->get_address(addr->ip);
|
||||||
if ((msg->rtm_dst_len == 0 &&
|
if ((msg->rtm_dst_len == 0 &&
|
||||||
@@ -865,6 +870,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* FALL through */
|
/* FALL through */
|
||||||
@@ -946,18 +952,19 @@ static status_t add_ip(private_kernel_netlink_net_t *this,
|
|||||||
{
|
{
|
||||||
iface_entry_t *iface;
|
iface_entry_t *iface;
|
||||||
addr_entry_t *addr;
|
addr_entry_t *addr;
|
||||||
iterator_t *addrs, *ifaces;
|
enumerator_t *addrs, *ifaces;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
|
||||||
DBG2(DBG_KNL, "adding virtual IP %H", virtual_ip);
|
DBG2(DBG_KNL, "adding virtual IP %H", virtual_ip);
|
||||||
|
|
||||||
ifaces = this->ifaces->create_iterator_locked(this->ifaces, &this->mutex);
|
pthread_mutex_lock(&this->mutex);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
|
while (ifaces->enumerate(ifaces, &iface))
|
||||||
{
|
{
|
||||||
bool iface_found = FALSE;
|
bool iface_found = FALSE;
|
||||||
|
|
||||||
addrs = iface->addrs->create_iterator(iface->addrs, TRUE);
|
addrs = iface->addrs->create_enumerator(iface->addrs);
|
||||||
while (addrs->iterate(addrs, (void**)&addr))
|
while (addrs->enumerate(addrs, &addr))
|
||||||
{
|
{
|
||||||
if (iface_ip->ip_equals(iface_ip, addr->ip))
|
if (iface_ip->ip_equals(iface_ip, addr->ip))
|
||||||
{
|
{
|
||||||
@@ -970,6 +977,7 @@ static status_t add_ip(private_kernel_netlink_net_t *this,
|
|||||||
virtual_ip, iface->ifname);
|
virtual_ip, iface->ifname);
|
||||||
addrs->destroy(addrs);
|
addrs->destroy(addrs);
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -993,14 +1001,17 @@ static status_t add_ip(private_kernel_netlink_net_t *this,
|
|||||||
pthread_cond_wait(&this->cond, &this->mutex);
|
pthread_cond_wait(&this->cond, &this->mutex);
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
DBG1(DBG_KNL, "adding virtual IP %H failed", virtual_ip);
|
DBG1(DBG_KNL, "adding virtual IP %H failed", virtual_ip);
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
|
|
||||||
DBG1(DBG_KNL, "interface address %H not found, unable to install"
|
DBG1(DBG_KNL, "interface address %H not found, unable to install"
|
||||||
"virtual IP %H", iface_ip, virtual_ip);
|
"virtual IP %H", iface_ip, virtual_ip);
|
||||||
@@ -1014,17 +1025,18 @@ static status_t del_ip(private_kernel_netlink_net_t *this, host_t *virtual_ip)
|
|||||||
{
|
{
|
||||||
iface_entry_t *iface;
|
iface_entry_t *iface;
|
||||||
addr_entry_t *addr;
|
addr_entry_t *addr;
|
||||||
iterator_t *addrs, *ifaces;
|
enumerator_t *addrs, *ifaces;
|
||||||
status_t status;
|
status_t status;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
|
||||||
DBG2(DBG_KNL, "deleting virtual IP %H", virtual_ip);
|
DBG2(DBG_KNL, "deleting virtual IP %H", virtual_ip);
|
||||||
|
|
||||||
ifaces = this->ifaces->create_iterator_locked(this->ifaces, &this->mutex);
|
pthread_mutex_lock(&this->mutex);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
|
while (ifaces->enumerate(ifaces, &iface))
|
||||||
{
|
{
|
||||||
addrs = iface->addrs->create_iterator(iface->addrs, TRUE);
|
addrs = iface->addrs->create_enumerator(iface->addrs);
|
||||||
while (addrs->iterate(addrs, (void**)&addr))
|
while (addrs->enumerate(addrs, &addr))
|
||||||
{
|
{
|
||||||
if (virtual_ip->ip_equals(virtual_ip, addr->ip))
|
if (virtual_ip->ip_equals(virtual_ip, addr->ip))
|
||||||
{
|
{
|
||||||
@@ -1042,6 +1054,7 @@ static status_t del_ip(private_kernel_netlink_net_t *this, host_t *virtual_ip)
|
|||||||
}
|
}
|
||||||
addrs->destroy(addrs);
|
addrs->destroy(addrs);
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1052,12 +1065,14 @@ static status_t del_ip(private_kernel_netlink_net_t *this, host_t *virtual_ip)
|
|||||||
virtual_ip);
|
virtual_ip);
|
||||||
addrs->destroy(addrs);
|
addrs->destroy(addrs);
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addrs->destroy(addrs);
|
addrs->destroy(addrs);
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
|
|
||||||
DBG2(DBG_KNL, "virtual IP %H not cached, unable to delete", virtual_ip);
|
DBG2(DBG_KNL, "virtual IP %H not cached, unable to delete", virtual_ip);
|
||||||
return FAILED;
|
return FAILED;
|
||||||
@@ -1155,7 +1170,7 @@ static status_t init_address_list(private_kernel_netlink_net_t *this)
|
|||||||
struct nlmsghdr *out, *current, *in;
|
struct nlmsghdr *out, *current, *in;
|
||||||
struct rtgenmsg *msg;
|
struct rtgenmsg *msg;
|
||||||
size_t len;
|
size_t len;
|
||||||
iterator_t *ifaces, *addrs;
|
enumerator_t *ifaces, *addrs;
|
||||||
iface_entry_t *iface;
|
iface_entry_t *iface;
|
||||||
addr_entry_t *addr;
|
addr_entry_t *addr;
|
||||||
|
|
||||||
@@ -1217,14 +1232,15 @@ static status_t init_address_list(private_kernel_netlink_net_t *this)
|
|||||||
}
|
}
|
||||||
free(out);
|
free(out);
|
||||||
|
|
||||||
ifaces = this->ifaces->create_iterator_locked(this->ifaces, &this->mutex);
|
pthread_mutex_lock(&this->mutex);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
|
while (ifaces->enumerate(ifaces, &iface))
|
||||||
{
|
{
|
||||||
if (iface->flags & IFF_UP)
|
if (iface->flags & IFF_UP)
|
||||||
{
|
{
|
||||||
DBG1(DBG_KNL, " %s", iface->ifname);
|
DBG1(DBG_KNL, " %s", iface->ifname);
|
||||||
addrs = iface->addrs->create_iterator(iface->addrs, TRUE);
|
addrs = iface->addrs->create_enumerator(iface->addrs);
|
||||||
while (addrs->iterate(addrs, (void**)&addr))
|
while (addrs->enumerate(addrs, (void**)&addr))
|
||||||
{
|
{
|
||||||
DBG1(DBG_KNL, " %H", addr->ip);
|
DBG1(DBG_KNL, " %H", addr->ip);
|
||||||
}
|
}
|
||||||
@@ -1232,6 +1248,7 @@ static status_t init_address_list(private_kernel_netlink_net_t *this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifaces->destroy(ifaces);
|
ifaces->destroy(ifaces);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <linux/rtnetlink.h>
|
#include <linux/rtnetlink.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "kernel_netlink_shared.h"
|
#include "kernel_netlink_shared.h"
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "load_tester_ipsec.h"
|
#include "load_tester_ipsec.h"
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
typedef struct private_load_tester_ipsec_t private_load_tester_ipsec_t;
|
typedef struct private_load_tester_ipsec_t private_load_tester_ipsec_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "stroke_list.h"
|
#include "stroke_list.h"
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
#include <utils/linked_list.h>
|
#include <utils/linked_list.h>
|
||||||
#include <credentials/certificates/x509.h>
|
#include <credentials/certificates/x509.h>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include <processing/jobs/callback_job.h>
|
#include <processing/jobs/callback_job.h>
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "callback_job.h"
|
#include "callback_job.h"
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
|
|
||||||
typedef struct private_callback_job_t private_callback_job_t;
|
typedef struct private_callback_job_t private_callback_job_t;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <printf.h>
|
#include <printf.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "ike_sa.h"
|
#include "ike_sa.h"
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "ike_auth_lifetime.h"
|
#include "ike_auth_lifetime.h"
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
#include <encoding/payloads/notify_payload.h>
|
#include <encoding/payloads/notify_payload.h>
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "fetcher_manager.h"
|
#include "fetcher_manager.h"
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "x509_ac.h"
|
#include "x509_ac.h"
|
||||||
#include "ietf_attr_list.h"
|
#include "ietf_attr_list.h"
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <asn1/oid.h>
|
#include <asn1/oid.h>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "x509_cert.h"
|
#include "x509_cert.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
typedef struct private_x509_crl_t private_x509_crl_t;
|
typedef struct private_x509_crl_t private_x509_crl_t;
|
||||||
typedef struct revoked_t revoked_t;
|
typedef struct revoked_t revoked_t;
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <asn1/oid.h>
|
#include <asn1/oid.h>
|
||||||
|
|||||||
@@ -120,11 +120,6 @@ struct private_iterator_t {
|
|||||||
*/
|
*/
|
||||||
bool forward;
|
bool forward;
|
||||||
|
|
||||||
/**
|
|
||||||
* Mutex to use to synchronize access
|
|
||||||
*/
|
|
||||||
pthread_mutex_t *mutex;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iteration hook
|
* iteration hook
|
||||||
*/
|
*/
|
||||||
@@ -428,10 +423,6 @@ static void insert_after(private_iterator_t *iterator, void *item)
|
|||||||
*/
|
*/
|
||||||
static void iterator_destroy(private_iterator_t *this)
|
static void iterator_destroy(private_iterator_t *this)
|
||||||
{
|
{
|
||||||
if (this->mutex)
|
|
||||||
{
|
|
||||||
pthread_mutex_unlock(this->mutex);
|
|
||||||
}
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,26 +797,11 @@ static iterator_t *create_iterator(private_linked_list_t *linked_list, bool forw
|
|||||||
this->forward = forward;
|
this->forward = forward;
|
||||||
this->current = NULL;
|
this->current = NULL;
|
||||||
this->list = linked_list;
|
this->list = linked_list;
|
||||||
this->mutex = NULL;
|
|
||||||
this->hook = iterator_hook;
|
this->hook = iterator_hook;
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of linked_list_t.create_iterator_locked.
|
|
||||||
*/
|
|
||||||
static iterator_t *create_iterator_locked(private_linked_list_t *linked_list,
|
|
||||||
pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
private_iterator_t *this = (private_iterator_t*)create_iterator(linked_list, TRUE);
|
|
||||||
this->mutex = mutex;
|
|
||||||
|
|
||||||
pthread_mutex_lock(mutex);
|
|
||||||
|
|
||||||
return &this->public;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
@@ -835,7 +811,6 @@ linked_list_t *linked_list_create()
|
|||||||
|
|
||||||
this->public.get_count = (int (*) (linked_list_t *)) get_count;
|
this->public.get_count = (int (*) (linked_list_t *)) get_count;
|
||||||
this->public.create_iterator = (iterator_t * (*) (linked_list_t *,bool))create_iterator;
|
this->public.create_iterator = (iterator_t * (*) (linked_list_t *,bool))create_iterator;
|
||||||
this->public.create_iterator_locked = (iterator_t * (*) (linked_list_t *,pthread_mutex_t*))create_iterator_locked;
|
|
||||||
this->public.create_enumerator = (enumerator_t*(*)(linked_list_t*))create_enumerator;
|
this->public.create_enumerator = (enumerator_t*(*)(linked_list_t*))create_enumerator;
|
||||||
this->public.get_first = (status_t (*) (linked_list_t *, void **item))get_first;
|
this->public.get_first = (status_t (*) (linked_list_t *, void **item))get_first;
|
||||||
this->public.get_last = (status_t (*) (linked_list_t *, void **item))get_last;
|
this->public.get_last = (status_t (*) (linked_list_t *, void **item))get_last;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2007-2008 Tobias Brunner
|
* Copyright (C) 2007-2008 Tobias Brunner
|
||||||
* Copyright (C) 2005-2006 Martin Willi
|
* Copyright (C) 2005-2008 Martin Willi
|
||||||
* Copyright (C) 2005 Jan Hutter
|
* Copyright (C) 2005 Jan Hutter
|
||||||
* Hochschule fuer Technik Rapperswil
|
* Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
@@ -27,13 +27,10 @@
|
|||||||
|
|
||||||
typedef struct linked_list_t linked_list_t;
|
typedef struct linked_list_t linked_list_t;
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <utils/iterator.h>
|
#include <utils/iterator.h>
|
||||||
#include <utils/enumerator.h>
|
#include <utils/enumerator.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to match elements in a linked list (used in find_* functions)
|
* Method to match elements in a linked list (used in find_* functions)
|
||||||
*
|
*
|
||||||
@@ -80,18 +77,6 @@ struct linked_list_t {
|
|||||||
*/
|
*/
|
||||||
iterator_t *(*create_iterator) (linked_list_t *this, bool forward);
|
iterator_t *(*create_iterator) (linked_list_t *this, bool forward);
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a iterator, locking a mutex.
|
|
||||||
*
|
|
||||||
* The supplied mutex is acquired immediately, and released
|
|
||||||
* when the iterator gets destroyed.
|
|
||||||
*
|
|
||||||
* @param mutex mutex to use for exclusive access
|
|
||||||
* @return new iterator_t object
|
|
||||||
*/
|
|
||||||
iterator_t *(*create_iterator_locked) (linked_list_t *this,
|
|
||||||
pthread_mutex_t *mutex);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an enumerator over the list.
|
* Create an enumerator over the list.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user