2 * \file fwp_sendrecv_test1.c
4 * This a test application that:
5 * - creates two vres without negotiation
6 * - creates send and receive endpoint
7 * - binds that endpoint to vres
13 #define CONFIGURE_FWP_MNGT 0
14 #include "fwp_confdefs.h"
22 // struct sockaddr_in local_addr, rem_addr, from;
24 fwp_vres_d_t vres_d1, vres_d2;
26 struct fwp_vres_params vparam1, vparam2;
27 char msg1[] = "Hello1";
28 char msg2[] = "Hello2";
30 fwp_endpoint_d_t sepoint_d1, sepoint_d2, repoint_d1, repoint_d2;
31 fwp_endpoint_attr_t attr;
34 fwp_endpoint_attr_init(&attr);
36 vparam1.ac_id = FWP_AC_VO;
38 vparam1.period.tv_sec = 2;
39 vparam1.period.tv_nsec = 0;
41 vparam2.ac_id = FWP_AC_BK;
43 vparam2.period.tv_sec = 0;
44 vparam2.period.tv_nsec = 100000;
49 printf("Create vres1, vres2\n");
50 if (fwp_vres_create(&vparam1, &vres_d1) < 0) {
51 printf("Unable to create vres1\n");
54 printf("Vres1 created \n");
56 if (fwp_vres_create(&vparam2, &vres_d2) < 0){
57 fprintf(stderr,"Unable to create vres2\n");
60 printf("Vres2 created\n");
62 /* local_addr should be handled when creating socket */
63 if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
66 printf("Receive endpoint created\n");
68 if (fwp_receive_endpoint_create(7778, &attr,&repoint_d2) < 0){
71 printf("Receive endpoint created\n");
73 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, 0,
77 printf("Send endpoint 1 created\n");
78 fwp_send_endpoint_bind(sepoint_d1, vres_d1);
80 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7778, 0,
84 printf("Send endpoint 2 created\n");
85 fwp_send_endpoint_bind(sepoint_d2, vres_d2);
87 fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
88 fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
90 for (i = 0; i < 2; i++) {
91 if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), &from,
93 perror("Error while receiving data");
96 else printf("Received - %s\n", buffer);
99 if (fwp_vres_destroy(vres_d1) < 0) {
100 perror("Unable to destroy vres1\n");
103 printf("Vres1 destroyed\n");
105 if (fwp_vres_destroy(vres_d2) < 0){
106 perror("Unable to destroy vres2\n");
109 printf("Vres2 destroyed\n");
111 printf("Test PASSED!\n");