From 98c3b72cf47d9af51906a79c6a8634684f8d3b59 Mon Sep 17 00:00:00 2001 From: gardners Date: Wed, 25 Apr 2012 20:33:25 +0930 Subject: [PATCH] mdp based dna lookup works now, but lacks duplicate suppression. --- commandline.c | 9 +++++---- overlay_mdp.c | 12 +----------- serval.h | 1 - 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/commandline.c b/commandline.c index fbe5bd91..08d9db2c 100644 --- a/commandline.c +++ b/commandline.c @@ -504,10 +504,11 @@ 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_RX) + else if ((rx.packetTypeAndFlags&MDP_TYPE_MASK)==MDP_TX) fprintf(stderr,"%s:%s\n", - overlay_render_sid(&rx.in.payload[0]), - &rx.in.payload[SID_SIZE]); + overlay_render_sid(&rx.in.src.sid[0]), + &rx.in.payload[0]); + else WHYF("packettype=0x%x",rx.packetTypeAndFlags); if (servalShutdown) break; } } @@ -787,7 +788,7 @@ int app_mdp_ping(int argc, const char *const *argv, struct command_line_option * fprintf(stderr,"mdpping: overlay_mdp_recv: %s (code %d)\n", mdp.error.message,mdp.error.error); break; - case MDP_RX: + case MDP_TX: { int *rxseq=(int *)&mdp.in.payload; long long *txtime=(long long *)&mdp.in.payload[4]; diff --git a/overlay_mdp.c b/overlay_mdp.c index 6d7b5a62..bdc4cd27 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -435,12 +435,7 @@ int overlay_saw_mdp_frame(int interface, overlay_mdp_frame *mdp,long long now) } } } - if (match>-1) { - /* We now know the socket, and so we can pass the MDP_TX frame to the - recipient. We do, however, translate it into an MDP_RX frame first, - so that the recipient understands the context. */ - mdp->packetTypeAndFlags&=~MDP_TYPE_MASK; - mdp->packetTypeAndFlags|=MDP_RX; + if (match>-1) { struct sockaddr_un addr; bcopy(mdp_bindings_sockets[match],&addr.sun_path[0],mdp_bindings_socket_name_lengths[match]); addr.sun_family=AF_UNIX; @@ -661,7 +656,6 @@ int overlay_mdp_dispatch(overlay_mdp_frame *mdp,int userGeneratedFrameP, /* Packet is addressed such that we should process it. */ overlay_saw_mdp_frame(-1 /* not received on a network interface */, mdp,overlay_gettime_ms()); - if (!broadcast) { /* Is local, and is not broadcast, so shouldn't get sent out on the wire. */ @@ -999,10 +993,6 @@ int overlay_mdp_relevant_bytes(overlay_mdp_frame *mdp) len=&mdp->out.payload[0]-(unsigned char *)mdp; len+=mdp->out.payload_length; break; - case MDP_RX: - len=&mdp->in.payload[0]-(unsigned char *)mdp; - len+=mdp->in.payload_length; - break; case MDP_BIND: len=&mdp->bind.sid[SID_SIZE]-(unsigned char *)mdp; break; diff --git a/serval.h b/serval.h index bf05d10d..a6731167 100644 --- a/serval.h +++ b/serval.h @@ -1108,7 +1108,6 @@ unsigned char *keyring_get_nm_bytes(sockaddr_mdp *priv,sockaddr_mdp *pub); #define MDP_NOCRYPT 0x0200 #define MDP_NOSIGN 0x0400 #define MDP_TX 1 -#define MDP_RX 2 typedef struct overlay_mdp_data_frame { sockaddr_mdp src; sockaddr_mdp dst;