25 RCSID(
"$Id: 67c2e0d67a8a23f032ffe67258f0a8f6641d2524 $")
27 #include "eap_chbind.h"
45 if (!vp->
da->
vendor && (vp->
da->
attr == PW_MESSAGE_AUTHENTICATOR))
continue;
47 total += 2 + vp->vp_length;
54 ptr = talloc_zero_array(chbind, uint8_t, 1);
56 ptr = talloc_zero_array(chbind, uint8_t, total + 4);
58 if (!ptr)
return false;
67 ptr[0] = vp->vp_integer;
72 if (!total)
return true;
75 ptr[1] = (total >> 8) & 0xff;
76 ptr[2] = total & 0xff;
79 RDEBUG(
"Sending chbind response: code %i", (
int )(ptr[0]));
96 if (!vp->
da->
vendor && (vp->
da->
attr == PW_MESSAGE_AUTHENTICATOR))
goto next;
115 uint8_t
const **
data)
124 ptr = (uint8_t
const *) packet;
125 end = ptr + talloc_array_length(packet);
135 if ((end - ptr) < 4)
return 0;
137 length = (ptr[0] << 8) | ptr[1];
138 if (length == 0)
return 0;
140 if ((ptr + length + 3) > end)
return 0;
143 if (nsid == desired_nsid) {
161 uint8_t
const *attr_data;
192 while (data_len > 0) {
196 attr_data, data_len, NULL);
206 attr_data += attr_len;
207 data_len -= attr_len;
215 fake->
server =
"channel_bindings";
254 if (!first)
return NULL;
263 length += vp->vp_length;
267 DEBUG(
"Invalid length %u for channel binding data", (
unsigned int) length);
274 ptr = talloc_zero_array(ctx, uint8_t, length);
275 if (!ptr)
return NULL;
284 memcpy(ptr, vp->vp_octets, vp->vp_length);
285 ptr += vp->vp_length;
295 if (!packet)
return NULL;
298 if (!vp)
return NULL;
VALUE_PAIR * config
VALUE_PAIR (s) used to set per request parameters for modules and the server core at runtime...
VALUE_PAIR * eap_chbind_packet2vp(REQUEST *request, chbind_packet_t *packet)
int fr_radius_encode_pair(uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx)
Encode a data structure into a RADIUS attribute.
The module is OK, continue.
VALUE_PAIR * fr_pair_afrom_num(TALLOC_CTX *ctx, unsigned int vendor, unsigned int attr)
Create a new valuepair.
VALUE_PAIR * fr_cursor_next_by_num(vp_cursor_t *cursor, unsigned int vendor, unsigned int attr, int8_t tag)
Iterate over a collection of VALUE_PAIRs of a given type in the pairlist.
#define CHBIND_NSID_RADIUS
VALUE_PAIR * username
Cached username VALUE_PAIR from request RADIUS_PACKET.
VALUE_PAIR * vps
Result of decoding the packet into VALUE_PAIRs.
#define pair_make_request(_a, _b, _c)
VALUE_PAIR * fr_cursor_init(vp_cursor_t *cursor, VALUE_PAIR *const *node)
Setup a cursor to iterate over attribute pairs.
REQUEST * request_alloc_fake(REQUEST *oldreq)
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
fr_dict_attr_flags_t flags
Flags.
RFC2865 - Access-Request.
static size_t chbind_get_data(chbind_packet_t const *packet, int desired_nsid, uint8_t const **data)
Highest priority debug messages (-x).
PW_CODE chbind_process(REQUEST *request, CHBIND_REQ *chbind)
void fr_pair_add(VALUE_PAIR **head, VALUE_PAIR *vp)
Add a VP to the end of the list.
unsigned int attr
Attribute number.
unsigned int code
Packet code (type).
unsigned int vendor
Vendor that defines this attribute.
Stores an attribute, a value and various bits of other data.
VALUE_PAIR * fr_cursor_current(vp_cursor_t *cursor)
Return the VALUE_PAIR the cursor current points to.
RADIUS_PACKET * reply
Outgoing response.
enum attr_flags::@0 encrypt
static bool chbind_build_response(REQUEST *request, CHBIND_REQ *chbind)
chbind_packet_t * request
void rdebug_pair_list(log_lvl_t level, REQUEST *, VALUE_PAIR *, char const *)
Print a list of VALUE_PAIRs.
chbind_packet_t * response
#define CHBIND_CODE_REQUEST
chbind_packet_t * eap_chbind_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
ssize_t fr_radius_decode_pair(TALLOC_CTX *ctx, vp_cursor_t *cursor, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decoder_ctx)
Create a "normal" VALUE_PAIR from the given data.
VALUE_PAIR * fr_cursor_next(vp_cursor_t *cursor)
Advanced the cursor to the next VALUE_PAIR.
RADIUS_PACKET * packet
Incoming request.
VALUE_PAIR * fr_pair_copy(TALLOC_CTX *ctx, VALUE_PAIR const *vp)
Copy a single valuepair.
VALUE_PAIR * fr_pair_find_by_num(VALUE_PAIR *head, unsigned int vendor, unsigned int attr, int8_t tag)
Find the pair with the matching attribute.
PW_CODE
RADIUS packet codes.
fr_dict_attr_t const * da
Dictionary attribute defines the attribute.
int rad_virtual_server(REQUEST *)
The module handled the request, so stop.
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.
#define CHBIND_CODE_FAILURE
void fr_pair_value_memcpy(VALUE_PAIR *vp, uint8_t const *src, size_t len)
Copy data into an "octets" data type.