From 92192654d01041d01d8880177a12be54f987195d Mon Sep 17 00:00:00 2001 From: gardners Date: Tue, 1 May 2012 13:39:43 +0930 Subject: [PATCH] cli_puts()ify "dna lookup". Add duplicate suppression to dna lookup --- commandline.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/commandline.c b/commandline.c index 57191d33..2719e473 100644 --- a/commandline.c +++ b/commandline.c @@ -436,6 +436,9 @@ int app_dna_lookup(int argc, const char *const *argv, struct command_line_option if (create_serval_instance_dir() == -1) return -1; + int sid_count=0; + unsigned char sids[128][SID_SIZE]; + const char *did; if (cli_arg(argc, argv, o, "did", &did, NULL, "*") == -1) return -1; @@ -444,10 +447,7 @@ int app_dna_lookup(int argc, const char *const *argv, struct command_line_option unsigned char srcsid[SID_SIZE]; int port=32768+(random()&32767); if (overlay_mdp_getmyaddr(0,srcsid)) return WHY("Could not get local address"); - printf("binding to %s:%d\n", - overlay_render_sid(srcsid),port); if (overlay_mdp_bind(srcsid,port)) return WHY("Could not bind to MDP socket"); - WHY("bound port"); /* use MDP to send the lookup request to MDP_PORT_DNALOOKUP, and wait for replies. */ @@ -494,10 +494,22 @@ int app_dna_lookup(int argc, const char *const *argv, struct command_line_option { fprintf(stderr," Error message: %s\n",mdp.error.message); } - else if ((rx.packetTypeAndFlags&MDP_TYPE_MASK)==MDP_TX) - fprintf(stderr,"%s:%s\n", - overlay_render_sid(&rx.in.src.sid[0]), - &rx.in.payload[0]); + else if ((rx.packetTypeAndFlags&MDP_TYPE_MASK)==MDP_TX) { + /* Display match unless it is a duplicate. + XXX - For wildcard searches, each sid will only show up once. */ + int i; + for(i=0;i