[pisa-src] r1834 - in trunk: libpisa/pisaconf.c libpisa/pisaconf.h pisacd/cdconfhandlers.c pisacd/cdmain.c pisacd/pisacdconf.c pisacd/pisaconftool.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 17:57:34 +0100

Author: tjansen
Date: Thu Nov 26 17:57:34 2009
New Revision: 1834

Log:
Removed the "server" command from pisacdconf.

Service can create a new connection now.

Modified:
   trunk/libpisa/pisaconf.c
   trunk/libpisa/pisaconf.h
   trunk/pisacd/cdconfhandlers.c
   trunk/pisacd/cdmain.c
   trunk/pisacd/pisacdconf.c
   trunk/pisacd/pisaconftool.c

Modified: trunk/libpisa/pisaconf.c
==============================================================================
--- trunk/libpisa/pisaconf.c    Thu Nov 26 17:52:49 2009        (r1833)
+++ trunk/libpisa/pisaconf.c    Thu Nov 26 17:57:34 2009        (r1834)
@@ -45,9 +45,6 @@
                case PISA_CONF_REQUEST_DEBUGMASK:
                        f = conf_handle_func_set.debugmask;
                        break;
-               case PISA_CONF_REQUEST_SERVER_ADD:
-                       f = conf_handle_func_set.serveradd;
-                       break;
                case PISA_CONF_REQUEST_SERVICE_ADD:
                        f = conf_handle_func_set.serviceadd;
                        break;

Modified: trunk/libpisa/pisaconf.h
==============================================================================
--- trunk/libpisa/pisaconf.h    Thu Nov 26 17:52:49 2009        (r1833)
+++ trunk/libpisa/pisaconf.h    Thu Nov 26 17:57:34 2009        (r1834)
@@ -22,8 +22,7 @@
 #define PISA_CONF_REQUEST_RELOAD_CONF  1
 #define PISA_CONF_REQUEST_DEBUGLEVEL   2
 #define PISA_CONF_REQUEST_DEBUGMASK    3
-#define PISA_CONF_REQUEST_SERVER_ADD   4
-#define PISA_CONF_REQUEST_SERVICE_ADD  5
+#define PISA_CONF_REQUEST_SERVICE_ADD  4
 
 #define PISA_CONF_PORT_SD 5005
 #define PISA_CONF_PORT_CD 5006
@@ -42,11 +41,6 @@
 } __attribute__ ((packed)) pisa_conf_debugmask;
 
 typedef struct {
-       uint8_t type; /* use PISA_CONTYPE_* */
-       struct in6_addr hit;
-} __attribute__ ((packed)) pisa_conf_serveradd;
-
-typedef struct {
        struct in6_addr hit;
        struct in_addr local;
        struct in_addr remote;
@@ -61,7 +55,6 @@
        union {
                pisa_conf_debuglevel debuglevel;
                pisa_conf_debugmask debugmask;
-               pisa_conf_serveradd serveradd;
                pisa_conf_serviceadd serviceadd;
        } rdata;
 } __attribute__ ((packed)) pisa_conf_request;
@@ -89,7 +82,6 @@
        pisa_conf_handle_cb reload_conf;
        pisa_conf_handle_cb debuglevel;
        pisa_conf_handle_cb debugmask;
-       pisa_conf_handle_cb serveradd;
        pisa_conf_handle_cb serviceadd;
 } pisa_conf_handle_func_set;
 

Modified: trunk/pisacd/cdconfhandlers.c
==============================================================================
--- trunk/pisacd/cdconfhandlers.c       Thu Nov 26 17:52:49 2009        (r1833)
+++ trunk/pisacd/cdconfhandlers.c       Thu Nov 26 17:57:34 2009        (r1834)
@@ -24,27 +24,10 @@
 #include "libpisa/nat.h"
 #include "cdconfhandlers.h"
 #include "cdctx.h"
+#include "cdconf.h"
 #include "cdservers.h"
 
 /**
- * Handle a pisacdconf server add request.
- * @param packet config command packet containing the parameters
- */
-void pisa_cdconf_cb_server_add(pisa_conf_packet *packet)
-{
-       pisa_conf_serveradd *serveradd;
-       pisa_conmgr_entry *entry;
-
-       assert(packet);
-       serveradd = &packet->body.request.rdata.serveradd;
-
-       entry = pisa_conmgr_add(cd_ctx.conlist, &serveradd->hit, 
PISACD_DEFAULT_PORTNUM_CONTROL, serveradd->type);
-
-       if (!entry)
-               PISA_ERROR("Failed to handle a server add request.\n");
-}
-
-/**
  * Handle a pisacdconf service add request.
  * @param packet config command packet containing the parameters
  */
@@ -56,10 +39,13 @@
        assert(packet);
        serviceadd = &packet->body.request.rdata.serviceadd;
 
