60 RCSID(
"$Id: cb0a56053a538845a9d1735cb707637f597747e7 $")
62 #include <freeradius-devel/libradius.h>
63 #include <freeradius-devel/rad_assert.h>
109 if (dv)
return dv->
name;
131 uint16_t total_length = 0;
142 if (reply->
code < 3) {
149 reply->
packet = talloc_array(reply, uint8_t, total_length);
155 header->
code = (reply->
code & 0xFF);
156 header->
id = (reply->
id & 0xFF);
158 total_length = htons(total_length);
159 memcpy(header->
length, &total_length,
sizeof(total_length));
219 vp->vp_octets = talloc_zero_array(vp, uint8_t, vp->vp_length);
226 if (!packet->
code)
switch (reply->
code) {
242 ERROR(
"rlm_eap: reply code %d is unknown, Rejecting the request.", reply->
code);
262 DEBUG(
"Asked to encode empty EAP-Message!");
266 ptr = (uint8_t
const *) eap;
271 if (size > 253) size = 253;
318 if (first->vp_length < 4) {
327 memcpy(&len, first->vp_strvalue + 2,
sizeof(len));
344 total_len += i->vp_length;
346 if (total_len > len) {
348 "does not match actual length %i", len, total_len);
356 if (total_len < len) {
358 "match actual length");
373 ptr = (
unsigned char *)eap_packet;
378 memcpy(ptr, i->vp_strvalue, i->vp_length);
389 char const *
name, uint8_t
const *value,
int len)
395 REDEBUG(
"Did not create attribute %s: %s\n",
426 fake->
server = vp ? vp->vp_strvalue : virtual_server;
431 RDEBUG2(
"Sending tunnelled request");
439 if (eap_session->
child) {
440 RDEBUG4(
"Adding eap_session_t %p to fake request", eap_session->
child);
446 if (!eap_session->
child || (eap_session->
child != inner_eap)) {
447 RDEBUG4(
"Binding lifetime of child eap_session %p to parent eap_session %p",
448 inner_eap, eap_session);
450 eap_session->
child = inner_eap;
452 RDEBUG4(
"Got eap_session_t %p back unmolested", eap_session->
child);
462 }
else if (eap_session->
child) {
463 RDEBUG4(
"Inner server freed eap_session %p", eap_session->
child);
464 eap_session->
child = NULL;
void fr_pair_list_free(VALUE_PAIR **)
Free memory used by a valuepair list.
VALUE_PAIR * fr_cursor_first(vp_cursor_t *cursor)
Rewind cursor to the start of the list.
VALUE_PAIR * config
VALUE_PAIR (s) used to set per request parameters for modules and the server core at runtime...
RFC2865 - Access-Challenge.
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.
eap_type_t eap_name2type(char const *name)
Return an EAP-Type for a particular name.
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.
The module considers the request invalid.
eap_session_t * child
Session for tunnelled EAP method.
VALUE_PAIR * eap_packet2vp(RADIUS_PACKET *packet, eap_packet_raw_t const *eap)
fr_dict_enum_t * fr_dict_enum_by_name(fr_dict_t *dict, fr_dict_attr_t const *da, char const *val)
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
enum eap_method eap_type_t
Structure to represent packet format of eap on wire
void fr_cursor_insert(vp_cursor_t *cursor, VALUE_PAIR *vp)
Insert a single VALUE_PAIR at the end of the list.
void fr_pair_add(VALUE_PAIR **head, VALUE_PAIR *vp)
Add a VP to the end of the list.
Tracks the progress of a single session of any EAP method.
Immediately reject the request.
void eap_add_reply(REQUEST *request, char const *name, uint8_t const *value, int len)
unsigned int code
Packet code (type).
void * request_data_get(REQUEST *request, void *unique_ptr, int unique_int)
Get opaque data from a request.
Stores an attribute, a value and various bits of other data.
int eap_wireformat(eap_packet_t *reply)
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.
char const * fr_strerror(void)
Get the last library error.
void fr_pair_delete_by_num(VALUE_PAIR **head, unsigned int vendor, unsigned int attr, int8_t tag)
Delete matching pairs.
#define REQUEST_DATA_EAP_SESSION
char const * eap_type2name(eap_type_t method)
Return an EAP-name for a particular type.
eap_packet_raw_t * eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
#define pair_make_reply(_a, _b, _c)
int request_data_add(REQUEST *request, void *unique_ptr, int unique_int, void *opaque, bool free_on_replace, bool free_on_parent, bool persist)
Add opaque data to a REQUEST.
fr_dict_enum_t * fr_dict_enum_by_da(fr_dict_t *dict, fr_dict_attr_t const *da, int value)
Lookup the structure representing an enum value in a fr_dict_attr_t.
void fr_strerror_printf(char const *,...) CC_HINT(format(printf
int fr_talloc_link_ctx(TALLOC_CTX *parent, TALLOC_CTX *child)
Link a parent and a child context, so the child is freed before the parent.
rlm_rcode_t eap_virtual_server(REQUEST *request, REQUEST *fake, eap_session_t *eap_session, char const *virtual_server)
Send a fake request to a virtual server, managing the eap_session_t of the child. ...
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.
EAP eap_session data not found.
int eap_basic_compose(RADIUS_PACKET *packet, eap_packet_t *reply)
Succeeded without doing anything.
Structure to hold EAP data.
const FR_NAME_NUMBER eap_rcode_table[]
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.
int rad_virtual_server(REQUEST *)
The module handled the request, so stop.
Value of an enumerated attribute.
void fr_pair_value_memcpy(VALUE_PAIR *vp, uint8_t const *src, size_t len)
Copy data into an "octets" data type.