当前位置: 首页>>代码示例>>C++>>正文


C++ os_memmove函数代码示例

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


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

示例1: p2p_channels_remove_freqs

void p2p_channels_remove_freqs(struct p2p_channels *chan,
			       const struct wpa_freq_range_list *list)
{
	size_t o, c;

	if (list == NULL)
		return;

	o = 0;
	while (o < chan->reg_classes) {
		struct p2p_reg_class *op = &chan->reg_class[o];

		c = 0;
		while (c < op->channels) {
			int freq = p2p_channel_to_freq(op->reg_class,
						       op->channel[c]);
			if (freq > 0 && freq_range_list_includes(list, freq)) {
				op->channels--;
				os_memmove(&op->channel[c],
					   &op->channel[c + 1],
					   op->channels - c);
			} else
				c++;
		}

		if (op->channels == 0) {
			chan->reg_classes--;
			os_memmove(&chan->reg_class[o], &chan->reg_class[o + 1],
				   (chan->reg_classes - o) *
				   sizeof(struct p2p_reg_class));
		} else
			o++;
	}
}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_wpa_supplicant_8,代码行数:34,代码来源:p2p_utils.c

示例2: btchip_decode_base58

unsigned char btchip_decode_base58(unsigned char WIDE *in, unsigned char length,
                                   unsigned char *out,
                                   unsigned char maxoutlen) {
    unsigned char tmp[164];
    unsigned char buffer[164];
    unsigned char i;
    unsigned char j;
    unsigned char startAt;
    unsigned char zeroCount = 0;
    if (length > sizeof(tmp)) {
        THROW(INVALID_PARAMETER);
    }
    os_memmove(tmp, in, length);
    L_DEBUG_BUF(("To decode\n", tmp, length));
    for (i = 0; i < length; i++) {
        if (in[i] > 128) {
            THROW(EXCEPTION);
        }
        tmp[i] = BASE58TABLE[in[i]];
        if (tmp[i] == 0xff) {
            THROW(EXCEPTION);
        }
    }
    while ((zeroCount < length) && (tmp[zeroCount] == 0)) {
        ++zeroCount;
    }
    j = length;
    startAt = zeroCount;
    while (startAt < length) {
        unsigned short remainder = 0;
        unsigned char divLoop;
        for (divLoop = startAt; divLoop < length; divLoop++) {
            unsigned short digit256 = (unsigned short)(tmp[divLoop] & 0xff);
            unsigned short tmpDiv = remainder * 58 + digit256;
            tmp[divLoop] = (unsigned char)(tmpDiv / 256);
            remainder = (tmpDiv % 256);
        }
        if (tmp[startAt] == 0) {
            ++startAt;
        }
        buffer[--j] = (unsigned char)remainder;
    }
    while ((j < length) && (buffer[j] == 0)) {
        ++j;
    }
    length = length - (j - zeroCount);
    if (maxoutlen < length) {
        L_DEBUG_APP(("Decode overflow %d %d\n", length, maxoutlen));
        THROW(EXCEPTION_OVERFLOW);
    }
    os_memmove(out, buffer + j - zeroCount, length);
    L_DEBUG_BUF(("Decoded\n", out, length));
    return length;
}
开发者ID:truekyleo,项目名称:blue-app-btc,代码行数:54,代码来源:btchip_base58.c

示例3: btchip_encode_base58

