]> rtime.felk.cvut.cz Git - frescor/fwp.git/blobdiff - fwp/mngr/fwp_mngr.c
fwp_mngr_hello simplification by use of fwp_mngt_send
[frescor/fwp.git] / fwp / mngr / fwp_mngr.c
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");
 }