mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 11:52:34 +01:00
wscutil: Add parser for M2 messages
This commit is contained in:
parent
f389b2ffbc
commit
966f0a974f
@ -983,6 +983,53 @@ done:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wsc_parse_m2(const uint8_t *pdu, uint32_t len, struct wsc_m2 *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(ENROLLEE_NONCE, &out->enrollee_nonce),
|
||||||
|
REQUIRED(REGISTRAR_NONCE, &out->registrar_nonce),
|
||||||
|
REQUIRED(UUID_R, &out->uuid_r),
|
||||||
|
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(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(CONFIGURATION_ERROR, &out->configuration_error),
|
||||||
|
REQUIRED(DEVICE_PASSWORD_ID, &out->device_password_id),
|
||||||
|
REQUIRED(OS_VERSION, &out->os_version),
|
||||||
|
REQUIRED(AUTHENTICATOR, &out->authenticator),
|
||||||
|
WSC_ATTR_INVALID);
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (msg_type != WSC_MESSAGE_TYPE_M2)
|
||||||
|
return -EBADMSG;
|
||||||
|
|
||||||
|
/* WSC 2.0.5, Section 8.3.2: "Specific RF band used for this message" */
|
||||||
|
if (__builtin_popcount(out->rf_bands) != 1)
|
||||||
|
return -EBADMSG;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct wsc_attr_builder {
|
struct wsc_attr_builder {
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
@ -405,6 +405,30 @@ struct wsc_m1 {
|
|||||||
bool request_to_enroll;
|
bool request_to_enroll;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wsc_m2 {
|
||||||
|
bool version2;
|
||||||
|
uint8_t enrollee_nonce[16];
|
||||||
|
uint8_t registrar_nonce[16];
|
||||||
|
uint8_t uuid_r[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;
|
||||||
|
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_configuration_error configuration_error;
|
||||||
|
enum wsc_device_password_id device_password_id;
|
||||||
|
uint32_t os_version;
|
||||||
|
uint8_t authenticator[8];
|
||||||
|
};
|
||||||
|
|
||||||
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,
|
||||||
@ -413,6 +437,7 @@ 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);
|
int wsc_parse_m1(const uint8_t *pdu, uint32_t len, struct wsc_m1 *out);
|
||||||
|
int wsc_parse_m2(const uint8_t *pdu, uint32_t len, struct wsc_m2 *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