Added WirelessManager, a port of wpa_supplicant.
[AROS.git] / workbench / network / WirelessManager / src / drivers / MobileApple80211.c
blobce004fe4c96f585ef84896fbc27dbccac614a636
1 #include "includes.h"
2 #include <dlfcn.h>
4 #include "common.h"
6 #include <CoreFoundation/CoreFoundation.h>
7 #include "MobileApple80211.h"
9 /*
10 * Code for dynamically loading Apple80211 functions from Aeropuerto to avoid
11 * having to link with full Preferences.framework.
14 static void *aeropuerto = NULL;
17 int _Apple80211Initialized(void)
19 return aeropuerto ? 1 : 0;
23 static int (*__Apple80211Open)(Apple80211Ref *ctx) = NULL;
25 int Apple80211Open(Apple80211Ref *ctx)
27 return __Apple80211Open(ctx);
31 static int (*__Apple80211Close)(Apple80211Ref ctx) = NULL;
33 int Apple80211Close(Apple80211Ref ctx)
35 return __Apple80211Close(ctx);
39 static int (*__Apple80211GetIfListCopy)(Apple80211Ref handle, CFArrayRef *list)
40 = NULL;
42 int Apple80211GetIfListCopy(Apple80211Ref handle, CFArrayRef *list)
44 return __Apple80211GetIfListCopy(handle, list);
48 static int (*__Apple80211BindToInterface)(Apple80211Ref handle,
49 CFStringRef interface) = NULL;
51 int Apple80211BindToInterface(Apple80211Ref handle,
52 CFStringRef interface)
54 return __Apple80211BindToInterface(handle, interface);
58 static int (*__Apple80211GetInterfaceNameCopy)(Apple80211Ref handle,
59 CFStringRef *name) = NULL;
61 int Apple80211GetInterfaceNameCopy(Apple80211Ref handle,
62 CFStringRef *name)
64 return __Apple80211GetInterfaceNameCopy(handle, name);
68 static int (*__Apple80211GetInfoCopy)(Apple80211Ref handle,
69 CFDictionaryRef *info) = NULL;
71 int Apple80211GetInfoCopy(Apple80211Ref handle,
72 CFDictionaryRef *info)
74 return __Apple80211GetInfoCopy(handle, info);
78 static int (*__Apple80211GetPower)(Apple80211Ref handle, char *pwr) = NULL;
80 int Apple80211GetPower(Apple80211Ref handle, char *pwr)
82 return __Apple80211GetPower(handle, pwr);
86 static int (*__Apple80211SetPower)(Apple80211Ref handle, char pwr) = NULL;
88 int Apple80211SetPower(Apple80211Ref handle, char pwr)
90 return __Apple80211SetPower(handle, pwr);
94 static int (*__Apple80211Scan)(Apple80211Ref handle, CFArrayRef *list,
95 CFDictionaryRef parameters) = NULL;
97 int Apple80211Scan(Apple80211Ref handle, CFArrayRef *list,
98 CFDictionaryRef parameters)
100 return __Apple80211Scan(handle, list, parameters);
104 static int (*__Apple80211Associate)(Apple80211Ref handle, CFDictionaryRef bss,
105 CFStringRef password) = NULL;
107 int Apple80211Associate(Apple80211Ref handle, CFDictionaryRef bss,
108 CFStringRef password)
110 return __Apple80211Associate(handle, bss, password);
114 static int (*__Apple80211AssociateAndCopyInfo)(Apple80211Ref handle,
115 CFDictionaryRef bss,
116 CFStringRef password,
117 CFDictionaryRef *info) =
118 NULL;
120 int Apple80211AssociateAndCopyInfo(Apple80211Ref handle, CFDictionaryRef bss,
121 CFStringRef password, CFDictionaryRef *info)
123 return __Apple80211AssociateAndCopyInfo(handle, bss, password, info);
127 static int (*__Apple80211CopyValue)(Apple80211Ref handle, int field,
128 CFDictionaryRef arg2, void *value) = NULL;
130 int Apple80211CopyValue(Apple80211Ref handle, int field, CFDictionaryRef arg2,
131 void *value)
133 return __Apple80211CopyValue(handle, field, arg2, value);
137 #define DLSYM(s) \
138 do { \
139 __ ## s = dlsym(aeropuerto, #s); \
140 if (__ ## s == NULL) { \
141 wpa_printf(MSG_ERROR, "MobileApple80211: Could not resolve " \
142 "symbol '" #s "' (%s)", dlerror()); \
143 err = 1; \
145 } while (0)
148 __attribute__ ((constructor))
149 void _Apple80211_constructor(void)
151 const char *fname = "/System/Library/SystemConfiguration/"
152 "Aeropuerto.bundle/Aeropuerto";
153 int err = 0;
155 aeropuerto = dlopen(fname, RTLD_LAZY);
156 if (!aeropuerto) {
157 wpa_printf(MSG_ERROR, "MobileApple80211: Failed to open %s "
158 "for symbols", fname);
159 return;
162 DLSYM(Apple80211Open);
163 DLSYM(Apple80211Close);
164 DLSYM(Apple80211GetIfListCopy);
165 DLSYM(Apple80211BindToInterface);
166 DLSYM(Apple80211GetInterfaceNameCopy);
167 DLSYM(Apple80211GetInfoCopy);
168 DLSYM(Apple80211GetPower);
169 DLSYM(Apple80211SetPower);
170 DLSYM(Apple80211Scan);
171 DLSYM(Apple80211Associate);
172 DLSYM(Apple80211AssociateAndCopyInfo);
173 DLSYM(Apple80211CopyValue);
175 if (err) {
176 dlclose(aeropuerto);
177 aeropuerto = NULL;
182 __attribute__ ((destructor))
183 void _Apple80211_destructor(void)
185 if (aeropuerto) {
186 dlclose(aeropuerto);
187 aeropuerto = NULL;