Browse code

Merged add_bypass_address() and add_host_route_if_nonlocal()

The add_host_route_if_nonlocal() function is too simple to really
benefit from calling add_bypass_address() when this function is the
only caller to this function.

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: Peter Stuge <peter@stuge.se>

David Sommerseth authored on 2010/11/15 17:00:12
Showing 1 changed files
... ...
@@ -59,26 +59,6 @@ print_bypass_addresses (const struct route_bypass *rb)
59 59
 
60 60
 #endif
61 61
 
62
-static bool
63
-add_bypass_address (struct route_bypass *rb, const in_addr_t a)
64
-{
65
-  int i;
66
-  for (i = 0; i < rb->n_bypass; ++i)
67
-    {
68
-      if (a == rb->bypass[i]) /* avoid duplicates */
69
-	return true;
70
-    }
71
-  if (rb->n_bypass < N_ROUTE_BYPASS)
72
-    {
73
-      rb->bypass[rb->n_bypass++] = a;
74
-      return true;
75
-    }
76
-  else
77
-    {
78
-      return false;
79
-    }
80
-}
81
-
82 62
 struct route_option_list *
83 63
 new_route_option_list (const int max_routes, struct gc_arena *a)
84 64
 {
... ...
@@ -2124,8 +2104,18 @@ netmask_to_netbits (const in_addr_t network, const in_addr_t netmask, int *netbi
2124 2124
 static void
2125 2125
 add_host_route_if_nonlocal (struct route_bypass *rb, const in_addr_t addr)
2126 2126
 {
2127
-  if (test_local_addr(addr) == TLA_NONLOCAL && addr != 0 && addr != ~0)
2128
-    add_bypass_address (rb, addr);
2127
+  if (test_local_addr(addr) == TLA_NONLOCAL && addr != 0 && addr != ~0) {
2128
+    int i;
2129
+    for (i = 0; i < rb->n_bypass; ++i)
2130
+      {
2131
+        if (addr == rb->bypass[i]) /* avoid duplicates */
2132
+          return;
2133
+      }
2134
+    if (rb->n_bypass < N_ROUTE_BYPASS)
2135
+      {
2136
+        rb->bypass[rb->n_bypass++] = addr;
2137
+      }
2138
+  }
2129 2139
 }
2130 2140
 
2131 2141
 static void