From: Tobias Brunner Date: Thu, 24 Jun 2010 11:57:03 +0000 (+0200) Subject: Helper function added to notify the Android frontend about status changes. X-Git-Tag: 4.4.1~136 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94ec9adc1088825ff59ef0be772740c1a97d2e0c;p=thirdparty%2Fstrongswan.git Helper function added to notify the Android frontend about status changes. --- diff --git a/src/libcharon/plugins/android/android_service.c b/src/libcharon/plugins/android/android_service.c index d417294c88..6afcc4c3fb 100644 --- a/src/libcharon/plugins/android/android_service.c +++ b/src/libcharon/plugins/android/android_service.c @@ -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); }