You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pxeparent_dhcp.c 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
  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 <string.h>
  21. #include <ipxe/dhcp.h>
  22. #include <ipxe/netdevice.h>
  23. #include <undipreload.h>
  24. #include <pxeparent.h>
  25. #include <realmode.h>
  26. #include <pxe_api.h>
  27. /**
  28. * Present cached DHCP packet if it exists
  29. */
  30. void get_cached_dhcpack ( void ) {
  31. struct undi_device *undi;
  32. struct s_PXENV_GET_CACHED_INFO get_cached_info;
  33. int rc;
  34. /* Use preloaded UNDI device to get at PXE entry point */
  35. undi = &preloaded_undi;
  36. if ( ! undi->entry.segment ) {
  37. DBG ( "PXEDHCP no preloaded UNDI device found\n" );
  38. return;
  39. }
  40. /* Check that stack is available to get cached info */
  41. if ( ! ( undi->flags & UNDI_FL_KEEP_ALL ) ) {
  42. DBG ( "PXEDHCP stack was unloaded, no cache available\n" );
  43. return;
  44. }
  45. /* Obtain cached DHCP packet */
  46. memset ( &get_cached_info, 0, sizeof ( get_cached_info ) );
  47. get_cached_info.PacketType = PXENV_PACKET_TYPE_DHCP_ACK;
  48. if ( ( rc = pxeparent_call ( undi->entry, PXENV_GET_CACHED_INFO,
  49. &get_cached_info,
  50. sizeof ( get_cached_info ) ) ) != 0 ) {
  51. DBG ( "PXEDHCP GET_CACHED_INFO failed: %s\n", strerror ( rc ) );
  52. return;
  53. }
  54. DBG ( "PXEDHCP got cached info at %04x:%04x length %d\n",
  55. get_cached_info.Buffer.segment, get_cached_info.Buffer.offset,
  56. get_cached_info.BufferSize );
  57. /* Present cached DHCP packet */
  58. store_cached_dhcpack ( real_to_user ( get_cached_info.Buffer.segment,
  59. get_cached_info.Buffer.offset ),
  60. get_cached_info.BufferSize );
  61. }