Functions to encode DHCP options.
More...
#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/struct.h>
#include <freeradius-devel/util/dns.h>
#include <freeradius-devel/util/encode.h>
#include "dhcpv4.h"
#include "attrs.h"
Go to the source code of this file.
|
static ssize_t | encode_child (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx) |
|
static ssize_t | encode_rfc (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx) |
| Write out an RFC option header and option data. More...
|
|
static int | encode_test_ctx (void **out, TALLOC_CTX *ctx) |
|
static ssize_t | encode_tlv (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx) |
| Write out a TLV header (and any sub TLVs or values) More...
|
|
static ssize_t | encode_value (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx) |
| Write DHCP option value into buffer. More...
|
|
static ssize_t | encode_vsio (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx) |
|
static ssize_t | encode_vsio_data (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx) |
|
static ssize_t | extend_option (fr_dbuff_t *dbuff, fr_dbuff_marker_t *hdr, size_t len) |
| Extend an encoded option in-place. More...
|
|
ssize_t | fr_dhcpv4_encode_foreign (fr_dbuff_t *dbuff, fr_pair_list_t const *list) |
|
ssize_t | fr_dhcpv4_encode_option (fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx) |
| Encode a DHCP option and any sub-options. More...
|
|
static ssize_t | fr_dhcpv4_encode_proto (UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, UNUSED void *proto_ctx) |
|
Functions to encode DHCP options.
- Id
- 804aa699298e3636eb78960daa48967705ff1408
- Copyright
- 2008,2017 The FreeRADIUS server project
-
2008 Alan DeKok (aland.nosp@m.@dep.nosp@m.loyin.nosp@m.grad.nosp@m.ius.c.nosp@m.om)
-
2015,2017 Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
Definition in file encode.c.
◆ DHCPV4_OPT_HDR_LEN
#define DHCPV4_OPT_HDR_LEN (2) |
◆ encode_child()
◆ encode_rfc()
Write out an RFC option header and option data.
- Note
- May coalesce options with fixed width values
- Parameters
-
[out] | dbuff | buffer to write the TLV to. |
[in] | da_stack | Describing nesting of options. |
[in] | depth | in the da_stack. |
[in,out] | cursor | Current attribute we're encoding. |
[in] | encode_ctx | Containing DHCPv4 dictionary. |
- Returns
- >0 length of data encoded.
- 0 if we ran out of space.
- < 0 on error.
Definition at line 291 of file encode.c.
◆ encode_test_ctx()
static int encode_test_ctx |
( |
void ** |
out, |
|
|
TALLOC_CTX * |
ctx |
|
) |
| |
|
static |
◆ encode_tlv()
Write out a TLV header (and any sub TLVs or values)
- Parameters
-
[out] | dbuff | buffer to write the TLV to. |
[in] | da_stack | Describing nesting of options. |
[in] | depth | in the da_stack. |
[in,out] | cursor | Current attribute we're encoding. |
[in] | encode_ctx | Containing DHCPv4 dictionary. |
- Returns
- >0 length of data encoded.
- 0 if we ran out of space.
- < 0 on error.
Definition at line 435 of file encode.c.
◆ encode_value()
Write DHCP option value into buffer.
Does not include DHCP option length or number.
- Parameters
-
[out] | dbuff | buffer to write the option to. |
[in] | da_stack | Describing nesting of options. |
[in] | depth | in da_stack. |
[in,out] | cursor | Current attribute we're encoding. |
[in] | encode_ctx | Containing DHCPv4 dictionary. |
- Returns
- The length of data written, may return 0 for bools < 0 if there's not enough space or option type is unsupported
Definition at line 58 of file encode.c.
◆ encode_vsio()
◆ encode_vsio_data()
◆ extend_option()
Extend an encoded option in-place.
- Parameters
-
[in] | dbuff | buffer containing the option |
[in] | hdr | marker (with dbuff as parent) set to where the option starts |
[in] | len | length of the data being written |
- Returns
- <0 if we can't extend the option
- >0 if we can, with hdr set to where the next option should start
- Note
- The option starts with a two-byte (type, length) header, where the length does not include the two bytes for the header. The starting length may be non-zero, hence its counting towards the header_byte calculation and its inclusion in sublen calculation. (All those following start out empty, hence the initialization of their lengths to zero.)
Definition at line 190 of file encode.c.
◆ fr_dhcpv4_encode_foreign()
◆ fr_dhcpv4_encode_option()
Encode a DHCP option and any sub-options.
- Parameters
-
[out] | dbuff | Where to write encoded DHCP attributes. |
[in] | cursor | with current VP set to the option to be encoded. Will be advanced to the next option to encode. |
[in] | encode_ctx | Containing DHCPv4 dictionary. |
- Returns
- > 0 length of data written.
- < 0 error.
- 0 not valid option for DHCP (skipping).
Definition at line 726 of file encode.c.
◆ fr_dhcpv4_encode_proto()
◆ dhcpv4_tp_encode_pair
Initial value:= {
}
void * fr_dhcpv4_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
DHCPV4-specific iterator.
static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
ssize_t fr_dhcpv4_encode_option(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
Encode a DHCP option and any sub-options.
Definition at line 823 of file encode.c.
◆ dhcpv4_tp_encode_proto
Initial value:= {
}
static ssize_t fr_dhcpv4_encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, UNUSED void *proto_ctx)
Definition at line 832 of file encode.c.