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;
|
int result;
|
||||||
|
|
||||||
a.packetTypeAndFlags=MDP_GETADDRS;
|
a.packetTypeAndFlags=MDP_GETADDRS;
|
||||||
|
a.addrlist.selfP=1; /* get own identities, not those of peers */
|
||||||
a.addrlist.first_sid=-1;
|
a.addrlist.first_sid=-1;
|
||||||
a.addrlist.last_sid=0x7fffffff;
|
a.addrlist.last_sid=0x7fffffff;
|
||||||
a.addrlist.frame_sid_count=MDP_MAX_SID_REQUEST;
|
a.addrlist.frame_sid_count=MDP_MAX_SID_REQUEST;
|
||||||
|
@ -917,32 +917,44 @@ int overlay_mdp_poll()
|
|||||||
|
|
||||||
/* Prepare reply packet */
|
/* Prepare reply packet */
|
||||||
mdpreply.packetTypeAndFlags=MDP_ADDRLIST;
|
mdpreply.packetTypeAndFlags=MDP_ADDRLIST;
|
||||||
{
|
if (mdp->addrlist.selfP)
|
||||||
int cn=0,in=0,kp=0;
|
{
|
||||||
int count=0;
|
/* For list of my own identities */
|
||||||
while(keyring_next_identity(keyring,&cn,&in,&kp)) {
|
int cn=0,in=0,kp=0;
|
||||||
in++; count++;
|
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.first_sid=sid_num;
|
||||||
mdpreply.addrlist.last_sid=max_sid;
|
mdpreply.addrlist.last_sid=max_sid;
|
||||||
mdpreply.addrlist.frame_sid_count=max_sids;
|
mdpreply.addrlist.frame_sid_count=max_sids;
|
||||||
|
|
||||||
/* Populate with SIDs */
|
/* Populate with SIDs */
|
||||||
int cn=0,in=0,kp=0;
|
if (mdp->addrlist.selfP) {
|
||||||
int i=0;
|
/* from self */
|
||||||
int count=0;
|
int cn=0,in=0,kp=0;
|
||||||
while(keyring_next_identity(keyring,&cn,&in,&kp)) {
|
int i=0;
|
||||||
if (count>=sid_num&&(i<max_sids))
|
int count=0;
|
||||||
bcopy(keyring->contexts[cn]->identities[in]->keypairs[kp]->public_key,
|
while(keyring_next_identity(keyring,&cn,&in,&kp)) {
|
||||||
mdpreply.addrlist.sids[i++],SID_SIZE);
|
if (count>=sid_num&&(i<max_sids))
|
||||||
in++; kp=0;
|
bcopy(keyring->contexts[cn]->identities[in]
|
||||||
count++;
|
->keypairs[kp]->public_key,
|
||||||
if (i>=max_sids) break;
|
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 */
|
/* Send back to caller */
|
||||||
return overlay_mdp_reply(mdp_named_socket,
|
return overlay_mdp_reply(mdp_named_socket,
|
||||||
|
1
serval.h
1
serval.h
@ -1131,6 +1131,7 @@ typedef struct overlay_mdp_error {
|
|||||||
#define MDP_GETADDRS 5
|
#define MDP_GETADDRS 5
|
||||||
#define MDP_ADDRLIST 6
|
#define MDP_ADDRLIST 6
|
||||||
typedef struct overlay_mdp_addrlist {
|
typedef struct overlay_mdp_addrlist {
|
||||||
|
int selfP;
|
||||||
unsigned int server_sid_count;
|
unsigned int server_sid_count;
|
||||||
unsigned int first_sid;
|
unsigned int first_sid;
|
||||||
unsigned int last_sid;
|
unsigned int last_sid;
|
||||||
|
Loading…
Reference in New Issue
Block a user