]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Fna ops mapped to fwp ops inluding new fna ops like bind, unbind, cretae , destroy...
authorMartin <molnam1@fel.cvut.cz>
Mon, 20 Oct 2008 15:27:12 +0000 (17:27 +0200)
committerMartin <molnam1@fel.cvut.cz>
Mon, 20 Oct 2008 15:27:12 +0000 (17:27 +0200)
fwp/lib/Makefile.omk
fwp/lib/core/fwp_endpoint.c
fwp/lib/core/fwp_endpoint.h
fwp/lib/core/tests/fwp_vrestest/fwp_vrestest1.c
fwp/lib/core/tests/fwp_vrestest/fwp_vrestest2.c
fwp/lib/fwp_fna.c

index 0e0be1095e9884f642bfde330b8a94c99be42107..4c39041fb5100a4dfefda30f8637a287d2328248 100644 (file)
@@ -1,4 +1,4 @@
-lib_LIBRARIES = fwp
+shared_LIBRARIES = fwp
 CFLAGS += -D_FWP_INTERNALS_
 SUBDIRS = core  
 #LDFLAGS = -lpthread  -lrt
@@ -8,9 +8,9 @@ fwp_SOURCES = core/fwp_util.c core/fwp_vres.c core/fwp_msgb.c core/fwp_msgq.c\
                mngt/fwp_mngt.c
 fwp_SOURCES += fwp.c fwp_fna.c
 
-include_HEADERS= fwp_conf.h fwp_confdefs.h fwp.h
+include_HEADERS= fwp_conf.h fwp_confdefs.h fwp_fna.h fwp.h
 
 #include_HEADERS=  fwp_vres.h fwp_msgb.h fwp_msgq.h \
                  fwp_conf.h  fwp_util.h fwp_endpoint.h fwp.h 
-lib_LOADLIBES+= ulut fna
+lib_LOADLIBES+= pthread ulut fna 
 #lib_LOADLIBES+= pthread rt
index bc9e7a74fdbe675cc0f5648f317152df89e18ea6..95449a4df6340ca61da667b5ffabda16d281ea31 100644 (file)
@@ -50,6 +50,18 @@ static fwp_endpoint_t* fwp_endpoint_alloc()
        return (fwp_endpoint_t*) calloc(1,sizeof(fwp_endpoint_t));
 }
 
+/**
+ * Allocates endpoint
+ *
+ * \return On success returns endpoint structure. 
+ * On error, NULL is returned. 
+ *
+ */
+static inline void fwp_endpoint_free(fwp_endpoint_t *endpoint)
+{
+       free(endpoint);
+}
+
 /**
  * Destroy endpoint
  *
@@ -59,12 +71,10 @@ static fwp_endpoint_t* fwp_endpoint_alloc()
  */
 int fwp_endpoint_destroy(fwp_endpoint_d_t epointd)
 {
-       fwp_endpoint_t *epoint;
-
-/*     epoint = (fwp_endpoint_t*) endpoint->endpoint_protocol_info.send.body;
-       if (epoint->sockd > 0) 
-               close(epoint->sockd);*/
+       if (epointd->sockd > 0) 
+               close(epointd->sockd);
        
+       fwp_endpoint_free(epointd);     
        return 0;
 }
 
@@ -292,7 +302,7 @@ err:
  *
  * \return On success returns 0. On error, -1 and errno is set appropriately.
  */
-int fwp_send_endpoint_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint)
+int fwp_send_endpoint_bind(fwp_endpoint_t *epoint, fwp_vres_d_t vresd)
 {
        int rv ;
        fwp_endpoint_t *fwp_epoint = epoint;
@@ -314,10 +324,10 @@ int fwp_send_endpoint_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint)
  * \return On success returns 0. On error, -1 is returned and errno is set appropriately.
  *
  */
