4 #include <fres_contract.h>
11 int contract_deadline_sec[N] = { 4,4,4,4 };
12 int contract_nodes[N] = { 0x04, 0x05, 0x02 ,0x03};
15 int contract_deadline_sec[N] = {2,2,2};
16 int contract_nodes[N] = { 0x02,0x03,0x04};
18 int main(int argc, char *argv[])
21 frsh_contract_t contract[N];
22 frsh_vres_id_t vres[N];
27 if (ret) PERROR_AND_EXIT(ret, "frsh_init");
29 /* Negotiate N contracts */
31 frsh_rel_time_t deadline;
32 frsh_signal_info_t si;
33 fres_block_item_nodes *nodes;
34 ret = frsh_contract_init(&contract[i]);
35 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_init");
38 ret = frsh_contract_set_resource_and_label(
39 &contract[i], FRSH_RT_NETWORK, FRSH_NETPF_ITEM, NULL);
40 if (ret) PERROR_AND_EXIT(ret, "Cannot set resource\n");
42 /* Set nodes we want to receive data from */
43 nodes = malloc(sizeof(*nodes));
44 if (!nodes) PERROR_AND_EXIT(errno, "malloc");
45 //nodes->mask = contract_nodes[i];
48 nodes->mask = nodes->mask << (contract_nodes[i]);
51 ret = fres_contract_add_item_nodes(contract[i], nodes);
52 if (ret) PERROR_AND_EXIT(ret, "Cannot add item_nodes block\n");
55 deadline = fosa_msec_to_rel_time(contract_deadline_sec[i]*1000);
56 ret = frsh_contract_set_timing_reqs(&contract[i],
59 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_timing_reqs");
61 /* Negotiate the contract */
62 ret = frsh_contract_negotiate(&contract[i], &vres[i]);
63 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
64 if (ret) printf(" \n frsh_contract_negotiate - NOT ACCEPTED \n");
66 printf("Contracts negotiated\n");
68 for (i=0; i<30; i++) {
70 //printf("Reading data\n");
71 //for (j=0; j<N; j++) {
75 ret = fra_item_receive(vres[1], &data);
76 if (ret == -1) PERROR_AND_EXIT(errno, "frs_item_receive");
79 /* Do something with the received data */
81 /* printf("JOP 89 : %i - ",len);
82 for (k = 0; k < len-1; k++)
84 printf("%02x ", data[k]);
92 for (l=1; l < len/4; l++)
96 if (data[4*l-1] > 6*m) putchar('*');
108 for (i=0; i<N; i++) {
109 frsh_contract_cancel(vres[i]);