From d5966e71e9915191b93b27bbc5f320e9305f05b2 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 2 May 2013 10:54:55 +0200 Subject: [PATCH] xpc: use the same XPC message "type" mechanism on Mach service as on channels --- src/frontends/osx/charon-xpc/xpc_dispatch.c | 43 +++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/frontends/osx/charon-xpc/xpc_dispatch.c b/src/frontends/osx/charon-xpc/xpc_dispatch.c index 56d7850f6..f99ad6775 100644 --- a/src/frontends/osx/charon-xpc/xpc_dispatch.c +++ b/src/frontends/osx/charon-xpc/xpc_dispatch.c @@ -195,7 +195,7 @@ xpc_object_t start_connection(private_xpc_dispatch_t *this, } /** - * XPC command dispatch table + * XPC RPC command dispatch table */ static struct { char *name; @@ -213,26 +213,47 @@ static void handle(private_xpc_dispatch_t *this, xpc_object_t request) { xpc_connection_t client; xpc_object_t reply; - const char *command; + const char *type, *rpc; + bool found = FALSE; int i; client = xpc_dictionary_get_remote_connection(request); - command = xpc_dictionary_get_string(request, "command"); - if (command) + type = xpc_dictionary_get_string(request, "type"); + if (type) { - for (i = 0; i < countof(commands); i++) + if (streq(type, "rpc")) { - if (streq(commands[i].name, command)) + rpc = xpc_dictionary_get_string(request, "rpc"); + if (rpc) { - reply = commands[i].handler(this, request, client); - if (reply) + for (i = 0; i < countof(commands); i++) { - xpc_connection_send_message(client, reply); - xpc_release(reply); + if (streq(commands[i].name, rpc)) + { + found = TRUE; + reply = commands[i].handler(this, request, client); + if (reply) + { + xpc_connection_send_message(client, reply); + xpc_release(reply); + } + break; + } } - break; + } + if (!found) + { + DBG1(DBG_CFG, "received unknown XPC rpc command: %s", rpc); } } + else + { + DBG1(DBG_CFG, "received unknown XPC message type: %s", type); + } + } + else + { + DBG1(DBG_CFG, "received XPC message without a type"); } }