summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/farp/farp_spoofer.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:27 +0200
committerYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:27 +0200
commitc7307e752d8f47c68f834e22ee2ce0a14a70e695 (patch)
treefbb442a20ab54aad511b46a070e65b8d09c22791 /src/libcharon/plugins/farp/farp_spoofer.c
parentf74c6d77c3efb529e7403eeef0613c061eb895b3 (diff)
parent6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (diff)
downloadvyos-strongswan-c7307e752d8f47c68f834e22ee2ce0a14a70e695.tar.gz
vyos-strongswan-c7307e752d8f47c68f834e22ee2ce0a14a70e695.zip
Merge tag 'upstream/5.1.0'
Upstream version 5.1.0
Diffstat (limited to 'src/libcharon/plugins/farp/farp_spoofer.c')
-rw-r--r--src/libcharon/plugins/farp/farp_spoofer.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/libcharon/plugins/farp/farp_spoofer.c b/src/libcharon/plugins/farp/farp_spoofer.c
index 52b037c19..9f66d7407 100644
--- a/src/libcharon/plugins/farp/farp_spoofer.c
+++ b/src/libcharon/plugins/farp/farp_spoofer.c
@@ -96,20 +96,16 @@ static void send_arp(private_farp_spoofer_t *this,
/**
* ARP request receiving
*/
-static job_requeue_t receive_arp(private_farp_spoofer_t *this)
+static bool receive_arp(private_farp_spoofer_t *this)
{
struct sockaddr_ll addr;
socklen_t addr_len = sizeof(addr);
arp_t arp;
- int oldstate;
ssize_t len;
host_t *local, *remote;
- oldstate = thread_cancelability(TRUE);
- len = recvfrom(this->skt, &arp, sizeof(arp), 0,
+ len = recvfrom(this->skt, &arp, sizeof(arp), MSG_DONTWAIT,
(struct sockaddr*)&addr, &addr_len);
- thread_cancelability(oldstate);
-
if (len == sizeof(arp))
{
local = host_create_from_chunk(AF_INET,
@@ -124,12 +120,13 @@ static job_requeue_t receive_arp(private_farp_spoofer_t *this)
remote->destroy(remote);
}
- return JOB_REQUEUE_DIRECT;
+ return TRUE;
}
METHOD(farp_spoofer_t, destroy, void,
private_farp_spoofer_t *this)
{
+ lib->watcher->remove(lib->watcher, this->skt);
close(this->skt);
free(this);
}
@@ -183,10 +180,8 @@ farp_spoofer_t *farp_spoofer_create(farp_listener_t *listener)
return NULL;
}
- lib->processor->queue_job(lib->processor,
- (job_t*)callback_job_create_with_prio((callback_job_cb_t)receive_arp,
- this, NULL, (callback_job_cancel_t)return_false, JOB_PRIO_CRITICAL));
+ lib->watcher->add(lib->watcher, this->skt, WATCHER_READ,
+ (watcher_cb_t)receive_arp, this);
return &this->public;
}
-