[pisa-src] r1783 - in trunk/pisacd: cdconf.c cdmain.c cdservers.c pisacd.conf

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 25 Nov 2009 16:06:47 +0100

Author: tjansen
Date: Wed Nov 25 16:06:46 2009
New Revision: 1783

Log:
Read trustpoint data in cdconf.c rather than cdservers.c.

This removes the last structure in the pisacd.conf. Config file is now a list
of plain key-value pairs. This also prepares code for removal in cdservers.c.

Modified:
   trunk/pisacd/cdconf.c
   trunk/pisacd/cdmain.c
   trunk/pisacd/cdservers.c
   trunk/pisacd/pisacd.conf

Modified: trunk/pisacd/cdconf.c
==============================================================================
--- trunk/pisacd/cdconf.c       Wed Nov 25 15:22:03 2009        (r1782)
+++ trunk/pisacd/cdconf.c       Wed Nov 25 16:06:46 2009        (r1783)
@@ -17,6 +17,7 @@
 #include "cdconf.h"
 #include "libpisa/util.h"
 #include "cdctx.h"
+#include "cdservers.h"
 
 #define PISACD_DEFAULT_IDLE_DISCONNECT_DELAY   600
 #define PISACD_DEFAULT_DEBUGLEVEL              "all"
@@ -193,6 +194,27 @@
 }
 
 /**
+ * Read the trustpoint
+ */
+static void cdconf_read_trustpoint(void)
+{
+       char hit[INET6_ADDRSTRLEN];
+       struct in6_addr addr;
+
+       if (!pisa_cfg_get_string_value("trustpoint", hit, sizeof(hit))) {
+               PISA_ERROR("No trustpoint specified.\n");
+               return;
+       }
+
+       if (inet_pton(AF_INET6, hit, &addr) != 1) {
+               PISA_ERROR("Invalid trustpoint format.\n");
+               return;
+       }
+
+       pisa_server_add(&addr, PISACD_DEFAULT_PORTNUM_CONTROL, 
PISA_CONTYPE_RELAY);
+}
+
+/**
  * Set the global debug level variable
  */
 void cdconf_set_debuglevel(void)
@@ -229,4 +251,9 @@
        cdconf_read_local_ipv4();
        cdconf_read_local_netmask();
        cdconf_read_mode();
+
+       /* Only read the trustpoint if we're in native mode.
+        * cdconf_read_mode has to be called before */
+       if (cd_cfg.flag_native)
+               cdconf_read_trustpoint();
 }

Modified: trunk/pisacd/cdmain.c
==============================================================================
--- trunk/pisacd/cdmain.c       Wed Nov 25 15:22:03 2009        (r1782)
+++ trunk/pisacd/cdmain.c       Wed Nov 25 16:06:46 2009        (r1783)
@@ -289,6 +289,10 @@
        /* Set default values in context and config */
        cdctx_init();
 
+       /* initialize the connection list */
+       cd_ctx.conlist = 
pisa_conmgr_init(pisacd_cleanup_after_removed_connection);
+       cd_ctx.natlist = pisa_nat_init();
+
        /* Set default values in config */
        cdconf_init();
 
@@ -317,8 +321,6 @@
        if (cd_ctx.flag_background)
                pisa_daemonize();
 
-       cd_ctx.natlist = pisa_nat_init();
-
        /* Setup configuration file.
         * This is needed before any cdconf_read_*() operations.
         */
@@ -354,9 +356,6 @@
        pisa_conf_read_file("foo", pisa_cdconf_parse);
 */
 
-       /* initialize the connection list */
-       cd_ctx.conlist = 
pisa_conmgr_init(pisacd_cleanup_after_removed_connection);
-
        pisa_tunnel_configure_main(cd_ctx.ifname_tunnel, &cd_cfg.local_ipv4, 
&cd_cfg.local_netmask, MTU_TUN);
 
        /* Initialize the scheduler */

Modified: trunk/pisacd/cdservers.c
==============================================================================
--- trunk/pisacd/cdservers.c    Wed Nov 25 15:22:03 2009        (r1782)
+++ trunk/pisacd/cdservers.c    Wed Nov 25 16:06:46 2009        (r1783)
@@ -93,17 +93,6 @@
        PISA_DEBUG(PL_CONFIG, "\nParsing %i server block(s):\n", max);
        for (i = 0; i < max; i++)
                pisa_servers_add_block(config_setting_get_elem(servers, i), 
type);
-
-       if (!cd_cfg.flag_native)
-               return;
-
-       servers = pisa_cfg_get_setting("trustpoint");
-       if (servers) {
-               PISA_DEBUG(PL_CONFIG, "Trustpoint:\n");
-               pisa_servers_add_block(servers, PISA_CONTYPE_RELAY);
-       } else {
-               PISA_DEBUG(PL_CONFIG, "No trustpoint defined for this native 
client.\n");
-       }
 }
 
 /**

Modified: trunk/pisacd/pisacd.conf
==============================================================================
--- trunk/pisacd/pisacd.conf    Wed Nov 25 15:22:03 2009        (r1782)
+++ trunk/pisacd/pisacd.conf    Wed Nov 25 16:06:46 2009        (r1783)
@@ -22,30 +22,4 @@
 mode = "native";
 
 # Trust point HIT, only used if we are in "native" mode.
-trustpoint = {
-       hit = "2001:1a:b1b0:aad:f92:15ca:280c:1234";
-};
-
-# A list of all servers we want to connect to.
-servers = (
-       {
-               # HIT is mandatory.
-               hit = "2001:1a:b1b0:aad:f92:15ca:280c:9430";
-
-               # List of NAT mappings for this server. May be omitted, but
-               # this does not make sense for service connections. Each
-               # mapping has two IPv4 addresses, a local one from the
-               # local_ipv4 virtual address space and a remote one from
-               # the servers private address space.
-               services = (
-                       {
-                               local = "192.168.44.17";
-                               remote = "192.168.3.1";
-                       },
-                       {
-                               local = "192.168.44.18";
-                               remote = "192.168.3.13";
-                       }
-               );
-       }
-);
+trustpoint = "2001:1a:b1b0:aad:f92:15ca:280c:1234";

Other related posts:

  • » [pisa-src] r1783 - in trunk/pisacd: cdconf.c cdmain.c cdservers.c pisacd.conf - Thomas Jansen