[PATCH] Re: hostapd/wpa_supplicant - new development release v0.4.3
Leonardo Maccari
maccari-thisaintpartofmyaddress-
Fri Jul 8 08:02:48 PDT 2005
On Fri, Jul 01, 2005 at 06:39:29PM +0200, Leonardo Maccari wrote:
> On Wed, Jun 29, 2005 at 06:54:27PM -0700, Jouni Malinen wrote:
I've cleaned things up. now wpa_supplicant.c defines two interfaces
(wpa_sm_i and preauth_i) made of pointers to functions needed by wpa.c
and preauth.c. From those two files the interface is loaded as an extern
variable (as you do for drivers), the structures of the interface are
defined in wpa_i.h. This way wpa.c and preauth.c don't need to load
wpa_supplicant_s.h file. The file still exists becouse ctrl_interface.c
and events.c still need it. I thought it was kind of pointless to do the
same for those files since they are part of wpa_supplicant mechanism and
not something to be exported.
I also moved wpa_state definition to wpa.h and added two functions to
fille the structures .
I've compiled it and run it, even if I didn't test preauth code.
you may not like the globals in wpa_supplicant.c but I had no better idea.
holidays compatible feedback? :)
ciao,
leonardo.
--
Key fingerprint = 3129 C583 F03B 2E73 0115 C040 3489 0185 B592 19FE
Obviously -thisaintpartofmyaddress- is not part of my real email address
-------------- next part --------------
Common subdirectories: wpa_supplicant-0.4.3/doc and wpa_supplicant-0.4.3-dev/doc
diff -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/preauth.c wpa_supplicant-0.4.3-dev/preauth.c
33d32
< #include "wpa_supplicant_s.h"
40a40
> extern struct preauth_interface preauth_i;
93,94c93,94
< wpa_supplicant_deauthenticate(sm->ctx, REASON_UNSPECIFIED);
< wpa_supplicant_req_scan(sm->ctx, 0, 0);
---
> preauth_i.deauthenticate(sm->ctx, REASON_UNSPECIFIED);
> preauth_i.req_scan(sm->ctx, 0, 0);
223c223
< wpa_supplicant_remove_pmkid(sm->ctx, pos->aa, pos->pmkid);
---
> preauth_i.remove_pmkid(sm->ctx, pos->aa, pos->pmkid);
247c247
< wpa_supplicant_add_pmkid(sm->ctx, entry->aa, entry->pmkid);
---
> preauth_i.add_pmkid(sm->ctx, entry->aa, entry->pmkid);
570c570
< msg = wpa_alloc_eapol(sm->ctx, sm->preauth_bssid, ETH_P_RSN_PREAUTH,
---
> msg = preauth_i.alloc_eapol(sm->ctx, sm->preauth_bssid, ETH_P_RSN_PREAUTH,
707c707
< wpa_supplicant_get_state(sm->ctx) != WPA_COMPLETED ||
---
> preauth_i.get_state(sm->ctx) != WPA_COMPLETED ||
734c734
< wpa_supplicant_add_pmkid(sm->ctx, candidate->bssid,
---
> preauth_i.add_pmkid(sm->ctx, candidate->bssid,
diff -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa.c wpa_supplicant-0.4.3-dev/wpa.c
34d33
< #include "wpa_supplicant_s.h"
38a38,39
> extern struct wpa_sm_interface wpa_sm_i;
>
744c745
< wpa_ether_send(sm->ctx, msg, msg_len);
---
> wpa_sm_i.ether_send(sm->ctx, msg, msg_len);
773c774
< if (wpa_supplicant_get_bssid(sm->ctx, bssid) < 0) {
---
> if (wpa_sm_i.get_bssid(sm->ctx, bssid) < 0) {
779c780
< rbuf = wpa_alloc_eapol(sm->ctx, bssid, ETH_P_EAPOL,
---
> rbuf = wpa_sm_i.alloc_eapol(sm->ctx, bssid, ETH_P_EAPOL,
980c981
< buf = wpa_alloc_eapol(sm->ctx, sm->bssid, ETH_P_EAPOL,
---
> buf = wpa_sm_i.alloc_eapol(sm->ctx, sm->bssid, ETH_P_EAPOL,
984c985
< wpa_ether_send(sm->ctx, buf, buflen);
---
> wpa_sm_i.ether_send(sm->ctx, buf, buflen);
1016c1017
< rbuf = wpa_alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
---
> rbuf = wpa_sm_i.alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
1076c1077
< if (wpa_supplicant_get_ssid(sm->ctx) == NULL) {
---
> if (wpa_sm_i.get_ssid(sm->ctx) == NULL) {
1082c1083
< wpa_supplicant_set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
---
> wpa_sm_i.set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
1124,1126c1125,1127
< eloop_cancel_timeout(wpa_supplicant_scan, sm->ctx, NULL);
< wpa_supplicant_cancel_auth_timeout(sm->ctx);
< wpa_supplicant_set_state(sm->ctx, WPA_COMPLETED);
---
> eloop_cancel_timeout(wpa_sm_i.scan, sm->ctx, NULL);
> wpa_sm_i.cancel_auth_timeout(sm->ctx);
> wpa_sm_i.set_state(sm->ctx, WPA_COMPLETED);
1189c1190
< if (wpa_supplicant_set_key(sm->ctx, alg, src_addr, 0, 1, key_rsc,
---
> if (wpa_sm_i.set_key(sm->ctx, alg, src_addr, 0, 1, key_rsc,
1280c1281
< if (wpa_supplicant_set_key(sm->ctx, gd->alg,
---
> if (wpa_sm_i.set_key(sm->ctx, gd->alg,
1289c1290
< } else if (wpa_supplicant_set_key(sm->ctx, gd->alg,
---
> } else if (wpa_sm_i.set_key(sm->ctx, gd->alg,
1400,1401c1401,1402
< wpa_supplicant_disassociate(sm->ctx, REASON_IE_IN_4WAY_DIFFERS);
< wpa_supplicant_req_scan(sm->ctx, 0, 0);
---
> wpa_sm_i.disassociate(sm->ctx, REASON_IE_IN_4WAY_DIFFERS);
> wpa_sm_i.req_scan(sm->ctx, 0, 0);
1414c1415
< if (wpa_supplicant_get_beacon_ie(sm->ctx) < 0) {
---
> if (wpa_sm_i.get_beacon_ie(sm->ctx) < 0) {
1461c1462
< rbuf = wpa_alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
---
> rbuf = wpa_sm_i.alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
1498c1499
< wpa_supplicant_set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
---
> wpa_sm_i.set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
1559c1560
< wpa_supplicant_set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
---
> wpa_sm_i.set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
1677c1678
< rbuf = wpa_alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
---
> rbuf = wpa_sm_i.alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
1716,1717c1717,1718
< rekey = wpa_supplicant_get_state(sm->ctx) == WPA_COMPLETED;
< wpa_supplicant_set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
---
> rekey = wpa_sm_i.get_state(sm->ctx) == WPA_COMPLETED;
> wpa_sm_i.set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
1745c1746
< wpa_supplicant_set_state(sm->ctx, WPA_COMPLETED);
---
> wpa_sm_i.set_state(sm->ctx, WPA_COMPLETED);
2232c2233
< if (wpa_supplicant_get_state(sm->ctx) == WPA_4WAY_HANDSHAKE)
---
> if (wpa_sm_i.get_state(sm->ctx) == WPA_4WAY_HANDSHAKE)
Common subdirectories: wpa_supplicant-0.4.3/wpa_gui and wpa_supplicant-0.4.3-dev/wpa_gui
diff -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa.h wpa_supplicant-0.4.3-dev/wpa.h
191a192,198
> typedef enum {
> WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
> WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
> WPA_COMPLETED
> } wpa_states;
>
>
diff -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa_i.h wpa_supplicant-0.4.3-dev/wpa_i.h
104a105,146
>
> struct preauth_interface {
>
> wpa_states (*get_state)(void * ctx);
> void (*deauthenticate)(void * ctx, int reason_code);
> void (*req_scan)(void * ctx, int sec, int usec);
>
> u8 * (*alloc_eapol)(void * ctx, const u8 *dest,
> u16 proto, u8 type, const void *data, u16 data_len,
> size_t *msg_len, void **data_pos);
>
> int (*add_pmkid)(void * ctx, const u8 *bssid, const u8
> *pmkid);
> int (*remove_pmkid)(void * ctx, const u8 *bssid, const
> u8 *pmkid);
> };
>
>
> struct wpa_sm_interface {
> void (*set_state)(void *ctx, wpa_states state);
> wpa_states (*get_state)(void *ctx);
> void (*req_scan)(void *ctx , int sec, int usec);
> void (*disassociate)(void *ctx,
> int reason_code);
> int (*set_key)(void *ctx, wpa_alg alg,
> const u8 *addr, int key_idx, int set_tx,
> const u8 *seq, size_t seq_len,
> const u8 *key, size_t key_len);
> void (*scan)(void *eloop_ctx, void *timeout_ctx);
> struct wpa_ssid * (*get_ssid)(void *ctx);
> int (*get_bssid)(void *ctx, u8 *bssid);
> int (*ether_send)(void *ctx, u8 *buf, size_t len);
> int (*get_beacon_ie)(void *ctx);
> void (*cancel_auth_timeout)(void *ctx);
> u8 * (*alloc_eapol)(void * ctx, const u8 *dest,
> u16 proto, u8 type, const void *data, u16 data_len,
> size_t *msg_len, void **data_pos); /*preauth.c*/
>
>
> };
>
>
diff -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa_supplicant.c wpa_supplicant-0.4.3-dev/wpa_supplicant.c
109a110,119
> void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
> void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
>
> struct preauth_interface;
> struct wpa_sm_interface;
>
> struct preauth_interface preauth_i;
> struct wpa_sm_interface wpa_sm_i;
>
>
1614a1625,1691
> struct wpa_sm_interface {
> void (*set_state)(struct wpa_supplicant *wpa_s, wpa_states state);
> wpa_states (*get_state)(struct wpa_supplicant *wpa_s);
> void (*req_scan)(struct wpa_supplicant *wpa_s, int sec, int usec);
> void (*disassociate)(struct wpa_supplicant *wpa_s,
> int reason_code);
> int (*set_key)(struct wpa_supplicant *wpa_s, wpa_alg alg,
> const u8 *addr, int key_idx, int set_tx,
> const u8 *seq, size_t seq_len,
> const u8 *key, size_t key_len);
> void (*scan)(void *eloop_ctx, void *timeout_ctx);
> struct wpa_ssid * (*get_ssid)(struct wpa_supplicant *wpa_s);
> int (*get_bssid)(struct wpa_supplicant *wpa_s, u8 *bssid);
> int (*ether_send)(struct wpa_supplicant *wpa_s, u8 *buf, size_t len);
> int (*get_beacon_ie)(struct wpa_supplicant *wpa_s);
> void (*cancel_auth_timeout)(struct wpa_supplicant *wpa_s);
> u8 * (*alloc_eapol)(const struct wpa_supplicant *wpa_s, const u8 *dest,
> u16 proto, u8 type, const void *data, u16 data_len,
> size_t *msg_len, void **data_pos);
> };
>
>
> struct preauth_interface {
>
> wpa_states (*get_state)(struct wpa_supplicant *wpa_s);
> void (*deauthenticate)(struct wpa_supplicant *wpa_s, int reason_code);
> void (*req_scan)(struct wpa_supplicant *wpa_s, int sec, int usec);
>
> u8 * (*alloc_eapol)(const struct wpa_supplicant *wpa_s, const u8 *dest,
> u16 proto, u8 type, const void *data, u16 data_len,
> size_t *msg_len, void **data_pos);
>
> int (*add_pmkid)(struct wpa_supplicant *wpa_s, const u8 *bssid, const u8
> *pmkid);
> int (*remove_pmkid)(struct wpa_supplicant *wpa_s, const u8 *bssid, const
> u8 *pmkid);
> };
>
>
> void export_wpa_interface(void){
>
> wpa_sm_i.set_state = wpa_supplicant_set_state;
> wpa_sm_i.get_state = wpa_supplicant_get_state;
> wpa_sm_i.req_scan = wpa_supplicant_req_scan;
> wpa_sm_i.disassociate = wpa_supplicant_disassociate;
> wpa_sm_i.set_key = wpa_supplicant_set_key;
> wpa_sm_i.scan = wpa_supplicant_scan;
> wpa_sm_i.get_ssid = wpa_supplicant_get_ssid;
> wpa_sm_i.ether_send = wpa_ether_send;
> wpa_sm_i.get_beacon_ie = wpa_supplicant_get_beacon_ie;
> wpa_sm_i.alloc_eapol = wpa_alloc_eapol;
> wpa_sm_i.cancel_auth_timeout = wpa_supplicant_cancel_auth_timeout;
> }
>
> void export_preauth_interface(void){
>
> preauth_i.get_state = wpa_supplicant_get_state;
> preauth_i.deauthenticate = wpa_supplicant_deauthenticate;
> preauth_i.req_scan = wpa_supplicant_req_scan;
> preauth_i.alloc_eapol = wpa_alloc_eapol;
> preauth_i.add_pmkid = wpa_supplicant_add_pmkid;
> preauth_i.remove_pmkid = wpa_supplicant_remove_pmkid;
> }
>
>
>
>
1673a1751,1754
> export_wpa_interface();
> export_preauth_interface();
>
>
1898,1899d1978
<
<
1921d1999
<
diff -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa_supplicant_s.h wpa_supplicant-0.4.3-dev/wpa_supplicant_s.h
23,27c23
< typedef enum {
< WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
< WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
< WPA_COMPLETED
< } wpa_states;
---
> void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state); /* needed by events.c*/
29,30d24
< void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
< wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s);
31a26,27
> struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s); /* needed by events.c*/
> void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s); /* needed by events.c*/
33,36c29,30
< u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, const u8 *dest,
< u16 proto, u8 type, const void *data, u16 data_len,
< size_t *msg_len, void **data_pos);
< int wpa_ether_send(struct wpa_supplicant *wpa_s, u8 *buf, size_t len);
---
> void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
> int reason_code);/*needed by events.c preauth.c*/
38,45d31
< int wpa_supplicant_get_beacon_ie(struct wpa_supplicant *wpa_s);
<
< struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
<
< void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
<
< void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
< int reason_code);
47,51c33
< int reason_code);
<
< void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
<
< void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
---
> int reason_code);/*needed by ctrl_iface.c events.c*/
53,61c35
< int wpa_supplicant_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid);
< int wpa_supplicant_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
< const u8 *addr, int key_idx, int set_tx,
< const u8 *seq, size_t seq_len,
< const u8 *key, size_t key_len);
< int wpa_supplicant_add_pmkid(struct wpa_supplicant *wpa_s,
< const u8 *bssid, const u8 *pmkid);
< int wpa_supplicant_remove_pmkid(struct wpa_supplicant *wpa_s,
< const u8 *bssid, const u8 *pmkid);
---
> void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);/*needed by ctrl_iface.c events.c preauth.c*/
More information about the Hostap
mailing list