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

Commit 4a3cb702 authored by Johannes Berg's avatar Johannes Berg
Browse files

mac80211: constify IE parsing



Make all the parsed IE pointers const, and propagate
the change to all the users etc.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 50640f16
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -2152,7 +2152,7 @@ static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
 * @tim_len: length of the TIM IE
 * @tim_len: length of the TIM IE
 * @aid: the AID to look for
 * @aid: the AID to look for
 */
 */
static inline bool ieee80211_check_tim(struct ieee80211_tim_ie *tim,
static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim,
				       u8 tim_len, u16 aid)
				       u8 tim_len, u16 aid)
{
{
	u8 mask;
	u8 mask;
+1 −1
Original line number Original line Diff line number Diff line
@@ -94,7 +94,7 @@ void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,


bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
				       struct ieee80211_supported_band *sband,
				       struct ieee80211_supported_band *sband,
				       struct ieee80211_ht_cap *ht_cap_ie,
				       const struct ieee80211_ht_cap *ht_cap_ie,
				       struct sta_info *sta)
				       struct sta_info *sta)
{
{
	struct ieee80211_sta_ht_cap ht_cap;
	struct ieee80211_sta_ht_cap ht_cap;
+44 −43
Original line number Original line Diff line number Diff line
@@ -1163,41 +1163,41 @@ struct ieee80211_ra_tid {


/* Parsed Information Elements */
/* Parsed Information Elements */
struct ieee802_11_elems {
struct ieee802_11_elems {
	u8 *ie_start;
	const u8 *ie_start;
	size_t total_len;
	size_t total_len;


	/* pointers to IEs */
	/* pointers to IEs */
	u8 *ssid;
	const u8 *ssid;
	u8 *supp_rates;
	const u8 *supp_rates;
	u8 *fh_params;
	const u8 *fh_params;
	u8 *ds_params;
	const u8 *ds_params;
	u8 *cf_params;
	const u8 *cf_params;
	struct ieee80211_tim_ie *tim;
	const struct ieee80211_tim_ie *tim;
	u8 *ibss_params;
	const u8 *ibss_params;
	u8 *challenge;
	const u8 *challenge;
	u8 *rsn;
	const u8 *rsn;
	u8 *erp_info;
	const u8 *erp_info;
	u8 *ext_supp_rates;
	const u8 *ext_supp_rates;
	u8 *wmm_info;
	const u8 *wmm_info;
	u8 *wmm_param;
	const u8 *wmm_param;
	struct ieee80211_ht_cap *ht_cap_elem;
	const struct ieee80211_ht_cap *ht_cap_elem;
	struct ieee80211_ht_operation *ht_operation;
	const struct ieee80211_ht_operation *ht_operation;
	struct ieee80211_vht_cap *vht_cap_elem;
	const struct ieee80211_vht_cap *vht_cap_elem;
	struct ieee80211_vht_operation *vht_operation;
	const struct ieee80211_vht_operation *vht_operation;
	struct ieee80211_meshconf_ie *mesh_config;
	const struct ieee80211_meshconf_ie *mesh_config;
	u8 *mesh_id;
	const u8 *mesh_id;
	u8 *peering;
	const u8 *peering;
	__le16 *awake_window;
	const __le16 *awake_window;
	u8 *preq;
	const u8 *preq;
	u8 *prep;
	const u8 *prep;
	u8 *perr;
	const u8 *perr;
	struct ieee80211_rann_ie *rann;
	const struct ieee80211_rann_ie *rann;
	struct ieee80211_channel_sw_ie *ch_switch_ie;
	const struct ieee80211_channel_sw_ie *ch_switch_ie;
	u8 *country_elem;
	const u8 *country_elem;
	u8 *pwr_constr_elem;
	const u8 *pwr_constr_elem;
	u8 *quiet_elem;	/* first quite element */
	const u8 *quiet_elem;	/* first quite element */
	u8 *timeout_int;
	const u8 *timeout_int;
	u8 *opmode_notif;
	const u8 *opmode_notif;


	/* length of them, respectively */
	/* length of them, respectively */
	u8 ssid_len;
	u8 ssid_len;
@@ -1276,10 +1276,10 @@ void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
int ieee80211_max_network_latency(struct notifier_block *nb,
int ieee80211_max_network_latency(struct notifier_block *nb,
				  unsigned long data, void *dummy);
				  unsigned long data, void *dummy);
int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
void
				      struct ieee80211_channel_sw_ie *sw_elem,
ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
				      struct ieee80211_bss *bss,
				 const struct ieee80211_channel_sw_ie *sw_elem,
				      u64 timestamp);
				 struct ieee80211_bss *bss, u64 timestamp);
void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata);
void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata);
void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
@@ -1387,7 +1387,7 @@ void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
				     struct ieee80211_sta_ht_cap *ht_cap);
				     struct ieee80211_sta_ht_cap *ht_cap);
bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
				       struct ieee80211_supported_band *sband,
				       struct ieee80211_supported_band *sband,
				       struct ieee80211_ht_cap *ht_cap_ie,
				       const struct ieee80211_ht_cap *ht_cap_ie,
				       struct sta_info *sta);
				       struct sta_info *sta);
void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
			  const u8 *da, u16 tid,
			  const u8 *da, u16 tid,
@@ -1428,9 +1428,10 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);


/* VHT */
/* VHT */
void ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
void
ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
				    struct ieee80211_supported_band *sband,
				    struct ieee80211_supported_band *sband,
					 struct ieee80211_vht_cap *vht_cap_ie,
				    const struct ieee80211_vht_cap *vht_cap_ie,
				    struct sta_info *sta);
				    struct sta_info *sta);
enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
void ieee80211_sta_set_rx_nss(struct sta_info *sta);
void ieee80211_sta_set_rx_nss(struct sta_info *sta);
@@ -1555,7 +1556,7 @@ static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local,


void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
			 u16 transaction, u16 auth_alg, u16 status,
			 u16 transaction, u16 auth_alg, u16 status,
			 u8 *extra, size_t extra_len, const u8 *bssid,
			 const u8 *extra, size_t extra_len, const u8 *bssid,
			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
			 u32 tx_flags);
			 u32 tx_flags);
void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
@@ -1606,7 +1607,7 @@ int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,


/* channel management */
/* channel management */
void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
				  struct ieee80211_ht_operation *ht_oper,
				  const struct ieee80211_ht_operation *ht_oper,
				  struct cfg80211_chan_def *chandef);
				  struct cfg80211_chan_def *chandef);


int __must_check
int __must_check
+6 −5
Original line number Original line Diff line number Diff line
@@ -265,7 +265,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
int mesh_nexthop_resolve(struct sk_buff *skb,
int mesh_nexthop_resolve(struct sk_buff *skb,
			 struct ieee80211_sub_if_data *sdata);
			 struct ieee80211_sub_if_data *sdata);
void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
struct mesh_path *mesh_path_lookup(u8 *dst,
struct mesh_path *mesh_path_lookup(const u8 *dst,
				   struct ieee80211_sub_if_data *sdata);
				   struct ieee80211_sub_if_data *sdata);
struct mesh_path *mpp_path_lookup(u8 *dst,
struct mesh_path *mpp_path_lookup(u8 *dst,
				  struct ieee80211_sub_if_data *sdata);
				  struct ieee80211_sub_if_data *sdata);
@@ -276,7 +276,7 @@ void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
		struct ieee80211_mgmt *mgmt, size_t len);
		struct ieee80211_mgmt *mgmt, size_t len);
int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
int mesh_path_add(const u8 *dst, struct ieee80211_sub_if_data *sdata);


int mesh_path_add_gate(struct mesh_path *mpath);
int mesh_path_add_gate(struct mesh_path *mpath);
int mesh_path_send_to_gates(struct mesh_path *mpath);
int mesh_path_send_to_gates(struct mesh_path *mpath);
@@ -301,8 +301,9 @@ void mesh_sta_cleanup(struct sta_info *sta);
void mesh_mpath_table_grow(void);
void mesh_mpath_table_grow(void);
void mesh_mpp_table_grow(void);
void mesh_mpp_table_grow(void);
/* Mesh paths */
/* Mesh paths */
int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
int mesh_path_error_tx(u8 ttl, const u8 *target, __le32 target_sn,
		       const u8 *ra, struct ieee80211_sub_if_data *sdata);
		       __le16 target_rcode, const u8 *ra,
		       struct ieee80211_sub_if_data *sdata);
void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
void mesh_path_flush_pending(struct mesh_path *mpath);
void mesh_path_flush_pending(struct mesh_path *mpath);
void mesh_path_tx_pending(struct mesh_path *mpath);
void mesh_path_tx_pending(struct mesh_path *mpath);
+23 −19
Original line number Original line Diff line number Diff line
@@ -30,14 +30,14 @@


static void mesh_queue_preq(struct mesh_path *, u8);
static void mesh_queue_preq(struct mesh_path *, u8);


static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae)
static inline u32 u32_field_get(const u8 *preq_elem, int offset, bool ae)
{
{
	if (ae)
	if (ae)
		offset += 6;
		offset += 6;
	return get_unaligned_le32(preq_elem + offset);
	return get_unaligned_le32(preq_elem + offset);
}
}


