1 #define CONFIGURE_FWP_MNGT 0
2 #include "fwp_confdefs.h"
10 // struct sockaddr_in local_addr, rem_addr, from;
12 fwp_vres_d_t vres_d1, vres_d2;
14 struct fwp_vres_params vparam1, vparam2;
15 char msg1[] = "Hello1";
16 char msg2[] = "Hello2";
18 fwp_endpoint_d_t sepoint_d1, sepoint_d2, repoint_d1, repoint_d2;
19 fwp_endpoint_attr_t attr;
21 fwp_endpoint_attr_init(&attr);
23 vparam1.ac_id = FWP_AC_VO;
25 vparam1.period_usec = 2000000;
27 vparam2.ac_id = FWP_AC_BK;
29 vparam2.period_usec = 100;
34 printf("Create vres1, vres2\n");
35 if (fwp_vres_create(&vparam1, &vres_d1) < 0) {
36 printf("Unable to create vres1\n");
39 printf("Vres1 created \n");
41 if (fwp_vres_create(&vparam2, &vres_d2) < 0){
42 fprintf(stderr,"Unable to create vres2\n");
45 printf("Vres2 created\n");
47 /* local_addr should be handled when creating socket */
48 if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
51 printf("Receive endpoint created\n");
53 if (fwp_receive_endpoint_create(7778, &attr,&repoint_d2) < 0){
56 printf("Receive endpoint created\n");
58 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, 0,
62 printf("Send endpoint 1 created\n");
63 fwp_send_endpoint_bind(sepoint_d1, vres_d1);
65 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7778, 0,
69 printf("Send endpoint 2 created\n");
70 fwp_send_endpoint_bind(sepoint_d2, vres_d2);
72 fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
73 fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
75 for (i = 0; i < 2; i++) {
76 if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
77 perror("Error while receiving data");
80 else printf("Received - %s\n", buffer);
83 if (fwp_vres_destroy(vres_d1) < 0) {
84 perror("Unable to destroy vres1\n");
87 printf("Vres1 destroyed\n");
89 if (fwp_vres_destroy(vres_d2) < 0){
90 perror("Unable to destroy vres2\n");
93 printf("Vres2 destroyed\n");
95 printf("Test PASSED!\n");