Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

route_ipv4.c 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <stdio.h>
  21. #include <ipxe/netdevice.h>
  22. #include <ipxe/ip.h>
  23. #include <usr/route.h>
  24. /** @file
  25. *
  26. * IPv4 routing management
  27. *
  28. */
  29. /**
  30. * Print IPv4 routing table
  31. *
  32. * @v netdev Network device
  33. */
  34. static void route_ipv4_print ( struct net_device *netdev ) {
  35. struct ipv4_miniroute *miniroute;
  36. list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
  37. if ( miniroute->netdev != netdev )
  38. continue;
  39. printf ( "%s: %s/", netdev->name,
  40. inet_ntoa ( miniroute->address ) );
  41. printf ( "%s", inet_ntoa ( miniroute->netmask ) );
  42. if ( miniroute->gateway.s_addr )
  43. printf ( " gw %s", inet_ntoa ( miniroute->gateway ) );
  44. if ( ! netdev_is_open ( miniroute->netdev ) )
  45. printf ( " (inaccessible)" );
  46. printf ( "\n" );
  47. }
  48. }
  49. /** IPv4 routing family */
  50. struct routing_family ipv4_routing_family __routing_family ( ROUTING_IPV4 ) = {
  51. .print = route_ipv4_print,
  52. };