]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
fwp_mngt_connect clean up
authorMartin Molnar <molnam1@fel.cvut.cz>
Thu, 29 May 2008 20:50:39 +0000 (22:50 +0200)
committerMartin Molnar <molnam1@fel.cvut.cz>
Thu, 29 May 2008 20:50:39 +0000 (22:50 +0200)
fwp/lib/core/fwp_endpoint.c
fwp/lib/mngt/fwp_mngt.c

index 762cdcff661fae4c250a88812ecb67cd4427c02f..0920efc30fb25f9000ee2c0aeab3d70863a87dc5 100644 (file)
@@ -182,7 +182,7 @@ int fwp_send_endpoint_create(unsigned int node, unsigned int port, int flags,
                
                getsockname(sockd, (struct sockaddr*) &myaddr, 
                                &addrlen);
-               epoint->sport = myaddr.sin_port;
+               epoint->sport = ntohs(myaddr.sin_port);
   
        }
 
index 121b75c0eca992b36cabcc0c91bc9b84930ce4f6..298ebff37802d27fcc35eca58c0d691ca0f60da8 100644 (file)
@@ -94,6 +94,8 @@ int fwp_mngt_service_vres_create(fwp_vres_d_t* fwp_service_vresd)
        return 0;
 }
 
+/* Launch discovery/connect process to 
+ * introduce itself to fwp manager and get description of manager*/
 void fwp_mngt_connect()
 {
        fwp_participant_info_t  my_info, mngr_info;
@@ -101,71 +103,45 @@ void fwp_mngt_connect()
        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);
-       
-       /* Create discovery endpint */
-       FWP_DEBUG("Discovery send endpoint created\n");
-       fwp_send_endpoint_create(inet_addr("127.0.0.1"), 
-                                FWP_MNGT_DISCOVERY_STREAM_ID,
-                                0, &discovery_epointd);        
-       fwp_send_endpoint_bind(discovery_epointd, service_vresd);
-#endif
 
-       /* Launch discovery process */
-       /* introduce yourself to resource manager */
+       /* prepare hello message */
        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");*/
+       /* Send hello to manager */
        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_msgb_put(msgb, size);
-
-       /*skip header right now
-        *fwp_msg_header_inflate(msgb->data, &msg_header);
-        */
-       fwp_msgb_pull(msgb, sizeof(struct fwp_msg_header));
-#endif 
+       /* receive hello from manager */
        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_DEBUG("Received HELLO msg from nodeid= %d appid= %d\n", 
+                       participant_id.node_id, participant_id.app_id);
+       
+       
+       /* Process hello msg from manager */
+       fwp_msg_hello_inflate(msgb->data, &mngr_info);
+       fwp_participant_mngr->id  = mngr_info.id;
+       fwp_participant_mngr->stream_id  = mngr_info.stream_id;
+       FWP_DEBUG("Received HELLO msg contains nodeid= %d appid= %d\n", 
                        mngr_info.id.node_id, mngr_info.id.app_id);
        
+       /* unbind and delete discovery mngr send endoint */
        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");
+       /* Create mngt send endpoint to manager */
        fwp_send_endpoint_create(fwp_participant_mngr->id.node_id, 
                                 fwp_participant_mngr->stream_id, 0,
                                 &fwp_participant_mngr->epointd);
+       FWP_DEBUG("Management send endpoint created\n");
        fwp_send_endpoint_bind(fwp_participant_mngr->epointd, 
                                fwp_participant_mngr->vresd);
 }