mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-19 05:07:56 +00:00
preparation for allowing MDP_GETADDRS to return either local IDs,
or SIDs of peers.
This commit is contained in:
parent
cf2216fecf
commit
35f231dcb0
@ -1131,6 +1131,7 @@ int app_id_self(int argc, const char *const *argv, struct command_line_option *o
|
||||
int result;
|
||||
|
||||
a.packetTypeAndFlags=MDP_GETADDRS;
|
||||
a.addrlist.selfP=1; /* get own identities, not those of peers */
|
||||
a.addrlist.first_sid=-1;
|
||||
a.addrlist.last_sid=0x7fffffff;
|
||||
a.addrlist.frame_sid_count=MDP_MAX_SID_REQUEST;
|
||||
|
@ -917,7 +917,9 @@ int overlay_mdp_poll()
|
||||
|
||||
/* Prepare reply packet */
|
||||
mdpreply.packetTypeAndFlags=MDP_ADDRLIST;
|
||||
if (mdp->addrlist.selfP)
|
||||
{
|
||||
/* For list of my own identities */
|
||||
int cn=0,in=0,kp=0;
|
||||
int count=0;
|
||||
while(keyring_next_identity(keyring,&cn,&in,&kp)) {
|
||||
@ -925,17 +927,24 @@ int overlay_mdp_poll()
|
||||
}
|
||||
mdpreply.addrlist.server_sid_count=count;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For peer list */
|
||||
}
|
||||
mdpreply.addrlist.first_sid=sid_num;
|
||||
mdpreply.addrlist.last_sid=max_sid;
|
||||
mdpreply.addrlist.frame_sid_count=max_sids;
|
||||
|
||||
/* Populate with SIDs */
|
||||
if (mdp->addrlist.selfP) {
|
||||
/* from self */
|
||||
int cn=0,in=0,kp=0;
|
||||
int i=0;
|
||||
int count=0;
|
||||
while(keyring_next_identity(keyring,&cn,&in,&kp)) {
|
||||
if (count>=sid_num&&(i<max_sids))
|
||||
bcopy(keyring->contexts[cn]->identities[in]->keypairs[kp]->public_key,
|
||||
bcopy(keyring->contexts[cn]->identities[in]
|
||||
->keypairs[kp]->public_key,
|
||||
mdpreply.addrlist.sids[i++],SID_SIZE);
|
||||
in++; kp=0;
|
||||
count++;
|
||||
@ -943,6 +952,9 @@ int overlay_mdp_poll()
|
||||
}
|
||||
mdpreply.addrlist.frame_sid_count=i;
|
||||
mdpreply.addrlist.last_sid=count-1;
|
||||
} else {
|
||||
/* from peer list */
|
||||
}
|
||||
|
||||
/* Send back to caller */
|
||||
return overlay_mdp_reply(mdp_named_socket,
|
||||
|
Loading…
Reference in New Issue
Block a user