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,32 +917,44 @@ int overlay_mdp_poll()
|
||||
|
||||
/* Prepare reply packet */
|
||||
mdpreply.packetTypeAndFlags=MDP_ADDRLIST;
|
||||
{
|
||||
int cn=0,in=0,kp=0;
|
||||
int count=0;
|
||||
while(keyring_next_identity(keyring,&cn,&in,&kp)) {
|
||||
in++; count++;
|
||||
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)) {
|
||||
in++; count++;
|
||||
}
|
||||
mdpreply.addrlist.server_sid_count=count;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For peer list */
|
||||
}
|
||||
mdpreply.addrlist.server_sid_count=count;
|
||||
}
|
||||
mdpreply.addrlist.first_sid=sid_num;
|
||||
mdpreply.addrlist.last_sid=max_sid;
|
||||
mdpreply.addrlist.frame_sid_count=max_sids;
|
||||
|
||||
/* Populate with SIDs */
|
||||
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,
|
||||
mdpreply.addrlist.sids[i++],SID_SIZE);
|
||||
in++; kp=0;
|
||||
count++;
|
||||
if (i>=max_sids) break;
|
||||
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,
|
||||
mdpreply.addrlist.sids[i++],SID_SIZE);
|
||||
in++; kp=0;
|
||||
count++;
|
||||
if (i>=max_sids) break;
|
||||
}
|
||||
mdpreply.addrlist.frame_sid_count=i;
|
||||
mdpreply.addrlist.last_sid=count-1;
|
||||
} else {
|
||||
/* from peer list */
|
||||
}
|
||||
mdpreply.addrlist.frame_sid_count=i;
|
||||
mdpreply.addrlist.last_sid=count-1;
|
||||
|
||||
/* Send back to caller */
|
||||
return overlay_mdp_reply(mdp_named_socket,
|
||||
|
Loading…
Reference in New Issue
Block a user