mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 05:37:57 +00:00
Trying to send unicast sas request
This commit is contained in:
parent
6b64f0cded
commit
2b530bb02a
21
keyring.c
21
keyring.c
@ -1318,7 +1318,7 @@ unsigned char *keyring_find_sas_public(keyring_file *k,unsigned char *sid)
|
|||||||
RETURN(sid_sas_mappings[i].sas_public);
|
RETURN(sid_sas_mappings[i].sas_public);
|
||||||
}
|
}
|
||||||
/* Don't flood the network with mapping requests */
|
/* Don't flood the network with mapping requests */
|
||||||
if (sid_sas_mappings[i].last_request_time_in_ms != -1 && now < sid_sas_mappings[i].last_request_time_in_ms + 1000) {
|
if (sid_sas_mappings[i].last_request_time_in_ms != -1 && now < sid_sas_mappings[i].last_request_time_in_ms + 100) {
|
||||||
INFO("Too soon to ask for SAS mapping again");
|
INFO("Too soon to ask for SAS mapping again");
|
||||||
RETURN(NULL);
|
RETURN(NULL);
|
||||||
}
|
}
|
||||||
@ -1343,25 +1343,24 @@ unsigned char *keyring_find_sas_public(keyring_file *k,unsigned char *sid)
|
|||||||
sid_sas_mappings[i].validP=0;
|
sid_sas_mappings[i].validP=0;
|
||||||
sid_sas_mappings[i].last_request_time_in_ms = now;
|
sid_sas_mappings[i].last_request_time_in_ms = now;
|
||||||
|
|
||||||
|
if (!my_subscriber)
|
||||||
|
RETURN(WHYNULL("couldn't request SAS (I don't know who I am)"));
|
||||||
|
|
||||||
// always send our sid in full, it's likely this is a new peer
|
// always send our sid in full, it's likely this is a new peer
|
||||||
if (my_subscriber)
|
my_subscriber->send_full = 1;
|
||||||
my_subscriber->send_full = 1;
|
|
||||||
|
|
||||||
/* request mapping (send request auth-crypted). */
|
/* request mapping (send request auth-crypted). */
|
||||||
overlay_mdp_frame mdp;
|
overlay_mdp_frame mdp;
|
||||||
|
memset(&mdp,0,sizeof(overlay_mdp_frame));
|
||||||
|
|
||||||
mdp.packetTypeAndFlags=MDP_TX;
|
mdp.packetTypeAndFlags=MDP_TX;
|
||||||
bcopy(&sid[0],&mdp.out.dst.sid[0],SID_SIZE);
|
bcopy(sid,mdp.out.dst.sid,SID_SIZE);
|
||||||
mdp.out.dst.port=MDP_PORT_KEYMAPREQUEST;
|
mdp.out.dst.port=MDP_PORT_KEYMAPREQUEST;
|
||||||
mdp.out.src.port=MDP_PORT_KEYMAPREQUEST;
|
mdp.out.src.port=MDP_PORT_KEYMAPREQUEST;
|
||||||
if (k->contexts[0]->identity_count&&
|
bcopy(my_subscriber->sid,mdp.out.src.sid,SID_SIZE);
|
||||||
k->contexts[0]->identities[0]->keypair_count&&
|
|
||||||
k->contexts[0]->identities[0]->keypairs[0]->type
|
|
||||||
==KEYTYPE_CRYPTOBOX)
|
|
||||||
bcopy(keyring->contexts[0]->identities[0]->keypairs[0]->public_key,
|
|
||||||
mdp.out.src.sid,SID_SIZE);
|
|
||||||
else { RETURN(WHYNULL("couldn't request SAS (I don't know who I am)")); }
|
|
||||||
mdp.out.payload_length=1;
|
mdp.out.payload_length=1;
|
||||||
mdp.out.payload[0]=KEYTYPE_CRYPTOSIGN;
|
mdp.out.payload[0]=KEYTYPE_CRYPTOSIGN;
|
||||||
|
|
||||||
if (overlay_mdp_dispatch(&mdp, 0 /* system generated */, NULL, 0))
|
if (overlay_mdp_dispatch(&mdp, 0 /* system generated */, NULL, 0))
|
||||||
RETURN(WHYNULL("Failed to send SAS resolution request"));
|
RETURN(WHYNULL("Failed to send SAS resolution request"));
|
||||||
if (debug & DEBUG_KEYRING)
|
if (debug & DEBUG_KEYRING)
|
||||||
|
@ -198,6 +198,9 @@ int reachable_unicast(struct subscriber *subscriber, overlay_interface *interfac
|
|||||||
|
|
||||||
// may be used in tests
|
// may be used in tests
|
||||||
DEBUGF("ADD DIRECT ROUTE TO %s via %s", alloca_tohex_sid(subscriber->sid), inet_ntoa(addr));
|
DEBUGF("ADD DIRECT ROUTE TO %s via %s", alloca_tohex_sid(subscriber->sid), inet_ntoa(addr));
|
||||||
|
|
||||||
|
/* Pre-emptively check if we have their sas in memory, or send a request */
|
||||||
|
keyring_find_sas_public(keyring, subscriber->sid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,6 +711,7 @@ overlay_broadcast_ensemble(int interface_number,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DEBUGF("Sending overlay frame on %s to %s",interface->name,inet_ntoa(recipientaddr->sin_addr));
|
||||||
if(sendto(interface->alarm.poll.fd,
|
if(sendto(interface->alarm.poll.fd,
|
||||||
bytes, len, 0, (struct sockaddr *)recipientaddr, sizeof(struct sockaddr_in)) != len){
|
bytes, len, 0, (struct sockaddr *)recipientaddr, sizeof(struct sockaddr_in)) != len){
|
||||||
WHY_perror("sendto(c)");
|
WHY_perror("sendto(c)");
|
||||||
|
@ -151,8 +151,8 @@ static void parse_frame(struct overlay_buffer *buff){
|
|||||||
|
|
||||||
frame.modifiers=ob_get(buff);
|
frame.modifiers=ob_get(buff);
|
||||||
|
|
||||||
dump("received headers", buff->bytes, buff->position);
|
// dump("received headers", buff->bytes, buff->position);
|
||||||
dump("received payload", buff->bytes+buff->position, buff->sizeLimit - buff->position);
|
// dump("received payload", buff->bytes+buff->position, buff->sizeLimit - buff->position);
|
||||||
|
|
||||||
// the remaining bytes are an mdp payload, process it
|
// the remaining bytes are an mdp payload, process it
|
||||||
frame.payload = buff;
|
frame.payload = buff;
|
||||||
@ -240,8 +240,8 @@ int olsr_send(struct overlay_frame *frame){
|
|||||||
overlay_broadcast_append(b, &frame->broadcast_id);
|
overlay_broadcast_append(b, &frame->broadcast_id);
|
||||||
ob_append_byte(b, frame->modifiers);
|
ob_append_byte(b, frame->modifiers);
|
||||||
|
|
||||||
dump("sent headers", b->bytes, b->position);
|
// dump("sent headers", b->bytes, b->position);
|
||||||
dump("sent payload", frame->payload->bytes, frame->payload->sizeLimit);
|
// dump("sent payload", frame->payload->bytes, frame->payload->sizeLimit);
|
||||||
|
|
||||||
// send the packet
|
// send the packet
|
||||||
int ret = send_packet(b->bytes, b->position, frame->payload->bytes, frame->payload->sizeLimit);
|
int ret = send_packet(b->bytes, b->position, frame->payload->bytes, frame->payload->sizeLimit);
|
||||||
|
Loading…
Reference in New Issue
Block a user