[ipv4] Abstract out protocol-specific portions of "route" command

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2013-09-03 16:28:34 +01:00
parent c6a04085d2
commit 43307b4e39
4 changed files with 115 additions and 14 deletions
+11 -13
View File
@@ -19,28 +19,26 @@
FILE_LICENCE ( GPL2_OR_LATER );
#include <stdio.h>
#include <ipxe/netdevice.h>
#include <ipxe/ip.h>
#include <usr/route.h>
/** @file
*
* Routing table management
* Routing management
*
*/
/**
* Print routing table
*
*/
void route ( void ) {
struct ipv4_miniroute *miniroute;
struct net_device *netdev;
struct routing_family *family;
list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
printf ( "%s: %s/", miniroute->netdev->name,
inet_ntoa ( miniroute->address ) );
printf ( "%s", inet_ntoa ( miniroute->netmask ) );
if ( miniroute->gateway.s_addr )
printf ( " gw %s", inet_ntoa ( miniroute->gateway ) );
if ( ! netdev_is_open ( miniroute->netdev ) )
printf ( " (inaccessible)" );
printf ( "\n" );
for_each_netdev ( netdev ) {
for_each_table_entry ( family, ROUTING_FAMILIES ) {
family->print ( netdev );
}
}
}