Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46900298 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

mac80211: split IBSS/managed code



This patch splits out the ibss code and data from managed (station) mode.
The reason to do this is to better separate the state machines, and have
the code be contained better so it gets easier to determine what exactly
a given change will affect, that in turn makes it easier to understand.

This is quite some churn, especially because I split sdata->u.sta into
sdata->u.mgd and sdata->u.ibss, but I think it's easier to maintain that
way. I've also shuffled around some code -- null function sending is only
applicable to managed interfaces so put that into that file, some other
functions are needed from various places so put them into util, and also
rearranged the prototypes in ieee80211_i.h accordingly.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 96f5e66e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ mac80211-y := \
	wpa.o \
	scan.o \
	ht.o agg-tx.o agg-rx.o \
	ibss.o \
	mlme.o \
	iface.o \
	rate.o \
+3 −3
Original line number Diff line number Diff line
@@ -129,7 +129,6 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d
				      u8 dialog_token, u16 status, u16 policy,
				      u16 buf_size, u16 timeout)
{
	struct ieee80211_if_sta *ifsta = &sdata->u.sta;
	struct ieee80211_local *local = sdata->local;
	struct sk_buff *skb;
	struct ieee80211_mgmt *mgmt;
@@ -151,8 +150,9 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d
	if (sdata->vif.type == NL80211_IFTYPE_AP ||
	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
		memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
	else
		memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
	else if (sdata->vif.type == NL80211_IFTYPE_STATION)
		memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);

	mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
					  IEEE80211_STYPE_ACTION);

+2 −3
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
					 u16 agg_size, u16 timeout)
{
	struct ieee80211_local *local = sdata->local;
	struct ieee80211_if_sta *ifsta = &sdata->u.sta;
	struct sk_buff *skb;
	struct ieee80211_mgmt *mgmt;
	u16 capab;
@@ -69,8 +68,8 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
	if (sdata->vif.type == NL80211_IFTYPE_AP ||
	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
		memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
	else
		memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
	else if (sdata->vif.type == NL80211_IFTYPE_STATION)
		memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);

	mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
					  IEEE80211_STYPE_ACTION);
