您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ wpabuf_set函数代码示例

51自学网 2021-06-03 10:02:52
  C++
这篇教程C++ wpabuf_set函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中wpabuf_set函数的典型用法代码示例。如果您正苦于以下问题:C++ wpabuf_set函数的具体用法?C++ wpabuf_set怎么用?C++ wpabuf_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了wpabuf_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: eap_peap_build_phase2_term

static struct wpabuf * eap_peap_build_phase2_term(struct eap_sm *sm,						  struct eap_peap_data *data,						  u8 id, int success){	struct wpabuf *encr_req, msgbuf;	size_t req_len;	struct eap_hdr *hdr;	req_len = sizeof(*hdr);	hdr = os_zalloc(req_len);	if (hdr == NULL)		return NULL;	hdr->code = success ? EAP_CODE_SUCCESS : EAP_CODE_FAILURE;	hdr->identifier = id;	hdr->length = host_to_be16(req_len);	wpa_hexdump_key(MSG_DEBUG, "EAP-PEAP: Encrypting Phase 2 data",			(u8 *) hdr, req_len);	wpabuf_set(&msgbuf, hdr, req_len);	encr_req = eap_server_tls_encrypt(sm, &data->ssl, &msgbuf);	os_free(hdr);	return encr_req;}
开发者ID:NAM-IL,项目名称:HostAP_2_4,代码行数:26,


示例2: 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;}
开发者ID:Keepenjoying,项目名称:lw_hostap,代码行数:60,


示例3: 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;}
开发者ID:springware,项目名称:92u10,代码行数:28,


示例4: eap_peap_build_phase2_req

static struct wpabuf * eap_peap_build_phase2_req(struct eap_sm *sm,						 struct eap_peap_data *data,						 u8 id){	struct wpabuf *buf, *encr_req, msgbuf;	const u8 *req;	size_t req_len;	if (data->phase2_method == NULL || data->phase2_priv == NULL) {		wpa_printf(MSG_DEBUG, "EAP-PEAP: Phase 2 method not ready");		return NULL;	}	buf = data->phase2_method->buildReq(sm, data->phase2_priv, id);	if (buf == NULL)		return NULL;	req = wpabuf_head(buf);	req_len = wpabuf_len(buf);	wpa_hexdump_key(MSG_DEBUG, "EAP-PEAP: Encrypting Phase 2 data",			req, req_len);	if (data->peap_version == 0 &&	    data->phase2_method->method != EAP_TYPE_TLV) {		req += sizeof(struct eap_hdr);		req_len -= sizeof(struct eap_hdr);	}	wpabuf_set(&msgbuf, req, req_len);	encr_req = eap_server_tls_encrypt(sm, &data->ssl, &msgbuf);	wpabuf_free(buf);	return encr_req;}
开发者ID:NAM-IL,项目名称:HostAP_2_4,代码行数:33,


示例5: 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;}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:30,


示例6: http_client_get_body

struct wpabuf * http_client_get_body(struct http_client *c){	if (c->hread == NULL)		return NULL;	wpabuf_set(&c->body, httpread_data_get(c->hread),		   httpread_length_get(c->hread));	return &c->body;}
开发者ID:09sea98,项目名称:rtl8188eu,代码行数:8,


示例7: eap_server_tls_reassemble

static int eap_server_tls_reassemble(struct eap_ssl_data *data, u8 flags,				     const u8 **pos, size_t *left){	unsigned int tls_msg_len = 0;	const u8 *end = *pos + *left;	if (flags & EAP_TLS_FLAGS_LENGTH_INCLUDED) {		if (*left < 4) {			wpa_printf(MSG_INFO, "SSL: Short frame with TLS "				   "length");			return -1;		}		tls_msg_len = WPA_GET_BE32(*pos);		wpa_printf(MSG_DEBUG, "SSL: TLS Message Length: %d",			   tls_msg_len);		*pos += 4;		*left -= 4;	}	wpa_printf(MSG_DEBUG, "SSL: Received packet: Flags 0x%x "		   "Message Length %u", flags, tls_msg_len);	if (data->state == WAIT_FRAG_ACK) {		if (*left != 0) {			wpa_printf(MSG_DEBUG, "SSL: Unexpected payload in "				   "WAIT_FRAG_ACK state");			return -1;		}		wpa_printf(MSG_DEBUG, "SSL: Fragment acknowledged");		return 1;	}	if (data->tls_in &&	    eap_server_tls_process_cont(data, *pos, end - *pos) < 0)		return -1;			if (flags & EAP_TLS_FLAGS_MORE_FRAGMENTS) {		if (eap_server_tls_process_fragment(data, flags, tls_msg_len,						    *pos, end - *pos) < 0)			return -1;		data->state = FRAG_ACK;		return 1;	}	if (data->state == FRAG_ACK) {		wpa_printf(MSG_DEBUG, "SSL: All fragments received");		data->state = MSG;	}	if (data->tls_in == NULL) {		/* Wrap unfragmented messages as wpabuf without extra copy */		wpabuf_set(&data->tmpbuf, *pos, end - *pos);		data->tls_in = &data->tmpbuf;	}	return 0;}
开发者ID:09sea98,项目名称:rtl8188eu,代码行数:58,