-       if ((entry = pisa_conmgr_findby_hit(cd_ctx.conlist, &serviceadd->hit)) 
== NULL) {
-               PISA_ERROR("Request to add a service with nonexisting server 
HIT.\n");
-               return;
+       if (!(entry = pisa_conmgr_findby_hit(cd_ctx.conlist, 
&serviceadd->hit))) {
+               pisa_contype type = cd_cfg.flag_native ? PISA_CONTYPE_SERVICE : 
PISA_CONTYPE_LEGACY_ROUTER;
+               entry = pisa_conmgr_add(cd_ctx.conlist, &serviceadd->hit, 
PISASD_DEFAULT_PORTNUM_CONTROL, type);
        }
 
+       if (!entry)
+               return;
+
        pisa_nat_add_mapping(cd_ctx.natlist, &serviceadd->local, 
&serviceadd->remote, entry, NULL);
 }

Modified: trunk/pisacd/cdmain.c
==============================================================================
--- trunk/pisacd/cdmain.c       Thu Nov 26 17:52:49 2009        (r1833)
+++ trunk/pisacd/cdmain.c       Thu Nov 26 17:57:34 2009        (r1834)
@@ -344,7 +344,6 @@
        memset(&conf_handle_func_set, 0, sizeof(conf_handle_func_set));
        conf_handle_func_set.debuglevel = pisa_conf_cb_debuglevel;
        conf_handle_func_set.debugmask = pisa_conf_cb_debugmask;
-       conf_handle_func_set.serveradd = pisa_cdconf_cb_server_add;
        conf_handle_func_set.serviceadd = pisa_cdconf_cb_service_add;
 
 /* TODO: Read a config file, long term goal is to replace libconfig.

Modified: trunk/pisacd/pisacdconf.c
==============================================================================
--- trunk/pisacd/pisacdconf.c   Thu Nov 26 17:52:49 2009        (r1833)
+++ trunk/pisacd/pisacdconf.c   Thu Nov 26 17:57:34 2009        (r1834)
@@ -26,49 +26,6 @@
 #include "pisacdconf.h"
 
 /**
- * Parse a pisacdconf server line and send out a packet to the client daemon.
- * @param argc number of arguments
- * @param argv array of arguments
- * @return 0 on success, 1 on general error, 2 on specific error.
- */
-static int pisa_cdconf_parse_server(int argc, char *argv[])
-{
-       pisa_conf_packet *packet;
-       pisa_conf_serveradd *serveradd;
-
-       if (argc != 2) {
-               PISA_ERROR("'server' needs 2 arguments.\n");
-               return 2;
-       }
-
-       packet = pisa_conf_packet_new_request();
-       serveradd = &packet->body.request.rdata.serveradd;
-       packet->body.request.header.type = htons(PISA_CONF_REQUEST_SERVER_ADD);
-       pisa_conf_packet_add_len(packet, sizeof(pisa_conf_serveradd));
-
-       if (inet_pton(AF_INET6, argv[0], &serveradd->hit) != 1) {
-               PISA_ERROR("HIT could not be parsed.\n");
-               return 2;
-       }
-
-       if (!strcmp("relay", argv[1])) {
-               serveradd->type = PISA_CONTYPE_RELAY;
-       } else if (!strcmp("service", argv[1])) {
-               serveradd->type = PISA_CONTYPE_SERVICE;
-       } else if (!strcmp("legacyrouter", argv[1])) {
-               serveradd->type = PISA_CONTYPE_LEGACY_ROUTER;
-       } else {
-               PISA_ERROR("Type '%s' not valid. Choose from 'relay', 'service' 
or 'legacyrouter'.\n", argv[1]);
-               return 2;
-       }
-
-       pisa_conf_send_packet(packet);
-       free(packet);
-
-       return 0;
-}
-
-/**
  * Parse a pisacdconf service line and send out a packet to the client daemon.
  * @param argc number of arguments
  * @param argv array of arguments
@@ -127,8 +84,6 @@
        if (common_result != 1)
                return common_result;
 
-       if (!strcmp("server", argv[0]))
-               return pisa_cdconf_parse_server(argc - 1, &argv[1]);
        if (!strcmp("service", argv[0]))
                return pisa_cdconf_parse_service(argc - 1, &argv[1]);
 

Modified: trunk/pisacd/pisaconftool.c
==============================================================================
--- trunk/pisacd/pisaconftool.c Thu Nov 26 17:52:49 2009        (r1833)
+++ trunk/pisacd/pisaconftool.c Thu Nov 26 17:57:34 2009        (r1834)
@@ -16,7 +16,6 @@
 
 const char *usage_text =
 "Client options:\n"
-"\tserver\t\t: Add a connection (HIT relay|service|legacyrouter)\n"
 "\tservice\t\t: Add NAT mapping (HIT local-IPv4 remote-IPv4)\n"
 ;
 

Other related posts:

  • » [pisa-src] r1834 - in trunk: libpisa/pisaconf.c libpisa/pisaconf.h pisacd/cdconfhandlers.c pisacd/cdmain.c pisacd/pisacdconf.c pisacd/pisaconftool.c - Thomas Jansen