26 RCSID(
"$Id: bba5ec549eeb555f324154e9ef09cc39bd115efa $")
28 #include <freeradius-devel/radius/defs.h>
29 #include <freeradius-devel/radius/radius.h>
30 #include <freeradius-devel/server/auth.h>
32 #include <freeradius-devel/io/pair.h>
51 if (
vp->
da->flags.internal || (!
vp->
da->flags.extra &&
vp->
da->flags.subtype))
continue;
54 total += 2 +
vp->vp_length;
61 ptr = talloc_zero_array(chbind,
uint8_t, 1);
63 ptr = talloc_zero_array(chbind,
uint8_t, total + 4);
65 if (!ptr)
return false;
74 ptr[0] =
vp->vp_uint32;
79 if (!total)
return true;
82 ptr[1] = (total >> 8) & 0xff;
83 ptr[2] = total & 0xff;
86 RDEBUG2(
"Sending chbind response: code %i", (
int )(ptr[0]));
99 if (
vp->
da->flags.subtype) {
108 RPERROR(
"Failed encoding chbind response");
138 ptr = (
uint8_t const *) packet;
139 end = ptr + talloc_array_length((
uint8_t const *) packet);
149 if ((end - ptr) < 4)
return 0;
152 if (length == 0)
return 0;
154 if ((ptr + length + 3) > end)
return 0;
157 if (nsid == desired_nsid) {
201 packet_ctx.
common = &common_ctx;
209 packet_ctx.
end = attr_data + data_len;
211 while (data_len > 0) {
215 attr_data, data_len, &packet_ctx);
227 attr_data += attr_len;
228 data_len -= attr_len;
231 talloc_free_children(packet_ctx.
tmp_ctx);
286 length +=
vp->vp_length;
290 DEBUG(
"Invalid length %u for channel binding data", (
unsigned int) length);
297 ptr = talloc_zero_array(ctx,
uint8_t, length);
298 if (!ptr)
return NULL;
307 memcpy(ptr,
vp->vp_octets,
vp->vp_length);
308 ptr +=
vp->vp_length;
318 if (!chbind)
return NULL;
unlang_action_t rad_virtual_server(rlm_rcode_t *p_result, request_t *request)
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
static size_t chbind_get_data(chbind_packet_t const *packet, int desired_nsid, uint8_t const **data)
fr_radius_packet_code_t chbind_process(request_t *request, CHBIND_REQ *chbind)
static bool chbind_build_response(request_t *request, CHBIND_REQ *chbind)
chbind_packet_t * eap_chbind_vp2packet(TALLOC_CTX *ctx, fr_pair_list_t *vps)
fr_pair_t * eap_chbind_packet2vp(TALLOC_CTX *ctx, chbind_packet_t *chbind)
chbind_packet_t * response
#define CHBIND_NSID_RADIUS
chbind_packet_t * request
#define CHBIND_CODE_REQUEST
#define CHBIND_CODE_FAILURE
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
static void * fr_dcursor_head(fr_dcursor_t *cursor)
Rewind cursor to the start of the list.
static void * fr_dcursor_current(fr_dcursor_t *cursor)
Return the item the cursor current points to.
fr_radius_packet_code_t
RADIUS packet codes.
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
@ FR_RADIUS_CODE_ACCESS_ACCEPT
RFC2865 - Access-Accept.
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
HIDDEN fr_dict_attr_t const * attr_chbind_response_code
HIDDEN fr_dict_attr_t const * attr_freeradius_proxied_to
HIDDEN fr_dict_attr_t const * attr_eap_channel_binding_message
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
@ L_DBG_LVL_1
Highest priority debug messages (-x).
static uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
Read an unsigned 16bit integer from wire format (big endian)
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
int fr_pair_value_from_str(fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, bool tainted)
Convert string value to native attribute value.
int fr_pair_prepend_by_da(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da)
Alloc a new fr_pair_t (and prepend)
ssize_t fr_radius_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, fr_radius_decode_ctx_t *packet_ctx)
Create a "normal" fr_pair_t from the given data.
ssize_t fr_radius_encode_pair(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
Encode a data structure into a RADIUS attribute.
fr_radius_tag_ctx_t ** tags
for decoding tagged attributes
uint8_t const * end
end of the packet
fr_radius_ctx_t const * common
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
static fr_dict_attr_t const * attr_message_authenticator
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
#define request_alloc_internal(_ctx, _args)
Allocate a new internal request.
Optional arguments for initialising requests.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
static TALLOC_CTX * talloc_init_const(char const *name)
Allocate a top level chunk with a constant name.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
#define fr_pair_dcursor_by_da_init(_cursor, _list, _da)
Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t.
fr_pair_t * fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item))
Get the next item in a valuepair list after a specific entry.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.