Message ID | 1482299344-4128-1-git-send-email-wsn.iot.xwq@cn.fujitsu.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Hello. On 21/12/16 06:49, wsn.iot.xwq@cn.fujitsu.com wrote: > From: Xue Wenqian <wsn.iot.xwq@cn.fujitsu.com> > > The filtering for wpan-ping client and server is made by checking frame header. > > Signed-off-by: Xue Wenqian <wsn.iot.xwq@cn.fujitsu.com> > --- > wpan-ping/wpan-ping.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c > index e6df2b4..f825b22 100644 > --- a/wpan-ping/wpan-ping.c > +++ b/wpan-ping/wpan-ping.c > @@ -303,6 +303,10 @@ static int measure_roundtrip(struct config *conf, int sd) { > } > gettimeofday(&start_time, NULL); > ret = recv(sd, buf, conf->packet_len, 0); > + if (buf[0] != NOT_A_6LOWPAN_FRAME) { > + printf("Non-wpanping packet was received\n"); > + continue; > + } > if (seq_num != ((buf[2] << 8)| buf[3])) { > printf("Sequenze number did not match\n"); > continue; > @@ -386,11 +390,13 @@ static void init_server(int sd) { > #if DEBUG > dump_packet(buf, len); > #endif > - /* Send same packet back */ > - len = sendto(sd, buf, len, 0, (struct sockaddr *)&src, addrlen); > - if (len < 0) { > - perror("sendto"); > - continue; > + if (buf[0] == NOT_A_6LOWPAN_FRAME) { > + /* Send same packet back */ > + len = sendto(sd, buf, len, 0, (struct sockaddr *)&src, addrlen); > + if (len < 0) { > + perror("sendto"); > + continue; > + } > } > } > free(buf); > Applied and pushed. Thanks! regards Stefan Schmidt -- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c index e6df2b4..f825b22 100644 --- a/wpan-ping/wpan-ping.c +++ b/wpan-ping/wpan-ping.c @@ -303,6 +303,10 @@ static int measure_roundtrip(struct config *conf, int sd) { } gettimeofday(&start_time, NULL); ret = recv(sd, buf, conf->packet_len, 0); + if (buf[0] != NOT_A_6LOWPAN_FRAME) { + printf("Non-wpanping packet was received\n"); + continue; + } if (seq_num != ((buf[2] << 8)| buf[3])) { printf("Sequenze number did not match\n"); continue; @@ -386,11 +390,13 @@ static void init_server(int sd) { #if DEBUG dump_packet(buf, len); #endif - /* Send same packet back */ - len = sendto(sd, buf, len, 0, (struct sockaddr *)&src, addrlen); - if (len < 0) { - perror("sendto"); - continue; + if (buf[0] == NOT_A_6LOWPAN_FRAME) { + /* Send same packet back */ + len = sendto(sd, buf, len, 0, (struct sockaddr *)&src, addrlen); + if (len < 0) { + perror("sendto"); + continue; + } } } free(buf);