unsigned char btchip_encode_base58(unsigned char WIDE *in, unsigned char length,
                                   unsigned char *out,
                                   unsigned char maxoutlen) {
    unsigned char tmp[164];
    unsigned char buffer[164];
    unsigned char j;
    unsigned char startAt;
    unsigned char zeroCount = 0;
    if (length > sizeof(tmp)) {
        THROW(INVALID_PARAMETER);
    }
    os_memmove(tmp, in, length);
    L_DEBUG_APP(("Length to encode %d\n", length));
    L_DEBUG_BUF(("To encode\n", tmp, length));
    while ((zeroCount < length) && (tmp[zeroCount] == 0)) {
        ++zeroCount;
    }
    j = 2 * length;
    startAt = zeroCount;
    while (startAt < length) {
        unsigned short remainder = 0;
        unsigned char divLoop;
        for (divLoop = startAt; divLoop < length; divLoop++) {
            unsigned short digit256 = (unsigned short)(tmp[divLoop] & 0xff);
            unsigned short tmpDiv = remainder * 256 + digit256;
            tmp[divLoop] = (unsigned char)(tmpDiv / 58);
            remainder = (tmpDiv % 58);
        }
        if (tmp[startAt] == 0) {
            ++startAt;
        }
        buffer[--j] = (unsigned char)BASE58ALPHABET[remainder];
    }
    while ((j < (2 * length)) && (buffer[j] == BASE58ALPHABET[0])) {
        ++j;
    }
    while (zeroCount-- > 0) {
        buffer[--j] = BASE58ALPHABET[0];
    }
    length = 2 * length - j;
    if (maxoutlen < length) {
        L_DEBUG_APP(("Encode overflow %d %d\n", length, maxoutlen));
        THROW(EXCEPTION_OVERFLOW);
    }
    os_memmove(out, (buffer + j), length);
    L_DEBUG_APP(("Length encoded %d\n", length));
    L_DEBUG_BUF(("Encoded\n", out, length));
    return length;
}
开发者ID:truekyleo,项目名称:blue-app-btc,代码行数:49,代码来源:btchip_base58.c

示例4: eloop_sock_table_remove_sock

static void eloop_sock_table_remove_sock(struct eloop_sock_table *table,
                                         int sock)
{
	int i;

	if (table == NULL || table->table == NULL || table->count == 0)
		return;

	for (i = 0; i < table->count; i++) {
		if (table->table[i].sock == sock)
			break;
	}
	if (i == table->count)
		return;
	eloop_trace_sock_remove_ref(table);
	if (i != table->count - 1) {
		os_memmove(&table->table[i], &table->table[i + 1],
			   (table->count - i - 1) *
			   sizeof(struct eloop_sock));
	}
	table->count--;
	eloop.count--;
	table->changed = 1;
	eloop_trace_sock_add_ref(table);
}
开发者ID:Anuriel,项目名称:wpasupplicant,代码行数:25,代码来源:eloop.c

示例5: encrypt_pw_block_with_password_hash

/**
 * encrypt_pw_block_with_password_hash - EncryptPwBlockWithPasswordHash() - RFC 2759, Sect. 8.10
 * @password: 0-to-256-unicode-char Password (IN; UTF-8)
 * @password_len: Length of password
 * @password_hash: 16-octet PasswordHash (IN)
 * @pw_block: 516-byte PwBlock (OUT)
 * Returns: 0 on success, -1 on failure
 */
int encrypt_pw_block_with_password_hash(
	const u8 *password, size_t password_len,
	const u8 *password_hash, u8 *pw_block)
{
	size_t ucs2_len, offset;
	u8 *pos;

	os_memset(pw_block, 0, PWBLOCK_LEN);

	if (utf8_to_ucs2(password, password_len, pw_block, 512, &ucs2_len) < 0)
		return -1;

	if (ucs2_len > 256)
		return -1;

	offset = (256 - ucs2_len) * 2;
	if (offset != 0) {
		os_memmove(pw_block + offset, pw_block, ucs2_len * 2);
		if (os_get_random(pw_block, offset) < 0)
			return -1;
	}
	/*
	 * PasswordLength is 4 octets, but since the maximum password length is
	 * 256, only first two (in little endian byte order) can be non-zero.
	 */
	pos = &pw_block[2 * 256];
	WPA_PUT_LE16(pos, password_len * 2);
	rc4_skip(password_hash, 16, 0, pw_block, PWBLOCK_LEN);
	return 0;
}
开发者ID:Adrellias,项目名称:mana,代码行数:38,代码来源:ms_funcs.c

示例6: eloop_unregister_read_sock

