MobileApple80211.c
Go to the documentation of this file.
00001 #include "includes.h"
00002 #include <dlfcn.h>
00003 
00004 #include "common.h"
00005 
00006 #include <CoreFoundation/CoreFoundation.h>
00007 #include "MobileApple80211.h"
00008 
00009 /*
00010  * Code for dynamically loading Apple80211 functions from Aeropuerto to avoid
00011  * having to link with full Preferences.framework.
00012  */
00013 
00014 static void *aeropuerto = NULL;
00015 
00016 
00017 int _Apple80211Initialized(void)
00018 {
00019         return aeropuerto ? 1 : 0;
00020 }
00021 
00022 
00023 static int (*__Apple80211Open)(Apple80211Ref *ctx) = NULL;
00024 
00025 int Apple80211Open(Apple80211Ref *ctx)
00026 {
00027         return __Apple80211Open(ctx);
00028 }
00029 
00030 
00031 static int (*__Apple80211Close)(Apple80211Ref ctx) = NULL;
00032 
00033 int Apple80211Close(Apple80211Ref ctx)
00034 {
00035         return __Apple80211Close(ctx);
00036 }
00037 
00038 
00039 static int (*__Apple80211GetIfListCopy)(Apple80211Ref handle, CFArrayRef *list)
00040         = NULL;
00041 
00042 int Apple80211GetIfListCopy(Apple80211Ref handle, CFArrayRef *list)
00043 {
00044         return __Apple80211GetIfListCopy(handle, list);
00045 }
00046 
00047 
00048 static int (*__Apple80211BindToInterface)(Apple80211Ref handle,
00049                                           CFStringRef interface) = NULL;
00050 
00051 int Apple80211BindToInterface(Apple80211Ref handle,
00052                               CFStringRef interface)
00053 {
00054         return __Apple80211BindToInterface(handle, interface);
00055 }
00056 
00057 
00058 static int (*__Apple80211GetInterfaceNameCopy)(Apple80211Ref handle,
00059                                                CFStringRef *name) = NULL;
00060 
00061 int Apple80211GetInterfaceNameCopy(Apple80211Ref handle,
00062                                    CFStringRef *name)
00063 {
00064         return __Apple80211GetInterfaceNameCopy(handle, name);
00065 }
00066 
00067 
00068 static int (*__Apple80211GetInfoCopy)(Apple80211Ref handle,
00069                                       CFDictionaryRef *info) = NULL;
00070 
00071 int Apple80211GetInfoCopy(Apple80211Ref handle,
00072                           CFDictionaryRef *info)
00073 {
00074         return __Apple80211GetInfoCopy(handle, info);
00075 }
00076 
00077 
00078 static int (*__Apple80211GetPower)(Apple80211Ref handle, char *pwr) = NULL;
00079 
00080 int Apple80211GetPower(Apple80211Ref handle, char *pwr)
00081 {
00082         return __Apple80211GetPower(handle, pwr);
00083 }
00084 
00085 
00086 static int (*__Apple80211SetPower)(Apple80211Ref handle, char pwr) = NULL;
00087 
00088 int Apple80211SetPower(Apple80211Ref handle, char pwr)
00089 {
00090         return __Apple80211SetPower(handle, pwr);
00091 }
00092 
00093 
00094 static int (*__Apple80211Scan)(Apple80211Ref handle, CFArrayRef *list,
00095                                CFDictionaryRef parameters) = NULL;
00096 
00097 int Apple80211Scan(Apple80211Ref handle, CFArrayRef *list,
00098                    CFDictionaryRef parameters)
00099 {
00100         return __Apple80211Scan(handle, list, parameters);
00101 }
00102 
00103 
00104 static int (*__Apple80211Associate)(Apple80211Ref handle, CFDictionaryRef bss,
00105                                     CFStringRef password) = NULL;
00106 
00107 int Apple80211Associate(Apple80211Ref handle, CFDictionaryRef bss,
00108                         CFStringRef password)
00109 {
00110         return __Apple80211Associate(handle, bss, password);
00111 }
00112 
00113 
00114 static int (*__Apple80211AssociateAndCopyInfo)(Apple80211Ref handle,
00115                                                CFDictionaryRef bss,
00116                                                CFStringRef password,
00117                                                CFDictionaryRef *info) =
00118         NULL;
00119 
00120 int Apple80211AssociateAndCopyInfo(Apple80211Ref handle, CFDictionaryRef bss,
00121                                    CFStringRef password, CFDictionaryRef *info)
00122 {
00123         return __Apple80211AssociateAndCopyInfo(handle, bss, password, info);
00124 }
00125 
00126 
00127 static int (*__Apple80211CopyValue)(Apple80211Ref handle, int field,
00128                                     CFDictionaryRef arg2, void *value) = NULL;
00129 
00130 int Apple80211CopyValue(Apple80211Ref handle, int field, CFDictionaryRef arg2,
00131                         void *value)
00132 {
00133         return __Apple80211CopyValue(handle, field, arg2, value);
00134 }
00135 
00136 
00137 #define DLSYM(s) \
00138 do { \
00139         __ ## s = dlsym(aeropuerto, #s); \
00140         if (__ ## s == NULL) { \
00141                 wpa_printf(MSG_ERROR, "MobileApple80211: Could not resolve " \
00142                            "symbol '" #s "' (%s)", dlerror()); \
00143                 err = 1; \
00144         } \
00145 } while (0)
00146 
00147 
00148 __attribute__ ((constructor))
00149 void _Apple80211_constructor(void)
00150 {
00151         const char *fname = "/System/Library/SystemConfiguration/"
00152                 "Aeropuerto.bundle/Aeropuerto";
00153         int err = 0;
00154 
00155         aeropuerto = dlopen(fname, RTLD_LAZY);
00156         if (!aeropuerto) {
00157                 wpa_printf(MSG_ERROR, "MobileApple80211: Failed to open %s "
00158                            "for symbols", fname);
00159                 return;
00160         }
00161 
00162         DLSYM(Apple80211Open);
00163         DLSYM(Apple80211Close);
00164         DLSYM(Apple80211GetIfListCopy);
00165         DLSYM(Apple80211BindToInterface);
00166         DLSYM(Apple80211GetInterfaceNameCopy);
00167         DLSYM(Apple80211GetInfoCopy);
00168         DLSYM(Apple80211GetPower);
00169         DLSYM(Apple80211SetPower);
00170         DLSYM(Apple80211Scan);
00171         DLSYM(Apple80211Associate);
00172         DLSYM(Apple80211AssociateAndCopyInfo);
00173         DLSYM(Apple80211CopyValue);
00174 
00175         if (err) {
00176                 dlclose(aeropuerto);
00177                 aeropuerto = NULL;
00178         }
00179 }
00180 
00181 
00182 __attribute__ ((destructor))
00183 void _Apple80211_destructor(void)
00184 {
00185         if (aeropuerto) {
00186                 dlclose(aeropuerto);
00187                 aeropuerto = NULL;
00188         }
00189 }


wpa_supplicant
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Jan 2 2014 11:26:38