From: Arran Cudbard-Bell Date: Thu, 29 Jun 2017 16:01:41 +0000 (-0400) Subject: Allow coa/acct/auth/status to be used for type too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50ca60c30bfdd04ec7d8163fb1cd37e8eed24fa9;p=thirdparty%2Ffreeradius-server.git Allow coa/acct/auth/status to be used for type too --- diff --git a/src/modules/proto_radius/proto_radius.c b/src/modules/proto_radius/proto_radius.c index afe5ad9f614..8408a314939 100644 --- a/src/modules/proto_radius/proto_radius.c +++ b/src/modules/proto_radius/proto_radius.c @@ -90,22 +90,35 @@ static int process_parse(TALLOC_CTX *ctx, void *out, CONF_ITEM *ci, UNUSED CONF_ } /* - * Look the type up using the Packet-Type enumv + * Allow the process module to be specified by + * packet type. */ type_enum = fr_dict_enum_by_alias(NULL, da, type_str); - if (!type_enum) { - invalid_type: - cf_log_err(ci, "Invalid type \"%s\"", type_str); - return -1; - } + if (type_enum) { + code = type_enum->value->vb_uint32; + if (code >= FR_CODE_MAX) { + invalid_type: + cf_log_err(ci, "No module associated with Packet-Type = '%s'", type_str); + return -1; + } - code = type_enum->value->vb_uint32; - if (code >= FR_CODE_MAX) goto invalid_type; + name = type_lib_table[code]; + if (!name) goto invalid_type; + /* + * ...or by module name. + */ + } else { + size_t i; - name = type_lib_table[code]; - if (!name) { - cf_log_err(ci, "No module associated with Packet-Type = '%s'", type_str); - return -1; + for (i = 0; i < (sizeof(type_lib_table) / sizeof(*type_lib_table)); i++) { + name = type_lib_table[i]; + if (name && (strcmp(name, type_str) == 0)) break; + } + + if (!name) { + cf_log_err(ci, "Invalid type \"%s\"", type_str); + return -1; + } } parent_inst = cf_data_value(cf_data_find(listen_cs, dl_instance_t, "proto_radius")); @@ -275,7 +288,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf) } if (!fr_schedule_socket_add(sc, listen)) { - cf_log_perr(conf, "Failed adding socket to scheduler"); talloc_free(listen); return -1; }