void eloop_unregister_read_sock(int sock)
{
	size_t i;

	if (eloop.readers == NULL || eloop.reader_count == 0)
		return;

	for (i = 0; i < eloop.reader_count; i++) {
		if (eloop.readers[i].sock == sock)
			break;
	}
	if (i == eloop.reader_count)
		return;

	WSAEventSelect(eloop.readers[i].sock, eloop.readers[i].event, 0);
	WSACloseEvent(eloop.readers[i].event);

	if (i != eloop.reader_count - 1) {
		os_memmove(&eloop.readers[i], &eloop.readers[i + 1],
			   (eloop.reader_count - i - 1) *
			   sizeof(struct eloop_sock));
	}
	eloop.reader_count--;
	eloop.reader_table_changed = 1;
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:25,代码来源:eloop_win.c

示例7: pkcs1_v15_private_key_decrypt

int pkcs1_v15_private_key_decrypt(struct crypto_rsa_key *key,
				  const u8 *in, size_t inlen,
				  u8 *out, size_t *outlen)
{
	int res;
	u8 *pos, *end;

	res = crypto_rsa_exptmod(in, inlen, out, outlen, key, 1);
	if (res)
		return res;

	if (*outlen < 2 || out[0] != 0 || out[1] != 2)
		return -1;

	/* Skip PS (pseudorandom non-zero octets) */
	pos = out + 2;
	end = out + *outlen;
	while (*pos && pos < end)
		pos++;
	if (pos == end)
		return -1;
	pos++;

	*outlen -= pos - out;

	/* Strip PKCS #1 header */
	os_memmove(out, pos, *outlen);

	return 0;
}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:30,代码来源:pkcs1.c

示例8: TMap_Remove

//! removes an Entry from map...
void TMap_Remove(TMap * me, void * key)
{
   void * foundElem;
   BYTE * pToKey;
   int iPos;
   int memsize;
   
   foundElem = TMap_Find(me, key);
   if (!foundElem) return; //???? not in map!!!
   
   //one less
   me->curCountElements--;
   
   //pointer to key is sizelenkey before...
   pToKey = ((BYTE*)foundElem) - me->size_Of_Key;
   
   //calc the current position
   iPos = (pToKey - me->mapfield) / (me->size_Of_Key+ me->size_Of_Value);
   memsize = (me->curCountElements - iPos) * (me->size_Of_Key+ me->size_Of_Value);
   
   
   //copy all memory above to the current pos...
   os_memmove(pToKey, 
              pToKey + me->size_Of_Key + me->size_Of_Value,
              memsize 
              );
}
开发者ID:pi2p,项目名称:libyasdi,代码行数:28,代码来源:minmap.c

示例9: eloop_sock_table_remove_sock

static void eloop_sock_table_remove_sock(struct eloop_sock_table *table,
                                         int sock)
{
	int i;

	if (table == NULL || table->table == NULL || table->count == 0)
		return;

	for (i = 0; i < table->count; i++) {
		if (table->table[i].sock == sock)
			break;
	}
	if (i == table->count)
		return;
	eloop_trace_sock_remove_ref(table);
	if (i != table->count - 1) {
		os_memmove(&table->table[i], &table->table[i + 1],
			   (table->count - i - 1) *
			   sizeof(struct eloop_sock));
	}
	table->count--;
	eloop.count--;
#ifndef CONFIG_ELOOP_EPOLL
	table->changed = 1;
#endif /* CONFIG_ELOOP_EPOLL */
	eloop_trace_sock_add_ref(table);
#ifdef CONFIG_ELOOP_EPOLL
	if (epoll_ctl(eloop.epollfd, EPOLL_CTL_DEL, sock, NULL) < 0) {
		wpa_printf(MSG_ERROR, "%s: epoll_ctl(DEL) for fd=%d "
			   "failed. %s\n", __func__, sock, strerror(errno));
		return;
	}
	os_memset(&eloop.epoll_table[sock], 0, sizeof(struct eloop_sock));
#endif /* CONFIG_ELOOP_EPOLL */
}
开发者ID:asb,项目名称:frankenlibc,代码行数:35,代码来源:eloop.c

示例10: wpa_bss_remove

static void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
                           const char *reason)
{
    if (wpa_s->last_scan_res) {
        unsigned int i;
        for (i = 0; i < wpa_s->last_scan_res_used; i++) {
            if (wpa_s->last_scan_res[i] == bss) {
                os_memmove(&wpa_s->last_scan_res[i],
                           &wpa_s->last_scan_res[i + 1],
                           (wpa_s->last_scan_res_used - i - 1)
                           * sizeof(struct wpa_bss *));
                wpa_s->last_scan_res_used--;
                break;
            }
        }
    }
    wpa_bss_update_pending_connect(wpa_s, bss, NULL);
    dl_list_del(&bss->list);
    dl_list_del(&bss->list_id);
    wpa_s->num_bss--;
    wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Remove id %u BSSID " MACSTR
            " SSID '%s' due to %s", bss->id, MAC2STR(bss->bssid),
            wpa_ssid_txt(bss->ssid, bss->ssid_len), reason);
    wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id);
    wpa_bss_anqp_free(bss->anqp);
    os_free(bss);
}
开发者ID:fengcc,项目名称:chameleon,代码行数:27,代码来源:bss.c

