*
*/
struct dict_enum_fixup_s {
+ char *filename; //!< where the "enum" was defined
+ int line; //!< ditto
char *attribute; //!< we couldn't find (and will need to resolve later).
char *alias; //!< Raw enum name.
char *value; //!< Raw enum value. We can't do anything with this until
*/
#define MAX_STACK (32)
typedef struct dict_ctx_stack_frame_t {
+ char *filename; //!< name of the file we're reading
+ int line; //!< line number of this file
fr_dict_attr_t const *da; //!< the da we care about
fr_type_t nest; //!< for manual vs automatic begin / end things
int member_num; //!< structure member numbers
ctx->stack_depth++;
memset(&ctx->stack[ctx->stack_depth], 0, sizeof(ctx->stack[ctx->stack_depth]));
+
ctx->stack[ctx->stack_depth].da = da;
+ ctx->stack[ctx->stack_depth].filename = ctx->stack[ctx->stack_depth - 1].filename;
+ ctx->stack[ctx->stack_depth].line = ctx->stack[ctx->stack_depth - 1].line;
return 0;
}
fr_strerror_printf("Out of memory");
return -1;
}
+
+ fixup->filename = talloc_strdup(fixup, ctx->stack[ctx->stack_depth].filename);
+ if (!fixup->filename) goto oom;
+ fixup->line = ctx->stack[ctx->stack_depth].line;
+
fixup->attribute = talloc_strdup(fixup, argv[0]);
if (!fixup->attribute) goto oom;
fixup->alias = talloc_strdup(fixup, argv[1]);
return -1;
}
- if (value == 0) {
+ /*
+ * 255 protocts FR_TYPE_GROUP type_size hack
+ */
+ if ((value == 0) || (value > 255)) {
fr_strerror_printf("Invalid value '%u' following PROTOCOL", value);
return -1;
}
next = this->next;
da = fr_dict_attr_by_name(ctx->dict, this->attribute);
if (!da) {
- fr_strerror_printf("No ATTRIBUTE '%s' defined for VALUE '%s'",
- this->attribute, this->alias);
+ fr_strerror_printf("No ATTRIBUTE '%s' defined for VALUE '%s' at %s[%d]",
+ this->attribute, this->alias, this->filename, this->line);
error:
return -1;
}
if (fr_value_box_from_str(this, &value, &type, NULL,
this->value, talloc_array_length(this->value) - 1, '\0', false) < 0) {
- fr_strerror_printf_push("Invalid VALUE for ATTRIBUTE \"%s\"", da->name);
+ fr_strerror_printf_push("Invalid VALUE for ATTRIBUTE \"%s\" at %s[%d]",
+ da->name, this->filename, this->line);
goto error;
}
}
}
+ ctx->stack[ctx->stack_depth].filename = fn;
+
if ((fp = fopen(fn, "r")) == NULL) {
if (!src_file) {
fr_strerror_printf_push("Couldn't open dictionary %s: %s", fr_syserror(errno), fn);
memset(&base_flags, 0, sizeof(base_flags));
while (fgets(buf, sizeof(buf), fp) != NULL) {
- line++;
+ ctx->stack[ctx->stack_depth].line = line++;
switch (buf[0]) {
case '#':
fclose(fp);
return -1;
}
+
+ /*
+ * Reset the filename.
+ */
+ ctx->stack[ctx->stack_depth].filename = fn;
continue;
} /* $INCLUDE */
ctx->dict = ctx->old_dict;
/*
- * Applies fixups to any attributes added to
- * the protocol dictionary.
+ * Applies fixups to any attributes added
+ * to the protocol dictionary. Note that
+ * the finalise function prints out the
+ * original filename / line of the
+ * error. So we don't need to do that
+ * here.
*/
- if (fr_dict_finalise(ctx) < 0) goto error;
+ if (fr_dict_finalise(ctx) < 0) {
+ fclose(fp);
+ return -1;
+ }
ctx->stack_depth--;
continue;