1/* 2 * Copyright (c) 2013 Apple Inc. 3 * All rights reserved. 4 */ 5 6#include <errno.h> 7 8#include <xpc/xpc.h> 9#include <uuid/uuid.h> 10 11#include <SystemConfiguration/SystemConfiguration.h> 12#include <SystemConfiguration/SNHelperPrivate.h> 13#include <SystemConfiguration/VPNAppLayerPrivate.h> 14 15#include "snhelper.h" 16#include "flow_divert.h" 17 18void 19handle_flow_divert_uuid_add(xpc_connection_t connection, xpc_object_t message) 20{ 21 int64_t result = 0; 22 const uint8_t *uuid = xpc_dictionary_get_uuid(message, kSNHelperMessageUUID); 23 24 if (uuid != NULL) { 25 result = VPNAppLayerUUIDPolicyAdd(uuid); 26 } else { 27 result = EINVAL; 28 } 29 30 send_reply(connection, message, result, NULL); 31} 32 33void 34handle_flow_divert_uuid_remove(xpc_connection_t connection, xpc_object_t message) 35{ 36 int64_t result = 0; 37 const uint8_t *uuid = xpc_dictionary_get_uuid(message, kSNHelperMessageUUID); 38 39 if (uuid != NULL) { 40 result = VPNAppLayerUUIDPolicyRemove(uuid); 41 } else { 42 result = EINVAL; 43 } 44 45 send_reply(connection, message, result, NULL); 46} 47 48void 49handle_flow_divert_uuid_clear(xpc_connection_t connection, xpc_object_t message) 50{ 51 send_reply(connection, message, VPNAppLayerUUIDPolicyClear(), NULL); 52} 53 54