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"
19 #include <arpa/inet.h>
26 // struct sockaddr_in local_addr, rem_addr, from;
28 fwp_vres_t *vres1, *vres2;
29 struct fwp_vres_params vparam1;
32 fwp_endpoint_t *sepoint, *repoint;
34 struct timespec sendtime;
35 fwp_endpoint_attr_t attr;
38 fwp_endpoint_attr_init(&attr);
40 vparam1.ac_id = FWP_AC_VO;
42 vparam1.period.tv_sec = 2;
43 vparam1.period.tv_nsec = 111111;
46 if (fwp_init() != 0) {
47 printf("fwp_init failed!\n");
51 printf("Create vres1\n");
52 if ((fwp_vres_create(&vparam1, &vres1) < 0)) {
53 printf("Unable to create vres1\n");
56 printf("Vres1 created\n");
58 printf("Create vres2\n");
59 if ((fwp_vres_create(&vparam1, &vres2) < 0)) {
60 printf("Unable to create vres2\n");
63 printf("Vres2 created\n");
64 /* local_addr should be handled when creating socket */
65 if (fwp_receive_endpoint_create(7777, &attr, &repoint) < 0) {
68 printf("Receive endpoint created\n");
70 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr,
74 printf("Send endpoint 1 created\n");
75 fwp_send_endpoint_bind(sepoint, vres1);
77 for (count = 0; count < NUM; count++) {
78 sprintf(msg1,"msg%d",count);
79 fwp_send(sepoint, msg1, sizeof(msg1));
81 clock_gettime(CLOCK_MONOTONIC, &sendtime);
82 printf("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
85 if ((len = fwp_recv(repoint, buffer, sizeof(buffer), &from, 0)) < 0) {
86 perror("Error while receiving data");
89 else printf("Received - %s\n", buffer);
92 if (fwp_vres_destroy(vres1) < 0) {
93 perror("Unable to destroy vres1\n");
96 printf("Vres1 detroyed\n");
97 printf("Test PASSED!\n");