本文整理汇总了C++中wpabuf_alloc_copy函数的典型用法代码示例。如果您正苦于以下问题:C++ wpabuf_alloc_copy函数的具体用法?C++ wpabuf_alloc_copy怎么用?C++ wpabuf_alloc_copy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpabuf_alloc_copy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p2p_parse_ies_separate
int p2p_parse_ies_separate(const u8 *wsc, size_t wsc_len, const u8 *p2p,
size_t p2p_len, struct p2p_message *msg)
{
os_memset(msg, 0, sizeof(*msg));
msg->wps_attributes = wpabuf_alloc_copy(wsc, wsc_len);
if (msg->wps_attributes &&
p2p_parse_wps_ie(msg->wps_attributes, msg)) {
p2p_parse_free(msg);
return -1;
}
msg->p2p_attributes = wpabuf_alloc_copy(p2p, p2p_len);
if (msg->p2p_attributes &&
p2p_parse_p2p_ie(msg->p2p_attributes, msg)) {
wpa_printf(MSG_DEBUG, "P2P: Failed to parse P2P IE data");
if (msg->p2p_attributes)
wpa_hexdump_buf(MSG_MSGDUMP, "P2P: P2P IE data",
msg->p2p_attributes);
p2p_parse_free(msg);
return -1;
}
return 0;
}
示例2: wps_process_pubkey
static int wps_process_pubkey(struct wps_data *wps, const u8 *pk,
size_t pk_len)
{
if (pk == NULL || pk_len == 0) {
wpa_printf(MSG_DEBUG, "WPS: No Public Key received");
return -1;
}
#ifdef CONFIG_WPS_OOB
if (wps->dev_pw_id != DEV_PW_DEFAULT &&
wps->wps->oob_conf.pubkey_hash) {
const u8 *addr[1];
u8 hash[WPS_HASH_LEN];
addr[0] = pk;
sha256_vector(1, addr, &pk_len, hash);
if (os_memcmp(hash,
wpabuf_head(wps->wps->oob_conf.pubkey_hash),
WPS_OOB_PUBKEY_HASH_LEN) != 0) {
wpa_printf(MSG_ERROR, "WPS: Public Key hash error");
return -1;
}
}
#endif /* CONFIG_WPS_OOB */
wpabuf_free(wps->dh_pubkey_r);
wps->dh_pubkey_r = wpabuf_alloc_copy(pk, pk_len);
if (wps->dh_pubkey_r == NULL)
return -1;
if (wps_derive_keys(wps) < 0)
return -1;
return 0;
}
示例3: eap_example_peer_rx
void eap_example_peer_rx(const u8 *data, size_t data_len)
{
/* Make received EAP message available to the EAP library */
eap_ctx.eapReq = TRUE;
wpabuf_free(eap_ctx.eapReqData);
eap_ctx.eapReqData = wpabuf_alloc_copy(data, data_len);
}
示例4: eap_peer_rx
void eap_peer_rx(const void *data, int data_len)
{
//wpa_hexdump(MSG_DEBUG, "lala EAP Server send", data, data_len); //Server send to peer :)
eap_ctx.eapReq = TRUE;
//wpabuf_free(eap_ctx.eapReqData);
eap_ctx.eapReqData = wpabuf_alloc_copy(data, data_len);
}
示例5: p2p_group_notif_noa
int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
size_t noa_len)
{
if (noa == NULL) {
wpabuf_free(group->noa);
group->noa = NULL;
} else {
if (group->noa) {
if (wpabuf_size(group->noa) >= noa_len) {
group->noa->used = 0;
wpabuf_put_data(group->noa, noa, noa_len);
} else {
wpabuf_free(group->noa);
group->noa = NULL;
}
}
if (!group->noa) {
group->noa = wpabuf_alloc_copy(noa, noa_len);
if (group->noa == NULL)
return -1;
}
}
group->beacon_update = 1;
p2p_group_update_ies(group);
return 0;
}
示例6: gas_query_rx_initial
static void gas_query_rx_initial(struct gas_query *gas,
struct gas_query_pending *query,
const u8 *adv_proto, const u8 *resp,
size_t len, u16 comeback_delay)
{
wpa_printf(MSG_DEBUG, "GAS: Received initial response from "
MACSTR " (dialog_token=%u comeback_delay=%u)",
MAC2STR(query->addr), query->dialog_token, comeback_delay);
query->adv_proto = wpabuf_alloc_copy(adv_proto, 2 + adv_proto[1]);
if (query->adv_proto == NULL) {
gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
return;
}
if (comeback_delay) {
query->wait_comeback = 1;
gas_query_tx_comeback_req_delay(gas, query, comeback_delay);
return;
}
/* Query was completed without comeback mechanism */
if (gas_query_append(query, resp, len) < 0) {
gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
return;
}
gas_query_done(gas, query, GAS_QUERY_SUCCESS);
}
示例7: tls_conn_hs_clienthello
static struct wpabuf * tls_conn_hs_clienthello(struct tls_global *global,
struct tls_connection *conn)
{
DWORD sspi_flags, sspi_flags_out;
SecBufferDesc outbuf;
SecBuffer outbufs[1];
SECURITY_STATUS status;
TimeStamp ts_expiry;
sspi_flags = ISC_REQ_REPLAY_DETECT |
ISC_REQ_CONFIDENTIALITY |
ISC_RET_EXTENDED_ERROR |
ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_MANUAL_CRED_VALIDATION;
wpa_printf(MSG_DEBUG, "%s: Generating ClientHello", __func__);
outbufs[0].pvBuffer = NULL;
outbufs[0].BufferType = SECBUFFER_TOKEN;
outbufs[0].cbBuffer = 0;
outbuf.cBuffers = 1;
outbuf.pBuffers = outbufs;
outbuf.ulVersion = SECBUFFER_VERSION;
#ifdef UNICODE
status = global->sspi->InitializeSecurityContextW(
&conn->creds, NULL, NULL /* server name */, sspi_flags, 0,
SECURITY_NATIVE_DREP, NULL, 0, &conn->context,
&outbuf, &sspi_flags_out, &ts_expiry);
#else /* UNICODE */
status = global->sspi->InitializeSecurityContextA(
&conn->creds, NULL, NULL /* server name */, sspi_flags, 0,
SECURITY_NATIVE_DREP, NULL, 0, &conn->context,
&outbuf, &sspi_flags_out, &ts_expiry);
#endif /* UNICODE */
if (status != SEC_I_CONTINUE_NEEDED) {
wpa_printf(MSG_ERROR, "%s: InitializeSecurityContextA "
"failed - 0x%x",
__func__, (unsigned int) status);
return NULL;
}
if (outbufs[0].cbBuffer != 0 && outbufs[0].pvBuffer) {
struct wpabuf *buf;
wpa_hexdump(MSG_MSGDUMP, "SChannel - ClientHello",
outbufs[0].pvBuffer, outbufs[0].cbBuffer);
conn->start = 0;
buf = wpabuf_alloc_copy(outbufs[0].pvBuffer,
outbufs[0].cbBuffer);
if (buf == NULL)
return NULL;
global->sspi->FreeContextBuffer(outbufs[0].pvBuffer);
return buf;
}
wpa_printf(MSG_ERROR, "SChannel: Failed to generate ClientHello");
return NULL;
}
示例8: ikev2_process_ker
static int ikev2_process_ker(struct ikev2_initiator_data *data,
const u8 *ker, size_t ker_len)
{
u16 group;
/*
* Key Exchange Payload:
* DH Group # (16 bits)
* RESERVED (16 bits)
* Key Exchange Data (Diffie-Hellman public value)
*/
if (ker == NULL) {
asd_printf(ASD_DEFAULT,MSG_DEBUG, "IKEV2: KEr not received");
return -1;
}
if (ker_len < 4 + 96) {
asd_printf(ASD_DEFAULT,MSG_DEBUG, "IKEV2: Too show Key Exchange Payload");
return -1;
}
group = WPA_GET_BE16(ker);
asd_printf(ASD_DEFAULT,MSG_DEBUG, "IKEV2: KEr DH Group #%u", group);
if (group != data->proposal.dh) {
asd_printf(ASD_DEFAULT,MSG_DEBUG, "IKEV2: KEr DH Group #%u does not match "
"with the selected proposal (%u)",
group, data->proposal.dh);
return -1;
}
if (data->dh == NULL) {
asd_printf(ASD_DEFAULT,MSG_DEBUG, "IKEV2: Unsupported DH group");
return -1;
}
/* RFC 4306, Section 3.4:
* The length of DH public value MUST be equal to the lenght of the
* prime modulus.
*/
if (ker_len - 4 != data->dh->prime_len) {
asd_printf(ASD_DEFAULT,MSG_DEBUG, "IKEV2: Invalid DH public value length "
"%ld (expected %ld)",
(long) (ker_len - 4), (long) data->dh->prime_len);
return -1;
}
wpabuf_free(data->r_dh_public);
data->r_dh_public = wpabuf_alloc_copy(ker + 4, ker_len - 4);
if (data->r_dh_public == NULL)
return -1;
wpa_hexdump_buf(MSG_DEBUG, "IKEV2: KEr Diffie-Hellman Public Value",
data->r_dh_public);
return 0;
}
示例9: wifi_display_subelem_set_from_ies
int wifi_display_subelem_set_from_ies(struct wpa_global *global,
struct wpabuf *ie)
{
int subelements[MAX_WFD_SUBELEMS] = {};
const u8 *pos, *end;
int len, subelem;
struct wpabuf *e;
wpa_printf(MSG_DEBUG, "WFD IEs set: %p - %lu",
ie, ie ? (unsigned long) wpabuf_len(ie) : 0);
if (ie == NULL || wpabuf_len(ie) < 6)
return -1;
pos = wpabuf_head(ie);
end = pos + wpabuf_len(ie);
while (end > pos) {
if (pos + 3 > end)
break;
len = WPA_GET_BE16(pos + 1) + 3;
wpa_printf(MSG_DEBUG, "WFD Sub-Element ID %d - len %d",
*pos, len - 3);
if (pos + len > end)
break;
subelem = *pos;
if (subelem < MAX_WFD_SUBELEMS && subelements[subelem] == 0) {
e = wpabuf_alloc_copy(pos, len);
if (e == NULL)
return -1;
wpabuf_free(global->wfd_subelem[subelem]);
global->wfd_subelem[subelem] = e;
subelements[subelem] = 1;
}
pos += len;
}
for (subelem = 0; subelem < MAX_WFD_SUBELEMS; subelem++) {
if (subelements[subelem] == 0) {
wpabuf_free(global->wfd_subelem[subelem]);
global->wfd_subelem[subelem] = NULL;
}
}
return wifi_display_update_wfd_ie(global);
}
示例10: process_wps_message
/* Processes a received WPS message and returns the message type */
enum wps_type process_wps_message(const void *data, size_t data_size) {
const struct wpabuf *msg = NULL;
enum wps_type type = UNKNOWN;
struct wps_data *wps = get_wps();
unsigned char *element_data = NULL;
struct wfa_element_header element = {0};
int i = 0, header_size = sizeof (struct wfa_element_header);
/* Shove data into a wpabuf structure for processing */
msg = wpabuf_alloc_copy(data, data_size);
if (msg) {
/* Process the incoming message */
wps_registrar_process_msg(wps, get_opcode(), msg);
wpabuf_free((struct wpabuf *) msg);
/* Loop through until we hit the end of the data buffer */
for (i = 0; i < data_size; i += header_size) {
element_data = NULL;
memset((void *) &element, 0, header_size);
/* Get the element header data */
memcpy((void *) &element, (data + i), header_size);
element.type = htons(element.type);
element.length = htons(element.length);
/* Make sure the element length does not exceed the remaining buffer size */
if (element.length <= (data_size - i - header_size)) {
element_data = (unsigned char *) (data + i + header_size);
switch (element.type) {
case MESSAGE_TYPE:
type = (uint8_t) element_data[0];
break;
case CONFIGURATION_ERROR:
/* Check element_data length */
if (element.length == 2)
set_nack_reason(htons(*((uint16_t*) element_data)));
break;
default:
break;
}
}
/* Offset must include element length(s) */
i += element.length;
}
}
return type;
}
示例11: atheros_set_opt_ie
static int
atheros_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
{
struct atheros_driver_data *drv = priv;
u8 buf[512];
struct ieee80211req_getset_appiebuf *app_ie;
wpa_printf(MSG_DEBUG, "%s buflen = %lu", __func__,
(unsigned long) ie_len);
wpabuf_free(drv->wpa_ie);
drv->wpa_ie = wpabuf_alloc_copy(ie, ie_len);
app_ie = (struct ieee80211req_getset_appiebuf *) buf;
os_memcpy(&(app_ie->app_buf[0]), ie, ie_len);
app_ie->app_buflen = ie_len;
app_ie->app_frmtype = IEEE80211_APPIE_FRAME_BEACON;
/* append WPS IE for Beacon */
if (drv->wps_beacon_ie != NULL) {
os_memcpy(&(app_ie->app_buf[ie_len]),
wpabuf_head(drv->wps_beacon_ie),
wpabuf_len(drv->wps_beacon_ie));
app_ie->app_buflen = ie_len + wpabuf_len(drv->wps_beacon_ie);
}
set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, app_ie,
sizeof(struct ieee80211req_getset_appiebuf) +
app_ie->app_buflen);
/* append WPS IE for Probe Response */
app_ie->app_frmtype = IEEE80211_APPIE_FRAME_PROBE_RESP;
if (drv->wps_probe_resp_ie != NULL) {
os_memcpy(&(app_ie->app_buf[ie_len]),
wpabuf_head(drv->wps_probe_resp_ie),
wpabuf_len(drv->wps_probe_resp_ie));
app_ie->app_buflen = ie_len +
wpabuf_len(drv->wps_probe_resp_ie);
} else
app_ie->app_buflen = ie_len;
set80211priv(drv, IEEE80211_IOCTL_SET_APPIEBUF, app_ie,
sizeof(struct ieee80211req_getset_appiebuf) +
app_ie->app_buflen);
return 0;
}
示例12: wps_process_pubkey
static int wps_process_pubkey(struct wps_data *wps, const u8 *pk,
size_t pk_len)
{
if (pk == NULL || pk_len == 0) {
wpa_printf(MSG_DEBUG, "WPS: No Public Key received");
return -1;
}
wpabuf_free(wps->dh_pubkey_r);
wps->dh_pubkey_r = wpabuf_alloc_copy(pk, pk_len);
if (wps->dh_pubkey_r == NULL)
return -1;
if (wps_derive_keys(wps) < 0)
return -1;
return 0;
}
示例13: parse_nack
/*
* Get the reason code for a WSC NACK message. Not really useful because in practice the NACK
* reason code could be anything (even a non-existent code!), but keep it around just in case...
*/
int parse_nack(const void *data, size_t data_size) {
struct wps_parse_attr attr = {0};
const struct wpabuf *msg = NULL;
int ret_val = 0;
/* Shove data into a wpabuf structure for processing */
msg = wpabuf_alloc_copy(data, data_size);
if (msg) {
if (wps_parse_msg(msg, &attr) >= 0) {
if (attr.config_error) {
ret_val = WPA_GET_BE16(attr.config_error);
}
}
wpabuf_free((struct wpabuf *) msg);
}
return ret_val;
}
示例14: wps_parse_oob_dev_pwd
static int wps_parse_oob_dev_pwd(struct wps_context *wps,
struct wpabuf *data)
{
struct oob_conf_data *oob_conf = &wps->oob_conf;
struct wps_parse_attr attr;
const u8 *pos;
if (wps_parse_msg(data, &attr) < 0 ||
attr.oob_dev_password == NULL) {
wpa_printf(MSG_ERROR, "WPS: OOB device password not found");
return -1;
}
pos = attr.oob_dev_password;
oob_conf->pubkey_hash =
wpabuf_alloc_copy(pos, WPS_OOB_PUBKEY_HASH_LEN);
if (oob_conf->pubkey_hash == NULL) {
wpa_printf(MSG_ERROR, "WPS: Failed to allocate memory for OOB "
"public key hash");
return -1;
}
pos += WPS_OOB_PUBKEY_HASH_LEN;
wps->oob_dev_pw_id = WPA_GET_BE16(pos);
pos += sizeof(wps->oob_dev_pw_id);
oob_conf->dev_password =
wpabuf_alloc(WPS_OOB_DEVICE_PASSWORD_LEN * 2 + 1);
if (oob_conf->dev_password == NULL) {
wpa_printf(MSG_ERROR, "WPS: Failed to allocate memory for OOB "
"device password");
return -1;
}
wpa_snprintf_hex_uppercase(wpabuf_put(oob_conf->dev_password,
wpabuf_size(oob_conf->dev_password)),
wpabuf_size(oob_conf->dev_password), pos,
WPS_OOB_DEVICE_PASSWORD_LEN);
return 0;
}
示例15: ndef_parse_records
static struct wpabuf * ndef_parse_records(struct wpabuf *buf,
int (*filter)(struct ndef_record *))
{
struct ndef_record record;
int len = wpabuf_len(buf);
u8 *data = wpabuf_mhead(buf);
while (len > 0) {
if (ndef_parse_record(data, len, &record) < 0) {
wpa_printf(MSG_ERROR, "NDEF : Failed to parse");
return NULL;
}
if (filter == NULL || filter(&record))
return wpabuf_alloc_copy(record.payload,
record.payload_length);
data += record.total_length;
len -= record.total_length;
}
wpa_printf(MSG_ERROR, "NDEF : Record not found");
return NULL;
}