-int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd)
+int fwp_send_endpoint_unbind(fwp_endpoint_t *epoint)
 {
        int rv = 0;
-       fwp_endpoint_t *fwp_epoint = epointd;
+       fwp_endpoint_t *fwp_epoint = epoint;
 
        /* unlink epoint-vres mutually */
        if ((rv = fwp_vres_unbind(fwp_epoint->vresd)) < 0) 
index bcfa5580163c904a2c86d0d41bed7aa4912cec3d..9be8db069beb36dcdd04bee7671a54730f68084d 100644 (file)
@@ -39,7 +39,7 @@ int fwp_receive_endpoint_create(/*unsigned int node,*/ unsigned int port,
                                fwp_endpoint_t **epoint);
 int fwp_endpoint_destroy(fwp_endpoint_d_t epointd);
 
-int fwp_send_endpoint_bind(fwp_vres_d_t vresd, fwp_endpoint_d_t epointd);
+int fwp_send_endpoint_bind(fwp_endpoint_d_t epointd, fwp_vres_d_t vresd);
 int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd);
 
 ssize_t fwp_recv(fwp_endpoint_t *endpoint,
index 59eb8fe1040ab5bc72ff6396e51196fc35e72e9b..e5efad98b25d30ffe1166654b211819819098193 100644 (file)
@@ -68,7 +68,7 @@ int main()
                return -1;
        }
        printf("Send endpoint 1 created\n");
-       fwp_send_endpoint_bind(vresd1, sepoint_d1);
+       fwp_send_endpoint_bind(sepoint_d1, vresd1);
        
        for (count = 0; count < NUM; count++) { 
                sprintf(msg1,"msg%d",count);
index e08923a7be7aaf2c6e0aca7f19cd7080621b0aa9..9f28db95b3d5bd703cd77a6b24c82b9623cc8505 100644 (file)
@@ -50,7 +50,7 @@ void* sender()
                return NULL;
        }
        printf("Send endpoint 1 created\n");
-       fwp_send_endpoint_bind(vres_d1, sepoint_d1);
+       fwp_send_endpoint_bind(sepoint_d1, vres_d1);
        
        sleep(2);
        //for (count = 0; count < NUM; count++) {       
index 17b060d13e30a663611762aba5da6b2eb2880eb3..76a6eeb5e3a52826bd4545793a66f1723099e50e 100644 (file)
@@ -8,7 +8,7 @@ int fwp_fna_init(const frsh_resource_id_t resource_id)
        return fwp_init();
 }
 
-int fwp_fna_send_endpoint_create(fna_endpoint_data_t  *endpoint)
+int fwp_fna_send_endpoint_created(fna_endpoint_data_t  *endpoint)
 {
        unsigned int node, port;
        fwp_endpoint_attr_t *attr;
@@ -25,7 +25,7 @@ int fwp_fna_send_endpoint_create(fna_endpoint_data_t  *endpoint)
        return 0;
 }
 
-int fwp_fna_recv_endpoint_create(fna_endpoint_data_t  *endpoint)
+int fwp_fna_receive_endpoint_created(fna_endpoint_data_t  *endpoint)
 {
        unsigned int node,port;
        fwp_endpoint_attr_t *attr;
@@ -43,15 +43,30 @@ int fwp_fna_recv_endpoint_create(fna_endpoint_data_t  *endpoint)
        return 0;
 }
 
-/** FNA send routine */
+int fwp_fna_send_endpoint_bind(fna_endpoint_data_t *endpoint, fna_vres_id_t vres)
+{
+       return fwp_send_endpoint_bind(endpoint->protocol_info.body, 
+                                       (fwp_vres_t*) vres);
+}
+
+int fwp_fna_send_endpoint_unbind(fna_endpoint_data_t *endpoint)
+{
+       return fwp_send_endpoint_unbind(endpoint->protocol_info.body);
+}
 
