diff --git a/commandline.c b/commandline.c index 1e281fc3..15427eb5 100644 --- a/commandline.c +++ b/commandline.c @@ -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; diff --git a/overlay_mdp.c b/overlay_mdp.c index 01a3767c..dcbec58e 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -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&&(icontexts[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&&(icontexts[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, diff --git a/serval.h b/serval.h index a6731167..55528c39 100644 --- a/serval.h +++ b/serval.h @@ -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;