#include <ip.h>
#include <gpxe/retry.h>
+#include <gpxe/hotplug.h>
/* IP constants */
uint16_t len;
};
+/** An IPv4 address/routing table entry */
+struct ipv4_miniroute {
+ /** List of miniroutes */
+ struct list_head list;
+
+ /** Network device */
+ struct net_device *netdev;
+ /** Reference to network device */
+ struct reference netdev_ref;
+
+ /** IPv4 address */
+ struct in_addr address;
+ /** Subnet mask */
+ struct in_addr netmask;
+ /** Gateway address */
+ struct in_addr gateway;
+};
+
/* Fragment reassembly buffer */
struct frag_buffer {
/* Identification number */
struct net_protocol;
struct tcpip_protocol;
+extern struct list_head ipv4_miniroutes;
+
extern struct net_protocol ipv4_protocol;
extern int add_ipv4_address ( struct net_device *netdev,
--- /dev/null
+#ifndef _USR_ROUTE_H
+#define _USR_ROUTE_H
+
+/** @file
+ *
+ * Routing table management
+ *
+ */
+
+extern void route ( void );
+
+#endif /* _USR_ROUTE_H */
*
* IPv4 protocol
*
- * The gPXE IP stack is currently implemented on top of the uIP
- * protocol stack. This file provides wrappers around uIP so that
- * higher-level protocol implementations do not need to talk directly
- * to uIP (which has a somewhat baroque API).
- *
*/
/* Unique IP datagram identification number */
struct net_protocol ipv4_protocol;
-/** An IPv4 address/routing table entry */
-struct ipv4_miniroute {
- /** List of miniroutes */
- struct list_head list;
-
- /** Network device */
- struct net_device *netdev;
- /** Reference to network device */
- struct reference netdev_ref;
-
- /** IPv4 address */
- struct in_addr address;
- /** Subnet mask */
- struct in_addr netmask;
- /** Gateway address */
- struct in_addr gateway;
-};
-
/** List of IPv4 miniroutes */
-static LIST_HEAD ( miniroutes );
+struct list_head ipv4_miniroutes = LIST_HEAD_INIT ( ipv4_miniroutes );
/** List of fragment reassembly buffers */
static LIST_HEAD ( frag_buffers );
* to start of list.
*/
if ( gateway.s_addr != INADDR_NONE ) {
- list_add_tail ( &miniroute->list, &miniroutes );
+ list_add_tail ( &miniroute->list, &ipv4_miniroutes );
} else {
- list_add ( &miniroute->list, &miniroutes );
+ list_add ( &miniroute->list, &ipv4_miniroutes );
}
/* Record reference to net_device */
void del_ipv4_address ( struct net_device *netdev ) {
struct ipv4_miniroute *miniroute;
- list_for_each_entry ( miniroute, &miniroutes, list ) {
+ list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
if ( miniroute->netdev == netdev ) {
del_ipv4_miniroute ( miniroute );
break;
int local;
int has_gw;
- list_for_each_entry ( miniroute, &miniroutes, list ) {
+ list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
local = ( ( ( dest->s_addr ^ miniroute->address.s_addr )
& miniroute->netmask.s_addr ) == 0 );
has_gw = ( miniroute->gateway.s_addr != INADDR_NONE );
const struct in_addr *address = net_addr;
struct ipv4_miniroute *miniroute;
- list_for_each_entry ( miniroute, &miniroutes, list ) {
+ list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
if ( ( miniroute->netdev == netdev ) &&
( miniroute->address.s_addr == address->s_addr ) ) {
/* Found matching address */
find_global_dhcp_ipv4_option ( DHCP_SUBNET_MASK, &netmask );
find_global_dhcp_ipv4_option ( DHCP_ROUTERS, &gateway );
- printf ( "IP %s", inet_ntoa ( address ) );
- printf ( " netmask %s", inet_ntoa ( netmask ) );
- printf ( " gateway %s\n", inet_ntoa ( gateway ) );
-
dhcp_snprintf ( filename, sizeof ( filename ),
find_global_dhcp_option ( DHCP_BOOTFILE_NAME ) );
gateway ) ) != 0 )
goto out_no_del_ipv4;
+ route();
+
/* Test boot */
if ( ( rc = test_dhcp_boot ( netdev, filename ) ) != 0 ) {
printf ( "Boot failed\n" );
#include <vsprintf.h>
#include <gpxe/netdevice.h>
#include <usr/ifmgmt.h>
+#include <usr/route.h>
#include <usr/autoboot.h>
/** @file
ifstat ( netdev );
test_dhcp ( netdev );
+
+ route();
}
/**
--- /dev/null
+/*
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <vsprintf.h>
+#include <gpxe/netdevice.h>
+#include <gpxe/ip.h>
+#include <usr/route.h>
+
+/** @file
+ *
+ * Routing table management
+ *
+ */
+
+void route ( void ) {
+ struct ipv4_miniroute *miniroute;
+
+ 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 != INADDR_NONE )
+ printf ( " gw %s", inet_ntoa ( miniroute->gateway ) );
+ printf ( "\n" );
+ }
+}