Ver código fonte

qcacld-3.0: Add access policy for vendor IE

qcacld-2.0 to qcacld-3.0 propagation

User configures vendor IE and access policy to allow or deny
association. PE should allow or deny connection based on access
policy and presence of vendor ie in probe request/association
irequest frame.

Change-Id: Ia2714ba07a67602e552a6f43928f02de0d4d0b9b
CRs-Fixed: 1020078
Kondabattini, Ganesh 8 anos atrás
pai
commit
e4f18e0c34

+ 17 - 0
core/mac/inc/sir_api.h

@@ -6452,4 +6452,21 @@ struct sir_mac_pwr_dbg_cmd {
 	uint8_t wait_for_ack;
  };
 
+/**
+ * struct sme_update_access_policy_vendor_ie - update vendor ie and access
+ * policy
+ * @msg_type: message id
+ * @msg_len: message length
+ * @sme_session_id: sme session id
+ * @ie: vendor ie
+ * @access_policy: access policy for vendor ie
+ */
+struct sme_update_access_policy_vendor_ie {
+	uint16_t msg_type;
+	uint16_t length;
+	uint32_t sme_session_id;
+	uint8_t ie[SIR_MAC_MAX_IE_LENGTH];
+	uint8_t access_policy;
+};
+
 #endif /* __SIR_API_H */

+ 1 - 0
core/mac/inc/wni_api.h

@@ -262,6 +262,7 @@ enum eWniMsgTypes {
 	eWNI_SME_NDP_END_IND,
 	eWNI_SME_REGISTER_P2P_ACK_CB,
 	eWNI_SME_SEND_DISASSOC_FRAME,
+	eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE,
 	eWNI_SME_MSG_TYPES_END
 };
 

+ 16 - 0
core/mac/src/pe/include/lim_api.h

@@ -83,6 +83,22 @@
 /* LIM exported function templates */
 #define LIM_MIN_BCN_PR_LENGTH  12
 #define LIM_BCN_PR_CAPABILITY_OFFSET 10
+#define LIM_ASSOC_REQ_IE_OFFSET 4
+
+/**
+ * enum lim_vendor_ie_access_policy - vendor ie access policy
+ * @LIM_ACCESS_POLICY_NONE: access policy not valid
+ * @LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT: respond only if vendor ie
+ *         is present in probe request and assoc request frames
+ * @LIM_ACCESS_POLICY_DONOT_RESPOND_IF_IE_IS_PRESENT: do not respond if vendor
+ *         ie is present in probe request or assoc request frames
+ */
+enum lim_vendor_ie_access_policy {
+	LIM_ACCESS_POLICY_NONE,
+	LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT,
+	LIM_ACCESS_POLICY_DONOT_RESPOND_IF_IE_IS_PRESENT,
+};
+
 typedef enum eMgmtFrmDropReason {
 	eMGMT_DROP_NO_DROP,
 	eMGMT_DROP_NOT_LAST_IBSS_BCN,

+ 1 - 1
core/mac/src/pe/include/lim_session.h

@@ -481,7 +481,7 @@ typedef struct sPESession       /* Added to Support BT-AMP */
 	tDot11fIEHTInfo ht_operation;
 	tDot11fIEVHTOperation vht_operation;
 	uint8_t beacon_tx_rate;
-	uint8_t *vendor_ie;
+	uint8_t *access_policy_vendor_ie;
 	uint8_t access_policy;
 } tPESession, *tpPESession;
 

+ 16 - 0
core/mac/src/pe/lim/lim_process_assoc_req_frame.c

@@ -1818,6 +1818,22 @@ void lim_process_assoc_req_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info,
 	if (false == lim_chk_tkip(mac_ctx, hdr, session, sub_type))
 		return;
 
