Use a directory service as a default route

This commit is contained in:
Jeremy Lakeman 2012-09-19 09:50:29 +09:30
parent 23f1110120
commit 5914bc92ce
4 changed files with 22 additions and 4 deletions

View File

@ -166,6 +166,14 @@ int subscriber_is_reachable(struct subscriber *subscriber){
if (!subscriber)
return REACHABLE_NONE;
// is there a default route?
if (subscriber->reachable==REACHABLE_NONE &&
directory_service &&
subscriber!=directory_service &&
subscriber_is_reachable(directory_service)!=REACHABLE_NONE){
return REACHABLE_DEFAULT_ROUTE;
}
if (subscriber->reachable==REACHABLE_INDIRECT){
if (!subscriber->next_hop)
return REACHABLE_NONE;

View File

@ -41,6 +41,8 @@
// this subscriber is in our keystore
#define REACHABLE_SELF 5
#define REACHABLE_DEFAULT_ROUTE 6
/* Codes used to describe abbreviated addresses.
Values 0x10 - 0xff are the first byte of, and implicit indicators of addresses written in full */
#define OA_CODE_SELF 0x00

View File

@ -1025,8 +1025,14 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
case REACHABLE_INDIRECT:
next_hop=next_hop->next_hop;
frame->sendBroadcast=0;
break;
case REACHABLE_DEFAULT_ROUTE:
next_hop=directory_service;
frame->sendBroadcast=0;
break;
// fall through
case REACHABLE_DIRECT:
case REACHABLE_UNICAST:
frame->sendBroadcast=0;

View File

@ -189,9 +189,11 @@ int overlay_payload_enqueue(int q, struct overlay_frame *p)
if (!p) return WHY("Cannot queue NULL");
if (p->destination &&
(p->destination->reachable == REACHABLE_NONE || p->destination->reachable == REACHABLE_SELF))
return WHYF("Destination %s is unreachable (%d)", alloca_tohex_sid(p->destination->sid), p->destination->reachable);
if (p->destination){
int r = subscriber_is_reachable(p->destination);
if (r == REACHABLE_SELF || r == REACHABLE_NONE)
return WHYF("Destination %s is unreachable (%d)", alloca_tohex_sid(p->destination->sid), r);
}
if (debug&DEBUG_PACKETTX)
DEBUGF("Enqueuing packet for %s* (q[%d]length = %d)",