2 * \file fwp_vrestest1.c
4 * This a test application that:
5 * - creates vres without negotiation
6 * - creates send and receive endpoint
7 * - binds that endpoint to vres
8 * - in cycle (NUM loops) sends messages and prints send time
13 #define CONFIGURE_FWP_MNGT 0
14 #include "fwp_confdefs.h"
24 // struct sockaddr_in local_addr, rem_addr, from;
26 fwp_vres_d_t vresd1, vresd2;
27 struct fwp_vres_params vparam1;
30 fwp_endpoint_d_t sepoint_d1, repoint_d;
32 struct timespec sendtime;
33 fwp_endpoint_attr_t attr;
36 fwp_endpoint_attr_init(&attr);
38 vparam1.ac_id = FWP_AC_VO;
40 vparam1.period.tv_sec = 2;
41 vparam1.period.tv_nsec = 111111;
44 if (fwp_init() != 0) {
45 printf("fwp_init failed!\n");
49 printf("Create vres1\n");
50 if ((fwp_vres_create(&vparam1, &vresd1) < 0)) {
51 printf("Unable to create vres1\n");
54 printf("Vres1 created\n");
56 printf("Create vres2\n");
57 if ((fwp_vres_create(&vparam1, &vresd2) < 0)) {
58 printf("Unable to create vres2\n");
61 printf("Vres2 created\n");
62 /* local_addr should be handled when creating socket */
63 if (fwp_receive_endpoint_create(7777, &attr, &repoint_d) < 0) {
66 printf("Receive endpoint created\n");
68 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr,
72 printf("Send endpoint 1 created\n");
73 fwp_send_endpoint_bind(sepoint_d1, vresd1);
75 for (count = 0; count < NUM; count++) {
76 sprintf(msg1,"msg%d",count);
77 fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
79 clock_gettime(CLOCK_MONOTONIC, &sendtime);
80 FWP_DEBUG("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
83 if ((len = fwp_recv(repoint_d, buffer, sizeof(buffer), &from, 0)) < 0) {
84 perror("Error while receiving data");
87 else printf("Received - %s\n", buffer);
90 if (fwp_vres_destroy(vresd1) < 0) {
91 perror("Unable to destroy vres1\n");
94 printf("Vres1 detroyed\n");
95 printf("Test PASSED!\n");