On 9 Sep 2015, at 06:34, Richard Levenberg <richardl@ufp.com> wrote:
I have been looking at source code to try and figure out how to use session-state programmatically from a module. I see that src/main/radiusd.c allocates a state using fr_state_init but I don't see how to get at that?
I see in the REQUEST there is a VALUE_PAIR that is a *state, but the session-state stuff looks like its from src/main/state.c and I would be looking for a state_entry_t or a state_t.
So are there any examples of using session-state programmatically?
The Session-State list is identical to any other VALUE_PAIR list, it's just managed by the server core, and is transferred between requests linked by the 'State' RADIUS attribute. You don't need to know about how it works to use it, just modify its contents during the lifetime of the request and the changes will be present in the next REQUEST * in the sequence. -Arran VALUE_PAIR *vp; vp_cursor_t cursor; for (vp = fr_cursor_init(&cursor, &request->state); vp; vp = fr_cursor_next(&cursor)) { <do stuff> } VALUE_PAIR *vp; vp_cursor_t cursor; MEM(vp = fr_pair_afrom_num(request, <attr num>, 0)); if (fr_pair_value_from_str(vp, "my_first_value", sizeof("my_first_value") - 1) < 0) { ERROR("Failed creating attribute value"); talloc_free(vp); return; } fr_cursor_init(&cursor, &request->state) fr_cursor_insert(&cursor, vp); See http://doc.freeradius.org for descriptions of the functions. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2