mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-08 03:24:13 +00:00
Add some MDP client DEBUG trace statements
This commit is contained in:
parent
7f0fef2209
commit
2cfdafdb56
@ -1406,6 +1406,7 @@ keyring_identity *keyring_inmemory_identity(){
|
||||
keyring_finalise_identity(NULL, id);
|
||||
if (id)
|
||||
add_subscriber(id);
|
||||
INFOF("Created in-memory identity: %s", alloca_tohex_sid_t(id->subscriber->sid));
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -284,6 +284,7 @@ int overlay_mdp_client_close(int mdp_sockfd)
|
||||
/* Tell MDP server to release all our bindings */
|
||||
overlay_mdp_frame mdp;
|
||||
mdp.packetTypeAndFlags = MDP_GOODBYE;
|
||||
DEBUGF(mdprequests, "Send MDP_GOODBYE");
|
||||
overlay_mdp_send(mdp_sockfd, &mdp, 0, 0);
|
||||
|
||||
socket_unlink_close(mdp_sockfd);
|
||||
@ -361,6 +362,9 @@ int overlay_mdp_bind(int mdp_sockfd, const sid_t *localaddr, mdp_port_t port)
|
||||
mdp.packetTypeAndFlags=MDP_BIND|MDP_FORCE;
|
||||
mdp.bind.sid = *localaddr;
|
||||
mdp.bind.port=port;
|
||||
DEBUGF(mdprequests, "Send MDP_BIND|MDP_FORCE sid=%s port=%" PRImdp_port_t,
|
||||
alloca_tohex_sid_t(mdp.bind.sid),
|
||||
mdp.bind.port);
|
||||
int result=overlay_mdp_send(mdp_sockfd, &mdp,MDP_AWAITREPLY,5000);
|
||||
if (result) {
|
||||
if (mdp.packetTypeAndFlags==MDP_ERROR)
|
||||
@ -383,6 +387,11 @@ int overlay_mdp_getmyaddr(int mdp_sockfd, unsigned index, sid_t *sidp)
|
||||
a.addrlist.first_sid=index;
|
||||
a.addrlist.last_sid=OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT;
|
||||
a.addrlist.frame_sid_count=MDP_MAX_SID_REQUEST;
|
||||
DEBUGF(mdprequests, "Send MDP_GETADDRS mode=MDP_ADDRLIST_MODE_SELF first_sid=%u last_sid=%u frame_sid_count=%u",
|
||||
a.addrlist.first_sid,
|
||||
a.addrlist.last_sid,
|
||||
a.addrlist.frame_sid_count,
|
||||
a.addrlist.server_sid_count);
|
||||
int result=overlay_mdp_send(mdp_sockfd,&a,MDP_AWAITREPLY,5000);
|
||||
if (result) {
|
||||
if (a.packetTypeAndFlags == MDP_ERROR)
|
||||
|
@ -368,12 +368,19 @@ static int app_id_self(const struct cli_parsed *parsed, struct cli_context *cont
|
||||
|
||||
a.packetTypeAndFlags=MDP_GETADDRS;
|
||||
const char *arg = parsed->labelc ? parsed->labelv[0].text : "";
|
||||
if (!strcasecmp(arg,"self"))
|
||||
const char *mode;
|
||||
if (!strcasecmp(arg,"self")) {
|
||||
a.addrlist.mode = MDP_ADDRLIST_MODE_SELF; /* get own identities */
|
||||
else if (!strcasecmp(arg,"allpeers"))
|
||||
mode = "MDP_ADDRLIST_MODE_SELF";
|
||||
}
|
||||
else if (!strcasecmp(arg,"allpeers")) {
|
||||
a.addrlist.mode = MDP_ADDRLIST_MODE_ALL_PEERS; /* get all known peers */
|
||||
else if (!strcasecmp(arg,"peers"))
|
||||
mode = "MDP_ADDRLIST_MODE_ALL_PEERS";
|
||||
}
|
||||
else if (!strcasecmp(arg,"peers")) {
|
||||
a.addrlist.mode = MDP_ADDRLIST_MODE_ROUTABLE_PEERS; /* get routable (reachable) peers */
|
||||
mode = "MDP_ADDRLIST_MODE_ROUTABLE_PEERS";
|
||||
}
|
||||
else
|
||||
return WHYF("unsupported arg '%s'", arg);
|
||||
a.addrlist.first_sid=0;
|
||||
@ -388,6 +395,12 @@ static int app_id_self(const struct cli_parsed *parsed, struct cli_context *cont
|
||||
size_t rowcount=0;
|
||||
|
||||
do{
|
||||
DEBUGF(mdprequests, "Send MDP_GETADDRS mode=%s first_sid=%u last_sid=%u frame_sid_count=%u",
|
||||
mode,
|
||||
a.addrlist.first_sid,
|
||||
a.addrlist.last_sid,
|
||||
a.addrlist.frame_sid_count,
|
||||
a.addrlist.server_sid_count);
|
||||
result=overlay_mdp_send(mdp_sockfd, &a, MDP_AWAITREPLY, 5000);
|
||||
if (result) {
|
||||
if (a.packetTypeAndFlags==MDP_ERROR){
|
||||
@ -432,6 +445,11 @@ static int app_count_peers(const struct cli_parsed *parsed, struct cli_context *
|
||||
a.packetTypeAndFlags=MDP_GETADDRS;
|
||||
a.addrlist.mode = MDP_ADDRLIST_MODE_ROUTABLE_PEERS;
|
||||
a.addrlist.first_sid = OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT;
|
||||
DEBUGF(mdprequests, "Send MDP_GETADDRS mode=MDP_ADDRLIST_MODE_ROUTABLE_PEERS first_sid=%u last_sid=%u frame_sid_count=%u",
|
||||
a.addrlist.first_sid,
|
||||
a.addrlist.last_sid,
|
||||
a.addrlist.frame_sid_count,
|
||||
a.addrlist.server_sid_count);
|
||||
int ret=overlay_mdp_send(mdp_sockfd, &a,MDP_AWAITREPLY,5000);
|
||||
overlay_mdp_client_close(mdp_sockfd);
|
||||
if (ret){
|
||||
@ -605,6 +623,7 @@ static int app_network_scan(const struct cli_parsed *parsed, struct cli_context
|
||||
|
||||
if ((mdp_sockfd = overlay_mdp_client_socket()) < 0)
|
||||
return WHY("Cannot create MDP socket");
|
||||
DEBUGF(mdprequests, "Send MDP_SCAN");
|
||||
overlay_mdp_send(mdp_sockfd, &mdp, MDP_AWAITREPLY, 5000);
|
||||
overlay_mdp_client_close(mdp_sockfd);
|
||||
|
||||
@ -624,13 +643,16 @@ static void lookup_send_request(int mdp_sockfd, const sid_t *srcsid, int srcport
|
||||
mdp.out.src.sid = *srcsid;
|
||||
|
||||
/* Send to destination address and DNA lookup port */
|
||||
const char *desc;
|
||||
if (dstsid) {
|
||||
/* Send an encrypted unicast packet */
|
||||
mdp.packetTypeAndFlags=MDP_TX;
|
||||
desc = "MDP_TX";
|
||||
mdp.out.dst.sid = *dstsid;
|
||||
}else{
|
||||
/* Send a broadcast packet, flooding across the local mesh network */
|
||||
mdp.packetTypeAndFlags=MDP_TX|MDP_NOCRYPT;
|
||||
desc = "MDP_TX|MDP_NOCRYPT";
|
||||
mdp.out.dst.sid = SID_BROADCAST;
|
||||
}
|
||||
mdp.out.dst.port=MDP_PORT_DNALOOKUP;
|
||||
@ -639,6 +661,11 @@ static void lookup_send_request(int mdp_sockfd, const sid_t *srcsid, int srcport
|
||||
bcopy(did,&mdp.out.payload[0],strlen(did)+1);
|
||||
mdp.out.payload_length=strlen(did)+1;
|
||||
|
||||
DEBUGF(mdprequests, "Send %s dst.sid=%s dst.port="PRImdp_port_t" payload_length=%u",
|
||||
desc,
|
||||
alloca_tohex_sid_t(mdp.out.dst.sid),
|
||||
mdp.out.dst.port,
|
||||
mdp.out.payload_length);
|
||||
overlay_mdp_send(mdp_sockfd, &mdp, 0, 0);
|
||||
|
||||
/* Also send an encrypted unicast request to a configured directory service */
|
||||
@ -646,6 +673,10 @@ static void lookup_send_request(int mdp_sockfd, const sid_t *srcsid, int srcport
|
||||
if (!is_sid_t_any(config.directory.service)) {
|
||||
mdp.out.dst.sid = config.directory.service;
|
||||
mdp.packetTypeAndFlags=MDP_TX;
|
||||
DEBUGF(mdprequests, "Send MDP_TX dst.sid=%s dst.port="PRImdp_port_t" payload_length=%u",
|
||||
alloca_tohex_sid_t(mdp.out.dst.sid),
|
||||
mdp.out.dst.port,
|
||||
mdp.out.payload_length);
|
||||
overlay_mdp_send(mdp_sockfd, &mdp,0,0);
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ struct subscriber *get_my_subscriber(){
|
||||
keyring_identity *id = keyring->identities;
|
||||
while(id && id->subscriber->reachable != REACHABLE_SELF)
|
||||
id = id->next;
|
||||
// If there is no reachable self-identity in the keyring, then roll one in-memory, which will
|
||||
// persist until the server terminates.
|
||||
if (!id)
|
||||
id = keyring_inmemory_identity();
|
||||
my_subscriber = id->subscriber;
|
||||
|
@ -1034,7 +1034,7 @@ static int search_subscribers(struct subscriber *subscriber, void *context){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int overlay_mdp_address_list(struct overlay_mdp_addrlist *request, struct overlay_mdp_addrlist *response)
|
||||
static void overlay_mdp_address_list(struct overlay_mdp_addrlist *request, struct overlay_mdp_addrlist *response)
|
||||
{
|
||||
DEBUGF(mdprequests, "MDP_GETADDRS first_sid=%u mode=%d", request->first_sid, request->mode);
|
||||
|
||||
@ -1054,7 +1054,6 @@ static int overlay_mdp_address_list(struct overlay_mdp_addrlist *request, struct
|
||||
response->frame_sid_count,
|
||||
response->server_sid_count
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct routing_state{
|
||||
@ -1713,12 +1712,8 @@ static void overlay_mdp_poll(struct sched_ent *alarm)
|
||||
overlay_mdp_frame mdpreply;
|
||||
bzero(&mdpreply, sizeof(overlay_mdp_frame));
|
||||
mdpreply.packetTypeAndFlags = MDP_ADDRLIST;
|
||||
if (!overlay_mdp_address_list(&mdp->addrlist, &mdpreply.addrlist))
|
||||
/* Send back to caller */
|
||||
overlay_mdp_reply(alarm->poll.fd,
|
||||
&client,
|
||||
&mdpreply);
|
||||
|
||||
overlay_mdp_address_list(&mdp->addrlist, &mdpreply.addrlist);
|
||||
overlay_mdp_reply(alarm->poll.fd, &client, &mdpreply);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -179,6 +179,7 @@ test_KeyringPinIdentityPin() {
|
||||
|
||||
doc_KeyringAutoCreate="Starting a server with no interfaces does not create an identity"
|
||||
test_KeyringAutoCreate() {
|
||||
executeOk_servald config set debug.mdprequests on
|
||||
configure_servald_server() {
|
||||
:
|
||||
}
|
||||
@ -195,8 +196,9 @@ teardown_KeyringAutoCreate() {
|
||||
teardown_servald
|
||||
}
|
||||
|
||||
doc_KeyringNoAutoCreate="Starting a server with interface creates in-memory identity"
|
||||
doc_KeyringNoAutoCreate="Starting a server with interface creates an in-memory identity"
|
||||
test_KeyringNoAutoCreate() {
|
||||
executeOk_servald config set debug.mdprequests on
|
||||
configure_servald_server() {
|
||||
add_servald_interface
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user