]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow coa/acct/auth/status to be used for type too
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Jun 2017 16:01:41 +0000 (12:01 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Jun 2017 16:01:41 +0000 (12:01 -0400)
src/modules/proto_radius/proto_radius.c

index afe5ad9f614be6b8906fecee1eacad7f816a2444..8408a314939f455ba6acba779baa0513bb7e2529 100644 (file)
@@ -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;
                }