gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28231 - in gnunet/src: exit include tun


From: gnunet
Subject: [GNUnet-SVN] r28231 - in gnunet/src: exit include tun
Date: Mon, 22 Jul 2013 09:16:58 +0200

Author: grothoff
Date: 2013-07-22 09:16:58 +0200 (Mon, 22 Jul 2013)
New Revision: 28231

Modified:
   gnunet/src/exit/gnunet-daemon-exit.c
   gnunet/src/include/gnunet_tun_lib.h
   gnunet/src/tun/regex.c
Log:
-move all code that deals with IP/policy to regex/string conversion to tun

Modified: gnunet/src/exit/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/exit/gnunet-daemon-exit.c        2013-07-21 16:40:32 UTC (rev 
28230)
+++ gnunet/src/exit/gnunet-daemon-exit.c        2013-07-22 07:16:58 UTC (rev 
28231)
@@ -3331,6 +3331,7 @@
   unsigned int app_idx;
   char *exit_ifname;
   char *tun_ifname;
+  char *policy;
   char *ipv6addr;
   char *ipv6prefix_s;
   char *ipv4addr;
@@ -3565,40 +3566,54 @@
   /* Mesh handle acquired, now announce regular expressions matching our exit 
*/
   if ( (GNUNET_YES == ipv4_enabled) && (GNUNET_YES == ipv4_exit) )
   {
+    policy = NULL;
     if (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_string (cfg,
                                                "exit",
                                                "EXIT_RANGE_IPV4_REGEX",
-                                               &regex))
-      regex = GNUNET_strdup ("(0|1)*");
-    (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
-                            GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
-                            "4", regex);
-    regex4 = GNUNET_REGEX_announce (cfg,                           
-                                   prefixed_regex,
-                                   REGEX_REFRESH_FREQUENCY,
-                                   REGEX_MAX_PATH_LEN_IPV4);
-    GNUNET_free (regex);
-    GNUNET_free (prefixed_regex);
+                                               &policy))
+      regex = NULL;
+    else
+      regex = GNUNET_TUN_ipv4policy2regex (policy);
+    GNUNET_free_non_null (policy);
+    if (NULL != regex)
+    {
+      (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
+                             GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+                             "4", regex);
+      regex4 = GNUNET_REGEX_announce (cfg,                         
+                                     prefixed_regex,
+                                     REGEX_REFRESH_FREQUENCY,
+                                     REGEX_MAX_PATH_LEN_IPV4);
+      GNUNET_free (regex);
+      GNUNET_free (prefixed_regex);    
+    }
   }
 
   if (GNUNET_YES == ipv6_enabled && GNUNET_YES == ipv6_exit)
   {
+    policy = NULL;
     if (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_string (cfg,
                                                "exit",
                                                "EXIT_RANGE_IPV6_REGEX",
-                                               &regex))
-      regex = GNUNET_strdup ("(0|1)*");
-    (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
-                            GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
-                            "6", regex);
-    regex6 = GNUNET_REGEX_announce (cfg,
-                                   prefixed_regex,
-                                   REGEX_REFRESH_FREQUENCY,
-                                   REGEX_MAX_PATH_LEN_IPV6);
-    GNUNET_free (regex);
-    GNUNET_free (prefixed_regex);
+                                               &policy))
+      regex = NULL;
+    else
+      regex = GNUNET_TUN_ipv6policy2regex (policy);
+    GNUNET_free_non_null (policy);      
+    if (NULL != regex)
+    {
+      (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
+                             GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+                             "6", regex);
+      regex6 = GNUNET_REGEX_announce (cfg,
+                                     prefixed_regex,
+                                     REGEX_REFRESH_FREQUENCY,
+                                     REGEX_MAX_PATH_LEN_IPV6);
+      GNUNET_free (regex);
+      GNUNET_free (prefixed_regex);
+    }
   }
   if ((ipv4_exit) || (ipv6_exit))
     helper_handle = GNUNET_HELPER_start (GNUNET_NO,

Modified: gnunet/src/include/gnunet_tun_lib.h
===================================================================
--- gnunet/src/include/gnunet_tun_lib.h 2013-07-21 16:40:32 UTC (rev 28230)
+++ gnunet/src/include/gnunet_tun_lib.h 2013-07-22 07:16:58 UTC (rev 28231)
@@ -455,5 +455,30 @@
                        unsigned int prefixlen, char *rxstr);
 
 
+/**
+ * Convert an exit policy to a regular expression.  The exit policy
+ * specifies a set of subnets this peer is willing to serve as an
+ * exit for; the resulting regular expression will match the
+ * IPv6 address strings as returned by 'GNUNET_TUN_ipv6toregex'.
+ *
+ * @param policy exit policy specification
+ * @return regular expression, NULL on error
+ */
+char *
+GNUNET_TUN_ipv6policy2regex (const char *policy);
 
+
+/**
+ * Convert an exit policy to a regular expression.  The exit policy
+ * specifies a set of subnets this peer is willing to serve as an
+ * exit for; the resulting regular expression will match the
+ * IPv4 address strings as returned by 'GNUNET_TUN_ipv4toregex'.
+ *
+ * @param policy exit policy specification
+ * @return regular expression, NULL on error
+ */
+char *
+GNUNET_TUN_ipv4policy2regex (const char *policy);
+
+
 #endif

Modified: gnunet/src/tun/regex.c
===================================================================
--- gnunet/src/tun/regex.c      2013-07-21 16:40:32 UTC (rev 28230)
+++ gnunet/src/tun/regex.c      2013-07-22 07:16:58 UTC (rev 28231)
@@ -138,4 +138,37 @@
       strcat (rxstr, "(0|1)+");
 }
 
+
+/**
+ * Convert an exit policy to a regular expression.  The exit policy
+ * specifies a set of subnets this peer is willing to serve as an
+ * exit for; the resulting regular expression will match the
+ * IPv4 address strings as returned by 'GNUNET_TUN_ipv4toregex'.
+ *
+ * @param policy exit policy specification
+ * @return regular expression, NULL on error
+ */
+char *
+GNUNET_TUN_ipv4policy2regex (const char *policy)
+{
+  return GNUNET_strdup (policy);
+}
+
+
+/**
+ * Convert an exit policy to a regular expression.  The exit policy
+ * specifies a set of subnets this peer is willing to serve as an
+ * exit for; the resulting regular expression will match the
+ * IPv4 address strings as returned by 'GNUNET_TUN_ipv4toregex'.
+ *
+ * @param policy exit policy specification
+ * @return regular expression, NULL on error
+ */
+char *
+GNUNET_TUN_ipv6policy2regex (const char *policy)
+{
+  return GNUNET_strdup (policy);
+}
+
+
 /* end of regex.c */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]