{ NULL , -1 }
};
+static fr_dict_t *dict_freeradius;
+static fr_dict_t *dict_radius;
+
+extern fr_dict_autoload_t radsniff_dict[];
+fr_dict_autoload_t radsniff_dict[] = {
+ { .out = &dict_freeradius, .proto = "freeradius" },
+ { .out = &dict_freeradius, .proto = "radius" },
+ { NULL }
+};
+
+static fr_dict_attr_t const *attr_packet_type;
+
+extern fr_dict_attr_autoload_t radsniff_dict_attr[];
+fr_dict_attr_autoload_t radsniff_dict_attr[] = {
+ { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
+ { NULL }
+};
+
static void NEVER_RETURNS usage(int status);
/** Fork and kill the parent process, writing out our PID
return -1;
}
- da = fr_dict_attr_by_name(NULL, tok);
+ da = fr_dict_attr_by_name(dict_radius, tok);
+ if (!da) da = fr_dict_attr_by_name(dict_freeradius, tok);
if (!da) {
ERROR("Error parsing attribute name \"%s\"", tok);
return -1;
int opt;
char const *raddb_dir = RADDBDIR;
char const *dict_dir = DICTDIR;
- fr_dict_t *dict = NULL;
rs_stats_t *stats;
exit(EXIT_FAILURE);
}
- if (fr_dict_from_file(&dict, FR_DICTIONARY_FILE) < 0) {
+ if (fr_dict_autoload(radsniff_dict) < 0) {
+ fr_perror("radsniff");
+ ret = 64;
+ goto finish;
+ }
+
+ if (fr_dict_attr_autoload(radsniff_dict_attr) < 0) {
fr_perror("radsniff");
ret = 64;
goto finish;
}
- if (fr_dict_read(dict, raddb_dir, FR_DICTIONARY_FILE) == -1) {
- fr_log_perror(&default_log, L_ERR, "Failed to initialize the dictionaries");
+ if (fr_dict_read(dict_freeradius, raddb_dir, FR_DICTIONARY_FILE) == -1) {
+ fr_perror("radsniff");
ret = 64;
goto finish;
}
}
fr_pair_cursor_init(&cursor, &conf->filter_request_vps);
- type = fr_pair_cursor_next_by_num(&cursor, 0, FR_PACKET_TYPE, TAG_ANY);
+ type = fr_pair_cursor_next_by_da(&cursor, attr_packet_type, TAG_ANY);
if (type) {
fr_pair_cursor_remove(&cursor);
conf->filter_request_code = type->vp_uint32;
}
fr_pair_cursor_init(&cursor, &conf->filter_response_vps);
- type = fr_pair_cursor_next_by_num(&cursor, 0, FR_PACKET_TYPE, TAG_ANY);
+ type = fr_pair_cursor_next_by_da(&cursor, attr_packet_type, TAG_ANY);
if (type) {
fr_pair_cursor_remove(&cursor);
conf->filter_response_code = type->vp_uint32;
if (conf->daemonize) unlink(conf->pidfile);
+ fr_dict_autofree(radsniff_dict);
+
/*
* Free all the things! This also closes all the sockets and file descriptors
*/