Implement task #14594: Improve consistency of ip route API parameters

reverse parameters of ip4_route_src to be consistent with other ip*_route* functions
This commit will break applications using this function!
This commit is contained in:
Dirk Ziegelmeier 2017-08-08 12:41:19 +02:00
parent 145d6ab5d2
commit 60dd518887
8 changed files with 23 additions and 15 deletions

View File

@ -71,6 +71,11 @@ HISTORY
++ Bugfixes:
2017-08-08: Dirk Ziegelmeier
* ip4_route_src: parameter order is reversed: ip4_route_src(dest, src) -> ip4_route_src(src, dest)
to make parameter order consistent with other ip*_route*() functions
2017-07-26: Simon Goldschmidt
* snmp_msg.c: fix bug #51578 (SNMP failed to decode some values on non 32bit platforms)

View File

@ -10,6 +10,9 @@ with newer versions.
++ Application changes:
* ip4_route_src: parameter order is reversed: ip4_route_src(dest, src) -> ip4_route_src(src, dest)
to make parameter order consistent with other ip*_route*() functions
* pbuf API: pbuf->type (an u8_t holding the enum 'pbuf_type') has changed to only hold a
description of the pbuf (e.g. data following pbuf struct, data volatile, allocation
source heap/pool/etc.). As a consequence, applications can't test pbuf->type any more.

View File

@ -380,7 +380,7 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
{
ip4_addr_t iphdr_dst;
ip4_addr_copy(iphdr_dst, iphdr->dest);
netif = ip4_route_src(&iphdr_dst, &iphdr_src);
netif = ip4_route_src(&iphdr_src, &iphdr_dst);
}
#else
netif = ip4_route(&iphdr_src);

View File

@ -126,11 +126,11 @@ ip4_set_default_multicast_netif(struct netif* default_multicast_netif)
* LWIP_HOOK_IP4_ROUTE_SRC(). This function only provides the parameters.
*/
struct netif *
ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
ip4_route_src(const ip4_addr_t *src, const ip4_addr_t *dest)
{
if (src != NULL) {
/* when src==NULL, the hook is called from ip4_route(dest) */
struct netif *netif = LWIP_HOOK_IP4_ROUTE_SRC(dest, src);
struct netif *netif = LWIP_HOOK_IP4_ROUTE_SRC(src, dest);
if (netif != NULL) {
return netif;
}
@ -196,7 +196,7 @@ ip4_route(const ip4_addr_t *dest)
#endif /* LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF */
#ifdef LWIP_HOOK_IP4_ROUTE_SRC
netif = LWIP_HOOK_IP4_ROUTE_SRC(dest, NULL);
netif = LWIP_HOOK_IP4_ROUTE_SRC(NULL, dest);
if (netif != NULL) {
return netif;
}
@ -287,7 +287,7 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
}
/* Find network interface where to forward this IP packet to. */
netif = ip4_route_src(ip4_current_dest_addr(), ip4_current_src_addr());
netif = ip4_route_src(ip4_current_src_addr(), ip4_current_dest_addr());
if (netif == NULL) {
LWIP_DEBUGF(IP_DEBUG, ("ip4_forward: no forwarding route for %"U16_F".%"U16_F".%"U16_F".%"U16_F" found\n",
ip4_addr1_16(ip4_current_dest_addr()), ip4_addr2_16(ip4_current_dest_addr()),
@ -1006,7 +1006,7 @@ ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p);
if ((netif = ip4_route_src(dest, src)) == NULL) {
if ((netif = ip4_route_src(src, dest)) == NULL) {
LWIP_DEBUGF(IP_DEBUG, ("ip4_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest)));
IP_STATS_INC(ip.rterr);
@ -1044,7 +1044,7 @@ ip4_output_hinted(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p);
if ((netif = ip4_route_src(dest, src)) == NULL) {
if ((netif = ip4_route_src(src, dest)) == NULL) {
LWIP_DEBUGF(IP_DEBUG, ("ip4_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest)));
IP_STATS_INC(ip.rterr);

View File

@ -539,7 +539,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
fails, we try regular routing as though no override was set. */
if (!ip4_addr_isany_val(pcb->mcast_ip4) &&
!ip4_addr_cmp(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) {
netif = ip4_route_src(&pcb->mcast_ip4, ip_2_ip4(&pcb->local_ip));
netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4);
}
}
#endif /* LWIP_IPV4 */

View File

@ -262,7 +262,7 @@ extern struct ip_globals ip_data;
#define ip_route(src, dest) \
(IP_IS_V6(dest) ? \
ip6_route(ip_2_ip6(src), ip_2_ip6(dest)) : \
ip4_route_src(ip_2_ip4(dest), ip_2_ip4(src)))
ip4_route_src(ip_2_ip4(src), ip_2_ip4(dest)))
/**
* @ingroup ip
* Get netif for IP.
@ -287,7 +287,7 @@ err_t ip_input(struct pbuf *p, struct netif *inp);
#define ip_output_if_hdrincl(p, src, dest, netif) \
ip4_output_if(p, src, LWIP_IP_HDRINCL, 0, 0, 0, netif)
#define ip_route(src, dest) \
ip4_route_src(dest, src)
ip4_route_src(src, dest)
#define ip_netif_get_local_ip(netif, dest) \
ip4_netif_get_local_ip(netif)
#define ip_debug_print(is_ipv6, p) ip4_debug_print(p)

View File

@ -64,9 +64,9 @@ extern "C" {
#define ip_init() /* Compatibility define, no init needed. */
struct netif *ip4_route(const ip4_addr_t *dest);
#if LWIP_IPV4_SRC_ROUTING
struct netif *ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src);
struct netif *ip4_route_src(const ip4_addr_t *src, const ip4_addr_t *dest);
#else /* LWIP_IPV4_SRC_ROUTING */
#define ip4_route_src(dest, src) ip4_route(dest)
#define ip4_route_src(src, dest) ip4_route(dest)
#endif /* LWIP_IPV4_SRC_ROUTING */
err_t ip4_input(struct pbuf *p, struct netif *inp);
err_t ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,

View File

@ -2629,10 +2629,10 @@
#endif
/**
* LWIP_HOOK_IP4_ROUTE_SRC(dest, src):
* LWIP_HOOK_IP4_ROUTE_SRC(src, dest):
* Source-based routing for IPv4 - called from ip_route() (IPv4)
* Signature:
* struct netif *my_hook(const ip4_addr_t *dest, const ip4_addr_t *src);
* struct netif *my_hook(const ip4_addr_t *src, const ip4_addr_t *dest);
* Arguments:
* - dest: destination IPv4 address
* - src: local/source IPv4 address
@ -2641,7 +2641,7 @@
* - NULL if no destination netif is found. In that case, ip_route() continues as normal.
*/
#ifdef __DOXYGEN__
#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src)
#define LWIP_HOOK_IP4_ROUTE_SRC(src, dest)
#endif
/**