*/
typedef ssize_t(*fr_dict_attr_encode_func_t)(fr_dbuff_t *dbuff, fr_pair_list_t const *vps);
+/** Init / free callbacks
+ *
+ * Only for "autoref" usage.
+ */
+typedef int (*fr_dict_protocol_init_t)(void);
+typedef void (*fr_dict_protocol_free_t)(void);
+
+
/** Protocol-specific callbacks in libfreeradius-PROTOCOL
*
*/
fr_table_num_ordered_t const *subtype_table; //!< for "encrypt=1", etc.
size_t subtype_table_len; //!< length of subtype_table
fr_dict_attr_valid_func_t attr_valid; //!< validation function for new attributes
+
+ fr_dict_protocol_init_t init; //!< initialize the library
+ fr_dict_protocol_free_t free; //!< free the library
+
fr_dict_attr_decode_func_t decode; //!< for decoding attributes
fr_dict_attr_encode_func_t encode; //!< for encoding attributes
} fr_dict_protocol_t;
return NULL;
}
+ if (dict->proto->init && (dict->proto->init() < 0)) return -1;
+
/*
* The reference is to the root of the foreign protocol, we're done.
*/
* else, try to resolve the attribute.
*/
name += slen + 1;
+
+ if (!*name) {
+ /*
+ * The reference is to the root of the foreign protocol, we're done.
+ */
+ *dict_def = dict;
+ return dict->root;
+ }
}
/*
}
for (i = 0; i < talloc_array_length(refd_list); i++) {
+ if (refd_list[i]->proto->free) refd_list[i]->proto->free();
+
if (fr_dict_free(&refd_list[i], dict->root->name) < 0) {
fr_strerror_printf("failed freeing autoloaded protocol %s", refd_list[i]->root->name);
return -1;
.subtype_table = subtype_table,
.subtype_table_len = NUM_ELEMENTS(subtype_table),
.attr_valid = attr_valid,
+
+ .init = fr_dhcpv4_global_init,
+ .free = fr_dhcpv4_global_free,
+
.encode = fr_dhcpv4_encode_foreign,
.decode = fr_dhcpv4_decode_foreign,
};
fr_dcursor_t cursor;
fr_dbuff_t work_dbuff = FR_DBUFF(dbuff);
- (void) fr_dhcpv4_global_init();
-
fr_assert(dict_dhcpv4 != NULL);
fr_pair_dcursor_iter_init(&cursor, list, fr_dhcpv4_next_encodable, dict_dhcpv4);
.subtype_table = subtype_table,
.subtype_table_len = NUM_ELEMENTS(subtype_table),
.attr_valid = attr_valid,
+
+ .init = fr_radius_init,
+ .free = fr_radius_free,
+
.decode = fr_radius_decode_foreign,
.encode = fr_radius_encode_foreign,
};