mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-24 07:16:43 +00:00
Trying to send unicast sas request
This commit is contained in:
parent
6b64f0cded
commit
2b530bb02a
19
keyring.c
19
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);
|
||||
}
|
||||
/* 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");
|
||||
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].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
|
||||
if (my_subscriber)
|
||||
my_subscriber->send_full = 1;
|
||||
|
||||
/* request mapping (send request auth-crypted). */
|
||||
overlay_mdp_frame mdp;
|
||||
memset(&mdp,0,sizeof(overlay_mdp_frame));
|
||||
|
||||
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.src.port=MDP_PORT_KEYMAPREQUEST;
|
||||
if (k->contexts[0]->identity_count&&
|
||||
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)")); }
|
||||
bcopy(my_subscriber->sid,mdp.out.src.sid,SID_SIZE);
|
||||
mdp.out.payload_length=1;
|
||||
mdp.out.payload[0]=KEYTYPE_CRYPTOSIGN;
|
||||
|
||||
if (overlay_mdp_dispatch(&mdp, 0 /* system generated */, NULL, 0))
|
||||
RETURN(WHYNULL("Failed to send SAS resolution request"));
|
||||
if (debug & DEBUG_KEYRING)
|
||||
|
@ -198,6 +198,9 @@ int reachable_unicast(struct subscriber *subscriber, overlay_interface *interfac
|
||||
|
||||
// may be used in tests
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -711,6 +711,7 @@ overlay_broadcast_ensemble(int interface_number,
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUGF("Sending overlay frame on %s to %s",interface->name,inet_ntoa(recipientaddr->sin_addr));
|
||||
if(sendto(interface->alarm.poll.fd,
|
||||
bytes, len, 0, (struct sockaddr *)recipientaddr, sizeof(struct sockaddr_in)) != len){
|
||||
WHY_perror("sendto(c)");
|
||||
|
@ -151,8 +151,8 @@ static void parse_frame(struct overlay_buffer *buff){
|
||||
|
||||
frame.modifiers=ob_get(buff);
|
||||
|
||||
dump("received headers", buff->bytes, buff->position);
|
||||
dump("received payload", buff->bytes+buff->position, buff->sizeLimit - buff->position);
|
||||
// dump("received headers", buff->bytes, buff->position);
|
||||
// dump("received payload", buff->bytes+buff->position, buff->sizeLimit - buff->position);
|
||||
|
||||
// the remaining bytes are an mdp payload, process it
|
||||
frame.payload = buff;
|
||||
@ -240,8 +240,8 @@ int olsr_send(struct overlay_frame *frame){
|
||||
overlay_broadcast_append(b, &frame->broadcast_id);
|
||||
ob_append_byte(b, frame->modifiers);
|
||||
|
||||
dump("sent headers", b->bytes, b->position);
|
||||
dump("sent payload", frame->payload->bytes, frame->payload->sizeLimit);
|
||||
// dump("sent headers", b->bytes, b->position);
|
||||
// dump("sent payload", frame->payload->bytes, frame->payload->sizeLimit);
|
||||
|
||||
// send the packet
|
||||
int ret = send_packet(b->bytes, b->position, frame->payload->bytes, frame->payload->sizeLimit);
|
||||
|
Loading…
Reference in New Issue
Block a user