Fix minsize build
authorHenning Rogge <hrogge@gmail.com>
Sat, 25 Jul 2015 08:34:20 +0000 (10:34 +0200)
committerHenning Rogge <hrogge@gmail.com>
Sat, 25 Jul 2015 08:34:20 +0000 (10:34 +0200)
src-plugins/subsystems/CMakeLists.txt
src-plugins/subsystems/os_generic/os_routing_generic_init_half_route_key.c [new file with mode: 0644]
src-plugins/subsystems/os_routing.h

index b1b7976..4e3e793 100644 (file)
@@ -68,6 +68,7 @@ IF(LINUX)
 
     SET(OS_ROUTING_SOURCE    os_generic/os_routing_generic_rt_to_string.c
                              os_generic/os_routing_generic_rtkey_avlcomp.c
+                             os_generic/os_routing_generic_init_half_route_key.c
                              os_linux/os_routing_linux.c)
     SET(OS_ROUTING_INCLUDE   ${OS_ROUTING_INCLUDE}
                              os_linux/os_routing_linux.h)
diff --git a/src-plugins/subsystems/os_generic/os_routing_generic_init_half_route_key.c b/src-plugins/subsystems/os_generic/os_routing_generic_init_half_route_key.c
new file mode 100644 (file)
index 0000000..10b0a85
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * os_routing_generic_init_half_route_key.c
+ *
+ *  Created on: 25.07.2015
+ *      Author: rogge
+ */
+
+#include "common/common_types.h"
+#include "common/netaddr.h"
+
+#include "subsystems/os_routing.h"
+
+/**
+ * Copy one address to 'specific', fill the other one with the
+ * fitting IP_ANY value
+ * @param ipany buffer for IP_ANY
+ * @param specific buffer for source
+ * @param source source IP value to copy
+ */
+void
+os_route_init_half_os_route_key(struct netaddr *ipany,
+    struct netaddr *specific, const struct netaddr *source) {
+  memcpy(specific, source, sizeof(*source));
+  switch (netaddr_get_address_family(source)) {
+    case AF_INET:
+      memcpy(ipany, &NETADDR_IPV4_ANY, sizeof(struct netaddr));
+      break;
+    case AF_INET6:
+      memcpy(ipany, &NETADDR_IPV6_ANY, sizeof(struct netaddr));
+      break;
+    default:
+      netaddr_invalidate(ipany);
+      break;
+  }
+}
index 49f2d74..9bb3618 100644 (file)
@@ -170,39 +170,20 @@ EXPORT const char *os_routing_to_string(
 EXPORT const struct os_route *os_routing_get_wildcard_route(void);
 
 EXPORT int os_route_avl_cmp_route_key(const void *, const void *);
+EXPORT void os_route_init_half_os_route_key(
+    struct netaddr *any, struct netaddr *specific,
+    const struct netaddr *source);
 
-static inline void
+static INLINE void
 os_route_init_sourcespec_prefix(struct os_route_key *prefix,
     const struct netaddr *destination) {
-  memcpy(&prefix->dst, destination, sizeof(*destination));
-  switch (netaddr_get_address_family(destination)) {
-    case AF_INET:
-      memcpy(&prefix->src, &NETADDR_IPV4_ANY, sizeof(struct netaddr));
-      break;
-    case AF_INET6:
-      memcpy(&prefix->src, &NETADDR_IPV6_ANY, sizeof(struct netaddr));
-      break;
-    default:
-      netaddr_invalidate(&prefix->src);
-      break;
-  }
+  os_route_init_half_os_route_key(&prefix->src, &prefix->dst, destination);
 }
 
-static inline void
+static INLINE void
 os_route_init_sourcespec_src_prefix(struct os_route_key *prefix,
     const struct netaddr *source) {
-  memcpy(&prefix->src, source, sizeof(*source));
-  switch (netaddr_get_address_family(source)) {
-    case AF_INET:
-      memcpy(&prefix->dst, &NETADDR_IPV4_ANY, sizeof(struct netaddr));
-      break;
-    case AF_INET6:
-      memcpy(&prefix->dst, &NETADDR_IPV6_ANY, sizeof(struct netaddr));
-      break;
-    default:
-      netaddr_invalidate(&prefix->dst);
-      break;
-  }
+  os_route_init_half_os_route_key(&prefix->dst, &prefix->src, source);
 }