mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Report the state of each network interface in routing table
This commit is contained in:
parent
fe7a839df5
commit
65831e31d4
@ -184,7 +184,7 @@ dna_helper_start()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *mysid = alloca_tohex_sid_t(get_my_subscriber()->sid);
|
||||
const char *mysid = alloca_tohex_sid_t(get_my_subscriber(1)->sid);
|
||||
|
||||
int stdin_fds[2], stdout_fds[2], stderr_fds[2];
|
||||
if (pipe(stdin_fds) == -1)
|
||||
@ -450,7 +450,7 @@ void handle_reply_line(const char *bufp, size_t len)
|
||||
WHYF("DNAHELPER reply %s contains spurious trailing chars -- ignored", alloca_toprint(-1, bufp, len));
|
||||
else {
|
||||
DEBUGF(dnahelper, "DNAHELPER reply %s", alloca_toprint(-1, bufp, len));
|
||||
overlay_mdp_dnalookup_reply(request_source, request_port, get_my_subscriber(), uri, did, name);
|
||||
overlay_mdp_dnalookup_reply(request_source, request_port, get_my_subscriber(1), uri, did, name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -21,6 +21,7 @@ public class RouteLink {
|
||||
public final SubscriberId prior_hop;
|
||||
public final int hop_count;
|
||||
public final int interface_id;
|
||||
public final boolean interface_up;
|
||||
public final String interface_name;
|
||||
private final int reachable;
|
||||
|
||||
@ -45,8 +46,9 @@ public class RouteLink {
|
||||
SubscriberId prior_hop = null;
|
||||
int interface_id=-1;
|
||||
String interface_name = null;
|
||||
boolean up = false;
|
||||
|
||||
if (reachable != 0 && reachable!= REACHABLE_SELF) {
|
||||
if (buff.hasRemaining()) {
|
||||
hop_count = 0xFF & (int)buff.get();
|
||||
if (hop_count>1) {
|
||||
next_hop = new SubscriberId(buff);
|
||||
@ -54,6 +56,7 @@ public class RouteLink {
|
||||
prior_hop = new SubscriberId(buff);
|
||||
}else{
|
||||
interface_id = 0xFF & (int)buff.get();
|
||||
up = buff.get() != 0;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
while(true){
|
||||
byte b = buff.get();
|
||||
@ -68,6 +71,7 @@ public class RouteLink {
|
||||
this.prior_hop = prior_hop;
|
||||
this.hop_count = hop_count;
|
||||
this.interface_id = interface_id;
|
||||
this.interface_up = up;
|
||||
this.interface_name = interface_name;
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,12 @@ public final class Subscriber {
|
||||
|
||||
public Subscriber(ByteBuffer buff) throws AbstractId.InvalidBinaryException {
|
||||
SubscriberId sid = new SubscriberId(buff);
|
||||
SigningKey signingKey = new SigningKey(buff);
|
||||
int signKeyFlags = 0xFF & (int)buff.get();
|
||||
if ((signKeyFlags&0x01)==0x00)
|
||||
signingKey = null;
|
||||
else
|
||||
signingKey = new SigningKey(buff);
|
||||
this.sid = sid;
|
||||
this.signingKey = signingKey;
|
||||
this.combined = (signKeyFlags&0x02)==0x02;
|
||||
}
|
||||
|
||||
|
@ -1749,7 +1749,7 @@ int keyring_send_unlock(struct subscriber *subscriber)
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.destination = subscriber;
|
||||
header.source_port = MDP_PORT_KEYMAPREQUEST;
|
||||
header.destination_port = MDP_PORT_KEYMAPREQUEST;
|
||||
@ -1790,7 +1790,7 @@ int keyring_send_identity_request(struct subscriber *subscriber){
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.destination = subscriber;
|
||||
header.source_port = MDP_PORT_KEYMAPREQUEST;
|
||||
header.destination_port = MDP_PORT_KEYMAPREQUEST;
|
||||
|
@ -492,9 +492,9 @@ static int monitor_lookup_match(const struct cli_parsed *parsed, struct cli_cont
|
||||
struct subscriber *destination = find_subscriber(dest.binary, sizeof(dest), 1);
|
||||
|
||||
char uri[256];
|
||||
snprintf(uri, sizeof(uri), "sid://%s/external/%s", alloca_tohex_sid_t(get_my_subscriber()->sid), ext);
|
||||
snprintf(uri, sizeof(uri), "sid://%s/external/%s", alloca_tohex_sid_t(get_my_subscriber(1)->sid), ext);
|
||||
DEBUGF(monitor, "Sending response to %s for %s", sid, uri);
|
||||
overlay_mdp_dnalookup_reply(destination, dest_port, get_my_subscriber(), uri, ext, name);
|
||||
overlay_mdp_dnalookup_reply(destination, dest_port, get_my_subscriber(1), uri, ext, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -506,7 +506,7 @@ static int monitor_call(const struct cli_parsed *parsed, struct cli_context *con
|
||||
if (str_to_sid_t(&sid, parsed->args[1]) == -1)
|
||||
return monitor_write_error(c,"invalid SID, so cannot place call");
|
||||
struct subscriber *remote = find_subscriber(sid.binary, SID_SIZE, 1);
|
||||
vomp_dial(get_my_subscriber(), remote, parsed->args[2], parsed->args[3]);
|
||||
vomp_dial(get_my_subscriber(1), remote, parsed->args[2], parsed->args[3]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,11 @@ static int app_route_print(const struct cli_parsed *parsed, struct cli_context *
|
||||
break;
|
||||
|
||||
// ignore signing key details for now
|
||||
ob_skip(buff, IDENTITY_SIZE+1);
|
||||
int id_flags = ob_get(buff);
|
||||
if (id_flags < 0)
|
||||
break;
|
||||
if (id_flags & 1)
|
||||
ob_skip(buff, IDENTITY_SIZE);
|
||||
if (ob_overrun(buff))
|
||||
break;
|
||||
|
||||
@ -532,9 +536,10 @@ static int app_route_print(const struct cli_parsed *parsed, struct cli_context *
|
||||
sid_t *next_hop = NULL;
|
||||
sid_t *prior_hop = NULL;
|
||||
int interface_id =-1;
|
||||
int interface_state = -1;
|
||||
const char *interface_name = NULL;
|
||||
|
||||
if (reachable & REACHABLE){
|
||||
if (ob_remaining(buff)>0){
|
||||
hop_count = ob_get(buff);
|
||||
if (hop_count<0)
|
||||
break;
|
||||
@ -547,10 +552,13 @@ static int app_route_print(const struct cli_parsed *parsed, struct cli_context *
|
||||
if (!prior_hop)
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
interface_id = ob_get(buff);
|
||||
if (interface_id<0)
|
||||
break;
|
||||
interface_state = ob_get(buff);
|
||||
if (interface_state<0)
|
||||
break;
|
||||
interface_name = ob_get_str_ptr(buff);
|
||||
if (!interface_name)
|
||||
break;
|
||||
|
@ -52,20 +52,26 @@ static __thread struct tree_root root={.binary_length=SID_SIZE};
|
||||
|
||||
static __thread struct subscriber *my_subscriber=NULL;
|
||||
|
||||
struct subscriber *get_my_subscriber(){
|
||||
struct subscriber *get_my_subscriber(bool_t create){
|
||||
if (!serverMode)
|
||||
return NULL;
|
||||
if (my_subscriber && my_subscriber->reachable != REACHABLE_SELF)
|
||||
my_subscriber = NULL;
|
||||
if (!my_subscriber){
|
||||
keyring_identity *id = keyring->identities;
|
||||
while(id && id->subscriber->reachable != REACHABLE_SELF)
|
||||
while(id){
|
||||
if (id->subscriber->reachable == REACHABLE_SELF){
|
||||
my_subscriber = id->subscriber;
|
||||
return my_subscriber;
|
||||
}
|
||||
id = id->next;
|
||||
}
|
||||
// If there is no reachable self-identity in the keyring, then roll one in-memory, which will
|
||||
// persist until the server terminates.
|
||||
if (!id)
|
||||
if (create){
|
||||
id = keyring_inmemory_identity();
|
||||
my_subscriber = id->subscriber;
|
||||
my_subscriber = id->subscriber;
|
||||
}
|
||||
}
|
||||
return my_subscriber;
|
||||
}
|
||||
@ -175,7 +181,7 @@ void overlay_address_append(struct decode_context *context, struct overlay_buffe
|
||||
ob_append_byte(b, OA_CODE_P2P_YOU);
|
||||
else if(context
|
||||
&& !subscriber->send_full
|
||||
&& subscriber == get_my_subscriber()
|
||||
&& subscriber == get_my_subscriber(1)
|
||||
&& context->point_to_point_device
|
||||
&& ((context->flags & DECODE_FLAG_ENCODING_HEADER)==0 || !context->interface->local_echo))
|
||||
ob_append_byte(b, OA_CODE_P2P_ME);
|
||||
@ -228,7 +234,7 @@ static int add_explain_response(void **record, void *context)
|
||||
|
||||
// if our primary routing identities is unknown,
|
||||
// the header of this packet must include our full sid.
|
||||
if (subscriber==get_my_subscriber()){
|
||||
if (subscriber==get_my_subscriber(1)){
|
||||
DEBUGF(subscriber, "Explaining SELF sid=%s", alloca_tohex_sid_t(subscriber->sid));
|
||||
response->please_explain->source_full=1;
|
||||
return 0;
|
||||
@ -343,7 +349,7 @@ int overlay_address_parse(struct decode_context *context, struct overlay_buffer
|
||||
case OA_CODE_P2P_YOU:
|
||||
// if we don't know who they are, we can't assume they mean us.
|
||||
if (context->point_to_point_device){
|
||||
context->previous = *subscriber = get_my_subscriber();
|
||||
context->previous = *subscriber = get_my_subscriber(1);
|
||||
}else{
|
||||
WHYF("Could not resolve address on %s, this isn't a configured point to point link", context->interface->name);
|
||||
context->flags|=DECODE_FLAG_INVALID_ADDRESS;
|
||||
@ -410,7 +416,7 @@ int send_please_explain(struct decode_context *context, struct subscriber *sourc
|
||||
if (source)
|
||||
frame->source = source;
|
||||
else
|
||||
frame->source = get_my_subscriber();
|
||||
frame->source = get_my_subscriber(1);
|
||||
|
||||
if (!context->sender)
|
||||
frame->source_full=1;
|
||||
@ -459,7 +465,7 @@ int process_explain(struct overlay_frame *frame)
|
||||
switch (len){
|
||||
case OA_CODE_P2P_YOU:
|
||||
{
|
||||
void *sid = get_my_subscriber();
|
||||
void *sid = get_my_subscriber(1);
|
||||
add_explain_response(&sid, &context);
|
||||
}
|
||||
break;
|
||||
|
@ -118,7 +118,7 @@ struct decode_context{
|
||||
struct subscriber *point_to_point_device;
|
||||
};
|
||||
|
||||
struct subscriber *get_my_subscriber();
|
||||
struct subscriber *get_my_subscriber(bool_t create);
|
||||
void release_my_subscriber();
|
||||
extern __thread struct subscriber *directory_service;
|
||||
|
||||
|
@ -153,7 +153,7 @@ int overlay_send_probe(struct subscriber *peer, struct network_destination *dest
|
||||
struct overlay_frame *frame=malloc(sizeof(struct overlay_frame));
|
||||
bzero(frame,sizeof(struct overlay_frame));
|
||||
frame->type=OF_TYPE_DATA;
|
||||
frame->source = get_my_subscriber();
|
||||
frame->source = get_my_subscriber(1);
|
||||
frame->destination = peer;
|
||||
frame->ttl=1;
|
||||
frame->queue=queue;
|
||||
@ -199,7 +199,7 @@ int overlay_send_stun_request(struct subscriber *server, struct subscriber *requ
|
||||
if (request->reachable&REACHABLE || (server && server->reachable & REACHABLE)){
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.destination = request;
|
||||
header.source_port = MDP_PORT_STUNREQ;
|
||||
header.destination_port = MDP_PORT_STUN;
|
||||
@ -213,7 +213,7 @@ int overlay_send_stun_request(struct subscriber *server, struct subscriber *requ
|
||||
if (overlay_interfaces[i].state == INTERFACE_STATE_UP
|
||||
&& overlay_interfaces[i].address.addr.sa_family == AF_INET){
|
||||
|
||||
overlay_address_append(NULL, payload, get_my_subscriber());
|
||||
overlay_address_append(NULL, payload, get_my_subscriber(1));
|
||||
ob_append_ui32(payload, overlay_interfaces[i].address.inet.sin_addr.s_addr);
|
||||
ob_append_ui16(payload, overlay_interfaces[i].address.inet.sin_port);
|
||||
if (ob_overrun(payload)){
|
||||
@ -233,7 +233,7 @@ int overlay_send_stun_request(struct subscriber *server, struct subscriber *requ
|
||||
if (server && server->reachable & REACHABLE){
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.destination = server;
|
||||
|
||||
header.source_port = MDP_PORT_STUN;
|
||||
|
@ -527,7 +527,7 @@ int overlay_saw_mdp_containing_frame(struct overlay_frame *f)
|
||||
|
||||
void mdp_init_response(const struct internal_mdp_header *in, struct internal_mdp_header *out)
|
||||
{
|
||||
out->source = in->destination ? in->destination : get_my_subscriber();
|
||||
out->source = in->destination ? in->destination : get_my_subscriber(1);
|
||||
out->source_port = in->destination_port;
|
||||
out->destination = in->source;
|
||||
out->destination_port = in->source_port;
|
||||
@ -949,7 +949,7 @@ static int overlay_mdp_dispatch(overlay_mdp_frame *mdp, struct socket_address *c
|
||||
|
||||
if (is_sid_t_any(mdp->out.src.sid)){
|
||||
/* set source to ourselves */
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
mdp->out.src.sid = header.source->sid;
|
||||
}else if (is_sid_t_broadcast(mdp->out.src.sid)){
|
||||
/* Nope, I'm sorry but we simply can't send packets from
|
||||
@ -1062,16 +1062,22 @@ struct routing_state{
|
||||
struct socket_address *client;
|
||||
};
|
||||
|
||||
static void send_route(struct subscriber *subscriber, struct socket_address *client, struct mdp_header *header)
|
||||
static void send_route(
|
||||
const struct subscriber *subscriber,
|
||||
const struct overlay_interface *interface,
|
||||
struct socket_address *client,
|
||||
struct mdp_header *header)
|
||||
{
|
||||
uint8_t payload[MDP_MTU];
|
||||
struct overlay_buffer *b = ob_static(payload, sizeof payload);
|
||||
ob_limitsize(b, sizeof payload);
|
||||
ob_append_bytes(b, subscriber->sid.binary, SID_SIZE);
|
||||
ob_append_bytes(b, subscriber->id_public.binary, IDENTITY_SIZE);
|
||||
ob_append_byte(b, subscriber->id_valid | (subscriber->id_combined<<1));
|
||||
if (subscriber->id_valid)
|
||||
ob_append_bytes(b, subscriber->id_public.binary, IDENTITY_SIZE);
|
||||
ob_append_byte(b, subscriber->reachable);
|
||||
if (subscriber->reachable & REACHABLE){
|
||||
|
||||
if ((subscriber->reachable & REACHABLE) || interface){
|
||||
ob_append_byte(b, subscriber->hop_count);
|
||||
if (subscriber->hop_count>1){
|
||||
ob_append_bytes(b, subscriber->next_hop->sid.binary, SID_SIZE);
|
||||
@ -1079,10 +1085,14 @@ static void send_route(struct subscriber *subscriber, struct socket_address *cli
|
||||
ob_append_bytes(b, subscriber->prior_hop->sid.binary, SID_SIZE);
|
||||
}
|
||||
}else{
|
||||
ob_append_byte(b, subscriber->destination->interface - overlay_interfaces);
|
||||
ob_append_str(b, subscriber->destination->interface->name);
|
||||
if (!interface)
|
||||
interface = subscriber->destination->interface;
|
||||
ob_append_byte(b, interface - overlay_interfaces);
|
||||
ob_append_byte(b, interface->state);
|
||||
ob_append_str(b, interface->name);
|
||||
}
|
||||
}
|
||||
|
||||
assert(!ob_overrun(b));
|
||||
mdp_reply2(__WHENCE__, client, header, 0, payload, ob_position(b));
|
||||
ob_free(b);
|
||||
@ -1093,7 +1103,9 @@ static int routing_table(void **record, void *context)
|
||||
struct subscriber *subscriber = *record;
|
||||
if (subscriber->reachable != REACHABLE_NONE){
|
||||
struct routing_state *state = (struct routing_state *)context;
|
||||
send_route(subscriber, state->client, state->header);
|
||||
if ((subscriber->reachable & REACHABLE_SELF) == 0 || subscriber != get_my_subscriber(0)){
|
||||
send_route(subscriber, NULL, state->client, state->header);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1108,13 +1120,34 @@ static void send_route_changed(struct subscriber *subscriber, int UNUSED(prior_r
|
||||
struct mdp_binding *b = mdp_bindings;
|
||||
while(b){
|
||||
if (b->port == MDP_ROUTE_TABLE && b->subscriber == internal){
|
||||
send_route(subscriber, &b->client, &header);
|
||||
send_route(subscriber, NULL, &b->client, &header);
|
||||
}
|
||||
b=b->_next;
|
||||
}
|
||||
}
|
||||
DEFINE_TRIGGER(link_change, send_route_changed);
|
||||
|
||||
static void send_interface_change(struct overlay_interface *interface)
|
||||
{
|
||||
struct mdp_header header;
|
||||
bzero(&header, sizeof(header));
|
||||
header.local.sid = SID_INTERNAL;
|
||||
header.local.port = MDP_ROUTE_TABLE;
|
||||
header.remote.port = MDP_ROUTE_TABLE;
|
||||
|
||||
struct mdp_binding *b = mdp_bindings;
|
||||
struct subscriber *subscriber = NULL;
|
||||
while(b){
|
||||
if (b->port == MDP_ROUTE_TABLE && b->subscriber == internal){
|
||||
if (!subscriber)
|
||||
subscriber = get_my_subscriber(1);
|
||||
send_route(subscriber, interface, &b->client, &header);
|
||||
}
|
||||
b=b->_next;
|
||||
}
|
||||
}
|
||||
DEFINE_TRIGGER(iupdown, send_interface_change);
|
||||
|
||||
struct scan_state{
|
||||
struct sched_ent alarm;
|
||||
overlay_interface *interface;
|
||||
@ -1409,7 +1442,7 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header
|
||||
switch(sid_type=sid_get_special_type(&header->local.sid)){
|
||||
case SID_TYPE_ANY:
|
||||
// leaving the sid blank indicates that we should use our main identity
|
||||
internal_header.source = get_my_subscriber();
|
||||
internal_header.source = get_my_subscriber(1);
|
||||
header->local.sid = internal_header.source->sid;
|
||||
break;
|
||||
case SID_TYPE_INTERNAL:
|
||||
@ -1537,6 +1570,15 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header
|
||||
.client = client,
|
||||
.header = header
|
||||
};
|
||||
unsigned i;
|
||||
struct subscriber *subscriber = NULL;
|
||||
for (i=0;i<OVERLAY_MAX_INTERFACES;i++){
|
||||
if (overlay_interfaces[i].state == INTERFACE_STATE_UP){
|
||||
if (!subscriber)
|
||||
subscriber = get_my_subscriber(1);
|
||||
send_route(subscriber, &overlay_interfaces[i], client, header);
|
||||
}
|
||||
}
|
||||
enum_subscribers(NULL, routing_table, &state);
|
||||
mdp_reply_ok(client, header);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ static int keyring_respond_challenge(struct subscriber *subscriber, struct overl
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.destination = subscriber;
|
||||
header.source_port = MDP_PORT_KEYMAPREQUEST;
|
||||
header.destination_port = MDP_PORT_KEYMAPREQUEST;
|
||||
|
@ -52,7 +52,7 @@ static int rhizome_mdp_send_block(struct subscriber *dest, const rhizome_bid_t *
|
||||
// beginning.
|
||||
|
||||
header.crypt_flags = MDP_FLAG_NO_CRYPT | MDP_FLAG_NO_SIGN;
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_RHIZOME_RESPONSE;
|
||||
|
||||
if (dest && (dest->reachable==REACHABLE_UNICAST || dest->reachable==REACHABLE_INDIRECT)){
|
||||
|
@ -77,7 +77,7 @@ static int overlay_mdp_service_trace(struct internal_mdp_header *header, struct
|
||||
INFOF("Trace from %s to %s", alloca_tohex_sid_t(src->sid), alloca_tohex_sid_t(dst->sid));
|
||||
struct internal_mdp_header next_header;
|
||||
next_header = *header;
|
||||
next_header.source = get_my_subscriber();
|
||||
next_header.source = get_my_subscriber(1);
|
||||
next_header.destination = NULL;
|
||||
|
||||
while(ob_remaining(payload)>0){
|
||||
|
@ -208,7 +208,7 @@ static void parse_frame(struct overlay_buffer *buff){
|
||||
|
||||
end:
|
||||
// if we didn't understand one of the address abreviations, ask for explanation
|
||||
send_please_explain(&context, get_my_subscriber(), context.sender);
|
||||
send_please_explain(&context, get_my_subscriber(1), context.sender);
|
||||
}
|
||||
|
||||
static void olsr_read(struct sched_ent *alarm){
|
||||
@ -292,7 +292,7 @@ int olsr_send(struct overlay_frame *frame){
|
||||
ob_append_byte(b, frame->ttl);
|
||||
|
||||
// address the packet as transmitted by me
|
||||
overlay_address_append(&context, b, get_my_subscriber());
|
||||
overlay_address_append(&context, b, get_my_subscriber(1));
|
||||
overlay_address_append(&context, b, frame->source);
|
||||
overlay_broadcast_append(b, &frame->broadcast_id);
|
||||
ob_append_byte(b, frame->modifiers);
|
||||
|
@ -55,10 +55,10 @@ int overlay_packet_init_header(int packet_version, int encapsulation,
|
||||
)
|
||||
context->point_to_point_device = context->interface->other_device;
|
||||
context->flags = DECODE_FLAG_ENCODING_HEADER;
|
||||
overlay_address_append(context, buff, get_my_subscriber());
|
||||
overlay_address_append(context, buff, get_my_subscriber(1));
|
||||
|
||||
context->flags = 0;
|
||||
context->sender = get_my_subscriber();
|
||||
context->sender = get_my_subscriber(1);
|
||||
|
||||
int flags=0;
|
||||
|
||||
@ -464,7 +464,7 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
|
||||
// We may need to schedule an ACK / NACK soon when we receive a payload addressed to us, or broadcast
|
||||
if (f.modifiers & PAYLOAD_FLAG_ACK_SOON &&
|
||||
(f.next_hop == get_my_subscriber() || f.destination == get_my_subscriber() || !f.destination))
|
||||
(f.next_hop == get_my_subscriber(1) || f.destination == get_my_subscriber(1) || !f.destination))
|
||||
link_state_ack_soon(context.sender);
|
||||
}
|
||||
|
||||
@ -476,7 +476,7 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
}
|
||||
|
||||
end:
|
||||
send_please_explain(&context, get_my_subscriber(), context.sender);
|
||||
send_please_explain(&context, get_my_subscriber(1), context.sender);
|
||||
|
||||
ob_free(b);
|
||||
|
||||
|
@ -447,7 +447,7 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
|
||||
// send a packet to this destination
|
||||
if (frame->source_full)
|
||||
get_my_subscriber()->send_full=1;
|
||||
get_my_subscriber(1)->send_full=1;
|
||||
if (overlay_init_packet(packet, frame->packet_version, dest) != -1) {
|
||||
if (debug){
|
||||
strbuf_sprintf(debug, "building packet %s %s %d [",
|
||||
|
@ -1038,7 +1038,7 @@ static int rhizome_fetch_mdp_requestblocks(struct rhizome_fetch_slot *slot)
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_RHIZOME_RESPONSE;
|
||||
header.destination = (struct subscriber *)slot->peer;
|
||||
header.destination_port = MDP_PORT_RHIZOME_REQUEST;
|
||||
|
@ -147,7 +147,7 @@ int rhizome_advertise_manifest(struct subscriber *dest, rhizome_manifest *m){
|
||||
struct overlay_frame *frame = malloc(sizeof(struct overlay_frame));
|
||||
bzero(frame,sizeof(struct overlay_frame));
|
||||
frame->type = OF_TYPE_RHIZOME_ADVERT;
|
||||
frame->source = get_my_subscriber();
|
||||
frame->source = get_my_subscriber(1);
|
||||
if (dest && dest->reachable&REACHABLE)
|
||||
frame->destination = dest;
|
||||
else
|
||||
@ -331,7 +331,7 @@ next:
|
||||
if (rhizome_is_bar_interesting(bars[index])==1){
|
||||
// add a request for the manifest
|
||||
if (!payload){
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_RHIZOME_RESPONSE;
|
||||
header.destination = f->source;
|
||||
header.destination_port = MDP_PORT_RHIZOME_MANIFEST_REQUEST;
|
||||
|
@ -110,7 +110,7 @@ static void rhizome_sync_request(struct subscriber *subscriber, uint64_t token,
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_RHIZOME_SYNC;
|
||||
header.destination = subscriber;
|
||||
header.destination_port = MDP_PORT_RHIZOME_SYNC;
|
||||
@ -158,7 +158,7 @@ static void rhizome_sync_send_requests(struct subscriber *subscriber, struct rhi
|
||||
}
|
||||
|
||||
if (!payload){
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_RHIZOME_RESPONSE;
|
||||
header.destination = subscriber;
|
||||
header.destination_port = MDP_PORT_RHIZOME_MANIFEST_REQUEST;
|
||||
@ -457,7 +457,7 @@ static void sync_send_response(struct subscriber *dest, int forwards, uint64_t t
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof header);
|
||||
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_RHIZOME_SYNC;
|
||||
header.destination = dest;
|
||||
header.destination_port = MDP_PORT_RHIZOME_SYNC;
|
||||
|
@ -111,7 +111,7 @@ static struct transfers **find_and_update_transfer(struct subscriber *peer, stru
|
||||
if (!keys_state->connection)
|
||||
keys_state->connection = msp_find_or_connect(&sync_connections,
|
||||
peer, MDP_PORT_RHIZOME_SYNC_KEYS,
|
||||
get_my_subscriber(), MDP_PORT_RHIZOME_SYNC_KEYS,
|
||||
get_my_subscriber(1), MDP_PORT_RHIZOME_SYNC_KEYS,
|
||||
OQ_OPPORTUNISTIC);
|
||||
|
||||
if (msp_can_send(keys_state->connection)){
|
||||
@ -539,7 +539,7 @@ void sync_send_keys(struct sched_ent *alarm)
|
||||
bzero(&header, sizeof header);
|
||||
|
||||
header.crypt_flags = MDP_FLAG_NO_CRYPT | MDP_FLAG_NO_SIGN;
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_RHIZOME_SYNC_KEYS;
|
||||
header.destination_port = MDP_PORT_RHIZOME_SYNC_KEYS;
|
||||
header.qos = OQ_OPPORTUNISTIC;
|
||||
|
22
route_link.c
22
route_link.c
@ -339,7 +339,7 @@ static void update_path_score(struct neighbour *neighbour, struct link *link){
|
||||
int hop_count = -1;
|
||||
int drop_rate = 0;
|
||||
|
||||
if (link->transmitter == get_my_subscriber()){
|
||||
if (link->transmitter == get_my_subscriber(1)){
|
||||
if (link->receiver==neighbour->subscriber){
|
||||
hop_count = 1;
|
||||
}
|
||||
@ -403,7 +403,7 @@ static struct link * find_best_link(struct subscriber *subscriber)
|
||||
if (!(link && link->transmitter))
|
||||
goto next;
|
||||
|
||||
if (link->transmitter != get_my_subscriber()){
|
||||
if (link->transmitter != get_my_subscriber(1)){
|
||||
struct link_state *parent_state = get_link_state(link->transmitter);
|
||||
find_best_link(link->transmitter);
|
||||
if (parent_state->next_hop != neighbour->subscriber)
|
||||
@ -499,7 +499,7 @@ static int append_link_state(struct overlay_buffer *payload, char flags,
|
||||
static int append_link(void **record, void *context)
|
||||
{
|
||||
struct subscriber *subscriber = *record;
|
||||
if (subscriber == get_my_subscriber())
|
||||
if (subscriber == get_my_subscriber(1))
|
||||
return 0;
|
||||
|
||||
struct link_state *state = get_link_state(subscriber);
|
||||
@ -514,7 +514,7 @@ static int append_link(void **record, void *context)
|
||||
if (subscriber->reachable==REACHABLE_SELF){
|
||||
if (state->next_update - 20 <= now){
|
||||
// Other entries in our keyring are always one hop away from us.
|
||||
if (append_link_state(payload, 0, get_my_subscriber(), subscriber, -1, 1, -1, 0, 0)){
|
||||
if (append_link_state(payload, 0, get_my_subscriber(1), subscriber, -1, 1, -1, 0, 0)){
|
||||
ALARM_STRUCT(link_send).alarm = now+5;
|
||||
return 1;
|
||||
}
|
||||
@ -744,7 +744,7 @@ static int send_legacy_self_announce_ack(struct neighbour *neighbour, struct lin
|
||||
frame->type = OF_TYPE_SELFANNOUNCE_ACK;
|
||||
frame->ttl = 6;
|
||||
frame->destination = neighbour->subscriber;
|
||||
frame->source = get_my_subscriber();
|
||||
frame->source = get_my_subscriber(1);
|
||||
if ((frame->payload = ob_new()) == NULL) {
|
||||
op_free(frame);
|
||||
return -1;
|
||||
@ -830,7 +830,7 @@ static int send_neighbour_link(struct neighbour *n)
|
||||
} else {
|
||||
struct overlay_frame *frame = emalloc_zero(sizeof(struct overlay_frame));
|
||||
frame->type=OF_TYPE_DATA;
|
||||
frame->source=get_my_subscriber();
|
||||
frame->source=get_my_subscriber(1);
|
||||
frame->ttl=1;
|
||||
frame->queue=OQ_MESH_MANAGEMENT;
|
||||
if ((frame->payload = ob_new()) == NULL) {
|
||||
@ -868,7 +868,7 @@ static int send_neighbour_link(struct neighbour *n)
|
||||
|
||||
DEBUGF(ack, "LINK STATE; Sending ack to %s for seq %d", alloca_tohex_sid_t(n->subscriber->sid), n->best_link->ack_sequence);
|
||||
|
||||
append_link_state(frame->payload, flags, n->subscriber, get_my_subscriber(), n->best_link->neighbour_interface, 1,
|
||||
append_link_state(frame->payload, flags, n->subscriber, get_my_subscriber(1), n->best_link->neighbour_interface, 1,
|
||||
n->best_link->ack_sequence, n->best_link->ack_mask, -1);
|
||||
if (overlay_payload_enqueue(frame) == -1)
|
||||
op_free(frame);
|
||||
@ -942,7 +942,7 @@ void link_send(struct sched_ent *alarm)
|
||||
}else{
|
||||
struct internal_mdp_header header;
|
||||
bzero(&header, sizeof(header));
|
||||
header.source = get_my_subscriber();
|
||||
header.source = get_my_subscriber(1);
|
||||
header.source_port = MDP_PORT_LINKSTATE;
|
||||
header.destination_port = MDP_PORT_LINKSTATE;
|
||||
header.ttl = 1;
|
||||
@ -1321,7 +1321,7 @@ static int link_receive(struct internal_mdp_header *header, struct overlay_buffe
|
||||
if (header->source->reachable == REACHABLE_SELF)
|
||||
RETURN(0);
|
||||
|
||||
struct subscriber *myself = get_my_subscriber();
|
||||
struct subscriber *myself = get_my_subscriber(1);
|
||||
|
||||
struct neighbour *neighbour = get_neighbour(header->source, 1);
|
||||
|
||||
@ -1591,10 +1591,10 @@ int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now)
|
||||
}
|
||||
if (neighbour->link_in_timeout < now)
|
||||
changed = 1;
|
||||
if (link->transmitter != get_my_subscriber())
|
||||
if (link->transmitter != get_my_subscriber(1))
|
||||
changed = 1;
|
||||
|
||||
link->transmitter = get_my_subscriber();
|
||||
link->transmitter = get_my_subscriber(1);
|
||||
link->link_version = 1;
|
||||
link->destination = interface->destination;
|
||||
|
||||
|
@ -44,7 +44,7 @@ static int root_page(httpd_request *r, const char *remainder)
|
||||
strbuf b = strbuf_local_buf(temp);
|
||||
strbuf_sprintf(b, "<html><head><meta http-equiv=\"refresh\" content=\"5\" ></head><body>"
|
||||
"<h1>Hello, I'm %s*</h1>",
|
||||
alloca_tohex_sid_t_trunc(get_my_subscriber()->sid, 16));
|
||||
alloca_tohex_sid_t_trunc(get_my_subscriber(1)->sid, 16));
|
||||
if (config.server.motd[0]) {
|
||||
strbuf_puts(b, "<p>");
|
||||
strbuf_html_escape(b, config.server.motd, strlen(config.server.motd));
|
||||
|
Loading…
Reference in New Issue
Block a user