mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-30 14:22:37 +01:00
wscutil: Add M1 parser
This commit is contained in:
parent
9ef4a40f0f
commit
f7338c45c5
@ -906,6 +906,68 @@ done:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wsc_parse_m1(const uint8_t *pdu, uint32_t len, struct wsc_m1 *out)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
struct wsc_wfa_ext_iter iter;
|
||||||
|
uint8_t version;
|
||||||
|
enum wsc_message_type msg_type;
|
||||||
|
|
||||||
|
memset(out, 0, sizeof(struct wsc_m1));
|
||||||
|
|
||||||
|
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
||||||
|
REQUIRED(VERSION, &version),
|
||||||
|
REQUIRED(MESSAGE_TYPE, &msg_type),
|
||||||
|
REQUIRED(UUID_E, &out->uuid_e),
|
||||||
|
REQUIRED(MAC_ADDRESS, &out->addr),
|
||||||
|
REQUIRED(ENROLLEE_NONCE, &out->enrollee_nonce),
|
||||||
|
REQUIRED(PUBLIC_KEY, &out->public_key),
|
||||||
|
REQUIRED(AUTHENTICATION_TYPE_FLAGS, &out->auth_type_flags),
|
||||||
|
REQUIRED(ENCRYPTION_TYPE_FLAGS, &out->encryption_type_flags),
|
||||||
|
REQUIRED(CONNECTION_TYPE_FLAGS, &out->connection_type_flags),
|
||||||
|
REQUIRED(CONFIGURATION_METHODS, &out->config_methods),
|
||||||
|
REQUIRED(WSC_STATE, &out->config_state),
|
||||||
|
REQUIRED(MANUFACTURER, &out->manufacturer),
|
||||||
|
REQUIRED(MODEL_NAME, &out->model_name),
|
||||||
|
REQUIRED(MODEL_NUMBER, &out->model_number),
|
||||||
|
REQUIRED(SERIAL_NUMBER, &out->serial_number),
|
||||||
|
REQUIRED(PRIMARY_DEVICE_TYPE, &out->primary_device_type),
|
||||||
|
REQUIRED(DEVICE_NAME, &out->device_name),
|
||||||
|
REQUIRED(RF_BANDS, &out->rf_bands),
|
||||||
|
REQUIRED(ASSOCIATION_STATE, &out->association_state),
|
||||||
|
REQUIRED(DEVICE_PASSWORD_ID, &out->device_password_id),
|
||||||
|
REQUIRED(CONFIGURATION_ERROR, &out->configuration_error),
|
||||||
|
REQUIRED(OS_VERSION, &out->os_version),
|
||||||
|
WSC_ATTR_INVALID);
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (msg_type != WSC_MESSAGE_TYPE_M1)
|
||||||
|
return -EBADMSG;
|
||||||
|
|
||||||
|
/* WSC 2.0.5, Section 8.3.1: "Specific RF band used for this message" */
|
||||||
|
if (__builtin_popcount(out->rf_bands) != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
struct wsc_attr_builder {
|
struct wsc_attr_builder {
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
@ -380,6 +380,31 @@ struct wsc_probe_request {
|
|||||||
struct wsc_primary_device_type requested_device_type;
|
struct wsc_primary_device_type requested_device_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wsc_m1 {
|
||||||
|
bool version2;
|
||||||
|
uint8_t uuid_e[16];
|
||||||
|
uint8_t addr[6];
|
||||||
|
uint8_t enrollee_nonce[16];
|
||||||
|
uint8_t public_key[192];
|
||||||
|
uint16_t auth_type_flags;
|
||||||
|
uint16_t encryption_type_flags;
|
||||||
|
uint8_t connection_type_flags;
|
||||||
|
uint16_t config_methods;
|
||||||
|
enum wsc_config_state config_state;
|
||||||
|
char manufacturer[65];
|
||||||
|
char model_name[33];
|
||||||
|
char model_number[33];
|
||||||
|
char serial_number[33];
|
||||||
|
struct wsc_primary_device_type primary_device_type;
|
||||||
|
char device_name[33];
|
||||||
|
uint8_t rf_bands;
|
||||||
|
enum wsc_association_state association_state;
|
||||||
|
enum wsc_device_password_id device_password_id;
|
||||||
|
enum wsc_configuration_error configuration_error;
|
||||||
|
uint32_t os_version;
|
||||||
|
bool request_to_enroll;
|
||||||
|
};
|
||||||
|
|
||||||
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,
|
||||||
@ -387,6 +412,8 @@ int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len,
|
|||||||
int wsc_parse_probe_request(const unsigned char *pdu, unsigned int len,
|
int wsc_parse_probe_request(const unsigned char *pdu, unsigned int len,
|
||||||
struct wsc_probe_request *out);
|
struct wsc_probe_request *out);
|
||||||
|
|
||||||
|
int wsc_parse_m1(const uint8_t *pdu, uint32_t len, struct wsc_m1 *out);
|
||||||
|
|
||||||
uint8_t *wsc_build_probe_request(const struct wsc_probe_request *probe_request,
|
uint8_t *wsc_build_probe_request(const struct wsc_probe_request *probe_request,
|
||||||
size_t *out_len);
|
size_t *out_len);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user