diff options
author | Martin Willi <martin@revosec.ch> | 2013-05-27 14:47:27 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2013-07-18 12:17:56 +0200 |
commit | 06e8712cb359635e99b3a792afad441b649ac5f5 (patch) | |
tree | fb2b4fb6e0faa81bb2933ada7b6ee2a560c7f771 /src/frontends/osx | |
parent | e7ee45ef38e55c39cd635c33125e2e926d6ff3b0 (diff) | |
download | strongswan-06e8712cb359635e99b3a792afad441b649ac5f5.tar.bz2 strongswan-06e8712cb359635e99b3a792afad441b649ac5f5.tar.xz |
xpc: forward some risen alerts over XPC to App
Diffstat (limited to 'src/frontends/osx')
-rw-r--r-- | src/frontends/osx/charon-xpc/xpc_channels.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/frontends/osx/charon-xpc/xpc_channels.c b/src/frontends/osx/charon-xpc/xpc_channels.c index 92a1049fa..9b5260047 100644 --- a/src/frontends/osx/charon-xpc/xpc_channels.c +++ b/src/frontends/osx/charon-xpc/xpc_channels.c @@ -234,6 +234,62 @@ METHOD(xpc_channels_t, add, void, xpc_connection_resume(conn); } +METHOD(listener_t, alert, bool, + private_xpc_channels_t *this, ike_sa_t *ike_sa, alert_t alert, va_list args) +{ + const char *desc; + + switch (alert) + { + case ALERT_LOCAL_AUTH_FAILED: + desc = "local-auth"; + break; + case ALERT_PEER_AUTH_FAILED: + desc = "remote-auth"; + break; + case ALERT_PEER_ADDR_FAILED: + desc = "dns"; + break; + case ALERT_PEER_INIT_UNREACHABLE: + desc = "unreachable"; + break; + case ALERT_RETRANSMIT_SEND_TIMEOUT: + desc = "timeout"; + break; + case ALERT_PROPOSAL_MISMATCH_IKE: + case ALERT_PROPOSAL_MISMATCH_CHILD: + desc = "proposal-mismatch"; + break; + case ALERT_TS_MISMATCH: + desc = "ts-mismatch"; + break; + default: + return TRUE; + } + if (ike_sa) + { + entry_t *entry; + uintptr_t sa; + + sa = ike_sa->get_unique_id(ike_sa); + this->lock->read_lock(this->lock); + entry = this->channels->get(this->channels, (void*)sa); + if (entry) + { + xpc_object_t msg; + + msg = xpc_dictionary_create(NULL, NULL, 0); + xpc_dictionary_set_string(msg, "type", "event"); + xpc_dictionary_set_string(msg, "event", "alert"); + xpc_dictionary_set_string(msg, "alert", desc); + xpc_connection_send_message(entry->conn, msg); + xpc_release(msg); + } + this->lock->unlock(this->lock); + } + return TRUE; +} + METHOD(listener_t, ike_rekey, bool, private_xpc_channels_t *this, ike_sa_t *old, ike_sa_t *new) { @@ -462,6 +518,7 @@ xpc_channels_t *xpc_channels_create() INIT(this, .public = { .listener = { + .alert = _alert, .ike_updown = _ike_updown, .ike_rekey = _ike_rekey, .ike_state_change = _ike_state_change, |