mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-16 08:43:17 +00:00
Use new macro ip_addr_copy where applicable
This commit is contained in:
parent
7e0204bb7b
commit
96e9689dbd
@ -246,7 +246,7 @@ dhcp_handle_offer(struct netif *netif)
|
|||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n",
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n",
|
||||||
ip4_addr_get_u32(&dhcp->server_ip_addr)));
|
ip4_addr_get_u32(&dhcp->server_ip_addr)));
|
||||||
/* remember offered address */
|
/* remember offered address */
|
||||||
ip_addr_set(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr);
|
ip_addr_copy(dhcp->offered_ip_addr, dhcp->msg_in->yiaddr);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n",
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n",
|
||||||
ip4_addr_get_u32(&dhcp->offered_ip_addr)));
|
ip4_addr_get_u32(&dhcp->offered_ip_addr)));
|
||||||
|
|
||||||
@ -535,12 +535,12 @@ dhcp_handle_ack(struct netif *netif)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* (y)our internet address */
|
/* (y)our internet address */
|
||||||
ip_addr_set(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr);
|
ip_addr_copy(dhcp->offered_ip_addr, dhcp->msg_in->yiaddr);
|
||||||
|
|
||||||
#if LWIP_DHCP_BOOTP_FILE
|
#if LWIP_DHCP_BOOTP_FILE
|
||||||
/* copy boot server address,
|
/* copy boot server address,
|
||||||
boot file name copied in dhcp_parse_reply if not overloaded */
|
boot file name copied in dhcp_parse_reply if not overloaded */
|
||||||
ip_addr_set(&dhcp->offered_si_addr, &dhcp->msg_in->siaddr);
|
ip_addr_copy(dhcp->offered_si_addr, dhcp->msg_in->siaddr);
|
||||||
#endif /* LWIP_DHCP_BOOTP_FILE */
|
#endif /* LWIP_DHCP_BOOTP_FILE */
|
||||||
|
|
||||||
/* subnet mask given? */
|
/* subnet mask given? */
|
||||||
@ -942,10 +942,10 @@ dhcp_bind(struct netif *netif)
|
|||||||
|
|
||||||
if (dhcp->subnet_mask_given) {
|
if (dhcp->subnet_mask_given) {
|
||||||
/* copy offered network mask */
|
/* copy offered network mask */
|
||||||
ip_addr_set(&sn_mask, &dhcp->offered_sn_mask);
|
ip_addr_copy(sn_mask, dhcp->offered_sn_mask);
|
||||||
} else {
|
} else {
|
||||||
/* subnet mask not given, choose a safe subnet mask given the network class */
|
/* subnet mask not given, choose a safe subnet mask given the network class */
|
||||||
u8_t first_octet = (u8_t)ip4_addr1_16(&dhcp->offered_ip_addr);
|
u8_t first_octet = ip4_addr1(&dhcp->offered_ip_addr);
|
||||||
if (first_octet <= 127) {
|
if (first_octet <= 127) {
|
||||||
ip4_addr_set_u32(&sn_mask, htonl(0xff000000));
|
ip4_addr_set_u32(&sn_mask, htonl(0xff000000));
|
||||||
} else if (first_octet >= 192) {
|
} else if (first_octet >= 192) {
|
||||||
@ -955,7 +955,7 @@ dhcp_bind(struct netif *netif)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_addr_set(&gw_addr, &dhcp->offered_gw_addr);
|
ip_addr_copy(gw_addr, dhcp->offered_gw_addr);
|
||||||
/* gateway address not given? */
|
/* gateway address not given? */
|
||||||
if (ip_addr_isany(&gw_addr)) {
|
if (ip_addr_isany(&gw_addr)) {
|
||||||
/* copy network address */
|
/* copy network address */
|
||||||
@ -1665,7 +1665,7 @@ dhcp_create_request(struct netif *netif, struct dhcp *dhcp)
|
|||||||
dhcp->msg_out->flags = 0;
|
dhcp->msg_out->flags = 0;
|
||||||
ip_addr_set_zero(&dhcp->msg_out->ciaddr);
|
ip_addr_set_zero(&dhcp->msg_out->ciaddr);
|
||||||
if (dhcp->state==DHCP_BOUND || dhcp->state==DHCP_RENEWING || dhcp->state==DHCP_REBINDING) {
|
if (dhcp->state==DHCP_BOUND || dhcp->state==DHCP_RENEWING || dhcp->state==DHCP_REBINDING) {
|
||||||
ip_addr_set(&dhcp->msg_out->ciaddr, &netif->ip_addr);
|
ip_addr_copy(dhcp->msg_out->ciaddr, netif->ip_addr);
|
||||||
}
|
}
|
||||||
ip_addr_set_zero(&dhcp->msg_out->yiaddr);
|
ip_addr_set_zero(&dhcp->msg_out->yiaddr);
|
||||||
ip_addr_set_zero(&dhcp->msg_out->siaddr);
|
ip_addr_set_zero(&dhcp->msg_out->siaddr);
|
||||||
|
@ -184,9 +184,9 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
/* We generate an answer by switching the dest and src ip addresses,
|
/* We generate an answer by switching the dest and src ip addresses,
|
||||||
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
|
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
|
||||||
iecho = (struct icmp_echo_hdr *)p->payload;
|
iecho = (struct icmp_echo_hdr *)p->payload;
|
||||||
ip_addr_set(&tmpaddr, &iphdr->src);
|
ip_addr_copy(tmpaddr, iphdr->src);
|
||||||
ip_addr_set(&iphdr->src, &iphdr->dest);
|
ip_addr_copy(iphdr->src, iphdr->dest);
|
||||||
ip_addr_set(&iphdr->dest, &tmpaddr);
|
ip_addr_copy(iphdr->dest, tmpaddr);
|
||||||
ICMPH_TYPE_SET(iecho, ICMP_ER);
|
ICMPH_TYPE_SET(iecho, ICMP_ER);
|
||||||
/* adjust the checksum */
|
/* adjust the checksum */
|
||||||
if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
|
if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
|
||||||
|
@ -776,7 +776,7 @@ igmp_send(struct igmp_group *group, u8_t type)
|
|||||||
{
|
{
|
||||||
struct pbuf* p = NULL;
|
struct pbuf* p = NULL;
|
||||||
struct igmp_msg* igmp = NULL;
|
struct igmp_msg* igmp = NULL;
|
||||||
ip_addr_t src = {0};
|
ip_addr_t src = *IP_ADDR_ANY;
|
||||||
ip_addr_t* dest = NULL;
|
ip_addr_t* dest = NULL;
|
||||||
|
|
||||||
/* IP header + "router alert" option + IGMP header */
|
/* IP header + "router alert" option + IGMP header */
|
||||||
@ -786,16 +786,16 @@ igmp_send(struct igmp_group *group, u8_t type)
|
|||||||
igmp = p->payload;
|
igmp = p->payload;
|
||||||
LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg",
|
LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg",
|
||||||
(p->len >= sizeof(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) {
|
if (type == IGMP_V2_MEMB_REPORT) {
|
||||||
dest = &(group->group_address);
|
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 */
|
group->last_reporter_flag = 1; /* Remember we were the last to report */
|
||||||
} else {
|
} else {
|
||||||
if (type == IGMP_LEAVE_GROUP) {
|
if (type == IGMP_LEAVE_GROUP) {
|
||||||
dest = &allrouters;
|
dest = &allrouters;
|
||||||
ip_addr_set(&(igmp->igmp_group_address), &(group->group_address));
|
ip_addr_copy(igmp->igmp_group_address, group->group_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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_TTL_SET(iphdr, ttl);
|
||||||
IPH_PROTO_SET(iphdr, proto);
|
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_VHLTOS_SET(iphdr, 4, ip_hlen / 4, tos);
|
||||||
IPH_LEN_SET(iphdr, htons(p->tot_len));
|
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;
|
++ip_id;
|
||||||
|
|
||||||
if (ip_addr_isany(src)) {
|
if (ip_addr_isany(src)) {
|
||||||
ip_addr_set(&(iphdr->src), &(netif->ip_addr));
|
ip_addr_copy(iphdr->src, netif->ip_addr);
|
||||||
} else {
|
} else {
|
||||||
ip_addr_set(&(iphdr->src), src);
|
/* src cannot be NULL here */
|
||||||
|
ip_addr_copy(iphdr->src, *src);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPH_CHKSUM_SET(iphdr, 0);
|
IPH_CHKSUM_SET(iphdr, 0);
|
||||||
|
@ -230,10 +230,10 @@ snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap)
|
|||||||
if ((td->enable != 0) && !ip_addr_isany(&td->dip))
|
if ((td->enable != 0) && !ip_addr_isany(&td->dip))
|
||||||
{
|
{
|
||||||
/* network order trap destination */
|
/* network order trap destination */
|
||||||
ip_addr_set(&trap_msg.dip, &td->dip);
|
ip_addr_copy(trap_msg.dip, td->dip);
|
||||||
/* lookup current source address for this dst */
|
/* lookup current source address for this dst */
|
||||||
dst_if = ip_route(&td->dip);
|
dst_if = ip_route(&td->dip);
|
||||||
ip_addr_set(&dst_ip, &dst_if->ip_addr);
|
ip_addr_copy(dst_ip, dst_if->ip_addr);
|
||||||
/* @todo: what about IPv6? */
|
/* @todo: what about IPv6? */
|
||||||
trap_msg.sip_raw[0] = ip4_addr1(&dst_ip);
|
trap_msg.sip_raw[0] = ip4_addr1(&dst_ip);
|
||||||
trap_msg.sip_raw[1] = ip4_addr2(&dst_ip);
|
trap_msg.sip_raw[1] = ip4_addr2(&dst_ip);
|
||||||
|
@ -232,8 +232,8 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
|
|||||||
} else {
|
} else {
|
||||||
seqno = pcb->snd_nxt;
|
seqno = pcb->snd_nxt;
|
||||||
ackno = pcb->rcv_nxt;
|
ackno = pcb->rcv_nxt;
|
||||||
ip_addr_set(&local_ip, &(pcb->local_ip));
|
ip_addr_copy(local_ip, pcb->local_ip);
|
||||||
ip_addr_set(&remote_ip, &(pcb->remote_ip));
|
ip_addr_copy(remote_ip, pcb->remote_ip);
|
||||||
local_port = pcb->local_port;
|
local_port = pcb->local_port;
|
||||||
remote_port = pcb->remote_port;
|
remote_port = pcb->remote_port;
|
||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
@ -391,7 +391,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
|||||||
lpcb->so_options |= SOF_ACCEPTCONN;
|
lpcb->so_options |= SOF_ACCEPTCONN;
|
||||||
lpcb->ttl = pcb->ttl;
|
lpcb->ttl = pcb->ttl;
|
||||||
lpcb->tos = pcb->tos;
|
lpcb->tos = pcb->tos;
|
||||||
ip_addr_set(&lpcb->local_ip, &pcb->local_ip);
|
ip_addr_copy(lpcb->local_ip, pcb->local_ip);
|
||||||
TCP_RMV(&tcp_bound_pcbs, pcb);
|
TCP_RMV(&tcp_bound_pcbs, pcb);
|
||||||
memp_free(MEMP_TCP_PCB, pcb);
|
memp_free(MEMP_TCP_PCB, pcb);
|
||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
|
@ -433,9 +433,9 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
|||||||
pcb->accepts_pending++;
|
pcb->accepts_pending++;
|
||||||
#endif /* TCP_LISTEN_BACKLOG */
|
#endif /* TCP_LISTEN_BACKLOG */
|
||||||
/* Set up the new PCB. */
|
/* Set up the new PCB. */
|
||||||
ip_addr_set(&(npcb->local_ip), &(iphdr->dest));
|
ip_addr_copy(npcb->local_ip, iphdr->dest);
|
||||||
npcb->local_port = pcb->local_port;
|
npcb->local_port = pcb->local_port;
|
||||||
ip_addr_set(&(npcb->remote_ip), &(iphdr->src));
|
ip_addr_copy(npcb->remote_ip, iphdr->src);
|
||||||
npcb->remote_port = tcphdr->src;
|
npcb->remote_port = tcphdr->src;
|
||||||
npcb->state = SYN_RCVD;
|
npcb->state = SYN_RCVD;
|
||||||
npcb->rcv_nxt = seqno + 1;
|
npcb->rcv_nxt = seqno + 1;
|
||||||
|
@ -703,7 +703,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
|||||||
if (netif == NULL) {
|
if (netif == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ip_addr_set(&(pcb->local_ip), &(netif->ip_addr));
|
ip_addr_copy(pcb->local_ip, netif->ip_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set retransmission timer running if it is not currently enabled */
|
/* Set retransmission timer running if it is not currently enabled */
|
||||||
|
@ -407,7 +407,7 @@ find_entry(ip_addr_t *ipaddr, u8_t flags)
|
|||||||
/* IP address given? */
|
/* IP address given? */
|
||||||
if (ipaddr != NULL) {
|
if (ipaddr != NULL) {
|
||||||
/* set IP address */
|
/* set IP address */
|
||||||
ip_addr_set(&arp_table[i].ipaddr, ipaddr);
|
ip_addr_copy(arp_table[i].ipaddr, *ipaddr);
|
||||||
}
|
}
|
||||||
arp_table[i].ctime = 0;
|
arp_table[i].ctime = 0;
|
||||||
#if LWIP_NETIF_HWADDRHINT
|
#if LWIP_NETIF_HWADDRHINT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user