From d44345ef9663d5aef391db333d13ee27fac00cc1 Mon Sep 17 00:00:00 2001 From: Martin Molnar Date: Fri, 30 May 2008 00:15:55 +0200 Subject: [PATCH] fwp_mngr_hello simplification by use of fwp_mngt_send --- fwp/lib/mngt/fwp_mngt.h | 5 +++++ fwp/mngr/fwp_mngr.c | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/fwp/lib/mngt/fwp_mngt.h b/fwp/lib/mngt/fwp_mngt.h index 6090534..8624101 100644 --- a/fwp/lib/mngt/fwp_mngt.h +++ b/fwp/lib/mngt/fwp_mngt.h @@ -13,6 +13,11 @@ 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); diff --git a/fwp/mngr/fwp_mngr.c b/fwp/mngr/fwp_mngr.c index 8640f5a..bf9d8ba 100644 --- a/fwp/mngr/fwp_mngr.c +++ b/fwp/mngr/fwp_mngr.c @@ -1,4 +1,5 @@ #include +#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"); } -- 2.39.2