]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
mngt intialization rework
authorMartin Molnar <molnar@sum.(none)>
Wed, 21 May 2008 16:18:18 +0000 (18:18 +0200)
committerMartin Molnar <molnar@sum.(none)>
Wed, 21 May 2008 16:18:18 +0000 (18:18 +0200)
fwp/mngr/fwp_mngr.c
fwp/mngr/fwp_participant_table.c
fwp/mngt/fwp_mngt.c
fwp/mngt/fwp_mngt.h
fwp/mngt/fwp_participant.h

index 4693d61768f732f9b7ce1c82410f06c886f4253b..1a5a92a2753d87fd9540ed7960e9b322ded32950 100644 (file)
@@ -15,7 +15,6 @@ static unsigned char  buffer[FWP_MTU];
 struct fwp_sockaddr    peer;
 
 /* service vres */
-struct fwp_vres_params service_vparams;                
 fwp_vres_d_t           service_vresd;  /**< service vres decriptor */
 
 /* List of requested contracts */
@@ -39,34 +38,14 @@ fwp_admctrl_test_t fwp_admctrl_test = &fwp_admctrl_stupid;
  */
 int fwp_mngr_init()
 {
-       #if 0
-       if ((fwp_lsockfd = fwp_create_unix_socket(FWP_AGENT_UNIXPATH, 
-                                                 &fwp_laddr)) < 0) {
-                               return (fwp_lsockfd);
-       }
-        #endif
-       if ((fwp_rsockfd = fwp_create_inet_socket(FWP_MNGR_UDP_PORT, 
-                                                 &fwp_raddr)) < 0) {
-                       return (fwp_rsockfd);
-       }
-               
-       FD_ZERO(&fwp_input_fdset);
-       //FD_SET(fwp_lsockfd, &fwp_input_fdset);
-       FD_SET(fwp_rsockfd, &fwp_input_fdset);
-               
-       FWP_DEBUG("Manager initialized \n");
-               
-       /* create service vres */
-       service_vparams.ac_id = FWP_AC_BK; 
-       service_vparams.budget = 100;
-       service_vparams.period_usec = 1000;
+       fwpmngr_info = my_info; 
        
-       if ((fwp_vres_create(&service_vparams, &service_vresd) < 0)) {
-               fprintf(stderr,"Unable to open service vres\n");
-               return -1;
-       }
+       FWP_DEBUG("Management receive endpoint created\n");
+       fwp_receive_endpoint_create(FWP_APP_MNGT_PORT, 0, &mngt_repointd);      
+       my_info.port = FWP_APP_MNGT_PORT;
        
-       FWP_DEBUG("Service vres negotiated\n");
+               
+               
        return 0;
 }
 
