]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
fwp_mngr_hello simplification by use of fwp_mngt_send
authorMartin Molnar <molnam1@fel.cvut.cz>
Thu, 29 May 2008 22:15:55 +0000 (00:15 +0200)
committerMartin Molnar <molnam1@fel.cvut.cz>
Thu, 29 May 2008 22:15:55 +0000 (00:15 +0200)
fwp/lib/mngt/fwp_mngt.h
fwp/mngr/fwp_mngr.c

index 60905344299d00057e006b260913f0a6374f654b..8624101c90f4786665bd899af9dae3b6663c7fa1 100644 (file)
 extern fwp_participant_t       *fwp_participant_this;
 extern fwp_participant_t       *fwp_participant_mngr;
 
+int fwp_mngt_send(fwp_msg_type_t type,fwp_msgb_t *msgb,
+                 fwp_participant_t *source, fwp_participant_t *dest);
+int fwp_mngt_recv(fwp_msg_type_t *type, fwp_participant_id_t *participant_id,
+                       fwp_msgb_t *msgb);
+
 int fwp_mngt_init();
 int fwp_mngt_service_vres_create(fwp_vres_d_t* fwp_service_vresd);
 
index 8640f5ab29ac187a1629d08bcd4e96651c0bd121..bf9d8ba600b437b377ba8fcdba300168ffaa85f4 100644 (file)
@@ -1,4 +1,5 @@
 #include <fwp.h>
+#include "fwp_mngt.h"
 #include "fwp_participant_table.h"
 
 #define FWP_MTU        2346  
@@ -27,6 +28,7 @@ int fwp_mngr_input(struct fwp_msgb **pmsgb)
        ssize_t size;
 
        FWP_DEBUG("Waiting for messages\n");
+       /* TODO: consider to replace with fwp_mngt_recv call */
        size = fwp_recv(fwp_participant_this->epointd, buffer, BUFFSIZE);
         
        FWP_DEBUG("Creating fwp msgb len=%d\n", size);  
@@ -64,16 +66,20 @@ void fwp_mngr_hello(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
        fwp_participant_table_insert(participant);
 
        /* Send back hello msg with mngr`s info */
+       /* prepare hello message */
        fwp_msgb_reset_data(msgb);
-       my_info.id = fwp_participant_this->id;
-       my_info.stream_id = fwp_participant_this->stream_id;
-       fwp_msg_header_deflate(msgb->tail, FWP_MSG_HELLO, 
-                               fwp_participant_this->id);
-       fwp_msgb_put(msgb, sizeof(struct fwp_msg_header));
+       fwp_msgb_reserve(msgb, sizeof(struct fwp_msg_header));
+       
+       my_info.id = fwp_participant_this->id;
+       my_info.stream_id = fwp_participant_this->stream_id;
+
        fwp_msg_hello_deflate(msgb->tail, &my_info);
        fwp_msgb_put(msgb, sizeof(struct fwp_msg_hello));
-       fwp_send(participant->epointd, msgb->data, msgb->len);
-       
+
+       /* Send hello to manager */
+       fwp_mngt_send(FWP_MSG_HELLO, msgb, 
+                       fwp_participant_this, participant);
+
        FWP_DEBUG("Sent HELLO msg \n");
 }