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

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