make netif_ip4_* get accessors return const pointers

This commit is contained in:
Dirk Ziegelmeier 2015-09-23 13:19:56 +02:00 committed by goldsimon
parent e588dfdbce
commit e00e4a6c13
9 changed files with 14 additions and 14 deletions

View File

@ -435,7 +435,7 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
mib2_remove_ip4(netif);
mib2_remove_route_ip4(0, netif);
/* set new IP address to netif */
ip4_addr_set(netif_ip4_addr(netif), ipaddr);
ip4_addr_set(&netif->ip_addr, ipaddr);
mib2_add_ip4(netif);
mib2_add_route_ip4(0, netif);
@ -463,7 +463,7 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
void
netif_set_gw(struct netif *netif, const ip4_addr_t *gw)
{
ip4_addr_set(netif_ip4_gw(netif), gw);
ip4_addr_set(&netif->gw, gw);
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
netif->name[0], netif->name[1],
ip4_addr1_16(netif_ip4_gw(netif)),
@ -486,7 +486,7 @@ netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask)
{
mib2_remove_route_ip4(0, netif);
/* set new netmask to netif */
ip4_addr_set(netif_ip4_netmask(netif), netmask);
ip4_addr_set(&netif->netmask, netmask);
mib2_add_route_ip4(0, netif);
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
netif->name[0], netif->name[1],

View File

@ -237,7 +237,7 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr)
{
err_t err;
struct netif *netif;
ip_addr_t *src_ip;
const ip_addr_t *src_ip;
struct pbuf *q; /* q will be sent down the stack */
s16_t header_size;
const ip_addr_t *dst_ip = ipaddr;

View File

@ -145,7 +145,7 @@ snmp_oidtoip(s32_t *ident, ip4_addr_t *ip)
* @param ident points to s32_t ident[4] output
*/
void
snmp_iptooid(ip4_addr_t *ip, s32_t *ident)
snmp_iptooid(const ip4_addr_t *ip, s32_t *ident)
{
ident[0] = ip4_addr1(ip);
ident[1] = ip4_addr2(ip);

View File

@ -231,7 +231,7 @@ snmp_send_trap(s8_t generic_trap, const struct snmp_obj_id *eoid, s32_t specific
#if LWIP_IPV4 && LWIP_IPV6
ip_addr_t dst_ip_storage;
#endif /* LWIP_IPV4 && LWIP_IPV6 */
ip_addr_t* dst_ip;
const ip_addr_t* dst_ip;
struct pbuf *p;
u16_t i,tot_len;
err_t err = ERR_OK;

View File

@ -777,7 +777,7 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
if (ip_addr_isany(&pcb->local_ip)) {
/* no local IP address set, yet. */
struct netif *netif;
ip_addr_t *local_ip;
const ip_addr_t *local_ip;
ip_route_get_local_ip(PCB_ISIPV6(pcb), &pcb->local_ip, &pcb->remote_ip, netif, local_ip, &local_ip_tmp);
if ((netif == NULL) || (local_ip == NULL)) {
/* Don't even try to send a SYN packet if we have no route

View File

@ -1197,7 +1197,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
/* If we don't have a local IP address, we get one from netif */
if (ip_addr_isany(&pcb->local_ip)) {
ip_addr_t *local_ip = ip_netif_get_local_ip(PCB_ISIPV6(pcb), netif,
const ip_addr_t *local_ip = ip_netif_get_local_ip(PCB_ISIPV6(pcb), netif,
&pcb->remote_ip, &pcb->local_ip);
if (local_ip == NULL) {
return ERR_RTE;

View File

@ -95,8 +95,8 @@ static const ip4_addr_t* ip_2_ip4_c(const ip_addr_t *ipaddr)
IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V6); } while(0)
#define ip_addr_copy(dest, src) do{if(IP_IS_V6_VAL(src)){ \
ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6); }else{ \
ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4); }}while(0)
ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6_c(&(src))); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6); }else{ \
ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4_c(&(src))); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4); }}while(0)
#define ip_addr_copy_from_ip6(dest, src) do{ \
ip6_addr_copy(*ip_2_ip6(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6); }while(0)
#define ip_addr_copy_from_ip4(dest, src) do{ \

View File

@ -349,9 +349,9 @@ void netif_set_default(struct netif *netif);
void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr);
void netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask);
void netif_set_gw(struct netif *netif, const ip4_addr_t *gw);
#define netif_ip4_addr(netif) (&((netif)->ip_addr))
#define netif_ip4_netmask(netif) (&((netif)->netmask))
#define netif_ip4_gw(netif) (&((netif)->gw))
#define netif_ip4_addr(netif) ((const ip4_addr_t*)&((netif)->ip_addr))
#define netif_ip4_netmask(netif) ((const ip4_addr_t*)&((netif)->netmask))
#define netif_ip4_gw(netif) ((const ip4_addr_t*)&((netif)->gw))
#endif /* LWIP_IPV4 */
void netif_set_up(struct netif *netif);

View File

@ -241,7 +241,7 @@ u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value);
void noleafs_set_value(struct obj_def *od, u16_t len, void *value);
void snmp_oidtoip(s32_t *ident, ip4_addr_t *ip);
void snmp_iptooid(ip4_addr_t *ip, s32_t *ident);
void snmp_iptooid(const ip4_addr_t *ip, s32_t *ident);
void snmp_ifindextonetif(s32_t ifindex, struct netif **netif);
void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx);