]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
FWP tests got to the functional state
authorMartin Molnar <molnar@sum.(none)>
Fri, 13 Jun 2008 15:04:12 +0000 (17:04 +0200)
committerMartin Molnar <molnar@sum.(none)>
Fri, 13 Jun 2008 15:04:12 +0000 (17:04 +0200)
19 files changed:
fwp/lib/core/fwp_endpoint.c
fwp/lib/core/fwp_endpoint.h
fwp/lib/fwp.h
fwp/lib/fwp_conf.h
fwp/lib/fwp_confdefs.h
fwp/lib/mngt/fwp_contract_table.h
fwp/lib/mngt/fwp_mngt.c
fwp/lib/mngt/fwp_mngt.h
fwp/mngr/fwp_admctrl.c
fwp/mngr/fwp_mngr.c
fwp/tests/Makefile.omk
fwp/tests/fwp_mngrtest/fwp_mngrtest.c
fwp/tests/fwp_msgtest/fwp_msgtest.c
fwp/tests/fwp_prototest/Makefile.omk
fwp/tests/fwp_prototest/fwp_sendrecv_test1.c [moved from fwp/tests/fwp_prototest/fwp_sendrecv_test.c with 74% similarity]
fwp/tests/fwp_prototest/fwp_sendrecv_test2.c [new file with mode: 0644]
fwp/tests/fwp_vrestest/Makefile.omk
fwp/tests/fwp_vrestest/fwp_vrestest1.c
fwp/tests/fwp_vrestest/fwp_vrestest2.c

index fd0e21ed1a7fd0ac0d90cb201eb0a439d5f412bc..e3632f30467c8f9713a085684b0df5014d551b30 100644 (file)
@@ -371,7 +371,6 @@ ssize_t fwp_recv(fwp_endpoint_d_t epointd, void *buffer, size_t buffer_size,
        int csockd, i;
        
        if (epoint->attr.reliability == FWP_EPOINT_BESTEFFORT) {        
-               FWP_DEBUG("Recv\n");
                _fwp_recvfrom(len, epoint->sockd, buffer, buffer_size, 0, 
                        peer->addr, &peer->addrlen);
                return len;
index e049410d7a65bed04e521e89d7bad81d1ac2bea0..af93ceb2ea53173eb99595b63543bd6101eaf0e3 100644 (file)
@@ -46,9 +46,11 @@ ssize_t fwp_recv(fwp_endpoint_d_t epointd, void *buffer,
                        size_t buffer_size, int flags);
 int fwp_send(fwp_endpoint_d_t epointd, void *msg, size_t size, int flags);
 
-static inline int fwp_endpoint_attr_setreliability(fwp_endpoint_attr_t *attr)
+int fwp_endpoint_attr_init(fwp_endpoint_attr_t *attr);
+static inline int 
+fwp_endpoint_attr_setreliability(fwp_endpoint_attr_t *attr, int reliability)
 {
-       attr->reliability = FWP_EPOINT_RELIABLE;
+       attr->reliability = reliability;
        return 0;
 }
 
index 15a745a253bc3f76bf720cb0a13334b44d72a931..3f1ac256cf247d86b56b7a9bb07914a4ab5ac249 100644 (file)
@@ -8,24 +8,18 @@
 #include "fwp_contract.h"
 #include "fwp_contract_table.h"
 
-/**
- * FWP initialisation
- *  1. endpoint table init
- *  2. vres table init
- *  3. mngt_init
- *  4. mngt connect
- *
- *  fwp mngr does not call 3., 4.
- */
-
 static inline int fwp_init()
 {
        int rv;
 
        if ((rv = fwp_endpoint_table_init(fwp_configuration.max_endpoints)) ||
-           (rv = fwp_vres_table_init(fwp_configuration.max_vres)) ||
-           (rv = fwp_mngt_init()) ) 
+           (rv = fwp_vres_table_init(fwp_configuration.max_vres)))
+               return rv;
+       
+       if (fwp_configuration.mngt) { 
+               rv = fwp_mngt_init(); 
                return rv;
+       }
 
        return 0;
 }
index 18c29b1b93be601fb70da25a4b2d7bc9cd8f5af1..fb0cda418f1e3d8dfba53d812907e69a120ca62b 100644 (file)
@@ -10,6 +10,7 @@ typedef
 struct {
        unsigned int max_vres;
        unsigned int max_endpoints;
+       unsigned int mngt;
        char         my_addr[16];
        unsigned int my_stream_id;
        char         mngr_addr[16];
index 3ab5ddabc2e51c2c7cd910f8e583c9074c76a5e0..ec3a11387075866f09232d1586f1f8aea6a6d0bc 100644 (file)
 #define CONFIGURE_FWP_ENDPOINTS_MAXIMUM 50
 #endif
 
+/** Turn on/off FWP mnanagement */
+#ifndef CONFIGURE_FWP_MNGT
+#define CONFIGURE_FWP_MNGT 1
+#endif
+
 /** IP Address of interface FWP operates on */
 #ifndef CONFIGURE_FWP_MY_ADDR
 #define CONFIGURE_FWP_MY_ADDR "127.0.0.1"
@@ -48,6 +53,7 @@
 fwp_configuration_table_t fwp_configuration = {
        CONFIGURE_FWP_VRES_MAXIMUM,
        CONFIGURE_FWP_ENDPOINTS_MAXIMUM,
+       CONFIGURE_FWP_MNGT,
        CONFIGURE_FWP_MY_ADDR,
        CONFIGURE_FWP_MY_STREAM_ID,
        CONFIGURE_FWP_MNGR_ADDR,
index b73605c019bf0e96f9e8e2eed4ce2ac5ae5fa11c..08fd6b649107894a66e6e6a920cb352063eab3da 100644 (file)
@@ -9,24 +9,19 @@
 #include "ul_list.h"
 #include "ul_gavlcust.h"
 
-/**
- * FWP vres parameters 
- * It is internal representation of the contract used inside 
- * protocol.
- * 
- */
-
 /**
  * List of contract_data structures
  *
  */
-typedef
+/*typedef
 struct fwp_contract_list {
        ul_list_head_t                  head;
 } fwp_contract_list_t;
 
 UL_LIST_CUST_DEC(fwp_contract_list, fwp_contract_list_t, fwp_contract_data_t,
                 head, list_node);
+*/
+
 
 /**
  * Table of contract_data structures
index bab6c14feb3ec3f683d1a0ad7caf7fd1e7a96634..1484b9842103138231316695ee4a232bb1dc731d 100644 (file)
@@ -60,7 +60,7 @@ int fwp_mngt_service_vres_create(fwp_vres_d_t* fwp_service_vresd)
        /* create service vres */
        fwp_service_vparams.ac_id = FWP_AC_BK; 
        fwp_service_vparams.budget = 100;
-       fwp_service_vparams.period_usec = 1000;
+       fwp_service_vparams.period_usec = 30;
        
        if ((fwp_vres_create(&fwp_service_vparams, fwp_service_vresd) < 0)) {
                fprintf(stderr,"Unable to open service vres\n");
@@ -80,7 +80,10 @@ int fwp_mngt_connect()
        fwp_participant_id_t    participant_id;
        fwp_msgb_t              *msgb;
        fwp_msg_type_t          msg_type;
-
+       fwp_endpoint_attr_t     attr;
+       
+       fwp_endpoint_attr_init(&attr);
+       fwp_endpoint_attr_setreliability(&attr, FWP_MNGT_RELIABILITY);
 
        /* Create discovery endpoint */
        FWP_DEBUG("Service vres created\n");
@@ -89,7 +92,7 @@ int fwp_mngt_connect()
        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);    
+                                &attr, &fwp_participant_mngr->epointd);        
        fwp_send_endpoint_bind(fwp_participant_mngr->epointd, 
                                fwp_participant_mngr->vresd);
        
@@ -126,7 +129,7 @@ int fwp_mngt_connect()
 
        /* 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->stream_id, &attr,
                                 &fwp_participant_mngr->epointd);
        FWP_DEBUG("Management send endpoint created\n");
        fwp_send_endpoint_bind(fwp_participant_mngr->epointd, 
@@ -141,8 +144,10 @@ int fwp_mngt_init()
        fwp_endpoint_attr_t attr;
        char *value;
        
-       /* Create fwp_participant_this */
-       
+       fwp_endpoint_attr_init(&attr);
+       fwp_endpoint_attr_setreliability(&attr, FWP_MNGT_RELIABILITY);
+
+       /* Create fwp_participant_this */       
        my_info.id.node_id = inet_addr(fwp_configuration.my_addr);
        if (my_info.id.node_id == inet_addr("127.0.0.1")) {
                /* if default then check env variable */
@@ -156,7 +161,7 @@ int fwp_mngt_init()
        my_info.stream_id = fwp_configuration.my_stream_id;
 
        fwp_participant_this = fwp_participant_create(&my_info);        
-       fwp_receive_endpoint_create(my_info.stream_id, NULL,
+       fwp_receive_endpoint_create(my_info.stream_id, &attr,
                                        &fwp_participant_this->epointd);
        /* FIXME 
        fwp_endpoint_get_params(&(fwp_participant_this->id.node_id), 
index 6e19e73e486f5b941da58480776f4513c3c3dac7..2c88a0fc13239c9947707fb94fc2d117b42e4b8d 100644 (file)
@@ -10,8 +10,9 @@
 #include "fwp_participant.h"
 #include "fwp_contract_table.h"
 
-#define FWP_MNGR_STREAM_ID     3000
+#define FWP_MNGR_STREAM_ID             3000
 #define FWP_MNGT_DISCOVERY_STREAM_ID   3000
+#define FWP_MNGT_RELIABILITY           FWP_EPOINT_BESTEFFORT
 
 extern fwp_participant_t       *fwp_participant_this;
 extern fwp_participant_t       *fwp_participant_mngr;
index 09c2364d9a5e55dfbb520364684264b0a004a5c9..155407b068b49f9f6cf258b6a5c64dd3e8df77f4 100644 (file)
@@ -8,7 +8,7 @@ void fwp_admctrl_stupid(fwp_contract_data_t *contdata)
 {
        contdata->vres_params.ac_id = FWP_AC_VI;
        contdata->vres_params.budget = 100;
-       contdata->vres_params.period_usec = 2000;       
+       contdata->vres_params.period_usec = 20; 
        
        if (nr_negotiated <= 2) { 
                nr_negotiated++;
index 5729ce0262e5cbc2617212c9db911e6f4196deb1..c89d06e69fb85e2dc84ae112262d1b6bb49fab15 100644 (file)
@@ -52,16 +52,19 @@ 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_endpoint_attr_t attr;
 
        FWP_DEBUG("Received HELLO msg from nodeid= %d appid= %d\n", 
                        participant_id.node_id, participant_id.app_id);
 
+       fwp_endpoint_attr_init(&attr);
+       fwp_endpoint_attr_setreliability(&attr, FWP_MNGT_RELIABILITY);
        /* Create a new participant */
        fwp_msg_hello_out(msgb->data, &participant_info);
        participant = fwp_participant_create(&participant_info);
        fwp_mngt_service_vres_create(&participant->vresd);
        fwp_send_endpoint_create(participant->id.node_id, participant->stream_id,
-                                       0, &participant->epointd);
+                                       &attr, &participant->epointd);
        fwp_send_endpoint_bind(participant->epointd, participant->vresd);
        fwp_contract_table_init(&participant->contract_table);
 
@@ -161,7 +164,7 @@ fwp_mngr_contract_commit(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
 
        fwp_msg_contracthdr_out(msgb->data, &id, &status);
        fwp_msgb_pull(msgb, sizeof(struct fwp_msg_contracthdr));
-       FWP_DEBUG("Contract id=%d to commit\n", contdata->id);
+       FWP_DEBUG("Contract id=%d to commit\n", id);
        
        contdata = fwp_contract_table_find(&participant->contract_table, id);
        contdata->status = FWP_CONT_NEGOTIATED; 
index bf936ccae8342dedbd6a0bbdebdf6a4a78494e14..2be3c8b60f5c0c04f689bdcef47e2684aebefd53 100644 (file)
@@ -1,3 +1,3 @@
-SUBDIRS= fwp_mngrtest  
+SUBDIRS= fwp_msgtest fwp_vrestest fwp_prototest fwp_mngrtest  
 #SUBDIRS= fwp_msgtest fwp_vrestest fwp_prototest fwp_mngrtest  
 #fwp_mngrtest unixsocktest
index 57317ad7fecedee9196403e3e4e11b15ea0b3b82..4a7a52e1c25b25e847fa7ad7bb5835902e214511 100644 (file)
@@ -1,5 +1,4 @@
 #define CONFIGURE_FWP_MNGR_ADDR "127.0.0.1"
-
 #include "fwp_confdefs.h"
 #include "fwp.h"
 
@@ -10,24 +9,32 @@ fwp_endpoint_attr_t  attr;
 
 void* receiver(void *arg)
 {
-       fwp_endpoint_d_t        repoint_d1;
+       fwp_endpoint_d_t repoint_d1;
        int i,len;
        char buffer[30];
 
+       FWP_DEBUG("Creating receive endpoint\n");
        if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
-               return ;
+               perror("Error while creating receive endpoint\n");
+               return NULL;
        }
                
        FWP_DEBUG("Receive endpoint created \n");
-       for (i = 0; i < 4; i++) {
+       for (i = 0; i < 3; i++) {
                if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
                        perror("Error while receiving data::");
-                       return ;
-               } 
-                       else printf("Received - %s\n", buffer);
+                       return NULL;
+               } else {
+                       printf("Received %s\n",buffer);
+                       //for (j = 0 ; j < 10; i++)
+                       //      printf("%c", buffer[i]);
+
+               }
+               printf("END\n");
        }
-}
 
+       return NULL;
+}
 
 int main()
 {
@@ -37,13 +44,12 @@ int main()
        fwp_endpoint_d_t sepoint_d1, sepoint_d2, repoint_d1, repoint_d2;
        char msg1[] = "Hello1";
        char msg2[] = "Hello2";
-
        fwp_contract_t cnt1;
        fwp_contract_t cnt2;
        fwp_contract_t cnt3;
-
        pthread_t       id;
-
+       struct fwp_vres_params vparam1;
+       
        cnt1.budget = 100;
        cnt1.period_usec = 10000;
 
@@ -60,10 +66,8 @@ int main()
        }       
        
        fwp_endpoint_attr_init(&attr);
-       attr.reliability = FWP_EPOINT_RELIABLE;
-       
-       pthread_create(&id, NULL, 
-                           receiver, (void*) NULL);
+       fwp_endpoint_attr_setreliability(&attr, FWP_EPOINT_RELIABLE);
+       pthread_create(&id, NULL, &receiver, (void*) NULL);
        
        cnt1d = fwp_contract_create(&cnt1);
        fwp_contract_negotiate(cnt1d, &vres_d1);
@@ -87,8 +91,7 @@ int main()
                printf("Contract3 not negotiated.\n");
 */     
        if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, 
-               &attr, &sepoint_d1)
-                < 0) {
+               &attr, &sepoint_d1) < 0) {
                return -1;
        }
        printf("Send endpoint 1 created\n");
@@ -97,7 +100,6 @@ int main()
 
        fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
        printf("Sent msg 1\n");
-//     sleep(2);
        fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
        printf("Sent msg 2\n");
 
@@ -105,5 +107,6 @@ int main()
        printf("Test PASSED!\n");
        
        scanf("Press key");     
+
        return 0;
 }
index 6d9b24172397a26f2aa0c6656381e7ce669361e4..407c4dac7b21ea9c5d6e700573c0e88237e78130 100644 (file)
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
 
        cont_a.budget = 50;
        cont_a.period_usec = 80;
-       fwp_msg_contract_deflate(msgb->data, &cont_a);
+       fwp_msg_contract_in(msgb->data, &cont_a);
 
        printf("Enqueue message A. ");
        if (!fwp_msgq_enqueue(&msgq, msgb))
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
 
        cont_b.budget = 30;
        cont_b.period_usec = 100;
-       fwp_msg_contract_deflate(msgb->data, &cont_b);
+       fwp_msg_contract_in(msgb->data, &cont_b);
 
        printf("Enqueue message B. ");
        if (!fwp_msgq_enqueue(&msgq, msgb))
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
 
        printf("in=%d out=%d pending=%d \n",msgq.in,msgq.out,msgq.nr_pending);
        
-       fwp_msg_contract_inflate(msgb->data, &cont_c);
+       fwp_msg_contract_out(msgb->data, &cont_c);
        fwp_msgb_free(msgb);
        
        if ((cont_a.budget != cont_c.budget)||
@@ -92,7 +92,7 @@ int main(int argc, char *argv[])
 
        printf("in=%d out=%d pending=%d \n",msgq.in,msgq.out,msgq.nr_pending);
        
-       fwp_msg_contract_inflate(msgb->data, &cont_d);
+       fwp_msg_contract_out(msgb->data, &cont_d);
        fwp_msgb_free(msgb);
        
        if ((cont_b.budget != cont_d.budget)||
index 0aa0a9ba56f171fbe557fbaccb61c15093d523c5..462773ac97c17ac9379fe7cbf3ca67ea375ea57c 100644 (file)
@@ -1,3 +1,4 @@
-test_PROGRAMS = fwp_sendrecv_test
-fwp_sendrecv_test_SOURCES+= fwp_sendrecv_test.c
-lib_LOADLIBES += fwp pthread rt 
+test_PROGRAMS = fwp_sendrecv_test1 fwp_sendrecv_test2
+fwp_sendrecv_test1_SOURCES+= fwp_sendrecv_test1.c
+fwp_sendrecv_test2_SOURCES+= fwp_sendrecv_test2.c
+lib_LOADLIBES += fwp pthread rt ulut 
similarity index 74%
rename from fwp/tests/fwp_prototest/fwp_sendrecv_test.c
rename to fwp/tests/fwp_prototest/fwp_sendrecv_test1.c
index 6163810a0b935da6935a2f72111000d5e9bec152..4b9e07c8f5fcbbedd6b2dbb51e252690989059e4 100644 (file)
@@ -1,3 +1,5 @@
+#define CONFIGURE_FWP_MNGT 0
+#include "fwp_confdefs.h"
 #include "fwp.h"
 
 #include <errno.h>
@@ -14,6 +16,9 @@ int main()
        char msg2[] = "Hello2";
        char buffer[30];
        fwp_endpoint_d_t sepoint_d1, sepoint_d2, repoint_d1, repoint_d2;
+       fwp_endpoint_attr_t attr;
+       
+       fwp_endpoint_attr_init(&attr);
 
        vparam1.ac_id = FWP_AC_VO; 
        vparam1.budget = 100;
@@ -40,37 +45,35 @@ int main()
        printf("Vres2 created\n");
        
        /* local_addr should be handled when creating socket */
-       if (fwp_receive_endpoint_create(7777, FWP_EPOINT_MNGT,&repoint_d1) < 0){
+       if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
                return -1;
        }
        printf("Receive endpoint created\n");
        
-       if (fwp_receive_endpoint_create(7778, FWP_EPOINT_MNGT,&repoint_d2) < 0){
+       if (fwp_receive_endpoint_create(7778, &attr,&repoint_d2) < 0){
                return -1;
        }
        printf("Receive endpoint created\n");
        
-       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, 
-               FWP_EPOINT_MNGT, &sepoint_d1)
-                < 0) {
+       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, 0, 
+                                       &sepoint_d1) < 0) {
                return -1;
        }
        printf("Send endpoint 1 created\n");
        fwp_send_endpoint_bind(sepoint_d1, vres_d1);
        
-       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7778, 
-               FWP_EPOINT_MNGT, &sepoint_d2) < 0){
-               
+       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7778, 0, 
+                                       &sepoint_d2) < 0){
                return -1;
        }
        printf("Send endpoint 2 created\n");
        fwp_send_endpoint_bind(sepoint_d2, vres_d2);
        
-       fwp_send(sepoint_d1, msg1, sizeof(msg1));
-       fwp_send(sepoint_d1, msg2, sizeof(msg2));
+       fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
+       fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
 
        for (i = 0; i < 2; i++) {
-               if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer))) < 0) {
+               if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
                        perror("Error while receiving data");
                        return -1;
                } 
diff --git a/fwp/tests/fwp_prototest/fwp_sendrecv_test2.c b/fwp/tests/fwp_prototest/fwp_sendrecv_test2.c
new file mode 100644 (file)
index 0000000..38777b2
--- /dev/null
@@ -0,0 +1,102 @@
+#define CONFIGURE_FWP_MNGT 0
+#include "fwp_confdefs.h"
+#include "fwp.h"
+
+#include <errno.h>
+#include <stdio.h>
+
+fwp_endpoint_attr_t  attr;
+
+void* receiver(void *arg)
+{
+       fwp_endpoint_d_t repoint_d1;
+       int i,len;
+       char buffer[30];
+
+       FWP_DEBUG("Creating receive endpoint\n");
+       if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
+               perror("Error while creating receive endpoint\n");
+               return NULL;
+       }
+               
+       FWP_DEBUG("Receive endpoint created \n");
+       for (i = 0; i < 3; i++) {
+               if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
+                       perror("Error while receiving data::");
+                       return NULL;
+               } else {
+                       printf("Received %s\n",buffer);
+                       //for (j = 0 ; j < 10; i++)
+                       //      printf("%c", buffer[i]);
+
+               }
+               printf("END\n");
+       }
+
+       return NULL;
+}
+
+int main()
+{
+       fwp_vres_d_t vres_d1;
+       struct fwp_vres_params vparam1, vparam2;
+       char msg1[] = "Hello1";
+       char msg2[] = "Hello2";
+       fwp_endpoint_d_t sepoint_d1;
+       pthread_t id;
+       
+       vparam1.ac_id = FWP_AC_VO; 
+       vparam1.budget = 100;
+       vparam1.period_usec = 10; 
+
+       vparam2.ac_id = FWP_AC_BK; 
+       vparam2.budget = 100;
+       vparam2.period_usec = 100;
+
+       printf("Start\n");
+       if (fwp_init() != 0) {
+               printf("FWP initialization failed!\n");
+               return -1;
+       }
+       
+       fwp_endpoint_attr_init(&attr);
+       fwp_endpoint_attr_setreliability(&attr, FWP_EPOINT_RELIABLE);
+       
+       pthread_create(&id, NULL, &receiver, (void*) NULL);
+       printf("Create vres1, vres2\n");
+       if (fwp_vres_create(&vparam1, &vres_d1) < 0) {
+               printf("Unable to create vres1\n");
+               return -1;
+       }
+       printf("Vres1 created \n");
+       
+       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr, 
+                                       &sepoint_d1) < 0) {
+               return -1;
+       }
+       printf("Send endpoint 1 created\n");
+       fwp_send_endpoint_bind(sepoint_d1, vres_d1);
+       
+       fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
+       FWP_DEBUG("Sent msg1\n");
+       fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
+       FWP_DEBUG("Sent msg2\n");
+
+       /*if (fwp_vres_destroy(vres_d1) < 0) {
+               perror("Unable to destroy vres1\n");
+               return -1;
+       }
+       printf("Vres1 destroyed\n");
+       
+       if (fwp_vres_destroy(vres_d2) < 0){
+               perror("Unable to destroy vres2\n");
+               return -1;
+       }       
+       printf("Vres2 destroyed\n");
+       */
+
+       printf("Test PASSED!\n");
+       scanf("Press key");     
+       
+       return 0;
+}
index ed67a9d83926a0d26d35dfd159fa502a6184ec2e..09e2dbf7f5cbcea2187185eb86d859968a2f5cd7 100644 (file)
@@ -1,4 +1,4 @@
 test_PROGRAMS = fwp_vrestest1 fwp_vrestest2
 fwp_vrestest1_SOURCES+= fwp_vrestest1.c
 fwp_vrestest2_SOURCES+= fwp_vrestest2.c
-lib_LOADLIBES += fwp pthread rt 
+lib_LOADLIBES += fwp pthread rt ulut 
index 9fac9dab53fe7491fc44210eec7133904f89abb6..dc9029a9400ce40662845f9a9f2e738e7898febd 100644 (file)
@@ -1,3 +1,5 @@
+#define  CONFIGURE_FWP_MNGT 0
+#include "fwp_confdefs.h"
 #include "fwp.h"
 
 #include <errno.h>
@@ -16,7 +18,9 @@ int main()
        fwp_endpoint_d_t sepoint_d1, repoint_d;
        int count;
        struct timespec  sendtime;
-
+       fwp_endpoint_attr_t attr ;
+       
+       fwp_endpoint_attr_init(&attr);
        vparam1.ac_id = FWP_AC_VO; 
        vparam1.budget = 100;
        vparam1.period_usec = 2111111; 
@@ -41,13 +45,13 @@ int main()
        }
        printf("Vres2 created\n");
        /* local_addr should be handled when creating socket */
-       if (fwp_receive_endpoint_create(7777, &repoint_d) < 0) {
+       if (fwp_receive_endpoint_create(7777, &attr, &repoint_d) < 0) {
                return -1;
        }
        printf("Receive endpoint created\n");
        
-       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &sepoint_d1) 
-               < 0){
+       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr, 
+                                       &sepoint_d1) < 0){
                return -1;
        }
        printf("Send endpoint 1 created\n");
@@ -55,13 +59,13 @@ int main()
        
        for (count = 0; count < NUM; count++) { 
                sprintf(msg1,"msg%d",count);
-               fwp_send(sepoint_d1, msg1, sizeof(msg1));
+               fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
                
                clock_gettime(CLOCK_MONOTONIC, &sendtime);
                FWP_DEBUG("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
                                sendtime.tv_nsec);
                
-               if ((len = fwp_recv(repoint_d, buffer, sizeof(buffer))) < 0) {
+               if ((len = fwp_recv(repoint_d, buffer, sizeof(buffer), 0)) < 0) {
                        perror("Error while receiving data");
                        return -1;
                } 
index 4ec00033edc85b9422f8bd0464accb676307cf8f..980a015bf18ba606e0a66c775d173bdf809b2a2c 100644 (file)
@@ -1,3 +1,5 @@
+#define  CONFIGURE_FWP_MNGT 0
+#include "fwp_confdefs.h"
 #include "fwp.h"
 
 #include <errno.h>
@@ -6,7 +8,8 @@
 #define  NUM  20
 
 int exit_flag = 0;
-
+fwp_endpoint_attr_t attr;
+       
 void* sender()
 {
        fwp_endpoint_d_t sepoint_d1;
@@ -27,8 +30,8 @@ void* sender()
        }
        printf("Vres1 created");
        
-       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &sepoint_d1) 
-               < 0){
+       if (fwp_send_endpoint_create(inet_addr("127.0.0.0"), 7777, &attr, 
+               &sepoint_d1) < 0){
                return NULL;
        }
        printf("Send endpoint 1 created\n");
@@ -42,7 +45,7 @@ void* sender()
        while (count < NUM){
                count++;
                sprintf(msg1,"msg%d",count);
-               fwp_send(sepoint_d1, msg1, sizeof(msg1));
+               fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
        
                printf("sent\n");       
                /*clock_gettime(CLOCK_MONOTONIC, &sendtime);
@@ -73,7 +76,7 @@ void* receiver()
        struct timespec recvtime;
        
        /* local_addr should be handled when creating socket */
-       if (fwp_receive_endpoint_create(7777, &repoint_d) < 0){
+       if (fwp_receive_endpoint_create(7777, &attr, &repoint_d) < 0){
                perror("Not initialized\n");
                return NULL;
        }
@@ -81,7 +84,7 @@ void* receiver()
        
        for (count = 1; count <= NUM; count++) {        
                
-               if ((len = fwp_recv(repoint_d, buffer, sizeof(buffer))) < 0){
+               if ((len = fwp_recv(repoint_d, buffer, sizeof(buffer), 0)) < 0){
                        perror("Error while receiving data");
                        return NULL;
                } 
@@ -100,15 +103,16 @@ void* receiver()
 int main()
 {
 //     struct sockaddr_in local_addr, rem_addr, from;
-       pthread_attr_t  attr;
+       pthread_attr_t  thattr;
        pthread_t       thread;
 
        printf("Start\n");
        fwp_init();
        
-       pthread_attr_init(&attr);
-       pthread_create(&thread, &attr, receiver, NULL); 
-       pthread_create(&thread, &attr, sender, NULL); 
+       fwp_endpoint_attr_init(&attr);
+       pthread_attr_init(&thattr);
+       pthread_create(&thread, &thattr, receiver, NULL); 
+       pthread_create(&thread, &thattr, sender, NULL); 
        pthread_join(thread, (void**) NULL);    
 
        printf("Test PASSED!\n");