]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
FORB can be initialized with a fixed ID
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 26 May 2009 13:19:43 +0000 (15:19 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 26 May 2009 15:07:36 +0000 (17:07 +0200)
This will be used to bypass discovery protocol and configure FCB location
and ID statically.

src/forb.c
src/forb.h
src/server_id.h

index 5a34670566c5c97eb42b0f009ecd261a2431d331..0aa087754df8ebc9bc5ef36855fc89eba7ddb91c 100644 (file)
@@ -169,8 +169,12 @@ forb_init(int *argc, char **argv[], const struct forb_init_attr *attr)
        } else {
                memset(&forb->attr, 0, sizeof(forb->attr));
        }
-       
-       forb_server_id_init(&forb->server_id);
+
+       if (forb_server_id_empty(&forb->attr.fixed_server_id)) {
+               forb_server_id_init(&forb->server_id);
+       } else {
+               forb->server_id = forb->attr.fixed_server_id;
+       }
        forb_server_id_to_string(forb->server_id_str, &forb->server_id,
                                 sizeof(forb->server_id_str));
        ul_logdeb("Initializing forb %s\n", forb->server_id_str);
@@ -241,7 +245,7 @@ forb_init(int *argc, char **argv[], const struct forb_init_attr *attr)
                        memset(port, 0, sizeof(*port));
                        listen_on.s_addr = INADDR_ANY;
                        ret = forb_inet_port_init(&port->desc, listen_on,
-                                                 attr->fixed_tcp_port);
+                                                 forb->attr.fixed_tcp_port);
                        if (ret) goto err_free_inet;
                        ret = forb_register_port(orb, port);
                        if (ret) goto err_free_inet; /* TODO: forb_inet_port_done() */
index c825c7d66c5e82298abcc51d8cb185a03e8189d4..9a1e00e86c47086bde1269fbbd7ab1580d7455f8 100644 (file)
@@ -159,6 +159,7 @@ typedef struct forb_init_attr {
        void (*peer_discovery_callback)(const forb_orb peer_orb, const char *orb_id);
        void (*peer_dead_callback)(const forb_orb peer_orb, const char *orb_id);
        uint16_t fixed_tcp_port; /**< If we want FORB's inet protocol to listen on a fixed port... */
+       forb_server_id fixed_server_id; /**< If we do not want the ID to be random. (HACK) */
 
 } forb_init_attr_t;
 
index f179b2817362fe18667af72a98fef4e672fd45b7..17effdc38a6f0925f29fdba49b200eb17b178660 100644 (file)
@@ -50,5 +50,15 @@ forb_server_id_from_string(forb_server_id *server_id, const char *string)
 }
 
 
+static inline bool
+forb_server_id_empty(const forb_server_id *server_id)
+{
+       unsigned i;
+       for (i=0; i<sizeof(server_id); i++) {
+               if (server_id->uuid[i] != 0)
+                       return false;
+       }
+       return true;
+}
 
 #endif