+	/* check for the presence of vendor IE */
+	if ((session->access_policy_vendor_ie) &&
+		(session->access_policy ==
+		LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
+		if (!cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+			&session->access_policy_vendor_ie[2],
+			3, frm_body + LIM_ASSOC_REQ_IE_OFFSET, frame_len)) {
+			lim_log(mac_ctx, LOGE,
+				FL("Vendor ie not present and access policy is %x, Rejected association"),
+				session->access_policy);
+			lim_send_assoc_rsp_mgmt_frame(mac_ctx,
+				eSIR_MAC_UNSPEC_FAILURE_STATUS, 1, hdr->sa,
+				sub_type, 0, session);
+			return;
+		}
+	}
 	/* Allocate memory for the Assoc Request frame */
 	assoc_req = qdf_mem_malloc(sizeof(*assoc_req));
 	if (NULL == assoc_req) {

+ 1 - 0
core/mac/src/pe/lim/lim_process_message_queue.c

@@ -1361,6 +1361,7 @@ void lim_process_messages(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
 	case eWNI_SME_SET_HW_MODE_REQ:
 	case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
 	case eWNI_SME_SET_ANTENNA_MODE_REQ:
+	case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
 		/* These messages are from HDD. Need to respond to HDD */
 		lim_process_normal_hdd_msg(mac_ctx, msg, true);
 		break;

+ 14 - 0
core/mac/src/pe/lim/lim_process_probe_req_frame.c

@@ -384,6 +384,20 @@ lim_process_probe_req_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info,
 		/* Get pointer to Probe Request frame body */
 		body_ptr = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
 
+		/* check for vendor IE presence */
+		if ((session->access_policy_vendor_ie) &&
+			(session->access_policy ==
+			LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
+			if (!cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+				&session->access_policy_vendor_ie[2],
+				3, body_ptr, frame_len)) {
+				lim_log(mac_ctx, LOG1, FL(
+					"Vendor IE is not present and access policy is %x, dropping probe request"),
+					session->access_policy);
+				return;
+			}
+		}
+
 		/* Parse Probe Request frame */
 		if (sir_convert_probe_req_frame2_struct(mac_ctx, body_ptr,
 				frame_len, &probe_req) == eSIR_FAILURE) {

+ 55 - 0
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -5013,6 +5013,58 @@ static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 				ht_vht_cfg->nss);
 }
 
+/**
+ * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
+ *
+ * access policy
+ * @mac_ctx: pointer to mac context
+ * @msg: message buffer
+ *
+ * function processes vendor IE and access policy from SME and updates PE
+ *
+ * session entry
+ *
+ * return: none
+*/
+static void lim_process_sme_update_access_policy_vendor_ie(
+						tpAniSirGlobal mac_ctx,
+						uint32_t *msg)
+{
+	struct sme_update_access_policy_vendor_ie *update_vendor_ie;
+	struct sPESession *pe_session_entry;
+	uint8_t num_bytes;
+
+	if (!msg) {
+		lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
+		return;
+	}
+	update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
+	pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
+					update_vendor_ie->sme_session_id);
+
+	if (!pe_session_entry) {
+		lim_log(mac_ctx, LOGE,
+			FL("Session does not exist for given sme session id(%hu)"),
+			update_vendor_ie->sme_session_id);
+		return;
+	}
+	if (pe_session_entry->access_policy_vendor_ie)
+		qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
+
+	num_bytes = update_vendor_ie->ie[1] + 2;
+	pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
+
+	if (!pe_session_entry->access_policy_vendor_ie) {
+		lim_log(mac_ctx, LOGE,
+			FL("Failed to allocate memory for vendor ie"));
+		return;
+	}
+	qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
+		&update_vendor_ie->ie[0], num_bytes);
+
+	pe_session_entry->access_policy = update_vendor_ie->access_policy;
+}
+
 /**
  * lim_process_sme_req_messages()
  *
@@ -5263,6 +5315,9 @@ bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
 	case eWNI_SME_REGISTER_P2P_ACK_CB:
 		lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
 		break;
+	case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
+		lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
+		break;
 	default:
 		qdf_mem_free((void *)pMsg->bodyptr);
 		pMsg->bodyptr = NULL;

+ 5 - 0
core/mac/src/pe/lim/lim_session.c

@@ -704,6 +704,11 @@ void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session)
 #endif
 	session->valid = false;
 
+	if (session->access_policy_vendor_ie)
+		qdf_mem_free(session->access_policy_vendor_ie);
+
+	session->access_policy_vendor_ie = NULL;
+
 	if (LIM_IS_AP_ROLE(session))
 		lim_check_and_reset_protection_params(mac_ctx);
 

+ 4 - 0
core/sme/inc/sme_api.h

@@ -1164,4 +1164,8 @@ QDF_STATUS sme_register_p2p_ack_ind_callback(tHalHandle hal,
 void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id, uint8_t
 				*peer_mac, uint16_t reason, uint8_t
 				wait_for_ack);
+QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
+					uint8_t session_id, uint8_t *vendor_ie,
+					int access_policy);
+
 #endif /* #if !defined( __SME_API_H ) */

+ 45 - 0
core/sme/src/common/sme_api.c

@@ -12056,6 +12056,51 @@ QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
 	return status;
 }
 
+/**
+ * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
+ * @hal: Pointer to the mac context
+ * @session_id: sme session id
+ * @vendor_ie: vendor ie
+ * @access_policy: vendor ie access policy
+ *
+ * This function updates the vendor ie and access policy to lim.
+ *
+ * Return: success or failure.
+ */
+QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
+		uint8_t session_id, uint8_t *vendor_ie, int access_policy)
+{
+	struct sme_update_access_policy_vendor_ie *msg;
+	uint16_t msg_len;
+	QDF_STATUS status = QDF_STATUS_E_FAILURE;
+	tpAniSirGlobal mac = PMAC_STRUCT(hal);
+
+	msg_len  = sizeof(*msg);
+
+	msg = qdf_mem_malloc(msg_len);
+	if (!msg) {
+		sms_log(mac, LOGE,
+			"failed to allocate memory for sme_update_access_policy_vendor_ie");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	qdf_mem_set(msg, msg_len, 0);
+	msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
+	msg->length = (uint16_t)msg_len;
+
+	qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
+
+	msg->sme_session_id = session_id;
+	msg->access_policy = access_policy;
+
+	sms_log(mac, LOG1, "sme_session_id %hu, access_policy %d", session_id,
+			access_policy);
+
+	status = cds_send_mb_message_to_mac(msg);
+
+	return status;
+}
+
 /**
  * sme_get_reg_info() - To get registration info
  * @hHal: HAL context