diff --git a/doc/NO_SYS_SampleCode.c b/doc/NO_SYS_SampleCode.c index a8dc377b..f20106f5 100644 --- a/doc/NO_SYS_SampleCode.c +++ b/doc/NO_SYS_SampleCode.c @@ -54,7 +54,7 @@ static err_t netif_init(struct netif *netif) netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP; MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, 100000000); - memcpy(netif->hwaddr, your_mac_address_goes_here, sizeof(netif->hwaddr)); + SMEMCPY(netif->hwaddr, your_mac_address_goes_here, sizeof(netif->hwaddr)); netif->hwaddr_len = sizeof(netif->hwaddr); return ERR_OK; diff --git a/src/api/sockets.c b/src/api/sockets.c index 68ff0a51..620e4849 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1829,7 +1829,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) /* write back optlen and optval */ *optlen = LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optlen; #if LWIP_MPU_COMPATIBLE - memcpy(optval, LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval, + MEMCPY(optval, LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval, LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optlen); #endif /* LWIP_MPU_COMPATIBLE */ @@ -2217,7 +2217,7 @@ lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t opt LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optname = optname; LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optlen = optlen; #if LWIP_MPU_COMPATIBLE - memcpy(LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval, optval, optlen); + MEMCPY(LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval, optval, optlen); #else /* LWIP_MPU_COMPATIBLE */ LWIP_SETGETSOCKOPT_DATA_VAR_REF(data).optval.pc = (const void*)optval; #endif /* LWIP_MPU_COMPATIBLE */ diff --git a/src/apps/lwiperf/lwiperf.c b/src/apps/lwiperf/lwiperf.c index 1682f358..fea2c06f 100644 --- a/src/apps/lwiperf/lwiperf.c +++ b/src/apps/lwiperf/lwiperf.c @@ -374,7 +374,7 @@ lwiperf_tx_start(lwiperf_state_tcp_t* conn) return ERR_MEM; } - memcpy(client_conn, conn, sizeof(lwiperf_state_tcp_t)); + MEMCPY(client_conn, conn, sizeof(lwiperf_state_tcp_t)); client_conn->base.server = 0; client_conn->server_pcb = NULL; client_conn->conn_pcb = newpcb; diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index 4cf32ea1..6fc7ce7f 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -322,7 +322,7 @@ mdns_domain_add_label(struct mdns_domain *domain, const char *label, u8_t len) domain->name[domain->length] = len; domain->length++; if (len) { - memcpy(&domain->name[domain->length], label, len); + MEMCPY(&domain->name[domain->length], label, len); domain->length += len; } return ERR_OK; @@ -1256,7 +1256,7 @@ mdns_init_outpacket(struct mdns_outpacket *out, struct mdns_packet *in) /* Copy source IP/port to use when responding unicast, or to choose * which pcb to use for multicast (IPv4/IPv6) */ - memcpy(&out->dest_addr, &in->source_addr, sizeof(ip_addr_t)); + SMEMCPY(&out->dest_addr, &in->source_addr, sizeof(ip_addr_t)); out->dest_port = in->source_port; if (in->source_port != MDNS_PORT) { @@ -1509,7 +1509,7 @@ mdns_announce(struct netif *netif, const ip_addr_t *destination) } announce.dest_port = MDNS_PORT; - memcpy(&announce.dest_addr, destination, sizeof(announce.dest_addr)); + SMEMCPY(&announce.dest_addr, destination, sizeof(announce.dest_addr)); mdns_send_outpacket(&announce); } @@ -1800,7 +1800,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, } memset(&packet, 0, sizeof(packet)); - memcpy(&packet.source_addr, addr, sizeof(packet.source_addr)); + SMEMCPY(&packet.source_addr, addr, sizeof(packet.source_addr)); packet.source_port = port; packet.netif = recv_netif; packet.pbuf = p; @@ -1909,7 +1909,7 @@ mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl) netif->client_data[mdns_netif_client_id] = mdns; memset(mdns, 0, sizeof(struct mdns_host)); - memcpy(&mdns->name, hostname, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(hostname))); + MEMCPY(&mdns->name, hostname, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(hostname))); mdns->dns_ttl = dns_ttl; /* Join multicast groups */ @@ -2016,8 +2016,8 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service memset(srv, 0, sizeof(struct mdns_service)); - memcpy(&srv->name, name, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(name))); - memcpy(&srv->service, service, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(service))); + MEMCPY(&srv->name, name, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(name))); + MEMCPY(&srv->service, service, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(service))); srv->txt_fn = txt_fn; srv->txt_userdata = txt_data; srv->proto = (u16_t)proto; diff --git a/src/apps/netbiosns/netbiosns.c b/src/apps/netbiosns/netbiosns.c index dd01c026..1b1f952e 100644 --- a/src/apps/netbiosns/netbiosns.c +++ b/src/apps/netbiosns/netbiosns.c @@ -346,7 +346,7 @@ netbiosns_set_name(const char* hostname) if (copy_len >= NETBIOS_NAME_LEN) { copy_len = NETBIOS_NAME_LEN - 1; } - memcpy(netbiosns_local_name, hostname, copy_len + 1); + MEMCPY(netbiosns_local_name, hostname, copy_len + 1); } #endif diff --git a/src/apps/snmp/snmp_msg.c b/src/apps/snmp/snmp_msg.c index 6a083ad1..b06266f6 100644 --- a/src/apps/snmp/snmp_msg.c +++ b/src/apps/snmp/snmp_msg.c @@ -1067,7 +1067,7 @@ snmp_prepare_outbound_frame(struct snmp_request *request) /* msgAuthoritativeEngineID */ snmpv3_get_engine_id(&id, &request->msg_authoritative_engine_id_len); - memcpy(request->msg_authoritative_engine_id, id, request->msg_authoritative_engine_id_len); + MEMCPY(request->msg_authoritative_engine_id, id, request->msg_authoritative_engine_id_len); SNMP_ASN1_SET_TLV_PARAMS(tlv, SNMP_ASN1_TYPE_OCTET_STRING, 0, request->msg_authoritative_engine_id_len); OF_BUILD_EXEC(snmp_ans1_enc_tlv(pbuf_stream, &tlv)); OF_BUILD_EXEC(snmp_asn1_enc_raw(pbuf_stream, request->msg_authoritative_engine_id, request->msg_authoritative_engine_id_len)); @@ -1142,7 +1142,7 @@ snmp_prepare_outbound_frame(struct snmp_request *request) /* contextEngineID */ snmpv3_get_engine_id(&id, &request->context_engine_id_len); - memcpy(request->context_engine_id, id, request->context_engine_id_len); + MEMCPY(request->context_engine_id, id, request->context_engine_id_len); SNMP_ASN1_SET_TLV_PARAMS(tlv, SNMP_ASN1_TYPE_OCTET_STRING, 0, request->context_engine_id_len); OF_BUILD_EXEC(snmp_ans1_enc_tlv(pbuf_stream, &tlv)); OF_BUILD_EXEC(snmp_asn1_enc_raw(pbuf_stream, request->context_engine_id, request->context_engine_id_len)); @@ -1519,7 +1519,7 @@ snmp_complete_outbound_frame(struct snmp_request *request) request->outbound_pbuf, 0, request->outbound_pbuf->tot_len)); OF_BUILD_EXEC(snmpv3_auth(&request->outbound_pbuf_stream, frame_size + outbound_padding, key, algo, hmac)); - memcpy(request->msg_authentication_parameters, hmac, SNMP_V3_MAX_AUTH_PARAM_LENGTH); + MEMCPY(request->msg_authentication_parameters, hmac, SNMP_V3_MAX_AUTH_PARAM_LENGTH); OF_BUILD_EXEC(snmp_pbuf_stream_init(&request->outbound_pbuf_stream, request->outbound_pbuf, 0, request->outbound_pbuf->tot_len)); OF_BUILD_EXEC(snmp_pbuf_stream_seek_abs(&request->outbound_pbuf_stream, diff --git a/src/apps/snmp/snmpv3.c b/src/apps/snmp/snmpv3.c index e5dfa321..69fb3a0a 100644 --- a/src/apps/snmp/snmpv3.c +++ b/src/apps/snmp/snmpv3.c @@ -114,8 +114,8 @@ snmpv3_build_priv_param(u8_t* priv_param) priv2 = LWIP_RAND(); } - memcpy(&priv_param[0], &priv1, sizeof(priv1)); - memcpy(&priv_param[4], &priv2, sizeof(priv2)); + SMEMCPY(&priv_param[0], &priv1, sizeof(priv1)); + SMEMCPY(&priv_param[4], &priv2, sizeof(priv2)); /* Emulate 64bit increment */ priv1++; @@ -125,8 +125,8 @@ snmpv3_build_priv_param(u8_t* priv_param) #else /* Based on RFC3414 */ static u32_t ctr; u32_t boots = LWIP_SNMPV3_GET_ENGINE_BOOTS(); - memcpy(&priv_param[0], &boots, 4); - memcpy(&priv_param[4], &ctr, 4); + SMEMCPY(&priv_param[0], &boots, 4); + SMEMCPY(&priv_param[4], &ctr, 4); ctr++; #endif return ERR_OK; diff --git a/src/apps/snmp/snmpv3_mbedtls.c b/src/apps/snmp/snmpv3_mbedtls.c index 2a0598ba..0b1eefb8 100644 --- a/src/apps/snmp/snmpv3_mbedtls.c +++ b/src/apps/snmp/snmpv3_mbedtls.c @@ -192,7 +192,7 @@ snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length, iv_local[4 + 1] = (engine_time >> 16) & 0xFF; iv_local[4 + 2] = (engine_time >> 8) & 0xFF; iv_local[4 + 3] = (engine_time >> 0) & 0xFF; - memcpy(iv_local + 8, priv_param, 8); + SMEMCPY(iv_local + 8, priv_param, 8); if(mbedtls_cipher_set_iv(&ctx, iv_local, LWIP_ARRAYSIZE(iv_local)) != 0) { goto error; } @@ -263,9 +263,9 @@ snmpv3_password_to_key_md5( /* May want to ensure that engineLength <= 32, */ /* otherwise need to use a buffer larger than 64 */ /*****************************************************/ - memcpy(password_buf, key, 16); - memcpy(password_buf + 16, engineID, engineLength); - memcpy(password_buf + 16 + engineLength, key, 16); + SMEMCPY(password_buf, key, 16); + MEMCPY(password_buf + 16, engineID, engineLength); + SMEMCPY(password_buf + 16 + engineLength, key, 16); mbedtls_md5_starts(&MD); mbedtls_md5_update(&MD, password_buf, 32 + engineLength); @@ -316,9 +316,9 @@ snmpv3_password_to_key_sha( /* May want to ensure that engineLength <= 32, */ /* otherwise need to use a buffer larger than 72 */ /*****************************************************/ - memcpy(password_buf, key, 20); - memcpy(password_buf + 20, engineID, engineLength); - memcpy(password_buf + 20 + engineLength, key, 20); + SMEMCPY(password_buf, key, 20); + MEMCPY(password_buf + 20, engineID, engineLength); + SMEMCPY(password_buf + 20 + engineLength, key, 20); mbedtls_sha1_starts(&SH); mbedtls_sha1_update(&SH, password_buf, 40 + engineLength);