+22 −23
Original line number Diff line number Diff line
@@ -1180,45 +1180,45 @@ static int set_mgmt_extra_ie_sta(struct ieee80211_sub_if_data *sdata,
				 u8 subtype, u8 *ies, size_t ies_len)
{
	struct ieee80211_local *local = sdata->local;
	struct ieee80211_if_sta *ifsta = &sdata->u.sta;
	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;

	switch (subtype) {
	case IEEE80211_STYPE_PROBE_REQ >> 4:
		if (local->ops->hw_scan)
			break;
		kfree(ifsta->ie_probereq);
		ifsta->ie_probereq = ies;
		ifsta->ie_probereq_len = ies_len;
		kfree(ifmgd->ie_probereq);
		ifmgd->ie_probereq = ies;
		ifmgd->ie_probereq_len = ies_len;
		return 0;
	case IEEE80211_STYPE_PROBE_RESP >> 4:
		kfree(ifsta->ie_proberesp);
		ifsta->ie_proberesp = ies;
		ifsta->ie_proberesp_len = ies_len;
		kfree(ifmgd->ie_proberesp);
		ifmgd->ie_proberesp = ies;
		ifmgd->ie_proberesp_len = ies_len;
		return 0;
	case IEEE80211_STYPE_AUTH >> 4:
		kfree(ifsta->ie_auth);
		ifsta->ie_auth = ies;
		ifsta->ie_auth_len = ies_len;
		kfree(ifmgd->ie_auth);
		ifmgd->ie_auth = ies;
		ifmgd->ie_auth_len = ies_len;
		return 0;
	case IEEE80211_STYPE_ASSOC_REQ >> 4:
		kfree(ifsta->ie_assocreq);
		ifsta->ie_assocreq = ies;
		ifsta->ie_assocreq_len = ies_len;
		kfree(ifmgd->ie_assocreq);
		ifmgd->ie_assocreq = ies;
		ifmgd->ie_assocreq_len = ies_len;
		return 0;
	case IEEE80211_STYPE_REASSOC_REQ >> 4:
		kfree(ifsta->ie_reassocreq);
		ifsta->ie_reassocreq = ies;
		ifsta->ie_reassocreq_len = ies_len;
		kfree(ifmgd->ie_reassocreq);
		ifmgd->ie_reassocreq = ies;
		ifmgd->ie_reassocreq_len = ies_len;
		return 0;
	case IEEE80211_STYPE_DEAUTH >> 4:
		kfree(ifsta->ie_deauth);
		ifsta->ie_deauth = ies;
		ifsta->ie_deauth_len = ies_len;
		kfree(ifmgd->ie_deauth);
		ifmgd->ie_deauth = ies;
		ifmgd->ie_deauth_len = ies_len;
		return 0;
	case IEEE80211_STYPE_DISASSOC >> 4:
		kfree(ifsta->ie_disassoc);
		ifsta->ie_disassoc = ies;
		ifsta->ie_disassoc_len = ies_len;
		kfree(ifmgd->ie_disassoc);
		ifmgd->ie_disassoc = ies;
		ifmgd->ie_disassoc_len = ies_len;
		return 0;
	}

@@ -1248,7 +1248,6 @@ static int ieee80211_set_mgmt_extra_ie(struct wiphy *wiphy,

	switch (sdata->vif.type) {
	case NL80211_IFTYPE_STATION:
	case NL80211_IFTYPE_ADHOC:
		ret = set_mgmt_extra_ie_sta(sdata, params->subtype,
					    ies, ies_len);
		break;
+26 −22
Original line number Diff line number Diff line
@@ -94,31 +94,31 @@ IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
IEEE80211_IF_FILE(force_unicast_rateidx, force_unicast_rateidx, DEC);
IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC);

/* STA/IBSS attributes */
IEEE80211_IF_FILE(state, u.sta.state, DEC);
IEEE80211_IF_FILE(bssid, u.sta.bssid, MAC);
IEEE80211_IF_FILE(prev_bssid, u.sta.prev_bssid, MAC);
IEEE80211_IF_FILE(ssid_len, u.sta.ssid_len, SIZE);
IEEE80211_IF_FILE(aid, u.sta.aid, DEC);
IEEE80211_IF_FILE(ap_capab, u.sta.ap_capab, HEX);
IEEE80211_IF_FILE(capab, u.sta.capab, HEX);
IEEE80211_IF_FILE(extra_ie_len, u.sta.extra_ie_len, SIZE);
IEEE80211_IF_FILE(auth_tries, u.sta.auth_tries, DEC);
IEEE80211_IF_FILE(assoc_tries, u.sta.assoc_tries, DEC);
IEEE80211_IF_FILE(auth_algs, u.sta.auth_algs, HEX);
IEEE80211_IF_FILE(auth_alg, u.sta.auth_alg, DEC);
IEEE80211_IF_FILE(auth_transaction, u.sta.auth_transaction, DEC);
/* STA attributes */
IEEE80211_IF_FILE(state, u.mgd.state, DEC);
IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC);
IEEE80211_IF_FILE(prev_bssid, u.mgd.prev_bssid, MAC);
IEEE80211_IF_FILE(ssid_len, u.mgd.ssid_len, SIZE);
IEEE80211_IF_FILE(aid, u.mgd.aid, DEC);
IEEE80211_IF_FILE(ap_capab, u.mgd.ap_capab, HEX);
IEEE80211_IF_FILE(capab, u.mgd.capab, HEX);
IEEE80211_IF_FILE(extra_ie_len, u.mgd.extra_ie_len, SIZE);
IEEE80211_IF_FILE(auth_tries, u.mgd.auth_tries, DEC);
IEEE80211_IF_FILE(assoc_tries, u.mgd.assoc_tries, DEC);
IEEE80211_IF_FILE(auth_algs, u.mgd.auth_algs, HEX);
IEEE80211_IF_FILE(auth_alg, u.mgd.auth_alg, DEC);
IEEE80211_IF_FILE(auth_transaction, u.mgd.auth_transaction, DEC);

static ssize_t ieee80211_if_fmt_flags(
	const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
{
	return scnprintf(buf, buflen, "%s%s%s%s%s%s%s\n",
		 sdata->u.sta.flags & IEEE80211_STA_SSID_SET ? "SSID\n" : "",
		 sdata->u.sta.flags & IEEE80211_STA_BSSID_SET ? "BSSID\n" : "",
		 sdata->u.sta.flags & IEEE80211_STA_PREV_BSSID_SET ? "prev BSSID\n" : "",
		 sdata->u.sta.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "",
		 sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "",
		 sdata->u.sta.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "",
		 sdata->u.mgd.flags & IEEE80211_STA_SSID_SET ? "SSID\n" : "",
		 sdata->u.mgd.flags & IEEE80211_STA_BSSID_SET ? "BSSID\n" : "",
		 sdata->u.mgd.flags & IEEE80211_STA_PREV_BSSID_SET ? "prev BSSID\n" : "",
		 sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "",
		 sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "",
		 sdata->u.mgd.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "",
		 sdata->vif.bss_conf.use_cts_prot ? "CTS prot\n" : "");
}
__IEEE80211_IF_FILE(flags);
@@ -283,9 +283,11 @@ static void add_files(struct ieee80211_sub_if_data *sdata)
#endif
		break;
	case NL80211_IFTYPE_STATION:
	case NL80211_IFTYPE_ADHOC:
		add_sta_files(sdata);
		break;
	case NL80211_IFTYPE_ADHOC:
		/* XXX */
		break;
	case NL80211_IFTYPE_AP:
		add_ap_files(sdata);
		break;
@@ -418,9 +420,11 @@ static void del_files(struct ieee80211_sub_if_data *sdata)
#endif
		break;
	case NL80211_IFTYPE_STATION:
	case NL80211_IFTYPE_ADHOC:
		del_sta_files(sdata);
		break;
	case NL80211_IFTYPE_ADHOC:
		/* XXX */
		break;
	case NL80211_IFTYPE_AP:
		del_ap_files(sdata);
		break;
Loading