]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
BugFix is endpoint port assigment, added fwp_msg_type_t
authorMartin Molnar <molnar@sum.(none)>
Thu, 29 May 2008 12:36:42 +0000 (14:36 +0200)
committerMartin Molnar <molnar@sum.(none)>
Thu, 29 May 2008 12:36:42 +0000 (14:36 +0200)
fwp/lib/core/fwp_endpoint.c
fwp/lib/mngt/fwp_mngt.c
fwp/lib/mngt/fwp_msg.c
fwp/lib/mngt/fwp_msg.h
fwp/mngr/fwp_mngr.c

index 654c19c59b834e7568ecf3e30a0cde83a75e3a08..762cdcff661fae4c250a88812ecb67cd4427c02f 100644 (file)
@@ -275,7 +275,7 @@ int fwp_receive_endpoint_create(unsigned int port, int flags,
        getsockname(epoint->sockd, (struct sockaddr*)&epoint->peer.addr, 
                        &epoint->peer.addrlen);
        
-       epoint->sport = addr->sin_port;
+       epoint->sport = ntohs(addr->sin_port);
        epoint->node = addr->sin_addr.s_addr;
        FWP_DEBUG("Receive endpoint port=%d created.\n", ntohs(epoint->sport)); 
        
index 1f723890ec941170cb830adaee7f1fa7aac92458..f3dc14248a230c6db522cb10706dcab2b7149e9b 100644 (file)
@@ -96,10 +96,12 @@ void fwp_mngt_connect()
        fwp_msgb_put(msgb, sizeof(struct fwp_msg_hello));
 
        fwp_send(discovery_epointd, msgb->data, msgb->len);
-       
+       FWP_DEBUG("Sent HELLO msg \n");
+
        /* receive info from manager */
        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
@@ -110,6 +112,8 @@ void fwp_mngt_connect()
        
        /* create fwp manager participant record */
        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;
@@ -139,6 +143,10 @@ int fwp_mngt_init()
                                &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->stream_id);
        
        return 0;
 }
index 5c399dbe3b34e6b49cfbd259b22e1f25b01cc5f3..31797f6942d8dc5ee7d75b0e63f00b9e255d5902 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-void fwp_msg_header_deflate(unsigned char *data, unsigned int type, 
+void fwp_msg_header_deflate(unsigned char *data, fwp_msg_type_t type, 
                                fwp_participant_id_t participant_id)
 {
        struct fwp_msg_header* msg_header;
@@ -19,7 +19,7 @@ void fwp_msg_header_deflate(unsigned char *data, unsigned int type,
        msg_header->app_id = htonl(participant_id.app_id);
 }
 
-void fwp_msg_header_inflate(unsigned char *data, unsigned int *type, 
+void fwp_msg_header_inflate(unsigned char *data, fwp_msg_type_t *type, 
                                fwp_participant_id_t *participant_id)
 {
        struct fwp_msg_header *msg_header;
index b7b5c49f2714336e25dc25267d9f3ebdb64f572b..b2b1d248b4002e709581b4539e8b037ff48ff7b7 100644 (file)
@@ -7,9 +7,13 @@
 #include "fwp_vres.h"
 #include "fwp_participant.h"
 
-#define FWP_MSG_HELLO           0x00  /* contract negotiation request */
-#define FWP_MSG_NEGTREQ  0x02  /* contract negotiation request */
-#define FWP_MSG_NEGTRES  0x03  /* contract negotiation response */
+typedef enum {
+       FWP_MSG_HELLO   = 1<<1,
+       FWP_MSG_NEGREQ  = 1<<2,
+       FWP_MSG_NEGRES  = 1<<3,
+       FWP_MSG_RESERVE = 1<<4,
+       FWP_MSG_COMMIT  = 1<<5
+} fwp_msg_type_t;
 
 
 struct fwp_msg_header{
@@ -37,9 +41,9 @@ struct fwp_msg_hello {
        uint16_t stream_id;
 }__attribute__((packed));
 
-void fwp_msg_header_deflate(unsigned char *data, unsigned int type, 
+void fwp_msg_header_deflate(unsigned char *data, fwp_msg_type_t type, 
                                fwp_participant_id_t participant_id);
-void fwp_msg_header_inflate(unsigned char *data, unsigned int *type, 
+void fwp_msg_header_inflate(unsigned char *data, fwp_msg_type_t *type, 
                                fwp_participant_id_t *participant_id);
 
 void fwp_msg_contract_deflate(unsigned char *data, struct fwp_contract *cont);
index 9b459bb9809c0a200b4eae77e8fa0408be461ba2..bf0bd6bc2c7bbed08d6a69d84f789cd1cd58da91 100644 (file)
@@ -48,6 +48,9 @@ void fwp_mngr_hello(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
        fwp_participant_info_t participant_info, my_info;
        fwp_participant_t *participant;
 
+       FWP_DEBUG("Received HELLO msg from nodeid= %d appid= %d\n", 
+                       participant_id.node_id, participant_id.app_id);
+
        /* Create a new participant */
        fwp_msg_hello_inflate(msgb->data, &participant_info);
        participant = fwp_participant_create(&participant_info);
@@ -69,7 +72,9 @@ void fwp_mngr_hello(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
        fwp_msgb_put(msgb, sizeof(struct fwp_msg_header));
        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); 
+       fwp_send(participant->epointd, msgb->data, msgb->len);
+       
+       FWP_DEBUG("Sent HELLO msg \n");
 }
 
 /*void fwp_mngr_negt_request(msgb, participant_id)
@@ -80,7 +85,7 @@ void fwp_mngr_hello(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
 
 void fwp_mngr_msg_handler(fwp_msgb_t *msgb)
 {
-       unsigned int msg_type;
+       fwp_msg_type_t msg_type;
        fwp_participant_id_t    participant_id;
 
        fwp_msg_header_inflate(msgb->data, &msg_type, &participant_id);