iPXE
dhcppkt.h
Go to the documentation of this file.
1#ifndef _IPXE_DHCPPKT_H
2#define _IPXE_DHCPPKT_H
3
4/** @file
5 *
6 * DHCP packets
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/dhcp.h>
14#include <ipxe/dhcpopts.h>
15#include <ipxe/refcnt.h>
16
17/**
18 * A DHCP packet
19 *
20 */
22 /** Reference counter */
23 struct refcnt refcnt;
24 /** The DHCP packet contents */
26 /** DHCP options */
28 /** Settings interface */
30};
31
32/**
33 * Increment reference count on DHCP packet
34 *
35 * @v dhcppkt DHCP packet
36 * @ret dhcppkt DHCP packet
37 */
38static inline __attribute__ (( always_inline )) struct dhcp_packet *
39dhcppkt_get ( struct dhcp_packet *dhcppkt ) {
40 ref_get ( &dhcppkt->refcnt );
41 return dhcppkt;
42}
43
44/**
45 * Decrement reference count on DHCP packet
46 *
47 * @v dhcppkt DHCP packet
48 */
49static inline __attribute__ (( always_inline )) void
50dhcppkt_put ( struct dhcp_packet *dhcppkt ) {
51 ref_put ( &dhcppkt->refcnt );
52}
53
54/**
55 * Get used length of DHCP packet
56 *
57 * @v dhcppkt DHCP packet
58 * @ret len Used length
59 */
60static inline size_t dhcppkt_len ( struct dhcp_packet *dhcppkt ) {
61 return ( offsetof ( struct dhcphdr, options ) +
62 dhcppkt->options.used_len );
63}
64
65extern int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
66 const void *data, size_t len );
67extern int dhcppkt_fetch ( struct dhcp_packet *dhcppkt, unsigned int tag,
68 void *data, size_t len );
69extern void dhcppkt_init ( struct dhcp_packet *dhcppkt,
70 struct dhcphdr *data, size_t len );
71
72#endif /* _IPXE_DHCPPKT_H */
static int options
Definition 3c515.c:286
DHCP options.
static struct dhcp_packet * dhcppkt_get(struct dhcp_packet *dhcppkt)
Increment reference count on DHCP packet.
Definition dhcppkt.h:39
static void dhcppkt_put(struct dhcp_packet *dhcppkt)
Decrement reference count on DHCP packet.
Definition dhcppkt.h:50
void dhcppkt_init(struct dhcp_packet *dhcppkt, struct dhcphdr *data, size_t len)
Initialise DHCP packet.
Definition dhcppkt.c:301
int dhcppkt_store(struct dhcp_packet *dhcppkt, unsigned int tag, const void *data, size_t len)
Store value of DHCP packet setting.
Definition dhcppkt.c:165
int dhcppkt_fetch(struct dhcp_packet *dhcppkt, unsigned int tag, void *data, size_t len)
Fetch value of DHCP packet setting.
Definition dhcppkt.c:196
static size_t dhcppkt_len(struct dhcp_packet *dhcppkt)
Get used length of DHCP packet.
Definition dhcppkt.h:60
ring len
Length.
Definition dwmac.h:226
uint64_t tag
Identity tag.
Definition edd.h:1
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
Dynamic Host Configuration Protocol.
Reference counting.
#define ref_get(refcnt)
Get additional reference to object.
Definition refcnt.h:93
#define ref_put(refcnt)
Drop reference to object.
Definition refcnt.h:107
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
A DHCP options block.
Definition dhcpopts.h:16
size_t used_len
Option block used length.
Definition dhcpopts.h:20
A DHCP packet.
Definition dhcppkt.h:21
struct refcnt refcnt
Reference counter.
Definition dhcppkt.h:23
struct settings settings
Settings interface.
Definition dhcppkt.h:29
struct dhcphdr * dhcphdr
The DHCP packet contents.
Definition dhcppkt.h:25
struct dhcp_options options
DHCP options.
Definition dhcppkt.h:27
A DHCP header.
Definition dhcp.h:616