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