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 __PPP_CLIENT_H__ 26#define __PPP_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_UI_CONTROLLER 0x2 // client is UI controller 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 67 uid_t uid; // user uid at the end of the control api 68 uid_t gid; // user gid at the end of the control api 69 70 u_int8_t *msg; // message in pogress from client 71 u_int32_t msglen; // current message length 72 u_int32_t msgtotallen; // total expected len 73 struct ppp_msg_hdr msghdr; // message header read 74 75 u_int32_t flags; //flags for this structure 76 77 /* 78 event notification 79 events can be for event transition of status change 80 Event/Status are generated for ALL the services or for a unique service 81 Service is the same for both status and events 82 */ 83 u_char *notify_serviceid; // add service id in the notification 84 u_long notify_link; // link ref we want notification (or 0xFFFFFFFF for all links) 85 86 /* option management */ 87 TAILQ_HEAD(, client_opts) opts_head; 88 89}; 90 91 92 93u_long client_init_all (); 94struct client *client_new_socket (CFSocketRef ref, int priviledged, uid_t uid, gid_t gid); 95struct client *client_new_mach (CFMachPortRef port, CFRunLoopSourceRef rls, CFStringRef serviceID, uid_t uid, gid_t gid, mach_port_t bootstrap, mach_port_t notify_port); 96void client_dispose (struct client *client); 97CFMutableDictionaryRef client_newoptset (struct client *client, CFStringRef serviceid); 98CFMutableDictionaryRef client_findoptset (struct client *client, CFStringRef serviceid); 99u_long client_notify (CFStringRef serviceID, u_char* sid, u_int32_t link, u_long state, u_long error, int notification); 100 101struct client *client_findbysocketref(CFSocketRef ref); 102struct client *client_findbymachport(mach_port_t port); 103 104 105#endif 106