]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Added discovery function
authorMartin Molnar <molnam1@fel.cvut.cz>
Sun, 18 May 2008 23:18:49 +0000 (01:18 +0200)
committerMartin Molnar <molnam1@fel.cvut.cz>
Sun, 18 May 2008 23:18:49 +0000 (01:18 +0200)
fwp/Makefile.omk
fwp/mngt/fwp_mngt.c
fwp/mngt/fwp_mngt.h
fwp/mngt/fwp_msg.c
fwp/mngt/fwp_msg.h

index a1b131f826a34daa7a69952ecf58c2fa14a347b0..78c40c3a302f89ba7aade44bb2af0fe160942636 100644 (file)
@@ -1,2 +1,2 @@
 #SUBDIRS = $(ALL_OMK_SUBDIRS)
-SUBDIRS = ulut lib mngt tests 
+SUBDIRS = ulut lib mngt  
index 502b8ca7ab539f067a7563426792c1fd97844fc9..5a9a2b2697ec028d2ae0cd5a56a7532b0b56a6a6 100644 (file)
@@ -7,16 +7,55 @@ int           fwp_client_sockfd;
 pid_t  fwp_appid;      
 uint16_t fwp_callid = 0; 
 
+fwp_endpoint_d_t discovery_epointd;
 fwp_endpoint_d_t mngt_sepointd;
 fwp_endpoint_d_t mngt_repointd;
 
-int fwp_reserve()
+/**
+ * struct resource {
+ *     char name[10];
+ *     int id;
+ *     general_ops;
+ *     fna_ops;
+ *
+ * }
+ *
+ */
+
+
+int fwp_negt_request(tr_id_t, fwp_contract_t contract)
+{
+
+
+}
+
+int fwp_negt_reserve(tr_id_t tr_id)
 {
 
 
 }
 
+int fwp_negt_commit(tr_id_t tr_id)
+{
+
+
+}
 
+void fwp_mngt_discovery(int *node, int *port)
+{
+       fwp_msg_hello_t msg_hello;
+       size_t size;
+       
+       msg_hello.node = inet_addr("127.0.0.1");
+       msg_hello.port = htons(FWP_APP_MNGT_PORT);
+       msg_hello.app_id = fwp_appid;
+
+       fwp_send(discovery_epointd, &msg_hello, sizeof(msg_hello));
+       fwp_recv(mngt_repointd, &msg_hello, size);
+       
+       *node = msg_hello.node;
+       *port = msg_hello.port;
+}
 
 /**
  * FWP initialisation
@@ -29,15 +68,18 @@ int fwp_mngt_init()
        FWP_DEBUG("Management receive endpoint created\n");
        fwp_receive_endpoint_create(FWP_APP_MNGT_PORT, 0, &mngt_repointd);      
        
-       /*
-        * FWP_DEBUG("Discovery send endpoint created\n");
-        * fwp_send_endpoint_create(inet_addr(255.255.255.255), 0, &mngt_sepointd);
-        * */
-       
+       FWP_DEBUG("Discovery send endpoint created\n");
+       /*fwp_send_endpoint_create(inet_addr("255.255.255.255"), 0, &mngt_sepointd);*/
+       fwp_send_endpoint_create(inet_addr("127.0.0.1"), FWP_MNGR_MNGT_PORT, 
+                                       &discovery_epointd);
+
        /* Launch discovery process*/
+       /* introduce yourself to resource manager */
+       fwp_mngt_discovery(&resmngr_addr, &resmngr_port);
 
        FWP_DEBUG("Management send endpoint created\n");
-       fwp_send_endpoint_create(inet_addr("127.0.0.1"), FWP_MNGR_MNGT_PORT, 0, &mngt_sepointd);
+       fwp_send_endpoint_create(resmngr_addr, resmngr_port, 0,
+                                       &mngt_sepointd);
        
        return 0;
 }
index 7de6258b191c61341bff2223666cbcfff332b4d1..c0d609aac4f9edb2b51327054dbff847711d2308 100644 (file)
@@ -24,6 +24,8 @@ extern struct         sockaddr_un fwp_agent_addr;
 extern pid_t   fwp_appid;
 extern uint16_t fwp_callid; 
 
+typedef int tr_id_t;
+
 int fwp_comm_init();
 
 #endif /* _FWP_COMM_H */
index 5c9899a7c211d72f034c592bbaad5bfc496c7c0b..a68d1bbfac43aef02cac4a06c7f40d24cbc001e6 100644 (file)
@@ -84,3 +84,11 @@ void fwp_msg_vres_params_inflate(unsigned char *data, unsigned int *status,
        vparams->budget = ntohs(msgvparams->budget);
        vparams->period_usec = ntohl(msgvparams->period_usec);
 }
+
+void fwp_msg_advertisement_deflate(unsigned char *data, unsigned int status,
+                                fwp_vres_params_t *vparams)
+{
+
+
+}
+
index 7dd4ba5f9a9094bb9d59e0fc7fae26ae2aebc29d..37a5a75505c1aa9f95397dadf5b21b4588a1739f 100644 (file)
@@ -30,9 +30,11 @@ struct fwp_msg_vres_params{
        uint8_t  status;
 }__attribute__((packed));
 
-struct fwp_msg_participant_info {
+struct fwp_msg_hello {
+       int32_t  node;
+       int32_t  app_id;
        uint16_t port;
-};
+}__attribute__((packed));
 
 void fwp_msg_header_deflate(unsigned char *data, unsigned int code, 
                                fwp_appcall_id_t *appcall_id);