From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-lb0-x229.google.com ([2a00:1450:4010:c04::229]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZFT4e-0005HQ-7c for barebox@lists.infradead.org; Wed, 15 Jul 2015 20:14:36 +0000 Received: by lbbzr7 with SMTP id zr7so31744803lbb.1 for ; Wed, 15 Jul 2015 13:14:14 -0700 (PDT) Received: from localhost.localdomain (ppp79-139-249-41.pppoe.spdop.ru. [79.139.249.41]) by smtp.gmail.com with ESMTPSA id ao8sm531319lac.38.2015.07.15.13.14.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Jul 2015 13:14:13 -0700 (PDT) From: Antony Pavlov Date: Wed, 15 Jul 2015 23:13:48 +0300 Message-Id: <1436991230-14251-11-git-send-email-antonynpavlov@gmail.com> In-Reply-To: <1436991230-14251-1-git-send-email-antonynpavlov@gmail.com> References: <1436991230-14251-1-git-send-email-antonynpavlov@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [RFC 10/12] net: picotcp: add route command To: barebox@lists.infradead.org Signed-off-by: Antony Pavlov --- 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 +#include +#include +#include + +#include +#include +#include + +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