1 #define CONFIGURE_FWP_MNGR_ADDR "127.0.0.1"
3 #include "fwp_confdefs.h"
9 fwp_endpoint_attr_t attr;
11 void* receiver(void *arg)
13 fwp_endpoint_d_t repoint_d1;
17 if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
21 FWP_DEBUG("Receive endpoint created \n");
22 for (i = 0; i < 4; i++) {
23 if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
24 perror("Error while receiving data::");
27 else printf("Received - %s\n", buffer);
35 fwp_vres_d_t vres_d1, vres_d2, vres_d3;
36 fwp_contract_d_t cnt1d, cnt2d, cnt3d;
37 fwp_endpoint_d_t sepoint_d1, sepoint_d2, repoint_d1, repoint_d2;
38 char msg1[] = "Hello1";
39 char msg2[] = "Hello2";
48 cnt1.period_usec = 10000;
51 cnt2.period_usec = 1000;
54 cnt3.period_usec = 2000;
57 if (fwp_init() != 0) {
58 printf("fwp_init failed!\n");
62 fwp_endpoint_attr_init(&attr);
63 attr.reliability = FWP_EPOINT_RELIABLE;
65 pthread_create(&id, NULL,
66 receiver, (void*) NULL);
68 cnt1d = fwp_contract_create(&cnt1);
69 fwp_contract_negotiate(cnt1d, &vres_d1);
70 if (fwp_contract_is_negotiated(cnt1d)) {
71 printf("Contract1 negotiated.\n");
73 printf("Contract1 not negotiated.\n");
75 /* cnt2d = fwp_contract_create(&cnt2);
76 fwp_contract_negotiate(cnt2d, &vres_d2);
77 if (fwp_contract_is_negotiated(cnt2d)) {
78 printf("Contract2 negotiated.\n");
80 printf("Contract2 not negotiated.\n");
82 cnt3d = fwp_contract_create(&cnt3);
83 fwp_contract_negotiate(cnt3d, &vres_d3);
84 if (fwp_contract_is_negotiated(cnt3d)) {
85 printf("Contract3 negotiated.\n");
87 printf("Contract3 not negotiated.\n");
89 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777,
94 printf("Send endpoint 1 created\n");
96 fwp_send_endpoint_bind(sepoint_d1, vres_d1);
98 fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
99 printf("Sent msg 1\n");
101 fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
102 printf("Sent msg 2\n");
105 printf("Test PASSED!\n");