Skip to content

Commit

Permalink
wash: add support for device_password_id in json mode
Browse files Browse the repository at this point in the history
this field, if present, and having the value 0x0004 indicates that
the push button method was activated.
ref: wiire-a/pixiewps#107
  • Loading branch information
rofl0r committed Jan 25, 2022
1 parent fa3fc51 commit a668362
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libwps/libwps.c
Expand Up @@ -109,6 +109,13 @@ char *wps_data_to_json(const char*bssid, const char *ssid, int channel, int rssi
json_str = append_and_free(old, buf, 1);
old = json_str;
}
if(*wps->device_password_id) {
tmp = sanitize_string(wps->device_password_id);
nl = snprintf(buf, sizeof buf, "\"wps_device_password_id\" : \"%s\", ", tmp);
free(tmp);
json_str = append_and_free(old, buf, 1);
old = json_str;
}
if(*wps->ssid) {
tmp = sanitize_string(wps->ssid);
nl = snprintf(buf, sizeof buf, "\"wps_ssid\" : \"%s\", ", tmp);
Expand Down Expand Up @@ -248,6 +255,7 @@ int parse_wps_tag(const u_char *tags, size_t len, struct libwps_data *wps)
MODEL_NAME,
MODEL_NUMBER,
DEVICE_NAME,
DEVICE_PASSWORD_ID,
SSID,
UUID,
SERIAL,
Expand Down Expand Up @@ -319,6 +327,10 @@ int parse_wps_tag(const u_char *tags, size_t len, struct libwps_data *wps)
src = hex2str(el, el_len);
ptr = wps->selected_registrar_config_methods;
break;
case DEVICE_PASSWORD_ID:
src = hex2str(el, el_len);
ptr = wps->device_password_id;
break;
case RESPONSE_TYPE:
src = hex2str(el, el_len);
ptr = wps->response_type;
Expand Down
2 changes: 2 additions & 0 deletions src/libwps/libwps.h
Expand Up @@ -39,6 +39,7 @@ struct libwps_data
char model_name[LIBWPS_MAX_STR_LEN];
char model_number[LIBWPS_MAX_STR_LEN];
char device_name[LIBWPS_MAX_STR_LEN];
char device_password_id[LIBWPS_MAX_STR_LEN];
char ssid[LIBWPS_MAX_STR_LEN];
char uuid[LIBWPS_MAX_STR_LEN];
char serial[LIBWPS_MAX_STR_LEN];
Expand Down Expand Up @@ -77,6 +78,7 @@ enum wps_el_number
MODEL_NAME = 0x1023,
MODEL_NUMBER = 0x1024,
DEVICE_NAME = 0x1011,
DEVICE_PASSWORD_ID = 0x1012,
SSID = 0x1045,
UUID = 0x1047,
SERIAL = 0x1042,
Expand Down

0 comments on commit a668362

Please sign in to comment.