示例8: eap_tls_process_input

/** * eap_tls_process_input - Process incoming TLS message * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @data: Data for TLS processing * @in_data: Message received from the server * @in_len: Length of in_data * @out_data: Buffer for returning a pointer to application data (if available) * Returns: 0 on success, 1 if more input data is needed, 2 if application data * is available, -1 on failure */static int eap_tls_process_input(struct eap_sm *sm, struct eap_ssl_data *data,				 const u8 *in_data, size_t in_len,				 struct wpabuf **out_data){	const struct wpabuf *msg;	int need_more_input;	struct wpabuf *appl_data;	struct wpabuf buf;	wpabuf_set(&buf, in_data, in_len);	msg = eap_peer_tls_data_reassemble(data, &buf, &need_more_input);	if (msg == NULL)		return need_more_input ? 1 : -1;	/* Full TLS message reassembled - continue handshake processing */	if (data->tls_out) {		/* This should not happen.. */		wpa_printf(MSG_INFO, "SSL: eap_tls_process_input - pending "			   "tls_out data even though tls_out_len = 0");		wpabuf_free(data->tls_out);		WPA_ASSERT(data->tls_out == NULL);	}	appl_data = NULL;	data->tls_out = tls_connection_handshake(data->ssl_ctx, data->conn,						 msg, &appl_data);	eap_peer_tls_reset_input(data);	if (appl_data &&	    tls_connection_established(data->ssl_ctx, data->conn) &&	    !tls_connection_get_failed(data->ssl_ctx, data->conn)) {		wpa_hexdump_buf_key(MSG_MSGDUMP, "SSL: Application data",				    appl_data);		*out_data = appl_data;		return 2;	}	wpabuf_free(appl_data);	return 0;}
开发者ID:aelarabawy,项目名称:hostap,代码行数:51,


示例9: wps_oob_use_cred

int wps_oob_use_cred(struct wps_context *wps, struct wps_parse_attr *attr){	struct wpabuf msg;	size_t i;	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;}
开发者ID:9A9A,项目名称:wpa_supplicant-fork,代码行数:22,


示例10: wps_er_process_wlanevent

static void wps_er_process_wlanevent(struct wps_er_ap *ap,				     struct wpabuf *event){	u8 *data;	u8 wlan_event_type;	u8 wlan_event_mac[ETH_ALEN];	struct wpabuf msg;	wpa_hexdump(MSG_MSGDUMP, "WPS ER: Received WLANEvent",		    wpabuf_head(event), wpabuf_len(event));	if (wpabuf_len(event) < 1 + 17) {		wpa_printf(MSG_DEBUG, "WPS ER: Too short WLANEvent");		return;	}	data = wpabuf_mhead(event);	wlan_event_type = data[0];	if (hwaddr_aton((char *) data + 1, wlan_event_mac) < 0) {		wpa_printf(MSG_DEBUG, "WPS ER: Invalid WLANEventMAC in "			   "WLANEvent");		return;	}	wpabuf_set(&msg, data + 1 + 17, wpabuf_len(event) - (1 + 17));	switch (wlan_event_type) {	case 1:		wps_er_process_wlanevent_probe_req(ap, wlan_event_mac, &msg);		break;	case 2:		wps_er_process_wlanevent_eap(ap, wlan_event_mac, &msg);		break;	default:		wpa_printf(MSG_DEBUG, "WPS ER: Unknown WLANEventType %d",			   wlan_event_type);		break;	}}
开发者ID:DentonGentry,项目名称:gfiber-gfrg100,代码行数:38,


示例11: wps_process_cred_e

