Helper function added to notify the Android frontend about status changes.
This commit is contained in:
parent
024dd37fa0
commit
94ec9adc10
|
@ -71,6 +71,15 @@ typedef enum {
|
|||
VPN_ERROR_CONNECTION_LOST = 103,
|
||||
} android_vpn_errors_t;
|
||||
|
||||
/**
|
||||
* send a status code back to the Android app
|
||||
*/
|
||||
static void send_status(private_android_service_t *this, u_char code)
|
||||
{
|
||||
DBG1(DBG_CFG, "status of Android plugin changed: %d", code);
|
||||
send(this->control, &code, 1, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a string argument from the Android control socket
|
||||
*/
|
||||
|
@ -125,7 +134,9 @@ static job_requeue_t initiate(private_android_service_t *this)
|
|||
strerror(errno));
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
/* the original control socket is not used anymore */
|
||||
close(this->control);
|
||||
this->control = fd;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
|
@ -218,15 +229,13 @@ static job_requeue_t initiate(private_android_service_t *this)
|
|||
charon->bus->add_listener(charon->bus, &this->listener);*/
|
||||
|
||||
/* confirm that we received the request */
|
||||
u_char code = i;
|
||||
send(fd, &code, 1, 0);
|
||||
send_status(this, i);
|
||||
|
||||
if (charon->controller->initiate(charon->controller, peer_cfg, child_cfg,
|
||||
controller_cb_empty, NULL) != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_CFG, "failed to initiate tunnel");
|
||||
code = VPN_ERROR_CONNECTION_FAILED;
|
||||
send(fd, &code, 1, 0);
|
||||
send_status(this, VPN_ERROR_CONNECTION_FAILED);
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
property_set("vpn.status", "ok");
|
||||
|
@ -236,6 +245,7 @@ static job_requeue_t initiate(private_android_service_t *this)
|
|||
METHOD(android_service_t, destroy, void,
|
||||
private_android_service_t *this)
|
||||
{
|
||||
close(this->control);
|
||||
free(this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue