24 RCSID(
"$Id: 3260f2e68b17b6fdf57eabfc809e1526354f9e1b $")
26 #include <freeradius-devel/libradius.h>
28 #include <freeradius-devel/radiusd.h>
29 #include <freeradius-devel/modules.h>
30 #include <freeradius-devel/dhcp.h>
34 #define PW_DHCP_PARAMETER_REQUEST_LIST 55
52 UNUSED void const *mod_inst,
UNUSED void const *xlat_inst,
53 REQUEST *request,
char const *fmt)
61 while (isspace((
int) *fmt)) fmt++;
76 REDEBUG(
"dhcp_options got a %s attribute needed octets",
86 uint8_t
const *p = vp->vp_octets, *end = p + vp->vp_length;
120 snprintf(*out, outlen,
"%i", decoded);
126 UNUSED void const *mod_inst,
UNUSED void const *xlat_inst,
127 REQUEST *request,
char const *fmt)
134 while (isspace((
int) *fmt)) fmt++;
136 if ((
radius_copy_vp(request, &vp, request, fmt) < 0) || !vp)
return 0;
147 if ((
size_t)((len * 2) + 1) > outlen) {
148 REDEBUG(
"DHCP option encoding failed: Output buffer exhausted, needed %zd bytes, have %zd bytes",
149 (len * 2) + 1, outlen);
179 for (i = 1; i < 255; i++) {
182 DEBUG3(
"No DHCP RFC space attribute at %i", i);
void fr_pair_list_free(VALUE_PAIR **)
Free memory used by a valuepair list.
static ssize_t dhcp_xlat(char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt)
2nd highest priority debug messages (-xx | -X).
VALUE_PAIR * fr_cursor_first(vp_cursor_t *cursor)
Rewind cursor to the start of the list.
int xlat_register(void *mod_inst, char const *name, xlat_func_t func, xlat_escape_t escape, xlat_instantiate_t instantiate, size_t inst_size, size_t buf_len)
Register an xlat function.
void rdebug_pair(log_lvl_t level, REQUEST *, VALUE_PAIR *, char const *)
Print a single valuepair to stderr or error log.
Metadata exported by the module.
int radius_copy_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char const *name)
Copy VP(s) from the specified request.
#define REMARKER(_m, _i, _e)
Output string with error marker, showing where format error occurred.
ssize_t fr_dhcp_encode_option(uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx)
ssize_t fr_dhcp_decode_option(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent, uint8_t const *data, size_t len, void *decoder_ctx)
VALUE_PAIR * vps
Result of decoding the packet into VALUE_PAIRs.
VALUE_PAIR * fr_cursor_init(vp_cursor_t *cursor, VALUE_PAIR *const *node)
Setup a cursor to iterate over attribute pairs.
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
#define XLAT_DEFAULT_BUF_LEN
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
VALUE_PAIR * tmpl_cursor_init(int *err, vp_cursor_t *cursor, REQUEST *request, vp_tmpl_t const *vpt)
Initialise a vp_cursor_t to the VALUE_PAIR specified by a vp_tmpl_t.
void fr_cursor_merge(vp_cursor_t *cursor, VALUE_PAIR *vp)
Merges multiple VALUE_PAIR into the cursor.
ssize_t tmpl_from_attr_str(vp_tmpl_t *vpt, char const *name, request_refs_t request_def, pair_lists_t list_def, bool allow_unknown, bool allow_undefined)
Parse a string into a TMPL_TYPE_ATTR_* or TMPL_TYPE_LIST type vp_tmpl_t.
const FR_NAME_NUMBER dict_attr_types[]
Map data types to names representing those types.
Attributes in incoming or internally proxied request.
int fr_dict_enum_add(fr_dict_t *dict, char const *attr, char const *alias, int value)
Stores an attribute, a value and various bits of other data.
static ssize_t dhcp_options_xlat(char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt)
tmpl_type_t type
What type of value tmpl refers to.
#define PW_DHCP_PARAMETER_REQUEST_LIST
char const * fr_strerror(void)
Get the last library error.
void fr_pair_list_move(TALLOC_CTX *ctx, VALUE_PAIR **to, VALUE_PAIR **from)
Move pairs from source list to destination list respecting operator.
char name[1]
Attribute name.
uint64_t magic
Used to validate module struct.
VALUE_PAIR * fr_cursor_next(vp_cursor_t *cursor)
Advanced the cursor to the next VALUE_PAIR.
RADIUS_PACKET * packet
Incoming request.
#define DHCP_MAGIC_VENDOR
static int mod_bootstrap(UNUSED CONF_SECTION *conf, void *instance)
struct rlm_dhcp_t rlm_dhcp_t
char const * fr_int2str(FR_NAME_NUMBER const *table, int number, char const *def)
fr_dict_attr_t const * fr_dict_attr_by_num(fr_dict_t *dict, unsigned int vendor, unsigned int attr)
Lookup a fr_dict_attr_t by its vendor and attribute numbers.
VALUE_PAIR * tmpl_cursor_next(vp_cursor_t *cursor, vp_tmpl_t const *vpt)
Returns the next VALUE_PAIR specified by vpt.
fr_dict_t * fr_dict_internal
Internal server dictionary.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
A source or sink of value data.
size_t fr_bin2hex(char *hex, uint8_t const *bin, size_t inlen)
Convert binary data to a hex string.
const FR_NAME_NUMBER tmpl_names[]
Map tmpl_type_t values to descriptive strings.