static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,                  size_t cred_len){    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 (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;}
开发者ID:Rajeev-Sirasanagandla,项目名称:t80_platform_external,代码行数:23,


示例12: eap_peap_build_phase2_soh

static struct wpabuf * eap_peap_build_phase2_soh(struct eap_sm *sm,						 struct eap_peap_data *data,						 u8 id){	struct wpabuf *buf1, *buf, *encr_req, msgbuf;	const u8 *req;	size_t req_len;	buf1 = tncs_build_soh_request();	if (buf1 == NULL)		return NULL;	buf = eap_msg_alloc(EAP_VENDOR_MICROSOFT, 0x21, wpabuf_len(buf1),			    EAP_CODE_REQUEST, id);	if (buf == NULL) {		wpabuf_free(buf1);		return NULL;	}	wpabuf_put_buf(buf, buf1);	wpabuf_free(buf1);	req = wpabuf_head(buf);	req_len = wpabuf_len(buf);	wpa_hexdump_key(MSG_DEBUG, "EAP-PEAP: Encrypting Phase 2 SOH data",			req, req_len);	req += sizeof(struct eap_hdr);	req_len -= sizeof(struct eap_hdr);	wpabuf_set(&msgbuf, req, req_len);	encr_req = eap_server_tls_encrypt(sm, &data->ssl, &msgbuf);	wpabuf_free(buf);	return encr_req;}
开发者ID:NAM-IL,项目名称:HostAP_2_4,代码行数:36,


示例13: eap_tnc_process

static void eap_tnc_process(struct eap_sm *sm, void *priv,			    struct wpabuf *respData){	struct eap_tnc_data *data = priv;	const u8 *pos, *end;	size_t len;	u8 flags;	u32 message_length = 0;	struct wpabuf tmpbuf;	pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_TNC, respData, &len);	if (pos == NULL)		return; /* Should not happen; message already verified */	end = pos + len;	if (len == 1 && (data->state == DONE || data->state == FAIL)) {		wpa_printf(MSG_DEBUG, "EAP-TNC: Peer acknowledged the last "			   "message");		return;	}	if (len == 0) {		/* fragment ack */		flags = 0;	} else		flags = *pos++;	if (flags & EAP_TNC_FLAGS_LENGTH_INCLUDED) {		if (end - pos < 4) {			wpa_printf(MSG_DEBUG, "EAP-TNC: Message underflow");			eap_tnc_set_state(data, FAIL);			return;		}		message_length = WPA_GET_BE32(pos);		pos += 4;		if (message_length < (u32) (end - pos) ||		    message_length > 75000) {			wpa_printf(MSG_DEBUG, "EAP-TNC: Invalid Message "				   "Length (%d; %ld remaining in this msg)",				   message_length, (long) (end - pos));			eap_tnc_set_state(data, FAIL);			return;		}	}	wpa_printf(MSG_DEBUG, "EAP-TNC: Received packet: Flags 0x%x "		   "Message Length %u", flags, message_length);	if (data->state == WAIT_FRAG_ACK) {		if (len > 1) {			wpa_printf(MSG_DEBUG, "EAP-TNC: Unexpected payload "				   "in WAIT_FRAG_ACK state");			eap_tnc_set_state(data, FAIL);			return;		}		wpa_printf(MSG_DEBUG, "EAP-TNC: Fragment acknowledged");		eap_tnc_set_state(data, CONTINUE);		return;	}	if (data->in_buf && eap_tnc_process_cont(data, pos, end - pos) < 0) {		eap_tnc_set_state(data, FAIL);		return;	}			if (flags & EAP_TNC_FLAGS_MORE_FRAGMENTS) {		if (eap_tnc_process_fragment(data, flags, message_length,					     pos, end - pos) < 0)			eap_tnc_set_state(data, FAIL);		else			eap_tnc_set_state(data, FRAG_ACK);		return;	} else if (data->state == FRAG_ACK) {		wpa_printf(MSG_DEBUG, "EAP-TNC: All fragments received");		eap_tnc_set_state(data, CONTINUE);	}	if (data->in_buf == NULL) {		/* Wrap unfragmented messages as wpabuf without extra copy */		wpabuf_set(&tmpbuf, pos, end - pos);		data->in_buf = &tmpbuf;	}	wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-TNC: Received payload",			  wpabuf_head(data->in_buf), wpabuf_len(data->in_buf));	tncs_process(data, data->in_buf);	if (data->in_buf != &tmpbuf)		wpabuf_free(data->in_buf);	data->in_buf = NULL;}
开发者ID:2asoft,项目名称:freebsd,代码行数:92,


示例14: eap_fast_process

static struct wpabuf * eap_fast_process(struct eap_sm *sm, void *priv,					struct eap_method_ret *ret,					const struct wpabuf *reqData){	const struct eap_hdr *req;	size_t left;	int res;	u8 flags, id;	struct wpabuf *resp;	const u8 *pos;	struct eap_fast_data *data = priv;	pos = eap_peer_tls_process_init(sm, &data->ssl, EAP_TYPE_FAST, ret,					reqData, &left, &flags);	if (pos == NULL)		return NULL;	req = wpabuf_head(reqData);	id = req->identifier;	if (flags & EAP_TLS_FLAGS_START) {		if (eap_fast_process_start(sm, data, flags, pos, left) < 0)			return NULL;		left = 0; /* A-ID is not used in further packet processing */	}	resp = NULL;	if (tls_connection_established(sm->ssl_ctx, data->ssl.conn) &&	    !data->resuming) {		/* Process tunneled (encrypted) phase 2 data. */		struct wpabuf msg;		wpabuf_set(&msg, pos, left);		res = eap_fast_decrypt(sm, data, ret, req, &msg, &resp);		if (res < 0) {			ret->methodState = METHOD_DONE;			ret->decision = DECISION_FAIL;			/*			 * Ack possible Alert that may have caused failure in			 * decryption.			 */			res = 1;		}	} else {		/* Continue processing TLS handshake (phase 1). */		res = eap_peer_tls_process_helper(sm, &data->ssl,						  EAP_TYPE_FAST,						  data->fast_version, id, pos,						  left, &resp);		if (tls_connection_established(sm->ssl_ctx, data->ssl.conn)) {			char cipher[80];			wpa_printf(MSG_DEBUG,				   "EAP-FAST: TLS done, proceed to Phase 2");			if (data->provisioning &&			    (!(data->provisioning_allowed &			       EAP_FAST_PROV_AUTH) ||			     tls_get_cipher(sm->ssl_ctx, data->ssl.conn,					    cipher, sizeof(cipher)) < 0 ||			     os_strstr(cipher, "ADH-") ||			     os_strstr(cipher, "anon"))) {				wpa_printf(MSG_DEBUG, "EAP-FAST: Using "					   "anonymous (unauthenticated) "					   "provisioning");				data->anon_provisioning = 1;			} else				data->anon_provisioning = 0;			data->resuming = 0;			eap_fast_derive_keys(sm, data);		}		if (res == 2) {			struct wpabuf msg;			/*			 * Application data included in the handshake message.			 */			wpabuf_free(data->pending_phase2_req);			data->pending_phase2_req = resp;			resp = NULL;			wpabuf_set(&msg, pos, left);			res = eap_fast_decrypt(sm, data, ret, req, &msg,					       &resp);		}	}	if (res == 1) {		wpabuf_free(resp);		return eap_peer_tls_build_ack(id, EAP_TYPE_FAST,					      data->fast_version);	}	return resp;}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:93,


示例15: eap_wsc_process

static void eap_wsc_process(struct eap_sm *sm, void *priv,			    struct wpabuf *respData){	struct eap_wsc_data *data = priv;	const u8 *start, *pos, *end;	size_t len;	u8 op_code, flags;	u16 message_length = 0;	enum wps_process_res res;	struct wpabuf tmpbuf;	eloop_cancel_timeout(eap_wsc_ext_reg_timeout, sm, data);	if (data->ext_reg_timeout) {		eap_wsc_state(data, FAIL);		return;	}	pos = eap_hdr_validate(EAP_VENDOR_WFA, EAP_VENDOR_TYPE_WSC,			       respData, &len);	if (pos == NULL || len < 2)		return; /* Should not happen; message already verified */	start = pos;	end = start + len;	op_code = *pos++;	flags = *pos++;	if (flags & WSC_FLAGS_LF) {		if (end - pos < 2) {			wpa_printf(MSG_DEBUG, "EAP-WSC: Message underflow");			return;		}		message_length = WPA_GET_BE16(pos);		pos += 2;		if (message_length < end - pos) {			wpa_printf(MSG_DEBUG, "EAP-WSC: Invalid Message "				   "Length");			return;		}	}	wpa_printf(MSG_DEBUG, "EAP-WSC: Received packet: Op-Code %d "		   "Flags 0x%x Message Length %d",		   op_code, flags, message_length);	if (data->state == WAIT_FRAG_ACK) {		if (op_code != WSC_FRAG_ACK) {			wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d "				   "in WAIT_FRAG_ACK state", op_code);			eap_wsc_state(data, FAIL);			return;		}		wpa_printf(MSG_DEBUG, "EAP-WSC: Fragment acknowledged");		eap_wsc_state(data, MESG);		return;	}	if (op_code != WSC_ACK && op_code != WSC_NACK && op_code != WSC_MSG &&	    op_code != WSC_Done) {		wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d",			   op_code);		eap_wsc_state(data, FAIL);		return;	}	if (data->in_buf &&	    eap_wsc_process_cont(data, pos, end - pos, op_code) < 0) {		eap_wsc_state(data, FAIL);		return;	}	if (flags & WSC_FLAGS_MF) {		if (eap_wsc_process_fragment(data, flags, op_code,					     message_length, pos, end - pos) <		    0)			eap_wsc_state(data, FAIL);		else			eap_wsc_state(data, FRAG_ACK);		return;	}	if (data->in_buf == NULL) {		/* Wrap unfragmented messages as wpabuf without extra copy */		wpabuf_set(&tmpbuf, pos, end - pos);		data->in_buf = &tmpbuf;	}	res = wps_process_msg(data->wps, op_code, data->in_buf);	switch (res) {	case WPS_DONE:		wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing completed "			   "successfully - report EAP failure");		eap_wsc_state(data, FAIL);		break;	case WPS_CONTINUE:		eap_wsc_state(data, MESG);		break;	case WPS_FAILURE:		wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing failed");//.........这里部分代码省略.........
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:101,


示例16: eap_ikev2_process

static void eap_ikev2_process(struct eap_sm *sm, void *priv,			      struct wpabuf *respData){	struct eap_ikev2_data *data = priv;	const u8 *start, *pos, *end;	size_t len;	u8 flags;	u32 message_length = 0;	struct wpabuf tmpbuf;	pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_IKEV2, respData,			       &len);	if (pos == NULL)		return; /* Should not happen; message already verified */	start = pos;	end = start + len;	if (len == 0) {		/* fragment ack */		flags = 0;	} else		flags = *pos++;	if (eap_ikev2_process_icv(data, respData, flags, pos, &end,				  data->state == WAIT_FRAG_ACK && len == 0) < 0)	{		eap_ikev2_state(data, FAIL);		return;	}	if (flags & IKEV2_FLAGS_LENGTH_INCLUDED) {		if (end - pos < 4) {			wpa_printf(MSG_DEBUG, "EAP-IKEV2: Message underflow");			eap_ikev2_state(data, FAIL);			return;		}		message_length = WPA_GET_BE32(pos);		pos += 4;		if (message_length < (u32) (end - pos)) {			wpa_printf(MSG_DEBUG, "EAP-IKEV2: Invalid Message "				   "Length (%d; %ld remaining in this msg)",				   message_length, (long) (end - pos));			eap_ikev2_state(data, FAIL);			return;		}	}	wpa_printf(MSG_DEBUG, "EAP-IKEV2: Received packet: Flags 0x%x "		   "Message Length %u", flags, message_length);	if (data->state == WAIT_FRAG_ACK) {		if (len != 0) {			wpa_printf(MSG_DEBUG, "EAP-IKEV2: Unexpected payload "				   "in WAIT_FRAG_ACK state");			eap_ikev2_state(data, FAIL);			return;		}		wpa_printf(MSG_DEBUG, "EAP-IKEV2: Fragment acknowledged");		eap_ikev2_state(data, MSG);		return;	}	if (data->in_buf && eap_ikev2_process_cont(data, pos, end - pos) < 0) {		eap_ikev2_state(data, FAIL);		return;	}			if (flags & IKEV2_FLAGS_MORE_FRAGMENTS) {		if (eap_ikev2_process_fragment(data, flags, message_length,					       pos, end - pos) < 0)			eap_ikev2_state(data, FAIL);		else			eap_ikev2_state(data, FRAG_ACK);		return;	} else if (data->state == FRAG_ACK) {		wpa_printf(MSG_DEBUG, "EAP-TNC: All fragments received");		data->state = MSG;	}	if (data->in_buf == NULL) {		/* Wrap unfragmented messages as wpabuf without extra copy */		wpabuf_set(&tmpbuf, pos, end - pos);		data->in_buf = &tmpbuf;	}	if (ikev2_initiator_process(&data->ikev2, data->in_buf) < 0) {		if (data->in_buf == &tmpbuf)			data->in_buf = NULL;		eap_ikev2_state(data, FAIL);		return;	}	switch (data->ikev2.state) {	case SA_AUTH:		/* SA_INIT was sent out, so message have to be		 * integrity protected from now on. */		data->keys_ready = 1;		break;	case IKEV2_DONE://.........这里部分代码省略.........
开发者ID:Bebooo43,项目名称:android_hardware_mediatek,代码行数:101,


示例17: eap_tnc_process

static struct wpabuf * eap_tnc_process(struct eap_sm *sm, void *priv,				       struct eap_method_ret *ret,				       const struct wpabuf *reqData){	struct eap_tnc_data *data = priv;	struct wpabuf *resp;	const u8 *pos, *end;	u8 *rpos, *rpos1;	size_t len, rlen;	size_t imc_len;	char *start_buf, *end_buf;	size_t start_len, end_len;	int tncs_done = 0;	u8 flags, id;	u32 message_length = 0;	struct wpabuf tmpbuf;	pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_TNC, reqData, &len);	if (pos == NULL) {		wpa_printf(MSG_INFO, "EAP-TNC: Invalid frame (pos=%p len=%lu)",			   pos, (unsigned long) len);		ret->ignore = TRUE;		return NULL;	}	id = eap_get_id(reqData);	end = pos + len;	if (len == 0)		flags = 0; /* fragment ack */	else		flags = *pos++;	if (len > 0 && (flags & EAP_TNC_VERSION_MASK) != EAP_TNC_VERSION) {		wpa_printf(MSG_DEBUG, "EAP-TNC: Unsupported version %d",			   flags & EAP_TNC_VERSION_MASK);		ret->ignore = TRUE;		return NULL;	}	if (flags & EAP_TNC_FLAGS_LENGTH_INCLUDED) {		if (end - pos < 4) {			wpa_printf(MSG_DEBUG, "EAP-TNC: Message underflow");			ret->ignore = TRUE;			return NULL;		}		message_length = WPA_GET_BE32(pos);		pos += 4;		if (message_length < (u32) (end - pos)) {			wpa_printf(MSG_DEBUG, "EAP-TNC: Invalid Message "				   "Length (%d; %ld remaining in this msg)",				   message_length, (long) (end - pos));			ret->ignore = TRUE;			return NULL;		}	}	wpa_printf(MSG_DEBUG, "EAP-TNC: Received packet: Flags 0x%x "		   "Message Length %u", flags, message_length);	if (data->state == WAIT_FRAG_ACK) {		if (len > 1) {			wpa_printf(MSG_DEBUG, "EAP-TNC: Unexpected payload in "				   "WAIT_FRAG_ACK state");			ret->ignore = TRUE;			return NULL;		}		wpa_printf(MSG_DEBUG, "EAP-TNC: Fragment acknowledged");		data->state = PROC_MSG;		return eap_tnc_build_msg(data, ret, id);	}	if (data->in_buf && eap_tnc_process_cont(data, pos, end - pos) < 0) {		ret->ignore = TRUE;		return NULL;	}			if (flags & EAP_TNC_FLAGS_MORE_FRAGMENTS) {		return eap_tnc_process_fragment(data, ret, id, flags,						message_length, pos,						end - pos);	}	if (data->in_buf == NULL) {		/* Wrap unfragmented messages as wpabuf without extra copy */		wpabuf_set(&tmpbuf, pos, end - pos);		data->in_buf = &tmpbuf;	}	if (data->state == WAIT_START) {		if (!(flags & EAP_TNC_FLAGS_START)) {			wpa_printf(MSG_DEBUG, "EAP-TNC: Server did not use "				   "start flag in the first message");			ret->ignore = TRUE;			goto fail;		}		tncc_init_connection(data->tncc);//.........这里部分代码省略.........
开发者ID:xiaoyeqiannian,项目名称:githubck,代码行数:101,


示例18: eap_fast_process_phase2_response

static void eap_fast_process_phase2_response(struct eap_sm *sm,					     struct eap_fast_data *data,					     u8 *in_data, size_t in_len){	u8 next_type = EAP_TYPE_NONE;	struct eap_hdr *hdr;	u8 *pos;	size_t left;	struct wpabuf buf;	const struct eap_method *m = data->phase2_method;	void *priv = data->phase2_priv;	if (priv == NULL) {		wpa_printf(MSG_DEBUG, "EAP-FAST: %s - Phase2 not "			   "initialized?!", __func__);		return;	}	hdr = (struct eap_hdr *) in_data;	pos = (u8 *) (hdr + 1);	if (in_len > sizeof(*hdr) && *pos == EAP_TYPE_NAK) {		left = in_len - sizeof(*hdr);		wpa_hexdump(MSG_DEBUG, "EAP-FAST: Phase2 type Nak'ed; "			    "allowed types", pos + 1, left - 1);#ifdef EAP_SERVER_TNC		if (m && m->vendor == EAP_VENDOR_IETF &&		    m->method == EAP_TYPE_TNC) {			wpa_printf(MSG_DEBUG, "EAP-FAST: Peer Nak'ed required "				   "TNC negotiation");			next_type = eap_fast_req_failure(sm, data);			eap_fast_phase2_init(sm, data, next_type);			return;		}#endif /* EAP_SERVER_TNC */		eap_sm_process_nak(sm, pos + 1, left - 1);		if (sm->user && sm->user_eap_method_index < EAP_MAX_METHODS &&		    sm->user->methods[sm->user_eap_method_index].method !=		    EAP_TYPE_NONE) {			next_type = sm->user->methods[				sm->user_eap_method_index++].method;			wpa_printf(MSG_DEBUG, "EAP-FAST: try EAP type %d",				   next_type);		} else {			next_type = eap_fast_req_failure(sm, data);		}		eap_fast_phase2_init(sm, data, next_type);		return;	}	wpabuf_set(&buf, in_data, in_len);	if (m->check(sm, priv, &buf)) {		wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 check() asked to "			   "ignore the packet");		eap_fast_req_failure(sm, data);		return;	}	m->process(sm, priv, &buf);	if (!m->isDone(sm, priv))		return;	if (!m->isSuccess(sm, priv)) {		wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 method failed");		next_type = eap_fast_req_failure(sm, data);		eap_fast_phase2_init(sm, data, next_type);		return;	}	switch (data->state) {	case PHASE2_ID:		if (eap_user_get(sm, sm->identity, sm->identity_len, 1) != 0) {			wpa_hexdump_ascii(MSG_DEBUG, "EAP-FAST: Phase2 "					  "Identity not found in the user "					  "database",					  sm->identity, sm->identity_len);			next_type = eap_fast_req_failure(sm, data);			break;		}		eap_fast_state(data, PHASE2_METHOD);		if (data->anon_provisioning) {			/*			 * Only EAP-MSCHAPv2 is allowed for anonymous			 * provisioning.			 */			next_type = EAP_TYPE_MSCHAPV2;			sm->user_eap_method_index = 0;		} else {			next_type = sm->user->methods[0].method;			sm->user_eap_method_index = 1;		}		wpa_printf(MSG_DEBUG, "EAP-FAST: try EAP type %d", next_type);		break;	case PHASE2_METHOD:	case CRYPTO_BINDING:		eap_fast_update_icmk(sm, data);		eap_fast_state(data, CRYPTO_BINDING);//.........这里部分代码省略.........
开发者ID:9A9A,项目名称:wpa_supplicant-fork,代码行数:101,


示例19: eap_wsc_process

//.........这里部分代码省略.........	if (data->state == WAIT_FRAG_ACK) {		if (op_code != WSC_FRAG_ACK) {			wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d "				   "in WAIT_FRAG_ACK state", op_code);			ret->ignore = TRUE;			return NULL;		}		wpa_printf(MSG_DEBUG, "EAP-WSC: Fragment acknowledged");		eap_wsc_state(data, MESG);		return eap_wsc_build_msg(data, ret, id);	}	if (op_code != WSC_ACK && op_code != WSC_NACK && op_code != WSC_MSG &&	    op_code != WSC_Done && op_code != WSC_Start) {		wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d",			   op_code);		ret->ignore = TRUE;		return NULL;	}	if (data->state == WAIT_START) {		if (op_code != WSC_Start) {			wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d "				   "in WAIT_START state", op_code);			ret->ignore = TRUE;			return NULL;		}		wpa_printf(MSG_DEBUG, "EAP-WSC: Received start");		eap_wsc_state(data, MESG);		/* Start message has empty payload, skip processing */		goto send_msg;	} else if (op_code == WSC_Start) {		wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d",			   op_code);		ret->ignore = TRUE;		return NULL;	}	if (data->in_buf &&	    eap_wsc_process_cont(data, pos, end - pos, op_code) < 0) {		ret->ignore = TRUE;		return NULL;	}	if (flags & WSC_FLAGS_MF) {		return eap_wsc_process_fragment(data, ret, id, flags, op_code,						message_length, pos,						end - pos);	}	if (data->in_buf == NULL) {		/* Wrap unfragmented messages as wpabuf without extra copy */		wpabuf_set(&tmpbuf, pos, end - pos);		data->in_buf = &tmpbuf;	}	res = wps_process_msg(data->wps, op_code, data->in_buf);	switch (res) {	case WPS_DONE:		wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing completed "			   "successfully - wait for EAP failure");		eap_wsc_state(data, FAIL);		break;	case WPS_CONTINUE:		eap_wsc_state(data, MESG);		break;	case WPS_FAILURE:	case WPS_PENDING:		wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing failed");		eap_wsc_state(data, FAIL);		break;	}	if (data->in_buf != &tmpbuf)		wpabuf_free(data->in_buf);	data->in_buf = NULL;send_msg:	if (data->out_buf == NULL) {		data->out_buf = wps_get_msg(data->wps, &data->out_op_code);		if (data->out_buf == NULL) {			wpa_printf(MSG_DEBUG, "EAP-WSC: Failed to receive "				   "message from WPS");			eap_wsc_state(data, FAIL);			ret->methodState = METHOD_DONE;			ret->decision = DECISION_FAIL;			return NULL;		}		data->out_used = 0;	}	eap_wsc_state(data, MESG);	r = eap_wsc_build_msg(data, ret, id);	if (data->state == FAIL && ret->methodState == METHOD_DONE) {		/* Use reduced client timeout for WPS to avoid long wait */		if (sm->ClientTimeout > 2)			sm->ClientTimeout = 2;	}	return r;}
开发者ID:2asoft,项目名称:freebsd,代码行数:101,


示例20: eap_fast_phase2_request

static int eap_fast_phase2_request(struct eap_sm *sm,				   struct eap_fast_data *data,				   struct eap_method_ret *ret,				   struct eap_hdr *hdr,				   struct wpabuf **resp){	size_t len = be_to_host16(hdr->length);	u8 *pos;	struct eap_method_ret iret;	struct eap_peer_config *config = eap_get_config(sm);	struct wpabuf msg;	if (len <= sizeof(struct eap_hdr)) {		wpa_printf(MSG_INFO, "EAP-FAST: too short "			   "Phase 2 request (len=%lu)", (unsigned long) len);		return -1;	}	pos = (u8 *) (hdr + 1);	wpa_printf(MSG_DEBUG, "EAP-FAST: Phase 2 Request: type=%d", *pos);	if (*pos == EAP_TYPE_IDENTITY) {		*resp = eap_sm_buildIdentity(sm, hdr->identifier, 1);		return 0;	}	if (data->phase2_priv && data->phase2_method &&	    *pos != data->phase2_type.method) {		wpa_printf(MSG_DEBUG, "EAP-FAST: Phase 2 EAP sequence - "			   "deinitialize previous method");		data->phase2_method->deinit(sm, data->phase2_priv);		data->phase2_method = NULL;		data->phase2_priv = NULL;		data->phase2_type.vendor = EAP_VENDOR_IETF;		data->phase2_type.method = EAP_TYPE_NONE;	}	if (data->phase2_type.vendor == EAP_VENDOR_IETF &&	    data->phase2_type.method == EAP_TYPE_NONE &&	    eap_fast_select_phase2_method(data, *pos) < 0) {		if (eap_peer_tls_phase2_nak(data->phase2_types,					    data->num_phase2_types,					    hdr, resp))			return -1;		return 0;	}	if (data->phase2_priv == NULL &&	    eap_fast_init_phase2_method(sm, data) < 0) {		wpa_printf(MSG_INFO, "EAP-FAST: Failed to initialize "			   "Phase 2 EAP method %d", *pos);		ret->methodState = METHOD_DONE;		ret->decision = DECISION_FAIL;		return -1;	}	os_memset(&iret, 0, sizeof(iret));	wpabuf_set(&msg, hdr, len);	*resp = data->phase2_method->process(sm, data->phase2_priv, &iret,					     &msg);	if (*resp == NULL ||	    (iret.methodState == METHOD_DONE &&	     iret.decision == DECISION_FAIL)) {		ret->methodState = METHOD_DONE;		ret->decision = DECISION_FAIL;	} else if ((iret.methodState == METHOD_DONE ||		    iret.methodState == METHOD_MAY_CONT) &&		   (iret.decision == DECISION_UNCOND_SUCC ||		    iret.decision == DECISION_COND_SUCC)) {		data->phase2_success = 1;	}	if (*resp == NULL && config &&	    (config->pending_req_identity || config->pending_req_password ||	     config->pending_req_otp || config->pending_req_new_password)) {		wpabuf_free(data->pending_phase2_req);		data->pending_phase2_req = wpabuf_alloc_copy(hdr, len);	} else if (*resp == NULL)		return -1;	return 0;}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:80,



注:本文中的wpabuf_set函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ wpabuf_tailroom函数代码示例
C++ wpabuf_resize函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。