1 #ifndef _IPXE_DHCPPKT_H
2 #define _IPXE_DHCPPKT_H
10 FILE_LICENCE ( GPL2_OR_LATER );
12 #include <ipxe/dhcp.h>
13 #include <ipxe/dhcpopts.h>
14 #include <ipxe/refcnt.h>
21 /** Reference counter */
23 /** The DHCP packet contents */
24 struct dhcphdr *dhcphdr;
26 struct dhcp_options options;
27 /** Settings interface */
28 struct settings settings;
32 * Increment reference count on DHCP packet
34 * @v dhcppkt DHCP packet
35 * @ret dhcppkt DHCP packet
37 static inline __attribute__ (( always_inline )) struct dhcp_packet *
38 dhcppkt_get ( struct dhcp_packet *dhcppkt ) {
39 ref_get ( &dhcppkt->refcnt );
44 * Decrement reference count on DHCP packet
46 * @v dhcppkt DHCP packet
48 static inline __attribute__ (( always_inline )) void
49 dhcppkt_put ( struct dhcp_packet *dhcppkt ) {
50 ref_put ( &dhcppkt->refcnt );
54 * Get used length of DHCP packet
56 * @v dhcppkt DHCP packet
57 * @ret len Used length
59 static inline int dhcppkt_len ( struct dhcp_packet *dhcppkt ) {
60 return ( offsetof ( struct dhcphdr, options ) +
61 dhcppkt->options.used_len );
64 extern int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
65 const void *data, size_t len );
66 extern int dhcppkt_fetch ( struct dhcp_packet *dhcppkt, unsigned int tag,
67 void *data, size_t len );
68 extern void dhcppkt_init ( struct dhcp_packet *dhcppkt,
69 struct dhcphdr *data, size_t len );
71 #endif /* _IPXE_DHCPPKT_H */