6 #include <CoreFoundation/CoreFoundation.h>
7 #include "MobileApple80211.h"
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
)
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
,
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
,
116 CFStringRef password
,
117 CFDictionaryRef
*info
) =
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
,
133 return __Apple80211CopyValue(handle
, field
, arg2
, value
);
139 __ ## s = dlsym(aeropuerto, #s); \
140 if (__ ## s == NULL) { \
141 wpa_printf(MSG_ERROR, "MobileApple80211: Could not resolve " \
142 "symbol '" #s "' (%s)", dlerror()); \
148 __attribute__ ((constructor
))
149 void _Apple80211_constructor(void)
151 const char *fname
= "/System/Library/SystemConfiguration/"
152 "Aeropuerto.bundle/Aeropuerto";
155 aeropuerto
= dlopen(fname
, RTLD_LAZY
);
157 wpa_printf(MSG_ERROR
, "MobileApple80211: Failed to open %s "
158 "for symbols", fname
);
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
);
182 __attribute__ ((destructor
))
183 void _Apple80211_destructor(void)