Use new macro ip_addr_copy where applicable

This commit is contained in:
goldsimon
2010-02-14 12:42:49 +00:00
parent 7e0204bb7b
commit 96e9689dbd
9 changed files with 28 additions and 26 deletions

View File

@@ -184,9 +184,9 @@ icmp_input(struct pbuf *p, struct netif *inp)
/* We generate an answer by switching the dest and src ip addresses,
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
iecho = (struct icmp_echo_hdr *)p->payload;
ip_addr_set(&tmpaddr, &iphdr->src);
ip_addr_set(&iphdr->src, &iphdr->dest);
ip_addr_set(&iphdr->dest, &tmpaddr);
ip_addr_copy(tmpaddr, iphdr->src);
ip_addr_copy(iphdr->src, iphdr->dest);
ip_addr_copy(iphdr->dest, tmpaddr);
ICMPH_TYPE_SET(iecho, ICMP_ER);
/* adjust the checksum */
if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {

View File

@@ -776,7 +776,7 @@ igmp_send(struct igmp_group *group, u8_t type)
{
struct pbuf* p = NULL;
struct igmp_msg* igmp = NULL;
ip_addr_t src = {0};
ip_addr_t src = *IP_ADDR_ANY;
ip_addr_t* dest = NULL;
/* IP header + "router alert" option + IGMP header */
@@ -786,16 +786,16 @@ igmp_send(struct igmp_group *group, u8_t type)
igmp = p->payload;
LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg",
(p->len >= sizeof(struct igmp_msg)));
ip_addr_set(&src, &((group->netif)->ip_addr));
ip_addr_copy(src, group->netif->ip_addr);
if (type == IGMP_V2_MEMB_REPORT) {
dest = &(group->group_address);
ip_addr_set(&(igmp->igmp_group_address), &(group->group_address));
ip_addr_copy(igmp->igmp_group_address, group->group_address);
group->last_reporter_flag = 1; /* Remember we were the last to report */
} else {
if (type == IGMP_LEAVE_GROUP) {
dest = &allrouters;
ip_addr_set(&(igmp->igmp_group_address), &(group->group_address));
ip_addr_copy(igmp->igmp_group_address, group->group_address);
}
}

View File

@@ -558,7 +558,8 @@ err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
IPH_TTL_SET(iphdr, ttl);
IPH_PROTO_SET(iphdr, proto);
ip_addr_set(&(iphdr->dest), dest);
/* dest cannot be NULL here */
ip_addr_copy(iphdr->dest, *dest);
IPH_VHLTOS_SET(iphdr, 4, ip_hlen / 4, tos);
IPH_LEN_SET(iphdr, htons(p->tot_len));
@@ -567,9 +568,10 @@ err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
++ip_id;
if (ip_addr_isany(src)) {
ip_addr_set(&(iphdr->src), &(netif->ip_addr));
ip_addr_copy(iphdr->src, netif->ip_addr);
} else {
ip_addr_set(&(iphdr->src), src);
/* src cannot be NULL here */
ip_addr_copy(iphdr->src, *src);
}
IPH_CHKSUM_SET(iphdr, 0);