static inline u32 u16_field_get(u8 *preq_elem, int offset, bool ae)
static inline u32 u16_field_get(const u8 *preq_elem, int offset, bool ae)
{
{
	if (ae)
	if (ae)
		offset += 6;
		offset += 6;
@@ -102,9 +102,12 @@ enum mpath_frame_type {
static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};


static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
		u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target,
				  const u8 *orig_addr, __le32 orig_sn,
		__le32 target_sn, const u8 *da, u8 hop_count, u8 ttl,
				  u8 target_flags, const u8 *target,
		__le32 lifetime, __le32 metric, __le32 preq_id,
				  __le32 target_sn, const u8 *da,
				  u8 hop_count, u8 ttl,
				  __le32 lifetime, __le32 metric,
				  __le32 preq_id,
				  struct ieee80211_sub_if_data *sdata)
				  struct ieee80211_sub_if_data *sdata)
{
{
	struct ieee80211_local *local = sdata->local;
	struct ieee80211_local *local = sdata->local;
@@ -235,7 +238,7 @@ static void prepare_frame_for_deferred_tx(struct ieee80211_sub_if_data *sdata,
 * also acquires in the TX path.  To avoid a deadlock we don't transmit the
 * also acquires in the TX path.  To avoid a deadlock we don't transmit the
 * frame directly but add it to the pending queue instead.
 * frame directly but add it to the pending queue instead.
 */
 */
int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn,
int mesh_path_error_tx(u8 ttl, const u8 *target, __le32 target_sn,
		       __le16 target_rcode, const u8 *ra,
		       __le16 target_rcode, const u8 *ra,
		       struct ieee80211_sub_if_data *sdata)
		       struct ieee80211_sub_if_data *sdata)
{
{
@@ -370,13 +373,13 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
 */
 */
static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
			       struct ieee80211_mgmt *mgmt,
			       struct ieee80211_mgmt *mgmt,
			    u8 *hwmp_ie, enum mpath_frame_type action)
			       const u8 *hwmp_ie, enum mpath_frame_type action)
{
{
	struct ieee80211_local *local = sdata->local;
	struct ieee80211_local *local = sdata->local;
	struct mesh_path *mpath;
	struct mesh_path *mpath;
	struct sta_info *sta;
	struct sta_info *sta;
	bool fresh_info;
	bool fresh_info;
	u8 *orig_addr, *ta;
	const u8 *orig_addr, *ta;
	u32 orig_sn, orig_metric;
	u32 orig_sn, orig_metric;
	unsigned long orig_lifetime, exp_time;
	unsigned long orig_lifetime, exp_time;
	u32 last_hop_metric, new_metric;
	u32 last_hop_metric, new_metric;
@@ -511,11 +514,11 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,


static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
				    struct ieee80211_mgmt *mgmt,
				    struct ieee80211_mgmt *mgmt,
				    u8 *preq_elem, u32 metric)
				    const u8 *preq_elem, u32 metric)
{
{
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct mesh_path *mpath = NULL;
	struct mesh_path *mpath = NULL;
	u8 *target_addr, *orig_addr;
	const u8 *target_addr, *orig_addr;
	const u8 *da;
	const u8 *da;
	u8 target_flags, ttl, flags;
	u8 target_flags, ttl, flags;
	u32 orig_sn, target_sn, lifetime, orig_metric;
	u32 orig_sn, target_sn, lifetime, orig_metric;
@@ -648,11 +651,11 @@ next_hop_deref_protected(struct mesh_path *mpath)


static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
				    struct ieee80211_mgmt *mgmt,
				    struct ieee80211_mgmt *mgmt,
				    u8 *prep_elem, u32 metric)
				    const u8 *prep_elem, u32 metric)
{
{
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct mesh_path *mpath;
	struct mesh_path *mpath;
	u8 *target_addr, *orig_addr;
	const u8 *target_addr, *orig_addr;
	u8 ttl, hopcount, flags;
	u8 ttl, hopcount, flags;
	u8 next_hop[ETH_ALEN];
	u8 next_hop[ETH_ALEN];
	u32 target_sn, orig_sn, lifetime;
	u32 target_sn, orig_sn, lifetime;
@@ -711,12 +714,13 @@ fail:
}
}


static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
			     struct ieee80211_mgmt *mgmt, u8 *perr_elem)
				    struct ieee80211_mgmt *mgmt,
				    const u8 *perr_elem)
{
{
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct mesh_path *mpath;
	struct mesh_path *mpath;
	u8 ttl;
	u8 ttl;
	u8 *ta, *target_addr;
	const u8 *ta, *target_addr;
	u32 target_sn;
	u32 target_sn;
	u16 target_rcode;
	u16 target_rcode;


@@ -759,14 +763,14 @@ endperr:


static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
				    struct ieee80211_mgmt *mgmt,
				    struct ieee80211_mgmt *mgmt,
				struct ieee80211_rann_ie *rann)
				    const struct ieee80211_rann_ie *rann)
{
{
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
	struct ieee80211_local *local = sdata->local;
	struct ieee80211_local *local = sdata->local;
	struct sta_info *sta;
	struct sta_info *sta;
	struct mesh_path *mpath;
	struct mesh_path *mpath;
	u8 ttl, flags, hopcount;
	u8 ttl, flags, hopcount;
	u8 *orig_addr;
	const u8 *orig_addr;
	u32 orig_sn, metric, metric_txsta, interval;
	u32 orig_sn, metric, metric_txsta, interval;
	bool root_is_gate;
	bool root_is_gate;


Loading