1/* 2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24 25#ifndef __SCNC_CLIENT_H__ 26#define __SCNC_CLIENT_H__ 27 28#include "ppp_msg.h" 29 30#include <sys/queue.h> 31 32#define MAXDATASIZE 2048 33 34struct msg { 35 struct ppp_msg_hdr hdr; 36 unsigned char data[MAXDATASIZE]; 37}; 38 39 40struct client_opts { 41 TAILQ_ENTRY(client_opts) next; 42 CFStringRef serviceid; // service for which options apply 43 CFMutableDictionaryRef opts; // options to apply 44}; 45 46#define CLIENT_FLAG_PRIVILEDGED 0x1 // client can send priviledged commands 47#define CLIENT_FLAG_IPC_READY 0x2 // client is IPC ready VPN configuration app 48#define CLIENT_FLAG_NOTIFY_EVENT 0x4 // client wants notifications for events 49#define CLIENT_FLAG_NOTIFY_STATUS 0x8 // client wants notifications for status 50#define CLIENT_FLAG_IS_SOCKET 0x10 // client uses socket API (instead of Mach) 51#define CLIENT_FLAG_SWAP_BYTES 0x20 // client requires bytes swapping (not in network order) 52 53struct client { 54 55 TAILQ_ENTRY(client) next; 56 57 /* socket API */ 58 CFSocketRef socketRef; // socket we talk with 59 60 /* Mach API */ 61 CFMachPortRef sessionPortRef; // session mach port ref 62 mach_port_t notify_port; // session mach port ref 63 CFRunLoopSourceRef sessionRls; // session mach port ref 64 CFStringRef serviceID; // service used by the client 65 mach_port_t bootstrap_port; // bootstrap port use by client 66 mach_port_name_t au_session; // audit session port 67 68 uid_t uid; // user uid at the end of the control api 69 uid_t gid; // user gid at the end of the control api 70 pid_t pid; // pid of user app 71 72 u_int8_t *msg; // message in pogress from client 73 u_int32_t msglen; // current message length 74 u_int32_t msgtotallen; // total expected len 75 struct ppp_msg_hdr msghdr; // message header read 76 77 u_int32_t flags; //flags for this structure 78 79 /* 80 event notification 81 events can be for event transition of status change 82 Event/Status are generated for ALL the services or for a unique service 83 Service is the same for both status and events 84 */ 85 u_char *notify_serviceid; // add service id in the notification 86 u_int32_t notify_link; // link ref we want notification (or 0xFFFFFFFF for all links) 87 88 Boolean has_machport_priv; // sandbox mach port privelege 89 /* option management */ 90 TAILQ_HEAD(, client_opts) opts_head; 91 92}; 93 94 95 96u_long client_init_all (); 97struct client *client_new_socket (CFSocketRef ref, int priviledged, uid_t uid, gid_t gid); 98struct client *client_new_mach (CFMachPortRef port, CFRunLoopSourceRef rls, CFStringRef serviceID, uid_t uid, gid_t gid, pid_t pid, mach_port_t bootstrap, mach_port_t notify_port, mach_port_t au_session, Boolean has_machport_priv); 99void client_dispose (struct client *client); 100CFMutableDictionaryRef client_newoptset (struct client *client, CFStringRef serviceid); 101CFMutableDictionaryRef client_findoptset (struct client *client, CFStringRef serviceid); 102u_long client_notify (CFStringRef serviceID, u_char* sid, u_int32_t link, u_long state, u_long error, int notification, SCNetworkConnectionStatus status); 103 104 105struct client *client_findbysocketref(CFSocketRef ref); 106struct client *client_findbymachport(mach_port_t port); 107 108 109#endif 110