- int err;
- rtep_station_id_t rtep_station = 3;
- frsh_network_address_t frsh_address;
- rtep_channel_t in_stream = 7;
- frsh_stream_id_t out_stream;
- struct timespec neg_period = {2,0};
- struct timespec get_period = {0,0};
-
- printf("1.- fna_init\n");
- printf("--------------------------------------------------\n");
- err=fna_init(FRSH_RESOURCE_ID_DEFAULT);
- assert(err == 0);
-
- printf("2.- frsh_rtep_map_network_address\n");
- printf("--------------------------------------------------\n");
- err=frsh_rtep_map_network_address
- (FRSH_RESOURCE_ID_DEFAULT, rtep_station, &frsh_address);
- assert(err == 0);
- printf("rtep_address: %d, frsh_address: %d\n", rtep_station, frsh_address);
- assert(rtep_station == frsh_address);
-
- printf("3.- frsh_rtep_map_stream_id\n");
- printf("--------------------------------------------------\n");
- err=frsh_rtep_map_stream_id
- (FRSH_RESOURCE_ID_DEFAULT, in_stream, &out_stream);
- assert(err == 0);
- printf("rtep_channel: %d, frsh_stream: %d\n", in_stream, out_stream);
- assert(in_stream == out_stream);
-
- printf("4.- frsh_rtep_negotiation_messages_vres_renegotiate period\n");
- printf("--------------------------------------------------\n");
- err=frsh_rtep_negotiation_messages_vres_get_period
- (FRSH_RESOURCE_ID_DEFAULT, &get_period);
- assert(err == 0);
- printf("get_period sec=%d nsec=%d\n", get_period.tv_sec, get_period.tv_nsec);
-
- err=frsh_rtep_negotiation_messages_vres_renegotiate
- (FRSH_RESOURCE_ID_DEFAULT, &neg_period);
- printf("renegotiation accepted: %d\n", !err);
- assert(err == 0);
-
- err=frsh_rtep_negotiation_messages_vres_get_period
- (FRSH_RESOURCE_ID_DEFAULT, &get_period);
- assert(err == 0);
- printf("get_period sec=%d nsec=%d\n", get_period.tv_sec, get_period.tv_nsec);
-
- return 0;
+ int err;
+ rtep_station_id_t rtep_station = 3;
+ frsh_network_address_t frsh_address;
+ rtep_channel_t in_stream = 7;
+ frsh_stream_id_t out_stream;
+ struct timespec neg_period = {2,0};
+ struct timespec get_period = {0,0};
+ struct timespec rtep_serv_thread_budget = {1,0};
+ struct timespec rtep_serv_thread_period = {5,0};
+ bool serv_thread_renegotiation_accepted = false;
+ struct timespec current_serv_thread_budget = {0,0};
+ struct timespec current_serv_thread_period = {0,0};
+
+ printf("1.- fna_init\n");
+ err=rtep_fna_operations.fna_init(FRSH_RESOURCE_ID_DEFAULT);
+ assert(err == 0);
+
+ printf("2.- frsh_rtep_map_network_address\n");
+ err=frsh_rtep_map_network_address
+ (FRSH_RESOURCE_ID_DEFAULT, rtep_station, &frsh_address);
+ assert(err == 0);
+ printf("rtep_address:%d -> frsh_address:%d\n", rtep_station, frsh_address);
+ assert(rtep_station == frsh_address);
+
+ printf("3.- frsh_rtep_map_stream_id\n");
+ err=frsh_rtep_map_stream_id
+ (FRSH_RESOURCE_ID_DEFAULT, in_stream, &out_stream);
+ assert(err == 0);
+ printf("rtep_channel:%d -> frsh_stream:%d\n", in_stream, out_stream);
+ assert(in_stream == out_stream);
+
+ printf("4.- frsh_rtep_negotiation_messages_vres_renegotiate period\n");
+ err=frsh_rtep_negotiation_messages_vres_get_period
+ (FRSH_RESOURCE_ID_DEFAULT, &get_period);
+ assert(err == 0);
+ printf("period before renegotiation: sec=%d nsec=%d\n",
+ get_period.tv_sec, get_period.tv_nsec);
+
+ err=frsh_rtep_negotiation_messages_vres_renegotiate
+ (FRSH_RESOURCE_ID_DEFAULT, &neg_period);
+ if (err == 0) {
+ printf("renegotiation accepted (period negotiated: sec=%d nsec=%d)\n",
+ neg_period.tv_sec, neg_period.tv_nsec);
+ } else {
+ printf("renegotiation not accepted\n");
+ }
+ assert (err == 0);
+
+ err=frsh_rtep_negotiation_messages_vres_get_period
+ (FRSH_RESOURCE_ID_DEFAULT, &get_period);
+ assert(err == 0);
+ printf("period after renegotiation: sec=%d nsec=%d\n",
+ get_period.tv_sec, get_period.tv_nsec);
+
+// TODO: uncomment step 5 when internal thread has a frescor contract
+// printf("5.- frsh_rtep_service_thread_vres_renegotiate\n");
+//
+// err=frsh_rtep_service_thread_vres_get_budget_and_period
+// (FRSH_RESOURCE_ID_DEFAULT,
+// ¤t_serv_thread_budget,
+// ¤t_serv_thread_period);
+// assert(err == 0);
+// printf("service thread budget (before renegotiation): sec=%d nsec=%d\n",
+// current_serv_thread_budget.tv_sec,
+// current_serv_thread_budget.tv_nsec);
+// printf("service thread period (before renegotiation): sec=%d nsec=%d\n",
+// current_serv_thread_period.tv_sec,
+// current_serv_thread_period.tv_nsec);
+//
+// err=frsh_rtep_service_thread_vres_renegotiate
+// (FRSH_RESOURCE_ID_DEFAULT,
+// &rtep_serv_thread_budget,
+// &rtep_serv_thread_period,
+// &serv_thread_renegotiation_accepted);
+// assert(err == 0);
+//
+// if (serv_thread_renegotiation_accepted) {
+// printf("service_thread renegotiation accepted\n");
+// } else {
+// printf("service_thread renegotiation not accepted\n");
+// }
+// assert (err == 0);
+//
+// err=frsh_rtep_service_thread_vres_get_budget_and_period
+// (FRSH_RESOURCE_ID_DEFAULT,
+// ¤t_serv_thread_budget,
+// ¤t_serv_thread_period);
+// assert(err == 0);
+// printf("service thread budget (after renegotiation): sec=%d nsec=%d\n",
+// current_serv_thread_budget.tv_sec,
+// current_serv_thread_budget.tv_nsec);
+// printf("service thread period (after renegotiation): sec=%d nsec=%d\n",
+// current_serv_thread_period.tv_sec,
+// current_serv_thread_period.tv_nsec);
+
+ printf("\nEND of the TEST\n");
+ return 0;