/** Release memory used by a map linked list. * * @param map Head of the map linked list. */ void radius_mapfree(VALUE_PAIR_MAP **map) { VALUE_PAIR_MAP *next, *vpm; if (!map) return; vpm = *map; while (vpm != NULL) { next = vpm->next; radius_tmplfree(&((*map)->dst)); radius_tmplfree(&((*map)->src)); free(vpm); vpm = next; } *map = NULL; }
/** Release memory used by a map linked list. * * @param map Head of the map linked list. */ void radius_mapfree(value_pair_map_t **map) { value_pair_map_t *next, *vpm; if (!map) return; vpm = *map; while (vpm != NULL) { next = vpm->next; radius_tmplfree(&((*map)->dst)); radius_tmplfree(&((*map)->src)); free(vpm); vpm = next; } *map = NULL; }
/** Parse qualifiers to convert attrname into a value_pair_tmpl_t. * * VPTs are used in various places where we need to pre-parse configuration * sections into attribute mappings. * * @param[in] name attribute name including qualifiers. * @param[in] request_def The default request to insert unqualified * attributes into. * @param[in] list_def The default list to insert unqualified attributes into. * @return pointer to a value_pair_tmpl_t struct (must be freed with * radius_tmplfree) or NULL on error. */ value_pair_tmpl_t *radius_attr2tmpl(const char *name, request_refs_t request_def, pair_lists_t list_def) { value_pair_tmpl_t *vpt; const char *copy = strdup(name); vpt = rad_calloc(sizeof(value_pair_tmpl_t)); if (radius_parse_attr(copy, vpt, request_def, list_def) < 0) { radius_tmplfree(&vpt); return NULL; } return vpt; }
/** Parse qualifiers to convert attrname into a value_pair_tmpl_t. * * VPTs are used in various places where we need to pre-parse configuration * sections into attribute mappings. * * @param[in] ctx for talloc * @param[in] name attribute name including qualifiers. * @param[in] request_def The default request to insert unqualified * attributes into. * @param[in] list_def The default list to insert unqualified attributes into. * @return pointer to a value_pair_tmpl_t struct (must be freed with * radius_tmplfree) or NULL on error. */ value_pair_tmpl_t *radius_attr2tmpl(TALLOC_CTX *ctx, char const *name, request_refs_t request_def, pair_lists_t list_def) { value_pair_tmpl_t *vpt; char const *copy; vpt = talloc(ctx, value_pair_tmpl_t); /* parse_attr zeroes it */ copy = talloc_strdup(vpt, name); if (radius_parse_attr(copy, vpt, request_def, list_def) < 0) { radius_tmplfree(&vpt); return NULL; } return vpt; }
/** Parse qualifiers to convert attrname into a VALUE_PAIR_TMPL. * * VPTs are used in various places where we need to pre-parse configuration * sections into attribute mappings. * * @param[in] name attribute name including qualifiers. * @param[in] request_def The default request to insert unqualified * attributes into. * @param[in] list_def The default list to insert unqualified attributes into. * @return pointer to a VALUE_PAIR_TMPL struct (must be freed with * radius_tmplfree) or NULL on error. */ VALUE_PAIR_TMPL *radius_attr2tmpl(const char *name, request_refs_t request_def, pair_lists_t list_def) { VALUE_PAIR_TMPL *vpt; const char *copy = strdup(name); vpt = rad_malloc(sizeof(VALUE_PAIR_TMPL)); memset(vpt, 0, sizeof(VALUE_PAIR_TMPL)); if (radius_parse_attr(copy, vpt, request_def, list_def) < 0) { radius_tmplfree(&vpt); return NULL; } return vpt; }