mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-24 06:52:37 +01:00
wsc: Add wsc_parse_probe_request
This commit is contained in:
parent
ab33a22149
commit
241e459ae7
66
src/wsc.c
66
src/wsc.c
@ -535,7 +535,7 @@ static int wsc_parse_attrs(const unsigned char *pdu, unsigned int len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
version2 = true;
|
version2 = true;
|
||||||
goto check;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->type == WSC_ATTR_SELECTED_REGISTRAR)
|
if (entry->type == WSC_ATTR_SELECTED_REGISTRAR)
|
||||||
@ -558,7 +558,6 @@ static int wsc_parse_attrs(const unsigned char *pdu, unsigned int len,
|
|||||||
parse_error = true;
|
parse_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
check:
|
|
||||||
/*
|
/*
|
||||||
* Check for Version 2.0 required attributes.
|
* Check for Version 2.0 required attributes.
|
||||||
* If version2 attribute is present in the WFA Vendor field,
|
* If version2 attribute is present in the WFA Vendor field,
|
||||||
@ -617,6 +616,17 @@ done:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool wfa_extract_bool(struct wsc_wfa_ext_iter *iter, void *data)
|
||||||
|
{
|
||||||
|
bool *to = data;
|
||||||
|
|
||||||
|
if (wsc_wfa_ext_iter_get_length(iter) != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*to = *wsc_wfa_ext_iter_get_data(iter);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool wfa_extract_authorized_macs(struct wsc_wfa_ext_iter *iter,
|
static bool wfa_extract_authorized_macs(struct wsc_wfa_ext_iter *iter,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
@ -762,3 +772,55 @@ int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len,
|
|||||||
done:
|
done:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wsc_parse_probe_request(const unsigned char *pdu, unsigned int len,
|
||||||
|
struct wsc_probe_request *out)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
struct wsc_wfa_ext_iter iter;
|
||||||
|
uint8_t version;
|
||||||
|
|
||||||
|
memset(out, 0, sizeof(struct wsc_probe_request));
|
||||||
|
|
||||||
|
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
||||||
|
WSC_ATTR_VERSION, ATTR_FLAG_REQUIRED, &version,
|
||||||
|
WSC_ATTR_REQUEST_TYPE, ATTR_FLAG_REQUIRED, &out->request_type,
|
||||||
|
WSC_ATTR_CONFIGURATION_METHODS,
|
||||||
|
ATTR_FLAG_REQUIRED, &out->config_methods,
|
||||||
|
WSC_ATTR_UUID_E, ATTR_FLAG_REQUIRED, &out->uuid_e,
|
||||||
|
WSC_ATTR_PRIMARY_DEVICE_TYPE,
|
||||||
|
ATTR_FLAG_REQUIRED, &out->primary_device_type,
|
||||||
|
WSC_ATTR_RF_BANDS, ATTR_FLAG_REQUIRED, &out->rf_bands,
|
||||||
|
WSC_ATTR_ASSOCIATION_STATE,
|
||||||
|
ATTR_FLAG_REQUIRED, &out->association_state,
|
||||||
|
WSC_ATTR_CONFIGURATION_ERROR,
|
||||||
|
ATTR_FLAG_REQUIRED, &out->configuration_error,
|
||||||
|
WSC_ATTR_DEVICE_PASSWORD_ID,
|
||||||
|
ATTR_FLAG_REQUIRED, &out->device_password_id,
|
||||||
|
WSC_ATTR_MANUFACTURER, ATTR_FLAG_VERSION2, &out->manufacturer,
|
||||||
|
WSC_ATTR_MODEL_NAME, ATTR_FLAG_VERSION2, &out->model_name,
|
||||||
|
WSC_ATTR_MODEL_NUMBER, ATTR_FLAG_VERSION2, &out->model_number,
|
||||||
|
WSC_ATTR_DEVICE_NAME, ATTR_FLAG_VERSION2, &out->device_name,
|
||||||
|
WSC_ATTR_REQUESTED_DEVICE_TYPE, 0, &out->requested_device_type,
|
||||||
|
WSC_ATTR_INVALID);
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (!wsc_wfa_ext_iter_next(&iter))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
if (wsc_wfa_ext_iter_get_type(&iter) ==
|
||||||
|
WSC_WFA_EXTENSION_REQUEST_TO_ENROLL) {
|
||||||
|
if (!wfa_extract_bool(&iter, &out->request_to_enroll))
|
||||||
|
return -EBADMSG;
|
||||||
|
|
||||||
|
if (!wsc_wfa_ext_iter_next(&iter))
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
done:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
21
src/wsc.h
21
src/wsc.h
@ -361,7 +361,28 @@ struct wsc_probe_response {
|
|||||||
uint16_t reg_config_methods;
|
uint16_t reg_config_methods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wsc_probe_request {
|
||||||
|
bool version2;
|
||||||
|
enum wsc_request_type request_type;
|
||||||
|
uint16_t config_methods;
|
||||||
|
uint8_t uuid_e[16];
|
||||||
|
struct wsc_primary_device_type primary_device_type;
|
||||||
|
uint8_t rf_bands;
|
||||||
|
enum wsc_association_state association_state;
|
||||||
|
enum wsc_configuration_error configuration_error;
|
||||||
|
enum wsc_device_password_id device_password_id;
|
||||||
|
char manufacturer[65];
|
||||||
|
char model_name[33];
|
||||||
|
char model_number[33];
|
||||||
|
char serial_number[33];
|
||||||
|
char device_name[33];
|
||||||
|
bool request_to_enroll;
|
||||||
|
struct wsc_primary_device_type requested_device_type;
|
||||||
|
};
|
||||||
|
|
||||||
int wsc_parse_beacon(const unsigned char *pdu, unsigned int len,
|
int wsc_parse_beacon(const unsigned char *pdu, unsigned int len,
|
||||||
struct wsc_beacon *out);
|
struct wsc_beacon *out);
|
||||||
int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len,
|
int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len,
|
||||||
struct wsc_probe_response *out);
|
struct wsc_probe_response *out);
|
||||||
|
int wsc_parse_probe_request(const unsigned char *pdu, unsigned int len,
|
||||||
|
struct wsc_probe_request *out);
|
||||||
|
Loading…
Reference in New Issue
Block a user