mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-20 12:39:25 +01:00
wscutil: Use macro magic to make more readable
This commit is contained in:
parent
7a19a10528
commit
f97d5778ea
101
src/wscutil.c
101
src/wscutil.c
@ -657,6 +657,18 @@ static bool wfa_extract_registrar_configuration_methods(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define REQUIRED(attr, out) \
|
||||||
|
WSC_ATTR_ ## attr, ATTR_FLAG_REQUIRED, out
|
||||||
|
|
||||||
|
#define OPTIONAL(attr, out) \
|
||||||
|
WSC_ATTR_ ## attr, 0, out
|
||||||
|
|
||||||
|
#define REGISTRAR(attr, out) \
|
||||||
|
WSC_ATTR_ ## attr, ATTR_FLAG_REGISTRAR, out
|
||||||
|
|
||||||
|
#define VERSION2(attr, out) \
|
||||||
|
WSC_ATTR_ ## attr, ATTR_FLAG_VERSION2, out
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -667,16 +679,15 @@ int wsc_parse_beacon(const unsigned char *pdu, unsigned int len,
|
|||||||
memset(out, 0, sizeof(struct wsc_beacon));
|
memset(out, 0, sizeof(struct wsc_beacon));
|
||||||
|
|
||||||
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
||||||
WSC_ATTR_VERSION, ATTR_FLAG_REQUIRED, &version,
|
REQUIRED(VERSION, &version),
|
||||||
WSC_ATTR_WSC_STATE, ATTR_FLAG_REQUIRED, &out->config_state,
|
REQUIRED(WSC_STATE, &out->config_state),
|
||||||
WSC_ATTR_AP_SETUP_LOCKED, 0, &out->ap_setup_locked,
|
OPTIONAL(AP_SETUP_LOCKED, &out->ap_setup_locked),
|
||||||
WSC_ATTR_SELECTED_REGISTRAR, 0, &out->selected_registrar,
|
OPTIONAL(SELECTED_REGISTRAR, &out->selected_registrar),
|
||||||
WSC_ATTR_DEVICE_PASSWORD_ID,
|
REGISTRAR(DEVICE_PASSWORD_ID, &out->device_password_id),
|
||||||
ATTR_FLAG_REGISTRAR, &out->device_password_id,
|
REGISTRAR(SELECTED_REGISTRAR_CONFIGURATION_METHODS,
|
||||||
WSC_ATTR_SELECTED_REGISTRAR_CONFIGURATION_METHODS,
|
&out->selected_reg_config_methods),
|
||||||
ATTR_FLAG_REGISTRAR, &out->selected_reg_config_methods,
|
REQUIRED(UUID_E, &out->uuid_e),
|
||||||
WSC_ATTR_UUID_E, ATTR_FLAG_REQUIRED, &out->uuid_e,
|
OPTIONAL(RF_BANDS, &out->rf_bands),
|
||||||
WSC_ATTR_RF_BANDS, 0, &out->rf_bands,
|
|
||||||
WSC_ATTR_INVALID);
|
WSC_ATTR_INVALID);
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -720,26 +731,23 @@ int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len,
|
|||||||
memset(out, 0, sizeof(struct wsc_probe_response));
|
memset(out, 0, sizeof(struct wsc_probe_response));
|
||||||
|
|
||||||
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
||||||
WSC_ATTR_VERSION, ATTR_FLAG_REQUIRED, &version,
|
REQUIRED(VERSION, &version),
|
||||||
WSC_ATTR_WSC_STATE, ATTR_FLAG_REQUIRED, &out->config_state,
|
REQUIRED(WSC_STATE, &out->config_state),
|
||||||
WSC_ATTR_AP_SETUP_LOCKED, 0, &out->ap_setup_locked,
|
OPTIONAL(AP_SETUP_LOCKED, &out->ap_setup_locked),
|
||||||
WSC_ATTR_SELECTED_REGISTRAR, 0, &out->selected_registrar,
|
OPTIONAL(SELECTED_REGISTRAR, &out->selected_registrar),
|
||||||
WSC_ATTR_DEVICE_PASSWORD_ID,
|
REGISTRAR(DEVICE_PASSWORD_ID, &out->device_password_id),
|
||||||
ATTR_FLAG_REGISTRAR, &out->device_password_id,
|
REGISTRAR(SELECTED_REGISTRAR_CONFIGURATION_METHODS,
|
||||||
WSC_ATTR_SELECTED_REGISTRAR_CONFIGURATION_METHODS,
|
&out->selected_reg_config_methods),
|
||||||
ATTR_FLAG_REGISTRAR, &out->selected_reg_config_methods,
|
REQUIRED(RESPONSE_TYPE, &out->response_type),
|
||||||
WSC_ATTR_RESPONSE_TYPE, ATTR_FLAG_REQUIRED, &out->response_type,
|
REQUIRED(UUID_E, &out->uuid_e),
|
||||||
WSC_ATTR_UUID_E, ATTR_FLAG_REQUIRED, &out->uuid_e,
|
REQUIRED(MANUFACTURER, &out->manufacturer),
|
||||||
WSC_ATTR_MANUFACTURER, ATTR_FLAG_REQUIRED, &out->manufacturer,
|
REQUIRED(MODEL_NAME, &out->model_name),
|
||||||
WSC_ATTR_MODEL_NAME, ATTR_FLAG_REQUIRED, &out->model_name,
|
REQUIRED(MODEL_NUMBER, &out->model_number),
|
||||||
WSC_ATTR_MODEL_NUMBER, ATTR_FLAG_REQUIRED, &out->model_number,
|
REQUIRED(SERIAL_NUMBER, &out->serial_number),
|
||||||
WSC_ATTR_SERIAL_NUMBER, ATTR_FLAG_REQUIRED, &out->serial_number,
|
REQUIRED(PRIMARY_DEVICE_TYPE, &out->primary_device_type),
|
||||||
WSC_ATTR_PRIMARY_DEVICE_TYPE,
|
REQUIRED(DEVICE_NAME, &out->device_name),
|
||||||
ATTR_FLAG_REQUIRED, &out->primary_device_type,
|
REQUIRED(CONFIGURATION_METHODS, &out->config_methods),
|
||||||
WSC_ATTR_DEVICE_NAME, ATTR_FLAG_REQUIRED, &out->device_name,
|
OPTIONAL(RF_BANDS, &out->rf_bands),
|
||||||
WSC_ATTR_CONFIGURATION_METHODS,
|
|
||||||
ATTR_FLAG_REQUIRED, &out->config_methods,
|
|
||||||
WSC_ATTR_RF_BANDS, 0, &out->rf_bands,
|
|
||||||
WSC_ATTR_INVALID);
|
WSC_ATTR_INVALID);
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -783,25 +791,20 @@ int wsc_parse_probe_request(const unsigned char *pdu, unsigned int len,
|
|||||||
memset(out, 0, sizeof(struct wsc_probe_request));
|
memset(out, 0, sizeof(struct wsc_probe_request));
|
||||||
|
|
||||||
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
r = wsc_parse_attrs(pdu, len, &out->version2, &iter,
|
||||||
WSC_ATTR_VERSION, ATTR_FLAG_REQUIRED, &version,
|
REQUIRED(VERSION, &version),
|
||||||
WSC_ATTR_REQUEST_TYPE, ATTR_FLAG_REQUIRED, &out->request_type,
|
REQUIRED(REQUEST_TYPE, &out->request_type),
|
||||||
WSC_ATTR_CONFIGURATION_METHODS,
|
REQUIRED(CONFIGURATION_METHODS, &out->config_methods),
|
||||||
ATTR_FLAG_REQUIRED, &out->config_methods,
|
REQUIRED(UUID_E, &out->uuid_e),
|
||||||
WSC_ATTR_UUID_E, ATTR_FLAG_REQUIRED, &out->uuid_e,
|
REQUIRED(PRIMARY_DEVICE_TYPE, &out->primary_device_type),
|
||||||
WSC_ATTR_PRIMARY_DEVICE_TYPE,
|
REQUIRED(RF_BANDS, &out->rf_bands),
|
||||||
ATTR_FLAG_REQUIRED, &out->primary_device_type,
|
REQUIRED(ASSOCIATION_STATE, &out->association_state),
|
||||||
WSC_ATTR_RF_BANDS, ATTR_FLAG_REQUIRED, &out->rf_bands,
|
REQUIRED(CONFIGURATION_ERROR, &out->configuration_error),
|
||||||
WSC_ATTR_ASSOCIATION_STATE,
|
REQUIRED(DEVICE_PASSWORD_ID, &out->device_password_id),
|
||||||
ATTR_FLAG_REQUIRED, &out->association_state,
|
VERSION2(MANUFACTURER, &out->manufacturer),
|
||||||
WSC_ATTR_CONFIGURATION_ERROR,
|
VERSION2(MODEL_NAME, &out->model_name),
|
||||||
ATTR_FLAG_REQUIRED, &out->configuration_error,
|
VERSION2(MODEL_NUMBER, &out->model_number),
|
||||||
WSC_ATTR_DEVICE_PASSWORD_ID,
|
VERSION2(DEVICE_NAME, &out->device_name),
|
||||||
ATTR_FLAG_REQUIRED, &out->device_password_id,
|
OPTIONAL(REQUESTED_DEVICE_TYPE, &out->requested_device_type),
|
||||||
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);
|
WSC_ATTR_INVALID);
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user