fwp_participant_t *fwp_participant_this;
fwp_participant_t *fwp_participant_mngr;
-fwp_endpoint_d_t fwp_mngt_repointd;
+/*fwp_endpoint_d_t fwp_mngt_repointd;*/
/* temporarily*/
}
#endif
+int fwp_mngt_send(fwp_msg_type_t type,fwp_msgb_t *msgb,
+ fwp_participant_t *source, fwp_participant_t *dest)
+{
+ fwp_msgb_push(msgb, sizeof(struct fwp_msg_header));
+ fwp_msg_header_deflate(msgb->data, type, source->id);
+
+ fwp_send(dest->epointd, msgb->data, msgb->len);
+
+ return 0;
+}
+
+int fwp_mngt_recv(fwp_msg_type_t *type, fwp_participant_id_t *participant_id,
+ fwp_msgb_t *msgb)
+{
+ int size;
+
+ fwp_msgb_reset_data(msgb);
+ size = fwp_recv(fwp_participant_this->epointd, msgb->data,
+ msgb->buffer_size);
+ fwp_msgb_put(msgb, size);
+
+ fwp_msg_header_inflate(msgb->data, type, participant_id);
+ fwp_msgb_pull(msgb, sizeof(struct fwp_msg_header));
+
+ FWP_DEBUG("Received msg: type=%d from nodeid=%d appid=%d\n", *type,
+ participant_id->node_id, participant_id->app_id);
+
+ return 0;
+}
+
int fwp_mngt_service_vres_create(fwp_vres_d_t* fwp_service_vresd)
{
struct fwp_vres_params fwp_service_vparams;
void fwp_mngt_connect()
{
fwp_participant_info_t my_info, mngr_info;
- fwp_endpoint_d_t discovery_epointd;
- fwp_vres_d_t service_vresd;
- ssize_t size;
+ fwp_participant_id_t participant_id;
fwp_msgb_t *msgb;
+ fwp_msg_type_t msg_type;
+#if 0
FWP_DEBUG("Service vres created\n");
fwp_mngt_service_vres_create(&service_vresd);
FWP_MNGT_DISCOVERY_STREAM_ID,
0, &discovery_epointd);
fwp_send_endpoint_bind(discovery_epointd, service_vresd);
+#endif
/* Launch discovery process */
- my_info.id = fwp_participant_this->id;
- my_info.stream_id = fwp_participant_this->stream_id;
-
/* introduce yourself to resource manager */
msgb = fwp_msgb_alloc(sizeof(struct fwp_msg_header) +
sizeof(struct fwp_msg_hello));
+ fwp_msgb_reserve(msgb, sizeof(struct fwp_msg_header));
+#if 0
fwp_msg_header_deflate(msgb->tail, FWP_MSG_HELLO,
fwp_participant_this->id);
fwp_msgb_put(msgb, sizeof(struct fwp_msg_header));
+#endif
+ 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(discovery_epointd, msgb->data, msgb->len);
- FWP_DEBUG("Sent HELLO msg \n");
+ /*fwp_send(discovery_epointd, msgb->data, msgb->len);
+ FWP_DEBUG("Sent HELLO msg \n");*/
+ fwp_mngt_send(FWP_MSG_HELLO, msgb,
+ fwp_participant_this, fwp_participant_mngr);
+
/* receive info from manager */
+
+#if 0
fwp_msgb_reset_data(msgb);
size = fwp_recv(fwp_mngt_repointd, msgb->data, msgb->buffer_size);
FWP_DEBUG("Received HELLO msg from mngr\n");
*fwp_msg_header_inflate(msgb->data, &msg_header);
*/
fwp_msgb_pull(msgb, sizeof(struct fwp_msg_header));
+#endif
+ fwp_mngt_recv(&msg_type, &participant_id, msgb);
fwp_msg_hello_inflate(msgb->data, &mngr_info);
/* create fwp manager participant record */
- fwp_participant_mngr = fwp_participant_create(&mngr_info);
+ //fwp_participant_mngr = fwp_participant_create(&mngr_info);
FWP_DEBUG("Received HELLO msg from nodeid= %d appid= %d\n",
mngr_info.id.node_id, mngr_info.id.app_id);
- fwp_send_endpoint_unbind(discovery_epointd);
- fwp_participant_mngr->vresd = service_vresd;
+ fwp_send_endpoint_unbind(fwp_participant_mngr->epointd);
+ /*fwp_endpoint_free(fwp_participant_mngr->epointd)*/
+ //fwp_participant_mngr->vresd = service_vresd;
+ fwp_participant_mngr->id = mngr_info.id;
+ fwp_participant_mngr->stream_id = mngr_info.stream_id;
FWP_DEBUG("Management send endpoint created\n");
fwp_send_endpoint_create(fwp_participant_mngr->id.node_id,
fwp_participant_mngr->stream_id, 0,
&fwp_participant_mngr->epointd);
- fwp_send_endpoint_bind(fwp_participant_mngr->epointd, service_vresd);
+ fwp_send_endpoint_bind(fwp_participant_mngr->epointd,
+ fwp_participant_mngr->vresd);
}
int fwp_mngt_init()
{
- fwp_participant_info_t my_info;
+ fwp_participant_info_t my_info, mngr_info;
int flags;
+ /* Create fwp_participant_this */
my_info.id.node_id = inet_addr("127.0.0.1");
my_info.id.app_id = getpid();
- /* temporarily*/
my_info.stream_id = 0;
fwp_participant_this = fwp_participant_create(&my_info);
-
- FWP_DEBUG("Management receive endpoint created\n");
- fwp_receive_endpoint_create(0, 0, &fwp_mngt_repointd);
+ fwp_receive_endpoint_create(0, 0, &fwp_participant_this->epointd);
fwp_endpoint_get_params(&(fwp_participant_this->id.node_id),
&fwp_participant_this->stream_id,
&flags,
- fwp_mngt_repointd);
-
- FWP_DEBUG("mngt_receive conf: nodeid=%d streamid=%d\n",
- fwp_participant_this->id.node_id,
+ fwp_participant_this->epointd);
+ FWP_DEBUG("Management receive endpoint created, stream id= %d\n",
fwp_participant_this->stream_id);
+
+ /* Create fwp_participant_mngr */
+
+ mngr_info.id.node_id = inet_addr("127.0.0.1");
+ /*mngr_info.id.node_id = inet_addr("255.255.255.255");*/
+ mngr_info.id.app_id = getpid();
+ mngr_info.stream_id = FWP_MNGR_STREAM_ID;
+
+ fwp_participant_mngr = fwp_participant_create(&mngr_info);
+
+ /* Create discovery endpoint */
+ FWP_DEBUG("Service vres created\n");
+ fwp_mngt_service_vres_create(&fwp_participant_mngr->vresd);
+
+ FWP_DEBUG("Discovery send endpoint created\n");
+ fwp_send_endpoint_create(fwp_participant_mngr->id.node_id,
+ fwp_participant_mngr->stream_id,
+ 0, &fwp_participant_mngr->epointd);
+ fwp_send_endpoint_bind(fwp_participant_mngr->epointd,
+ fwp_participant_mngr->vresd);
+
return 0;
}