Эх сурвалжийг харах

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!

Dirk Ziegelmeier 8 жил өмнө
parent
commit
60dd518887

+ 5 - 0
CHANGELOG

@@ -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)
 

+ 3 - 0
UPGRADING

@@ -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.

+ 1 - 1
src/core/ipv4/icmp.c

@@ -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);

+ 6 - 6
src/core/ipv4/ip4.c

@@ -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);

+ 1 - 1
src/core/udp.c

@@ -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 */

+ 2 - 2
src/include/lwip/ip.h

@@ -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)

+ 2 - 2
src/include/lwip/ip4.h

@@ -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,

+ 3 - 3
src/include/lwip/opt.h

@@ -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
 
 /**