示例11: eap_fast_derive_key

u8 * eap_fast_derive_key(void *ssl_ctx, struct tls_connection *conn,
			 const char *label, size_t len)
{
	struct tls_keys keys;
	u8 *rnd = NULL, *out;
	int block_size;

	block_size = tls_connection_get_keyblock_size(ssl_ctx, conn);
	if (block_size < 0)
		return NULL;

	out = os_malloc(block_size + len);
	if (out == NULL)
		return NULL;

	if (tls_connection_prf(ssl_ctx, conn, label, 1, out, block_size + len)
	    == 0) {
		os_memmove(out, out + block_size, len);
		return out;
	}

	if (tls_connection_get_keys(ssl_ctx, conn, &keys))
		goto fail;

	rnd = os_malloc(keys.client_random_len + keys.server_random_len);
	if (rnd == NULL)
		goto fail;

	os_memcpy(rnd, keys.server_random, keys.server_random_len);
	os_memcpy(rnd + keys.server_random_len, keys.client_random,
		  keys.client_random_len);

	wpa_hexdump_key(MSG_MSGDUMP, "EAP-FAST: master_secret for key "
			"expansion", keys.master_key, keys.master_key_len);
	if (tls_prf(keys.master_key, keys.master_key_len,
		    label, rnd, keys.client_random_len +
		    keys.server_random_len, out, block_size + len))
		goto fail;
	os_free(rnd);
	os_memmove(out, out + block_size, len);
	return out;

fail:
	os_free(rnd);
	os_free(out);
	return NULL;
}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:47,代码来源:eap_fast_common.c

示例12: microrl_backspace

//*****************************************************************************
// remove one char at cursor
static void ICACHE_FLASH_ATTR microrl_backspace (microrl_t * pThis)
{
	if (pThis->cursor > 0) {
		terminal_backspace (pThis);
		os_memmove (pThis->cmdline + pThis->cursor-1,
						 pThis->cmdline + pThis->cursor,
						 pThis->cmdlen-pThis->cursor+1);
		pThis->cursor--;
		pThis->cmdline [pThis->cmdlen] = '\0';
		pThis->cmdlen--;
	}
}
开发者ID:Squonk42,项目名称:nodelua,代码行数:14,代码来源:microrl.c

示例13: eap_sm_process_nak

/**
 * eap_sm_process_nak - Process EAP-Response/Nak
 * @sm: Pointer to EAP state machine allocated with eap_server_sm_init()
 * @nak_list: Nak list (allowed methods) from the supplicant
 * @len: Length of nak_list in bytes
 *
 * This function is called when EAP-Response/Nak is received from the
 * supplicant. This can happen for both phase 1 and phase 2 authentications.
 */
