]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
FCB was enhanced by INET port
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 20 Jan 2009 14:18:18 +0000 (15:18 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 20 Jan 2009 14:19:58 +0000 (15:19 +0100)
This allows communication between FCB agents in different nodes.

fres/cbroker/Makefile.omk
fres/cbroker/fcb.c

index 0d74860dfaa8e1e94a3c14c629af158923e1dd66..926e3c34e732fb1ba74eca0df27bc51f1de4dac6 100644 (file)
@@ -8,3 +8,7 @@ lib_LIBRARIES += fcb_client
 fcb_client_CLIENT_IDL = fcb.idl
 
 include_GEN_HEADERS += fcb.h
+
+default_CONFIG = CONFIG_FCB_INET=y
+
+LOCAL_CONFIG_H = fcb_config.h
index 8a2ee7a571983efe1be324268c0020d56511b6c6..194e37624d2028f7c909d0e74cd31b7d52c371f3 100644 (file)
 #include <ul_log.h>
 #include <forb/server_id.h>
 #include <fres_contract.h>
+#include "fcb_config.h"
+
+#ifdef CONFIG_FCB_INET
+#include <forb/proto_inet.h>
+#endif
 
 UL_LOG_CUST(ulogd_fcb);
 ul_log_domain_t ulogd_fcb = {UL_LOGL_MSG, "fcb"};
@@ -467,6 +472,26 @@ err:
        return -1;      
 }
 
+#ifdef CONFIG_FCB_INET
+static int register_inet_port(forb_orb orb)
+{
+       forb_port_t *port = forb_malloc(sizeof(*port));
+       int ret;
+       struct in_addr listen_on;
+       
+       if (!port)
+               return -1;
+       memset(port, 0, sizeof(*port));
+       listen_on.s_addr = INADDR_ANY;
+       ret = forb_inet_port_init(&port->desc, listen_on);
+       if (ret) error(1, errno, "INET port initialization failed");
+       ret = forb_register_port(orb, port);
+       if (ret) error(1, errno /* TODO: FOSA errno */,
+                      "INET port registration failed");
+       return 0;
+}
+#endif
+
 struct forb_fres_contract_broker_impl impl = {
        .negotiate_contract = negotiate_contract,
        .cancel_contract = cancel_contract,
@@ -485,6 +510,11 @@ int main(int argc, char *argv[])
        orb = forb_init(&argc, &argv, "fcb");
        if (!orb) error(1, errno, "FORB initialization failed");
 
+#ifdef CONFIG_FCB_INET
+       ret = register_inet_port(orb);
+       if (ret) error(1, errno, "INET port registration failed");
+#endif
+
        fcb_resource_init_root_field(&fcb_data);
 
        fcb = forb_fres_contract_broker_new(orb, &impl, &fcb_data);