+int fwp_fna_endpoint_destroy(fna_endpoint_data_t  *endpoint)
+{      
+       return fwp_endpoint_destroy(endpoint->endpoint_protocol_info.send.body);
+}
+
+/** FNA send routine */
 int fwp_fna_send(const fna_endpoint_data_t *endpoint, const void *msg, 
                        const size_t size)
 {
        fwp_endpoint_t *fwp_epoint;
        int flags = 0;
 
-       fwp_epoint = endpoint->endpoint_protocol_info.send.body;
+       fwp_epoint = endpoint->protocol_info.body;
        return fwp_send(fwp_epoint, msg, size, flags);
 }
 
@@ -61,7 +76,7 @@ int fwp_fna_send_sync(const fna_endpoint_data_t *endpoint, const void *msg,
        fwp_endpoint_t *fwp_epoint;
        int flags = 0;
 
-       fwp_epoint = endpoint->endpoint_protocol_info.send.body;
+       fwp_epoint = endpoint->protocol_info.body;
        return fwp_send(fwp_epoint, msg, size, flags);
 }
 
@@ -70,7 +85,7 @@ int fwp_fna_send_async(const fna_endpoint_data_t *endpoint,const void *msg,
 {
        fwp_endpoint_t *fwp_epoint;
 
-       fwp_epoint = endpoint->endpoint_protocol_info.send.body;
+       fwp_epoint = (fwp_endpoint_t*) endpoint->protocol_info.body;
        return fwp_send(fwp_epoint, msg, size, MSG_DONTWAIT);
 }
 
@@ -84,9 +99,7 @@ int fwp_fna_receive(const fna_endpoint_data_t *endpoint,
        fwp_endpoint_t *fwp_epoint;
        int flags = 0;
        
-       fwp_epoint = (fwp_endpoint_t*) 
-                       endpoint->protocol_info.body;
-
+       fwp_epoint = (fwp_endpoint_t*) endpoint->protocol_info.body;
        len = fwp_recv(fwp_epoint, buffer, buffer_size, &from_addr, flags);
        if (len < 0) 
                return len;
@@ -106,9 +119,7 @@ int fwp_fna_receive_sync(const fna_endpoint_data_t *endpoint, void *buffer,
        fwp_endpoint_t *fwp_epoint;
        int flags = 0;
        
-       fwp_epoint = (fwp_endpoint_t*) 
-                       endpoint->protocol_info.body;
-
+       fwp_epoint = (fwp_endpoint_t*) endpoint->protocol_info.body;
        len = fwp_recv(fwp_epoint, buffer, buffer_size, &from_addr, flags);
        if (len < 0) 
                return len;
@@ -128,9 +139,7 @@ int fwp_fna_receive_async(const fna_endpoint_data_t *endpoint, void *buffer,
        fwp_endpoint_t *fwp_epoint;
        int flags = 0;
        
-       fwp_epoint = (fwp_endpoint_t*) 
-                       endpoint->protocol_info.body;
-
+       fwp_epoint = (fwp_endpoint_t*) endpoint->protocol_info.body;
        len = fwp_recv(fwp_epoint, buffer, buffer_size, &from_addr, flags);
        if (len < 0) 
                return len;
@@ -167,7 +176,11 @@ fna_operations_t fwp_fna_operations = {
     .fna_receive_sync = fwp_fna_receive_sync,
     .fna_receive_async = fwp_fna_receive_async,
     .fna_send_endpoint_get_status = NULL,
-    .fna_receive_endpoint_created = NULL,
+    .fna_endpoint_destroy = fwp_fna_endpoint_destroy,
+    .fna_send_endpoint_created = fwp_fna_send_endpoint_created,
+    .fna_send_endpoint_bind = fwp_fna_send_endpoint_bind,
+    .fna_send_endpoint_unbind = fwp_fna_send_endpoint_unbind,
+    .fna_receive_endpoint_created = fwp_fna_receive_endpoint_created,
     .fna_receive_endpoint_get_status = NULL,
     .fna_network_get_max_message_size = NULL,
     .fna_network_bytes_to_budget = NULL,