void eap_sm_process_nak(struct eap_sm *sm, const u8 *nak_list, size_t len)
{
    int i;
    size_t j;

    if (sm->user == NULL)
        return;

    wpa_printf(MSG_MSGDUMP, "EAP: processing NAK (current EAP method "
               "index %d)", sm->user_eap_method_index);

    wpa_hexdump(MSG_MSGDUMP, "EAP: configured methods",
                (u8 *) sm->user->methods,
                EAP_MAX_METHODS * sizeof(sm->user->methods[0]));
    wpa_hexdump(MSG_MSGDUMP, "EAP: list of methods supported by the peer",
                nak_list, len);

    i = sm->user_eap_method_index;
    while (i < EAP_MAX_METHODS &&
            (sm->user->methods[i].vendor != EAP_VENDOR_IETF ||
             sm->user->methods[i].method != EAP_TYPE_NONE)) {
        if (sm->user->methods[i].vendor != EAP_VENDOR_IETF)
            goto not_found;
        for (j = 0; j < len; j++) {
            if (nak_list[j] == sm->user->methods[i].method) {
                break;
            }
        }

        if (j < len) {
            /* found */
            i++;
            continue;
        }

not_found:
        /* not found - remove from the list */
        if (i + 1 < EAP_MAX_METHODS) {
            os_memmove(&sm->user->methods[i],
                       &sm->user->methods[i + 1],
                       (EAP_MAX_METHODS - i - 1) *
                       sizeof(sm->user->methods[0]));
        }
        sm->user->methods[EAP_MAX_METHODS - 1].vendor =
            EAP_VENDOR_IETF;
        sm->user->methods[EAP_MAX_METHODS - 1].method = EAP_TYPE_NONE;
    }

    wpa_hexdump(MSG_MSGDUMP, "EAP: new list of configured methods",
                (u8 *) sm->user->methods, EAP_MAX_METHODS *
                sizeof(sm->user->methods[0]));
}
开发者ID:wufuyue,项目名称:TCL_S820,代码行数:61,代码来源:eap_server.c

示例14: eap_eke_shared_secret

int eap_eke_shared_secret(struct eap_eke_session *sess, const u8 *key,
			  const u8 *dhpriv, const u8 *peer_dhcomp)
{
	u8 zeros[EAP_EKE_MAX_HASH_LEN];
	u8 peer_pub[EAP_EKE_MAX_DH_LEN];
	u8 modexp[EAP_EKE_MAX_DH_LEN];
	size_t len;
	const struct dh_group *dh;

	dh = eap_eke_dh_group(sess->dhgroup);
	if (sess->encr != EAP_EKE_ENCR_AES128_CBC || !dh)
		return -1;

	/* Decrypt peer DHComponent */
	os_memcpy(peer_pub, peer_dhcomp + AES_BLOCK_SIZE, dh->prime_len);
	if (aes_128_cbc_decrypt(key, peer_dhcomp, peer_pub, dh->prime_len) < 0) {
		wpa_printf(MSG_INFO, "EAP-EKE: Failed to decrypt DHComponent");
		return -1;
	}
	wpa_hexdump_key(MSG_DEBUG, "EAP-EKE: Decrypted peer DH pubkey",
			peer_pub, dh->prime_len);

	/* SharedSecret = prf(0+, g ^ (x_s * x_p) (mod p)) */
	len = dh->prime_len;
	if (crypto_dh_derive_secret(*dh->generator, dh->prime, dh->prime_len,
				    NULL, 0, dhpriv, dh->prime_len, peer_pub,
				    dh->prime_len, modexp, &len) < 0)
		return -1;
	if (len < dh->prime_len) {
		size_t pad = dh->prime_len - len;
		os_memmove(modexp + pad, modexp, len);
		os_memset(modexp, 0, pad);
	}

	os_memset(zeros, 0, sess->auth_len);
	if (eap_eke_prf(sess->prf, zeros, sess->auth_len, modexp, dh->prime_len,
			NULL, 0, sess->shared_secret) < 0)
		return -1;
	wpa_hexdump_key(MSG_DEBUG, "EAP-EKE: SharedSecret",
			sess->shared_secret, sess->auth_len);

	return 0;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:43,代码来源:eap_eke_common.c

示例15: microrl_insert_text

//*****************************************************************************
// insert len char of text at cursor position
static int ICACHE_FLASH_ATTR microrl_insert_text (microrl_t * pThis, char * text, int len)
{
	int i;
	if (pThis->cmdlen + len < _COMMAND_LINE_LEN) {
		os_memmove (pThis->cmdline + pThis->cursor + len,
						 pThis->cmdline + pThis->cursor,
						 pThis->cmdlen - pThis->cursor);
		for (i = 0; i < len; i++) {
			pThis->cmdline [pThis->cursor + i] = text [i];
			// if (pThis->cmdline [pThis->cursor + i] == ' ') {
			// 	pThis->cmdline [pThis->cursor + i] = 0;
			// }
		}
		pThis->cursor += len;
		pThis->cmdlen += len;
		pThis->cmdline [pThis->cmdlen] = '\0';
		return true;
	}
	return false;
}
开发者ID:Squonk42,项目名称:nodelua,代码行数:22,代码来源:microrl.c


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