preparation for allowing MDP_GETADDRS to return either local IDs,

or SIDs of peers.
This commit is contained in:
gardners 2012-04-26 05:58:16 +09:30
parent cf2216fecf
commit 35f231dcb0
3 changed files with 33 additions and 19 deletions

View File

@ -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;

View File

@ -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,

View File

@ -1131,6 +1131,7 @@ typedef struct overlay_mdp_error {
#define MDP_GETADDRS 5
#define MDP_ADDRLIST 6
typedef struct overlay_mdp_addrlist {
int selfP;
unsigned int server_sid_count;
unsigned int first_sid;
unsigned int last_sid;