本文整理汇总了C++中wps_parse_msg函数的典型用法代码示例。如果您正苦于以下问题:C++ wps_parse_msg函数的具体用法?C++ wps_parse_msg怎么用?C++ wps_parse_msg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wps_parse_msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wps_parse_oob_cred
static int wps_parse_oob_cred(struct wps_context *wps, struct wpabuf *data)
{
struct wpabuf msg;
struct wps_parse_attr attr;
size_t i;
if (wps_parse_msg(data, &attr) < 0 || attr.num_cred <= 0) {
wpa_printf(MSG_ERROR, "WPS: OOB credential not found");
return -1;
}
for (i = 0; i < attr.num_cred; i++) {
struct wps_credential local_cred;
struct wps_parse_attr cattr;
os_memset(&local_cred, 0, sizeof(local_cred));
wpabuf_set(&msg, attr.cred[i], attr.cred_len[i]);
if (wps_parse_msg(&msg, &cattr) < 0 ||
wps_process_cred(&cattr, &local_cred)) {
wpa_printf(MSG_ERROR, "WPS: Failed to parse OOB "
"credential");
return -1;
}
wps->cred_cb(wps->cb_ctx, &local_cred);
}
return 0;
}
示例2: wps_get_uuid_e
/**
* wps_get_uuid_e - Get UUID-E from WPS IE
* @msg: WPS IE contents from Beacon or Probe Response frame
* Returns: Pointer to UUID-E or %NULL if not included
*
* The returned pointer is to the msg contents and it remains valid only as
* long as the msg buffer is valid.
*/
const u8 * wps_get_uuid_e(const struct wpabuf *msg) {
struct wps_parse_attr attr;
if (wps_parse_msg(msg, &attr) < 0)
return NULL;
return attr.uuid_e;
}
示例3: wps_validate_m8
int wps_validate_m8(const struct wpabuf *tlvs)
{
struct wps_parse_attr attr;
int wps2;
if (tlvs == NULL) {
wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M8");
return -1;
}
if (wps_parse_msg(tlvs, &attr) < 0) {
wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
"in M8");
return -1;
}
wps2 = attr.version2 != NULL;
if (wps_validate_version(attr.version, 1) ||
wps_validate_msg_type(attr.msg_type, 1) ||
wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
wps_validate_encr_settings(attr.encr_settings,
attr.encr_settings_len, 1) ||
wps_validate_version2(attr.version2, wps2) ||
wps_validate_authenticator(attr.authenticator, 1)) {
wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M8");
#ifdef WPS_STRICT_WPS2
if (wps2)
return -1;
#else /* WPS_STRICT_WPS2 */
return -1;
#endif /* WPS_STRICT_WPS2 */
}
return 0;
}
示例4: wps_er_process_wlanevent_probe_req
static void wps_er_process_wlanevent_probe_req(struct wps_er_ap *ap,
const u8 *addr,
struct wpabuf *msg)
{
struct wps_parse_attr attr;
wpa_printf(MSG_DEBUG, "WPS ER: WLANEvent - Probe Request - from "
MACSTR, MAC2STR(addr));
wpa_hexdump_buf(MSG_MSGDUMP, "WPS ER: WLANEvent - Enrollee's message "
"(TLVs from Probe Request)", msg);
if (wps_validate_probe_req(msg, addr) < 0) {
wpa_printf(MSG_INFO, "WPS-STRICT: ER: Ignore invalid proxied "
"Probe Request frame from " MACSTR, MAC2STR(addr));
return;
}
if (wps_parse_msg(msg, &attr) < 0) {
wpa_printf(MSG_DEBUG, "WPS ER: Failed to parse TLVs in "
"WLANEvent message");
return;
}
wps_er_add_sta_data(ap, addr, &attr, 1);
wps_registrar_probe_req_rx(ap->er->wps->registrar, addr, msg, 0);
}
示例5: wps_process_cred_e
static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
size_t cred_len, int wps2)
{
struct wps_parse_attr attr;
struct wpabuf msg;
wpa_printf(MSG_DEBUG, "WPS: Received Credential");
os_memset(&wps->cred, 0, sizeof(wps->cred));
wpabuf_set(&msg, cred, cred_len);
if (wps_parse_msg(&msg, &attr) < 0 ||
wps_process_cred(&attr, &wps->cred))
return -1;
if (os_memcmp(wps->cred.mac_addr, wps->wps->dev.mac_addr, ETH_ALEN) !=
0) {
wpa_printf(MSG_DEBUG, "WPS: MAC Address in the Credential ("
MACSTR ") does not match with own address (" MACSTR
")", MAC2STR(wps->cred.mac_addr),
MAC2STR(wps->wps->dev.mac_addr));
/*
* In theory, this could be consider fatal error, but there are
* number of deployed implementations using other address here
* due to unclarity in the specification. For interoperability
* reasons, allow this to be processed since we do not really
* use the MAC Address information for anything.
*/
#ifdef CONFIG_WPS_STRICT
if (wps2) {
wpa_printf(MSG_INFO, "WPS: Do not accept incorrect "
"MAC Address in AP Settings");
return -1;
}
#endif /* CONFIG_WPS_STRICT */
}
#ifdef CONFIG_WPS2
if (!(wps->cred.encr_type &
(WPS_ENCR_NONE | WPS_ENCR_TKIP | WPS_ENCR_AES))) {
if (wps->cred.encr_type & WPS_ENCR_WEP) {
wpa_printf(MSG_INFO, "WPS: Reject Credential "
"due to WEP configuration");
return -2;
}
wpa_printf(MSG_INFO, "WPS: Reject Credential due to "
"invalid encr_type 0x%x", wps->cred.encr_type);
return -1;
}
#endif /* CONFIG_WPS2 */
if (wps->wps->cred_cb) {
wps->cred.cred_attr = cred - 4;
wps->cred.cred_attr_len = cred_len + 4;
wps->wps->cred_cb(wps->wps->cb_ctx, &wps->cred);
wps->cred.cred_attr = NULL;
wps->cred.cred_attr_len = 0;
}
return 0;
}
示例6: wps_validate_cred
static int wps_validate_cred(const u8 *cred, size_t len)
{
struct wps_parse_attr attr;
struct wpabuf buf;
if (cred == NULL)
return -1;
wpabuf_set(&buf, cred, len);
if (wps_parse_msg(&buf, &attr) < 0) {
wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse Credential");
return -1;
}
if (wps_validate_network_idx(attr.network_idx, 1) ||
wps_validate_ssid(attr.ssid, attr.ssid_len, 1) ||
wps_validate_auth_type(attr.auth_type, 1) ||
wps_validate_encr_type(attr.encr_type, 1) ||
wps_validate_network_key_index(attr.network_key_idx, 0) ||
wps_validate_network_key(attr.network_key, attr.network_key_len,
attr.encr_type, 1) ||
wps_validate_mac_addr(attr.mac_addr, 1) ||
wps_validate_network_key_shareable(attr.network_key_shareable, 0))
{
wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Credential");
return -1;
}
return 0;
}
示例7: wps_init
/**
* wps_init - Initialize WPS Registration protocol data
* @cfg: WPS configuration
* Returns: Pointer to allocated data or %NULL on failure
*
* This function is used to initialize WPS data for a registration protocol
* instance (i.e., each run of registration protocol as a Registrar of
* Enrollee. The caller is responsible for freeing this data after the
* registration run has been completed by calling wps_deinit().
*/
struct wps_data * wps_init(const struct wps_config *cfg)
{
struct wps_data *data = os_zalloc(sizeof(*data));
if (data == NULL)
return NULL;
data->wps = cfg->wps;
data->registrar = cfg->registrar;
if (cfg->registrar) {
os_memcpy(data->uuid_r, cfg->wps->uuid, WPS_UUID_LEN);
} else {
os_memcpy(data->mac_addr_e, cfg->wps->dev.mac_addr, ETH_ALEN);
os_memcpy(data->uuid_e, cfg->wps->uuid, WPS_UUID_LEN);
}
if (cfg->pin) {
data->dev_pw_id = DEV_PW_DEFAULT;
data->dev_password = os_malloc(cfg->pin_len);
if (data->dev_password == NULL) {
os_free(data);
return NULL;
}
os_memcpy(data->dev_password, cfg->pin, cfg->pin_len);
data->dev_password_len = cfg->pin_len;
}
data->pbc = cfg->pbc;
if (cfg->pbc) {
/* Use special PIN '00000000' for PBC */
data->dev_pw_id = DEV_PW_PUSHBUTTON;
os_free(data->dev_password);
data->dev_password = os_malloc(8);
if (data->dev_password == NULL) {
os_free(data);
return NULL;
}
os_memset(data->dev_password, '0', 8);
data->dev_password_len = 8;
}
data->state = data->registrar ? RECV_M1 : SEND_M1;
if (cfg->assoc_wps_ie) {
struct wps_parse_attr attr;
wpa_hexdump_buf(MSG_DEBUG, "WPS: WPS IE from (Re)AssocReq",
cfg->assoc_wps_ie);
if (wps_parse_msg(cfg->assoc_wps_ie, &attr) < 0) {
wpa_printf(MSG_DEBUG, "WPS: Failed to parse WPS IE "
"from (Re)AssocReq");
} else if (attr.request_type == NULL) {
wpa_printf(MSG_DEBUG, "WPS: No Request Type attribute "
"in (Re)AssocReq WPS IE");
} else {
wpa_printf(MSG_DEBUG, "WPS: Request Type (from WPS IE "
"in (Re)AssocReq WPS IE): %d",
*attr.request_type);
data->request_type = *attr.request_type;
}
}
return data;
}
示例8: wps_is_addr_authorized
/**
* wps_is_addr_authorized - Check whether WPS IE authorizes MAC address
* @msg: WPS IE contents from Beacon or Probe Response frame
* @addr: MAC address to search for
* @ver1_compat: Whether to use version 1 compatibility mode
* Returns: 2 if the specified address is explicit authorized, 1 if address is
* authorized (broadcast), 0 if not
*/
int wps_is_addr_authorized(const struct wpabuf *msg, const u8 *addr,
int ver1_compat)
{
struct wps_parse_attr attr;
unsigned int i;
const u8 *pos;
const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
if (wps_parse_msg(msg, &attr) < 0)
return 0;
if (!attr.version2 && ver1_compat) {
/*
* Version 1.0 AP - AuthorizedMACs not used, so revert back to
* old mechanism of using SelectedRegistrar.
*/
return is_selected_pin_registrar(&attr);
}
if (!attr.authorized_macs)
return 0;
pos = attr.authorized_macs;
for (i = 0; i < attr.authorized_macs_len / ETH_ALEN; i++) {
if (os_memcmp(pos, addr, ETH_ALEN) == 0)
return 2;
if (os_memcmp(pos, bcast, ETH_ALEN) == 0)
return 1;
pos += ETH_ALEN;
}
return 0;
}
示例9: wps_validate_m8_encr
int wps_validate_m8_encr(const struct wpabuf *tlvs, int ap, int wps2)
{
struct wps_parse_attr attr;
if (tlvs == NULL) {
wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M8 encrypted "
"settings");
return -1;
}
if (wps_parse_msg(tlvs, &attr) < 0) {
wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
"in M8 encrypted settings");
return -1;
}
if (wps_validate_ssid(attr.ssid, attr.ssid_len, ap) ||
wps_validate_auth_type(attr.auth_type, ap) ||
wps_validate_encr_type(attr.encr_type, ap) ||
wps_validate_network_key_index(attr.network_key_idx, 0) ||
wps_validate_mac_addr(attr.mac_addr, ap) ||
wps_validate_credential(attr.cred, attr.cred_len, attr.num_cred,
!ap) ||
wps_validate_key_wrap_auth(attr.key_wrap_auth, 1)) {
wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M8 encrypted "
"settings");
#ifdef WPS_STRICT_WPS2
if (wps2)
return -1;
#else /* WPS_STRICT_WPS2 */
return -1;
#endif /* WPS_STRICT_WPS2 */
}
return 0;
}
示例10: wps_validate_assoc_resp
int wps_validate_assoc_resp(const struct wpabuf *wps_ie)
{
struct wps_parse_attr attr;
int wps2;
if (wps_ie == NULL) {
wpa_printf(MSG_INFO, "WPS-STRICT: No WPS IE in "
"(Re)Association Response frame");
return -1;
}
if (wps_parse_msg(wps_ie, &attr) < 0) {
wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse WPS IE in "
"(Re)Association Response frame");
return -1;
}
wps2 = attr.version2 != NULL;
if (wps_validate_version(attr.version, 1) ||
wps_validate_response_type(attr.response_type, 1) ||
wps_validate_version2(attr.version2, wps2)) {
wpa_printf(MSG_INFO, "WPS-STRICT: Invalid (Re)Association "
"Response frame");
return -1;
}
return 0;
}
示例11: wps_validate_m6_encr
int wps_validate_m6_encr(const struct wpabuf *tlvs, int wps2)
{
struct wps_parse_attr attr;
if (tlvs == NULL) {
wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M6 encrypted "
"settings");
return -1;
}
if (wps_parse_msg(tlvs, &attr) < 0) {
wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
"in M6 encrypted settings");
return -1;
}
if (wps_validate_r_snonce2(attr.r_snonce2, 1) ||
wps_validate_key_wrap_auth(attr.key_wrap_auth, 1)) {
wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M6 encrypted "
"settings");
#ifdef WPS_STRICT_WPS2
if (wps2)
return -1;
#else /* WPS_STRICT_WPS2 */
return -1;
#endif /* WPS_STRICT_WPS2 */
}
return 0;
}
示例12: wps_is_selected_pbc_registrar
/**
* wps_is_selected_pbc_registrar - Check whether WPS IE indicates active PBC
* @msg: WPS IE contents from Beacon or Probe Response frame
* Returns: 1 if PBC Registrar is active, 0 if not
*/
int wps_is_selected_pbc_registrar(const struct wpabuf *msg)
{
struct wps_parse_attr attr;
/*
* In theory, this could also verify that attr.sel_reg_config_methods
* includes WPS_CONFIG_PUSHBUTTON, but some deployed AP implementations
* do not set Selected Registrar Config Methods attribute properly, so
* it is safer to just use Device Password ID here.
*/
if (wps_parse_msg(msg, &attr) < 0 ||
!attr.selected_registrar || *attr.selected_registrar == 0 ||
!attr.dev_password_id ||
WPA_GET_BE16(attr.dev_password_id) != DEV_PW_PUSHBUTTON)
return 0;
#ifdef CONFIG_WPS_STRICT
if (!attr.sel_reg_config_methods ||
!(WPA_GET_BE16(attr.sel_reg_config_methods) &
WPS_CONFIG_PUSHBUTTON))
return 0;
#endif /* CONFIG_WPS_STRICT */
return 1;
}
示例13: p2p_parse_wps_ie
static int p2p_parse_wps_ie(const struct wpabuf *buf, struct p2p_message *msg)
{
struct wps_parse_attr attr;
wpa_printf(MSG_DEBUG, "P2P: Parsing WPS IE");
if (wps_parse_msg(buf, &attr))
return -1;
if (attr.dev_name && attr.dev_name_len < sizeof(msg->device_name) &&
!msg->device_name[0])
os_memcpy(msg->device_name, attr.dev_name, attr.dev_name_len);
if (attr.config_methods) {
msg->wps_config_methods =
WPA_GET_BE16(attr.config_methods);
wpa_printf(MSG_DEBUG, "P2P: Config Methods (WPS): 0x%x",
msg->wps_config_methods);
}
if (attr.dev_password_id) {
msg->dev_password_id = WPA_GET_BE16(attr.dev_password_id);
wpa_printf(MSG_DEBUG, "P2P: Device Password ID: %d",
msg->dev_password_id);
}
if (attr.primary_dev_type) {
char devtype[WPS_DEV_TYPE_BUFSIZE];
msg->wps_pri_dev_type = attr.primary_dev_type;
wpa_printf(MSG_DEBUG, "P2P: Primary Device Type (WPS): %s",
wps_dev_type_bin2str(msg->wps_pri_dev_type, devtype,
sizeof(devtype)));
}
return 0;
}
示例14: wps_validate_wsc_done
int wps_validate_wsc_done(const struct wpabuf *tlvs)
{
struct wps_parse_attr attr;
int wps2;
if (tlvs == NULL) {
wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in WSC_Done");
return -1;
}
if (wps_parse_msg(tlvs, &attr) < 0) {
wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
"in WSC_Done");
return -1;
}
wps2 = attr.version2 != NULL;
if (wps_validate_version(attr.version, 1) ||
wps_validate_msg_type(attr.msg_type, 1) ||
wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
wps_validate_version2(attr.version2, wps2)) {
wpa_printf(MSG_INFO, "WPS-STRICT: Invalid WSC_Done");
#ifdef WPS_STRICT_WPS2
if (wps2)
return -1;
#else /* WPS_STRICT_WPS2 */
return -1;
#endif /* WPS_STRICT_WPS2 */
}
return 0;
}
示例15: wps_is_20
/**
* wps_is_20 - Check whether WPS attributes claim support for WPS 2.0
*/
int wps_is_20(const struct wpabuf *msg)
{
struct wps_parse_attr attr;
if (msg == NULL || wps_parse_msg(msg, &attr) < 0)
return 0;
return attr.version2 != NULL;
}