mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [RFC 10/12] net: picotcp: add route command
Date: Wed, 15 Jul 2015 23:13:48 +0300	[thread overview]
Message-ID: <1436991230-14251-11-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1436991230-14251-1-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/Makefile        |  1 +
 net/picotcp/Kconfig |  5 +++++
 net/picotcp_route.c | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index 04e347f..6261454 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_NET_PICOTCP) += picotcp.o
 obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
 obj-$(CONFIG_CMD_PICOTCP_IFCONFIG) += picotcp_ifconfig.o
 obj-$(CONFIG_CMD_PICOTCP_PING) += picotcp_ping.o
+obj-$(CONFIG_CMD_PICOTCP_ROUTE) += picotcp_route.o
diff --git a/net/picotcp/Kconfig b/net/picotcp/Kconfig
index cb60001..2cd04d2 100644
--- a/net/picotcp/Kconfig
+++ b/net/picotcp/Kconfig
@@ -48,4 +48,9 @@ config CMD_PICOTCP_PING
 	depends on NET_PICO_SUPPORT_ICMP4
 	prompt "ping command"
 
+config CMD_PICOTCP_ROUTE
+	bool
+	depends on NET_PICO_SUPPORT_IPV4
+	prompt "route command"
+
 endif # NET_PICOTCP
diff --git a/net/picotcp_route.c b/net/picotcp_route.c
new file mode 100644
index 0000000..a2b1453
--- /dev/null
+++ b/net/picotcp_route.c
@@ -0,0 +1,37 @@
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+#include <poller.h>
+
+#include <pico_stack.h>
+#include <pico_ipv4.h>
+#include <pico_icmp4.h>
+
+static int do_route(int argc, char *argv[])
+{
+	struct pico_ipv4_route *r;
+	struct pico_tree_node *index;
+
+	printf("picotcp IPv4 routing table\n");
+	printf("Destination     Gateway         Genmask         Metric Iface\n");
+
+	pico_tree_foreach(index, &Routes) {
+		char ipstr[32];
+
+		r = index->keyValue;
+
+		pico_ipv4_to_string(ipstr, r->dest.addr);
+		printf("%-16s", ipstr);
+		pico_ipv4_to_string(ipstr, r->gateway.addr);
+		printf("%-16s", ipstr);
+		pico_ipv4_to_string(ipstr, r->netmask.addr);
+		printf("%-16s", ipstr);
+		printf("%-7d%s\n", r->metric, r->link->dev->name);
+	}
+
+	return 0;
+}
+
+BAREBOX_CMD_START(route)
+	.cmd		= do_route,
+BAREBOX_CMD_END
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-07-15 20:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
2015-07-15 20:13 ` [RFC 01/12] picotcp: add barebox target support Antony Pavlov
2015-07-15 20:13 ` [RFC 02/12] picotcp: switch to Kbuild Antony Pavlov
2015-07-15 20:13 ` [RFC 03/12] net: add initial picotcp support Antony Pavlov
2015-07-15 20:13 ` [RFC 04/12] WIP: fs/nfs.c: convert to picotcp Antony Pavlov
2015-07-16 19:51   ` Sascha Hauer
2015-07-17  7:18     ` Antony Pavlov
2015-07-15 20:13 ` [RFC 05/12] WIP: fs/tftp.c: " Antony Pavlov
2015-07-15 20:13 ` [RFC 06/12] WIP: net/dns: " Antony Pavlov
2015-07-15 20:13 ` [RFC 07/12] net: picotcp: add test_picotcp command Antony Pavlov
2015-07-15 20:13 ` [RFC 08/12] net: picotcp: add ifconfig command Antony Pavlov
2015-07-15 20:13 ` [RFC 09/12] net: picotcp: add ping command Antony Pavlov
2015-07-15 20:13 ` Antony Pavlov [this message]
2015-07-15 20:13 ` [RFC 11/12] sandbox_defconfig: switch to picotcp Antony Pavlov
2015-07-15 20:13 ` [RFC 12/12] WIP: sandbox_defconfig: enable network testing-related stuff Antony Pavlov

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=1436991230-14251-11-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox