qcacmn: Add Passphrase and Service Name parameter to NDP cmds

Add Passphrase and Service Name to NDP initiator request and NDP
responder request.

Change-Id: I6a189747760a15393fcbac9dc382847fef789ab1
CRs-Fixed: 2072498
This commit is contained in:
Naveen Rawat 2017-06-30 10:48:48 -07:00 • committed by snandini
commit 7981ec30cb
2 changed files with 82 additions and 34 deletions

View file

@ -37,6 +37,9 @@ struct wlan_objmgr_vdev;
#define NDP_PMK_LEN 32
#define NDP_SCID_BUF_LEN 256
#define NDP_NUM_INSTANCE_ID 255
#define NAN_MAX_SERVICE_NAME_LEN 255
#define NAN_PASSPHRASE_MIN_LEN 8
#define NAN_PASSPHRASE_MAX_LEN 63
/**
* enum qca_wlan_vendor_attr_ndp_params - vendor attribute parameters
@ -60,6 +63,8 @@ struct wlan_objmgr_vdev;
* @QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE: Cipher Suit ID
* @QCA_WLAN_VENDOR_ATTR_NDP_PMK: Pairwise Master Key
* @QCA_WLAN_VENDOR_ATTR_NDP_SCID: Security Context ID
* @QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE - pass phrase
* @QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME - service name
*/
enum qca_wlan_vendor_attr_ndp_params {
QCA_WLAN_VENDOR_ATTR_NDP_PARAM_INVALID = 0,
@ -83,6 +88,8 @@ enum qca_wlan_vendor_attr_ndp_params {
QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE,
QCA_WLAN_VENDOR_ATTR_NDP_PMK,
QCA_WLAN_VENDOR_ATTR_NDP_SCID,
QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE,
QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME,
QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_AFTER_LAST,
QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX =

View file

@ -65,6 +65,10 @@ vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX + 1] = {
[QCA_WLAN_VENDOR_ATTR_NDP_DRV_RESPONSE_STATUS_TYPE] = { .type =
NLA_U32 },
[QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_VALUE] = { .type = NLA_U32 },
[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE] = { .type = NLA_BINARY,
.len = NAN_PASSPHRASE_MAX_LEN },
[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME] = { .type = NLA_BINARY,
.len = NAN_MAX_SERVICE_NAME_LEN },
};
static int os_if_nan_process_ndi_create(struct wlan_objmgr_psoc *psoc,
@ -169,6 +173,67 @@ static int os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
return cb_obj.ndi_delete(vdev_id, iface_name, transaction_id);
}
/**
* os_if_nan_parse_security_params() - parse vendor attributes for security
* params.
* @tb: parsed NL attribute list
* @ncs_sk_type: out parameter to populate ncs_sk_type
* @pmk: out parameter to populate pmk
* @passphrase: out parameter to populate passphrase
* @service_name: out parameter to populate service_name
*
* Return: 0 on success or error code on failure
*/
static int os_if_nan_parse_security_params(struct nlattr **tb,
uint32_t *ncs_sk_type, struct nan_datapath_pmk *pmk,
struct ndp_passphrase *passphrase,
struct ndp_service_name *service_name)
{
if (!ncs_sk_type || !pmk || !passphrase || !service_name) {
cfg80211_err("out buffers for one ore more parameters is null");
return -EINVAL;
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE]) {
*ncs_sk_type =
nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE]);
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]) {
pmk->pmk_len =
nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
pmk->pmk =
nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
cfg80211_err("pmk len: %d", pmk->pmk_len);
QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
pmk->pmk, pmk->pmk_len);
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE]) {
passphrase->passphrase_len =
nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE]);
passphrase->passphrase =
nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE]);
cfg80211_err("passphrase len: %d", passphrase->passphrase_len);
QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
passphrase->passphrase, passphrase->passphrase_len);
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME]) {
service_name->service_name_len =
nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME]);
service_name->service_name =
nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME]);
cfg80211_err("service_name len: %d",
service_name->service_name_len);
QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
service_name->service_name,
service_name->service_name_len);
}
return 0;
}
/**
* os_if_nan_process_ndp_initiator_req() - NDP initiator request handler
* @ctx: hdd context
@ -185,6 +250,8 @@ static int os_if_nan_process_ndi_delete(struct wlan_objmgr_psoc *psoc,
* QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS - optional
* QCA_WLAN_VENDOR_ATTR_NDP_PMK - optional
* QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE - optional
* QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE - optional
* QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME - optional
*
* Return: 0 on success or error code on failure
*/
@ -276,27 +343,13 @@ static int os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc,
nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS]);
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE] &&
!tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]) {
cfg80211_err("PMK cannot be absent when CSID is present.");
if (os_if_nan_parse_security_params(tb, &req.ncs_sk_type, &req.pmk,
&req.passphrase, &req.service_name)) {
cfg80211_err("inconsistent security params in request.");
ret = -EINVAL;
goto initiator_req_failed;
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]) {
req.pmk.pmk = nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
req.pmk.pmk_len = nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
QDF_TRACE_LEVEL_DEBUG,
req.pmk.pmk, req.pmk.pmk_len);
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE]) {
req.ncs_sk_type =
nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE]);
}
cfg80211_debug("vdev_id: %d, transaction_id: %d, channel: %d, service_instance_id: %d, ndp_app_info_len: %d, csid: %d, peer_discovery_mac_addr: %pM",
wlan_vdev_get_id(nan_vdev), req.transaction_id, req.channel,
req.service_instance_id, req.ndp_info.ndp_app_info_len,
@ -324,6 +377,8 @@ initiator_req_failed:
* QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS - optional
* QCA_WLAN_VENDOR_ATTR_NDP_PMK - optional
* QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE - optional
* QCA_WLAN_VENDOR_ATTR_NDP_PASSPHRASE - optional
* QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_NAME - optional
*
* Return: 0 on success or error code on failure
*/
@ -406,27 +461,13 @@ static int os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc,
cfg80211_debug("NDP config data is unavailable");
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE] &&
!tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]) {
cfg80211_err("PMK cannot be absent when CSID is present.");
if (os_if_nan_parse_security_params(tb, &req.ncs_sk_type, &req.pmk,
&req.passphrase, &req.service_name)) {
cfg80211_err("inconsistent security params in request.");
ret = -EINVAL;
goto responder_req_failed;
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]) {
req.pmk.pmk = nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
req.pmk.pmk_len = nla_len(tb[QCA_WLAN_VENDOR_ATTR_NDP_PMK]);
QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
QDF_TRACE_LEVEL_DEBUG,
req.pmk.pmk, req.pmk.pmk_len);
}
if (tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE]) {
req.ncs_sk_type =
nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_NDP_NCS_SK_TYPE]);
}
cfg80211_debug("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d, csid: %d",
wlan_vdev_get_id(nan_vdev), req.transaction_id, req.ndp_rsp,
req.ndp_instance_id, req.ndp_info.ndp_app_info_len,