From: wsn.iot.xwq@cn.fujitsu.com
To: linux-wpan@vger.kernel.org
Cc: stefan@osg.samsung.com, aar@pengutronix.de,
Xue Wenqian <wsn.iot.xwq@cn.fujitsu.com>
Subject: [PATCH wpan-tools v2] wpan-ping: Add the filtering function for frame receiving
Date: Wed, 21 Dec 2016 05:49:04 +0000 [thread overview]
Message-ID: <1482299344-4128-1-git-send-email-wsn.iot.xwq@cn.fujitsu.com> (raw)
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);
--
1.7.10.4
next reply other threads:[~2016-12-21 5:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-21 5:49 wsn.iot.xwq [this message]
2016-12-23 10:46 ` [PATCH wpan-tools v2] wpan-ping: Add the filtering function for frame receiving Stefan Schmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1482299344-4128-1-git-send-email-wsn.iot.xwq@cn.fujitsu.com \
--to=wsn.iot.xwq@cn.fujitsu.com \
--cc=aar@pengutronix.de \
--cc=linux-wpan@vger.kernel.org \
--cc=stefan@osg.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.