index d5246f8df33ed4dcf8e397eddeaee15a922ef028..230efec2251bbd1c6a0a45afe5ca9b37219d1974 100644 (file)
@@ -23,12 +23,12 @@ int fwp_cmp_participant_id(const void *a, const void *b)
 
 GAVL_CUST_NODE_INT_DEC(_fwp_participant_table, fwp_participant_table_t, 
                        fwp_participant_data_t, fwp_participant_id_t, 
-                       participant_tree, tree_node, id, 
+                       participant_tree, participant_tree_node, id, 
                        fwp_cmp_participant_id);
 
 GAVL_CUST_NODE_INT_IMP(_fwp_participant_table, fwp_participant_table_t, 
                        fwp_participant_data_t, fwp_participant_id_t, 
-                       participant_tree, tree_node, id, 
+                       participant_tree, participant_tree_node, id, 
                        fwp_cmp_participant_id);
 
 fwp_participant_table_t  fwp_participant_table = {
index e7461ba53912623f827adece31dbf702a314cacf..befcb658b1aa20b3b0b49902e1a3b370cb126ff4 100644 (file)
@@ -1,18 +1,22 @@
 #include "fwp_mngt.h"
 #include "fwp_participant.h"
 
-struct sockaddr_un     fwp_agent_addr;
-struct sockaddr_un     fwp_client_addr;
-int                            fwp_client_sockfd;
+/* 
+ * Global mngt variables
+ */
+static fwp_participant_info_t  fwp_my_info;
 
-fwp_participant_info_t         my_info;
-fwp_participant_info_t         fwpmngr_info;
+fwp_participant_t      *fwp_this;
+fwp_participant_t      *fwp_mngr;
 
 fwp_endpoint_d_t       discovery_epointd;
 fwp_endpoint_d_t       mngt_sepointd;
 fwp_endpoint_d_t       mngt_repointd;
 
-fwp_participant_t      me;
+/* temporarily*/
+struct fwp_vres_params fwp_service_vparams;            
+fwp_vres_d_t           fwp_service_vresd;
+
 
 /**
  * struct resource {
@@ -45,7 +49,7 @@ int fwp_negt_commit(tr_id_t tr_id)
 }
 #endif
 
-void fwp_mngt_discovery(fwp_participant_info_t *fwpmngr_info)
+void fwp_mngt_discovery(fwp_participant_info_t *participant_)
 {
        struct fwp_msg_hello msg_hello;
        size_t size;
@@ -58,18 +62,9 @@ void fwp_mngt_discovery(fwp_participant_info_t *fwpmngr_info)
        fwp_msg_hello_inflate((unsigned char*) &msg_hello, fwpmngr_info);
 }
 
-/**
- * FWP initialisation
- *
- */
-int fwp_mngt_init()
+void fwp_mngt_connect()
+       fwp_send_endpoint_bind(discovery_epointd, fwp_service_vresd);
 {
-       my_info.id.node_id = inet_addr("127.0.0.1");
-       my_info.id.app_id = getpid();
-       
-       FWP_DEBUG("Management receive endpoint created\n");
-       fwp_receive_endpoint_create(FWP_APP_MNGT_PORT, 0, &mngt_repointd);      
-       my_info.port = FWP_APP_MNGT_PORT;
        
        FWP_DEBUG("Discovery send endpoint created\n");
        /*fwp_send_endpoint_create(inet_addr("255.255.255.255"), 0, 
@@ -77,14 +72,49 @@ int fwp_mngt_init()
         * */
        fwp_send_endpoint_create(inet_addr("127.0.0.1"), FWP_MNGT_DISCOVERY_PORT, 0, 
                                        &discovery_epointd);
+       
+       fwp_send_endpoint_bind(discovery_epointd, fwp_service_vresd);
 
        /* Launch discovery process*/
        /* introduce yourself to resource manager */
        fwp_mngt_discovery(&fwpmngr_info);
 
+       fwp_send_endpoint_unbind(discovery_epointd, fwp_service_vresd);
+       
        FWP_DEBUG("Management send endpoint created\n");
        fwp_send_endpoint_create(fwpmngr_info.id.node_id, fwpmngr_info.port, 0,
                                        &mngt_sepointd);
+
+       fwp_send_endpoint_bind(mngt_sepointd, fwp_service_vresd);
+}
+
+/**
+ * FWP initialisation
+ *
+ */
+int fwp_mngt_init()
+{
+       my_info.id.node_id = inet_addr("127.0.0.1");
+       my_info.id.app_id = getpid();
+       /* temporarily*/
+       my_info.port = FWP_APP_MNGT_PORT;
+
+       me = fwp_participant_create(my_info);   
+       
+       FWP_DEBUG("Management receive endpoint created\n");
+       fwp_receive_endpoint_create(FWP_APP_MNGT_PORT, 0, &mngt_repointd);      
+       
+       /* create service vres */
+       fwp_service_vparams.ac_id = FWP_AC_BK; 
+       fwp_service_vparams.budget = 100;
+       fwp_service_vparams.period_usec = 1000;
+       
+       if ((fwp_vres_create(&fwp_service_vparams, &fwp_service_vresd) < 0)) {
+               fprintf(stderr,"Unable to open service vres\n");
+               return -1;
+       }
+       
+       FWP_DEBUG("Service vres negotiated\n");
        
        return 0;
 }
index 11ae0c89b6c0df1b05062a4414a9965111234b51..557cb26a93fd2556a763674456d37b3e18131f9d 100644 (file)
@@ -7,24 +7,14 @@
 #include "fwp_util.h"
 #include "fwp_endpoint.h"
 
-#define FWP_AGENT_UNIXPATH  "/tmp/fwp-agent"
-#define FWP_CLIENT_UNIXPATH "/tmp" /*temporarily*/
+#define FWP_APP_MNGT_STREAMID  3001
 
-#define FWP_MNGR_UDP_PORT      3000
-#define FWP_AGENT_UDP_PORT     3001
-#define FWP_APP_MNGT_PORT      3001
-
-extern int     fwp_client_sockfd;
-extern struct  sockaddr_un fwp_client_addr;
-extern struct  sockaddr_un fwp_agent_addr;
-
-extern pid_t   fwp_appid;
-extern uint16_t fwp_callid; 
 
 typedef int tr_id_t;
 
 
-#define FWP_MNGT_DISCOVERY_PORT        3000
+#define FWP_MNGT_DISCOVERY_STREAMID    3000
+#define FWP_MNGR_STREAMID              3000
 
 int fwp_mngt_init();
 
index 2bdfa73ac68af5375e8412f4f136d23efda5ac90..8c96efec9e3b7eea5714c9e99e2091ada22ffebd 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _FWP_PARTICIPANT_H
 #define _FWP_PARTICIPANT_H
 
-#include "fwp_contract_table.h"
+#include "ul_gavlcust.h"
 
 typedef 
 struct fwp_participant_id {
@@ -10,6 +10,7 @@ struct fwp_participant_id {
 } fwp_participant_id_t;
 
 typedef 
+/*struct fwp_participant_conf {*/
 struct fwp_participant_info {
        fwp_participant_id_t    id;
        unsigned int            port;
@@ -19,8 +20,10 @@ typedef
 struct fwp_participant {
        fwp_participant_id_t    id;
        unsigned int            stream_id;
-       
-       fwp_contract_table_t    contract_tbl;
+       fwp_endpoint_d_t        epointd;
+       fwp_vres_d_t            service_vresd;
+               
+       gavl_node_t             participant_tree_node;
 } fwp_participant_t;
 
 #endif /*_FWP_PARTICIPANT_H */