125 int *encap_offset ) {
130 unsigned int option_len;
137 while ( remaining ) {
144 remaining -= option_len;
159 DBGC (
options,
"DHCPOPT %p found %s (length %d)\n",
204 int offset,
int encap_offset,
205 size_t old_len,
size_t new_len ) {
208 ssize_t delta = ( new_len - old_len );
209 size_t old_alloc_len;
211 size_t new_encapsulator_len;
221 new_used_len = (
options->used_len + delta );
224 if ( new_used_len >
options->alloc_len ) {
226 old_alloc_len =
options->alloc_len;
228 DBGC (
options,
"DHCPOPT %p could not reallocate to "
229 "%zd bytes\n",
options, new_used_len );
234 (
options->alloc_len - old_alloc_len ) );
238 if ( encap_offset >= 0 ) {
240 new_encapsulator_len = ( encapsulator->
len + delta );
242 DBGC (
options,
"DHCPOPT %p overlength encapsulator\n",
246 encapsulator->
len = new_encapsulator_len;
250 options->used_len = new_used_len;
254 source = ( ( (
void * )
option ) + old_len );
259 if ( new_used_len < options->alloc_len ) {
261 DBGC (
options,
"DHCPOPT %p could not reallocate to "
262 "%zd bytes\n",
options, new_used_len );
288 const void *
data,
size_t len ) {
291 int encap_offset = -1;
305 if ( creation_offset < 0 )
306 creation_offset =
options->used_len;
312 DBGC (
options,
"DHCPOPT %p resizing %s from %zd to %zd\n",
315 DBGC (
options,
"DHCPOPT %p creating %s (length %zd)\n",
321 if ( encap_offset < 0 ) {
325 sizeof ( empty_encap ) );
327 if ( encap_offset < 0 )
338 old_len, new_len ) ) != 0 )
350 if ( encap_offset >= 0 ) {
381 const void *
data,
size_t len ) {
411 if (
len > option_len )
430 unsigned int option_len;
434 while ( remaining ) {
437 remaining -= option_len;
463 options->alloc_len = alloc_len;
469 DBGC (
options,
"DHCPOPT %p created (data %p lengths %#zx,%#zx)\n",
#define NULL
NULL pointer (VOID *).
struct arbelprm_rc_send_wqe rc
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
uint16_t offset
Offset to command line.
int dhcpopt_no_realloc(struct dhcp_options *options, size_t len)
Refuse to reallocate DHCP option block.
int dhcpopt_applies(unsigned int tag)
Check applicability of DHCP option setting.
static int set_dhcp_option(struct dhcp_options *options, unsigned int tag, const void *data, size_t len)
Set value of DHCP option.
void dhcpopt_init(struct dhcp_options *options, void *data, size_t alloc_len, int(*realloc)(struct dhcp_options *options, size_t len))
Initialise prepopulated block of DHCP options.
int dhcpopt_fetch(struct dhcp_options *options, unsigned int tag, void *data, size_t len)
Fetch value of DHCP option setting.
void dhcpopt_update_used_len(struct dhcp_options *options)
Recalculate length of DHCP options block.
int dhcpopt_store(struct dhcp_options *options, unsigned int tag, const void *data, size_t len)
Store value of DHCP option setting.
static int find_dhcp_option_with_encap(struct dhcp_options *options, unsigned int tag, int *encap_offset)
Find DHCP option within DHCP options block, and its encapsulator (if any).
static unsigned int dhcp_option_len(struct dhcp_option *option, size_t remaining)
Calculate length of any DHCP option.
static char * dhcp_tag_name(unsigned int tag)
Obtain printable version of a DHCP option tag.
static struct dhcp_option * dhcp_option(struct dhcp_options *options, unsigned int offset)
Get pointer to DHCP option.
static int dhcp_option_offset(struct dhcp_options *options, struct dhcp_option *option)
Get offset of a DHCP option.
static int resize_dhcp_option(struct dhcp_options *options, int offset, int encap_offset, size_t old_len, size_t new_len)
Resize a DHCP option.
uint64_t tag
Identity tag.
uint8_t data[48]
Additional event data.
#define DHCP_MAX_OPTION
Maximum normal DHCP option.
#define DHCP_END
End of options.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define ENOENT
No such file or directory.
#define ENOSPC
No space left on device.
#define ENOTTY
Inappropriate I/O control operation.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Dynamic Host Configuration Protocol.
#define DHCP_ENCAP_OPT(encapsulator, encapsulated)
Construct a tag value for an encapsulated option.
#define DHCP_ENCAPSULATOR(encap_opt)
Extract encapsulating option block tag from encapsulated tag value.
#define DHCP_OPTION_HEADER_LEN
Length of a DHCP option header.
#define DHCP_IS_ENCAP_OPT(opt)
Option is encapsulated.
#define DHCP_ENCAPSULATED(encap_opt)
Extract encapsulated option tag from encapsulated tag value.
#define DHCP_MAX_LEN
Maximum length for a single DHCP option.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void * memmove(void *dest, const void *src, size_t len) __nonnull
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
A long option, as used for getopt_long().
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.