}
/*
- * 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"));
}
if (!fr_schedule_socket_add(sc, listen)) {
- cf_log_perr(conf, "Failed adding socket to scheduler");
talloc_free(listen);
return -1;
}