void pairlist_free(PAIR_LIST **);
/* auth.c */
-char *auth_name(char *buf, size_t buflen, REQUEST *request, bool do_cli);
rlm_rcode_t rad_authenticate (REQUEST *);
rlm_rcode_t rad_postauth(REQUEST *);
rlm_rcode_t rad_virtual_server(REQUEST *);
#include <ctype.h>
-/*
- * Return a short string showing the terminal server, port
- * and calling station ID.
- */
-char *auth_name(char *buf, size_t buflen, REQUEST *request, bool do_cli)
-{
- VALUE_PAIR *cli;
- VALUE_PAIR *pair;
- uint32_t port = 0; /* RFC 2865 NAS-Port is 4 bytes */
- char const *tls = "";
-
- if ((cli = fr_pair_find_by_num(request->packet->vps, 0, FR_CALLING_STATION_ID, TAG_ANY)) == NULL) {
- do_cli = false;
- }
-
- if ((pair = fr_pair_find_by_num(request->packet->vps, 0, FR_NAS_PORT, TAG_ANY)) != NULL) {
- port = pair->vp_uint32;
- }
-
- if (request->packet->dst_port == 0) {
- tls = " via proxy to virtual server";
- }
-
- snprintf(buf, buflen, "from client %.128s port %u%s%.128s%s",
- request->client->shortname, port,
- (do_cli ? " cli " : ""), (do_cli ? cli->vp_strvalue : ""),
- tls);
-
- return buf;
-}
-
/*
* Check password.
*
rcode = rad_authenticate(request);
if (request->reply->code == FR_CODE_ACCESS_REJECT) {
- fr_pair_delete_by_num(&request->control, 0, FR_POST_AUTH_TYPE, TAG_ANY);
+ fr_pair_delete_by_child_num(&request->control, fr_dict_root(fr_dict_internal), FR_POST_AUTH_TYPE, TAG_ANY);
- MEM(vp = fr_pair_afrom_num(request, 0, FR_POST_AUTH_TYPE));
+ MEM(vp = fr_pair_afrom_child_num(request, fr_dict_root(fr_dict_internal), FR_POST_AUTH_TYPE));
fr_pair_value_from_str(vp, "Reject", -1);
fr_pair_add(&request->control, vp);
fr_pair_add(&request->reply->vps, vp); \
} while (0)
+static fr_dict_attr_t const *freeradius_vendor_root;
+
static void request_stats_addvp(REQUEST *request,
fr_stats2vp *table, fr_stats_t *stats)
{
proto_radius_t *inst = talloc_get_type_abort(instance, proto_radius_t);
size_t i;
- fr_dict_attr_t const *da;
CONF_PAIR *cp = NULL;
CONF_ITEM *ci = NULL;
CONF_SECTION *server = cf_item_to_section(cf_parent(conf));
- /*
- * Needed to populate the code array
- */
- da = fr_dict_attr_by_name(NULL, "Packet-Type");
- if (!da) {
- ERROR("Missing definition for Packet-Type");
- return -1;
- }
-
/*
* Compile each "send/recv + RADIUS packet type" section.
* This is so that the submodules don't need to do this.
* Check that the packet type is known.
*/
packet_type = cf_section_name2(subcs);
- dv = fr_dict_enum_by_alias(da, packet_type, -1);
+ dv = fr_dict_enum_by_alias(attr_packet_type, packet_type, -1);
if (!dv || (dv->value->vb_uint32 > FR_CODE_DO_NOT_RESPOND) ||
!code2component[dv->value->vb_uint32]) {
cf_log_err(subcs, "Invalid RADIUS packet type in '%s %s {...}'", name, packet_type);
{ NULL }
};
+static fr_dict_attr_t const *attr_calling_station_id;
static fr_dict_attr_t const *attr_auth_type;
static fr_dict_attr_t const *attr_module_failure_message;
static fr_dict_attr_t const *attr_module_success_message;
static fr_dict_attr_t const *attr_state;
static fr_dict_attr_t const *attr_user_name;
static fr_dict_attr_t const *attr_user_password;
+static fr_dict_attr_t const *attr_nas_port;
extern fr_dict_attr_autoload_t proto_radius_auth_dict_attr[];
fr_dict_attr_autoload_t proto_radius_auth_dict_attr[] = {
{ .out = &attr_module_failure_message, .name = "Module-Failure-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_module_success_message, .name = "Module-Success-Message", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
+
+ { .out = &attr_calling_station_id, .name = "Calling-Station-Id", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ .out = &attr_chap_password, .name = "CHAP-Password", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_service_type, .name = "Service-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
{ .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
+ { .out = &attr_nas_port, .name = "NAS-Port", .type = FR_TYPE_UINT32, .dict = &dict_radius },
+
{ NULL }
};
+/*
+ * Return a short string showing the terminal server, port
+ * and calling station ID.
+ */
+static char *auth_name(char *buf, size_t buflen, REQUEST *request, bool do_cli)
+{
+ VALUE_PAIR *cli;
+ VALUE_PAIR *pair;
+ uint32_t port = 0; /* RFC 2865 NAS-Port is 4 bytes */
+ char const *tls = "";
+
+ cli = fr_pair_find_by_da(request->packet->vps, attr_calling_station_id, TAG_ANY);
+ if (!cli) do_cli = false;
+
+ pair = fr_pair_find_by_da(request->packet->vps, attr_nas_port, TAG_ANY);
+ if (pair != NULL) port = pair->vp_uint32;
+
+ if (request->packet->dst_port == 0) tls = " via proxy to virtual server";
+
+ snprintf(buf, buflen, "from client %.128s port %u%s%.128s%s",
+ request->client->shortname, port,
+ (do_cli ? " cli " : ""), (do_cli ? cli->vp_strvalue : ""),
+ tls);
+
+ return buf;
+}
+
/*
* Make sure user/pass are clean and then create an attribute
* which contains the log message.