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/* ----------------------------------------------------------------------------- 26includes 27----------------------------------------------------------------------------- */ 28#include <string.h> 29#include <stdio.h> 30#include <sys/errno.h> 31#include <sys/signal.h> 32#include <sys/types.h> 33#include <sys/socket.h> 34#include <sys/stat.h> 35#include <sys/un.h> 36#include <unistd.h> 37#include <sys/param.h> 38#include <sys/fcntl.h> 39#include <CoreFoundation/CoreFoundation.h> 40#include <SystemConfiguration/SystemConfiguration.h> 41#ifdef DEBUG 42#include <SystemConfiguration/SCPrivate.h> // for SCLog() 43#endif 44 45#include "ppp_msg.h" 46#include "ppp_privmsg.h" 47#include "ppp_client.h" 48#include "ppp_manager.h" 49#include "ppp_option.h" 50#include "ppp_mach_server.h" 51#include "ppp_socket_server.h" 52 53/* ----------------------------------------------------------------------------- 54definitions 55----------------------------------------------------------------------------- */ 56 57enum { 58 do_nothing = 0, 59 do_process, 60 do_close, 61 do_error 62}; 63 64#define ICON "NetworkConnect.icns" 65 66/* ----------------------------------------------------------------------------- 67forward declarations 68----------------------------------------------------------------------------- */ 69 70 71int initThings(); 72 73 74/* ----------------------------------------------------------------------------- 75globals 76----------------------------------------------------------------------------- */ 77 78CFStringRef gPluginsDir = 0; 79CFBundleRef gBundleRef = 0; 80CFURLRef gBundleURLRef = 0; 81CFStringRef gCancelRef = 0; 82CFStringRef gInternetConnectRef = 0; 83CFURLRef gIconURLRef = 0; 84 85/* ----------------------------------------------------------------------------- 86plugin entry points, called by configd 87----------------------------------------------------------------------------- */ 88void load(CFBundleRef bundle, Boolean debug) 89{ 90 gBundleRef = bundle; 91 92 if (initThings()) 93 return; 94 if (ppp_socket_start_server()) 95 return; 96 if (ppp_mach_start_server()) 97 return; 98 if (client_init_all()) 99 return; 100 101 CFRetain(bundle); 102} 103 104void prime() 105{ 106 ppp_init_all(); 107} 108 109void stop(CFRunLoopSourceRef stopRls) 110{ 111 ppp_stop_all(stopRls); 112} 113 114/* ----------------------------------------------------------------------------- 115----------------------------------------------------------------------------- */ 116int initThings() 117{ 118 CFURLRef urlref, absurlref; 119 120 121 gBundleURLRef = CFBundleCopyBundleURL(gBundleRef); 122 123 // create plugins dir 124 urlref = CFBundleCopyBuiltInPlugInsURL(gBundleRef); 125 if (urlref) { 126 absurlref = CFURLCopyAbsoluteURL(urlref); 127 if (absurlref) { 128 gPluginsDir = CFURLCopyPath(absurlref); 129 CFRelease(absurlref); 130 } 131 CFRelease(urlref); 132 } 133 134 // create misc notification strings 135 gCancelRef = CFBundleCopyLocalizedString(gBundleRef, CFSTR("Cancel"), CFSTR("Cancel"), NULL); 136 gInternetConnectRef = CFBundleCopyLocalizedString(gBundleRef, CFSTR("Internet Connect"), CFSTR("Internet Connect"), NULL); 137 gIconURLRef = CFBundleCopyResourceURL(gBundleRef, CFSTR(ICON), NULL, NULL); 138 return 0; 139} 140