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.

dhcppkt.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _GPXE_DHCPPKT_H
  2. #define _GPXE_DHCPPKT_H
  3. /** @file
  4. *
  5. * DHCP packets
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <gpxe/dhcp.h>
  10. #include <gpxe/dhcpopts.h>
  11. #include <gpxe/refcnt.h>
  12. /**
  13. * A DHCP packet
  14. *
  15. */
  16. struct dhcp_packet {
  17. /** Reference counter */
  18. struct refcnt refcnt;
  19. /** The DHCP packet contents */
  20. struct dhcphdr *dhcphdr;
  21. /** Maximum length of the DHCP packet buffer */
  22. size_t max_len;
  23. /** Used length of the DHCP packet buffer */
  24. size_t len;
  25. /** DHCP options */
  26. struct dhcp_options options;
  27. /** Settings interface */
  28. struct settings settings;
  29. };
  30. /**
  31. * Increment reference count on DHCP packet
  32. *
  33. * @v dhcppkt DHCP packet
  34. * @ret dhcppkt DHCP packet
  35. */
  36. static inline __attribute__ (( always_inline )) struct dhcp_packet *
  37. dhcppkt_get ( struct dhcp_packet *dhcppkt ) {
  38. ref_get ( &dhcppkt->refcnt );
  39. return dhcppkt;
  40. }
  41. /**
  42. * Decrement reference count on DHCP packet
  43. *
  44. * @v dhcppkt DHCP packet
  45. */
  46. static inline __attribute__ (( always_inline )) void
  47. dhcppkt_put ( struct dhcp_packet *dhcppkt ) {
  48. ref_put ( &dhcppkt->refcnt );
  49. }
  50. extern int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
  51. const void *data, size_t len );
  52. extern int dhcppkt_fetch ( struct dhcp_packet *dhcppkt, unsigned int tag,
  53. void *data, size_t len );
  54. extern void dhcppkt_init ( struct dhcp_packet *dhcppkt,
  55. struct dhcphdr *data, size_t len );
  56. #endif /* _GPXE_DHCPPKT_H */