1 #define CONFIGURE_FWP_MNGR_ADDR "127.0.0.1"
2 #include "fwp_confdefs.h"
8 fwp_endpoint_attr_t attr;
10 void* receiver(void *arg)
12 fwp_endpoint_d_t repoint_d1;
16 FWP_DEBUG("Creating receive endpoint\n");
17 if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
18 perror("Error while creating receive endpoint\n");
22 FWP_DEBUG("Receive endpoint created \n");
23 for (i = 0; i < 3; i++) {
24 if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
25 perror("Error while receiving data::");
28 printf("Received %s\n",buffer);
29 //for (j = 0 ; j < 10; i++)
30 // printf("%c", buffer[i]);
42 fwp_vres_d_t vres_d1, vres_d2, vres_d3;
43 fwp_contract_d_t cnt1d, cnt2d, cnt3d;
44 fwp_endpoint_d_t sepoint_d1, sepoint_d2, repoint_d1, repoint_d2;
45 char msg1[] = "Hello1";
46 char msg2[] = "Hello2";
51 struct fwp_vres_params vparam1;
54 cnt1.period_usec = 10000;
57 cnt2.period_usec = 1000;
60 cnt3.period_usec = 2000;
63 if (fwp_init() != 0) {
64 printf("fwp_init failed!\n");
68 fwp_endpoint_attr_init(&attr);
69 fwp_endpoint_attr_setreliability(&attr, FWP_EPOINT_RELIABLE);
70 pthread_create(&id, NULL, &receiver, (void*) NULL);
72 cnt1d = fwp_contract_create(&cnt1);
73 fwp_contract_negotiate(cnt1d, &vres_d1);
74 if (fwp_contract_is_negotiated(cnt1d)) {
75 printf("Contract1 negotiated.\n");
77 printf("Contract1 not negotiated.\n");
79 /* cnt2d = fwp_contract_create(&cnt2);
80 fwp_contract_negotiate(cnt2d, &vres_d2);
81 if (fwp_contract_is_negotiated(cnt2d)) {
82 printf("Contract2 negotiated.\n");
84 printf("Contract2 not negotiated.\n");
86 cnt3d = fwp_contract_create(&cnt3);
87 fwp_contract_negotiate(cnt3d, &vres_d3);
88 if (fwp_contract_is_negotiated(cnt3d)) {
89 printf("Contract3 negotiated.\n");
91 printf("Contract3 not negotiated.\n");
93 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777,
94 &attr, &sepoint_d1) < 0) {
97 printf("Send endpoint 1 created\n");
99 fwp_send_endpoint_bind(sepoint_d1, vres_d1);
101 fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
102 printf("Sent msg 1\n");
103 fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
104 printf("Sent msg 2\n");
107 printf("Test PASSED!\n");