aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-06-24 13:57:03 +0200
committerTobias Brunner <tobias@strongswan.org>2010-06-24 14:30:05 +0200
commit94ec9adc1088825ff59ef0be772740c1a97d2e0c (patch)
tree3cd5bfb378916e24fbf3098368a2f8258419ee39 /src/libcharon/plugins
parent024dd37fa0eff64df74bc0b51c494e71b3c7acff (diff)
downloadstrongswan-94ec9adc1088825ff59ef0be772740c1a97d2e0c.tar.bz2
strongswan-94ec9adc1088825ff59ef0be772740c1a97d2e0c.tar.xz
Helper function added to notify the Android frontend about status changes.
Diffstat (limited to 'src/libcharon/plugins')
-rw-r--r--src/libcharon/plugins/android/android_service.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libcharon/plugins/android/android_service.c b/src/libcharon/plugins/android/android_service.c
index d417294c8..6afcc4c3f 100644
--- a/src/libcharon/plugins/android/android_service.c
+++ b/src/libcharon/plugins/android/android_service.c
@@ -72,6 +72,15 @@ typedef enum {
} 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
*/
static char *read_argument(int fd, u_char length)
@@ -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);
}