aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-07-27 13:54:13 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-07-27 13:54:13 +0000
commit13643639871e823f168392e7da631021b2d154c6 (patch)
tree1c71c947a9c8949a7399d0d52ca35698f04cb384 /src/testbed
parent9a34927cbc2a5d2113a9fea346de92a99465d94e (diff)
downloadgnunet-13643639871e823f168392e7da631021b2d154c6.tar.gz
gnunet-13643639871e823f168392e7da631021b2d154c6.zip
fixed LCF forwarding
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-service-testbed.c63
1 files changed, 49 insertions, 14 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 6f7e38429..5162c6a11 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -184,6 +184,11 @@ enum LCFContextState
184 DELEGATED_HOST_REGISTERED, 184 DELEGATED_HOST_REGISTERED,
185 185
186 /** 186 /**
187 * The slave host has been registred at the forwarding controller
188 */
189 SLAVE_HOST_REGISTERED,
190
191 /**
187 * The context has been finished (may have error) 192 * The context has been finished (may have error)
188 */ 193 */
189 FINISHED 194 FINISHED
@@ -235,7 +240,11 @@ struct LCFContext
235 * The delegated host 240 * The delegated host
236 */ 241 */
237 uint32_t delegated_host_id; 242 uint32_t delegated_host_id;
238 243
244 /**
245 * The slave host
246 */
247 uint32_t slave_host_id;
239 248
240}; 249};
241 250
@@ -654,19 +663,26 @@ lcf_proc_cc (void *cls, const char *emsg)
654 { 663 {
655 case INIT: 664 case INIT:
656 if (NULL != emsg) 665 if (NULL != emsg)
657 { 666 goto registration_error;
658 LOG (GNUNET_ERROR_TYPE_WARNING,
659 "Host registration failed with message: %s\n", emsg);
660 lcf->state = FINISHED;
661 lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
662 return;
663 }
664 lcf->state = DELEGATED_HOST_REGISTERED; 667 lcf->state = DELEGATED_HOST_REGISTERED;
665 lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); 668 lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
666 break; 669 break;
670 case DELEGATED_HOST_REGISTERED:
671 if (NULL != emsg)
672 goto registration_error;
673 lcf->state = SLAVE_HOST_REGISTERED;
674 lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
675 break;
667 default: 676 default:
668 GNUNET_assert (0); /* Shouldn't reach here */ 677 GNUNET_assert (0); /* Shouldn't reach here */
669 } 678 }
679 return;
680
681 registration_error:
682 LOG (GNUNET_ERROR_TYPE_WARNING,
683 "Host registration failed with message: %s\n", emsg);
684 lcf->state = FINISHED;
685 lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
670} 686}
671 687
672 688
@@ -693,7 +709,7 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
693 lcf->rhandle = 709 lcf->rhandle =
694 GNUNET_TESTBED_register_host (lcf->gateway->controller, 710 GNUNET_TESTBED_register_host (lcf->gateway->controller,
695 host_list[lcf->delegated_host_id], 711 host_list[lcf->delegated_host_id],
696 lcf_proc_cc, lcf); 712 lcf_proc_cc, lcf);
697 } 713 }
698 else 714 else
699 { 715 {
@@ -702,14 +718,32 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
702 } 718 }
703 break; 719 break;
704 case DELEGATED_HOST_REGISTERED: 720 case DELEGATED_HOST_REGISTERED:
721 if (GNUNET_NO ==
722 GNUNET_TESTBED_is_host_registered_ (host_list[lcf->slave_host_id],
723 lcf->gateway->controller))
724 {
725 lcf->rhandle =
726 GNUNET_TESTBED_register_host (lcf->gateway->controller,
727 host_list[lcf->slave_host_id],
728 lcf_proc_cc, lcf);
729 }
730 else
731 {
732 lcf->state = SLAVE_HOST_REGISTERED;
733 lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
734 }
735 break;
736 case SLAVE_HOST_REGISTERED:
705 GNUNET_TESTBED_controller_link_2 (lcf->gateway->controller, 737 GNUNET_TESTBED_controller_link_2 (lcf->gateway->controller,
706 host_list[lcf->delegated_host_id], 738 host_list[lcf->delegated_host_id],
707 host_list[lcf->gateway->host_id], 739 host_list[lcf->slave_host_id],
708 lcf->sxcfg, lcf->sxcfg_size, 740 lcf->sxcfg, lcf->sxcfg_size,
709 lcf->scfg_size, 741 lcf->scfg_size,
710 lcf->is_subordinate); 742 lcf->is_subordinate);
711 lcf->state = FINISHED; 743 lcf->state = FINISHED;
712 case FINISHED: 744 lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
745 break;
746 case FINISHED:
713 lcfq = lcfq_head; 747 lcfq = lcfq_head;
714 GNUNET_assert (lcfq->lcf == lcf); 748 GNUNET_assert (lcfq->lcf == lcf);
715 GNUNET_free (lcf->sxcfg); 749 GNUNET_free (lcf->sxcfg);
@@ -1137,6 +1171,10 @@ handle_link_controllers (void *cls,
1137 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1171 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1138 return; 1172 return;
1139 } 1173 }
1174 lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue));
1175 lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
1176 lcfq->lcf->delegated_host_id = delegated_host_id;
1177 lcfq->lcf->slave_host_id = slave_host_id;
1140 while (NULL != (route = route_list[slave_host_id])) 1178 while (NULL != (route = route_list[slave_host_id]))
1141 { 1179 {
1142 if (route->thru == master_context->host_id) 1180 if (route->thru == master_context->host_id)
@@ -1146,9 +1184,6 @@ handle_link_controllers (void *cls,
1146 GNUNET_assert (NULL != route); /* because we add routes carefully */ 1184 GNUNET_assert (NULL != route); /* because we add routes carefully */
1147 GNUNET_assert (route->dest < slave_list_size); 1185 GNUNET_assert (route->dest < slave_list_size);
1148 GNUNET_assert (NULL != slave_list[route->dest]); 1186 GNUNET_assert (NULL != slave_list[route->dest]);
1149 lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue));
1150 lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
1151 lcfq->lcf->delegated_host_id = delegated_host_id;
1152 lcfq->lcf->is_subordinate = 1187 lcfq->lcf->is_subordinate =
1153 (1 == msg->is_subordinate) ? GNUNET_YES : GNUNET_NO; 1188 (1 == msg->is_subordinate) ? GNUNET_YES : GNUNET_NO;
1154 lcfq->lcf->state = INIT; 1189 lcfq->lcf->state = INIT;