Changeset 1088:1d1a20a0779d in freeDiameter for extensions/app_radgw/rgwx_echodrop.c
- Timestamp:
- May 5, 2013, 4:25:27 AM (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_radgw/rgwx_echodrop.c
r996 r1088 38 38 #include "rgwx_echodrop.h" 39 39 40 struct sess_state { 41 struct fd_list sentinel; 42 }; 43 40 44 /* If a session is destroyed, empty the list of ed_saved_attribute */ 41 static void state_delete(void * arg, char * sid, void * opaque) { 42 struct fd_list * list = (struct fd_list *)arg; 43 44 CHECK_PARAMS_DO( list, return ); 45 46 while (!FD_IS_LIST_EMPTY(list)) { 47 struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(list->next); 45 static void state_delete(struct sess_state * arg, os0_t sid, void * opaque) { 46 while (!FD_IS_LIST_EMPTY(&arg->sentinel)) { 47 struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(arg->sentinel.next); 48 48 fd_list_unlink(&esa->chain); 49 49 free(esa); 50 50 } 51 free(list); 52 } 53 51 free(arg); 52 } 53 54 static DECLARE_FD_DUMP_PROTOTYPE(ed_session_state_dump, struct sess_state * st) 55 { 56 struct fd_list * li; 57 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state](@%p):\n", st), return NULL); 58 for (li = st->sentinel.next; li != &st->sentinel; li = li->next) { 59 struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(li); 60 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state {esa}] t:%2hhx l:%2hhx d:", esa->attr.type, esa->attr.length), return NULL); 61 CHECK_MALLOC_DO( fd_dump_extend_hexdump(FD_DUMP_STD_PARAMS, (&esa->attr.length) + 1, esa->attr.length - 2, 0,0), return NULL); 62 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); 63 } 64 } 54 65 55 66 /* Initialize the plugin and parse the configuration. */ … … 69 80 70 81 /* Create the session handler */ 71 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, state_delete, NULL ) );82 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, state_delete, ed_session_state_dump, NULL ) ); 72 83 73 84 /* Parse the configuration file */ … … 217 228 if (!FD_IS_LIST_EMPTY(&echo_list)) { 218 229 struct session * sess; 230 struct sess_state * st; 219 231 220 232 CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *diam_fw, &sess, NULL) ); … … 229 241 230 242 /* Move the values in a dynamically allocated list */ 231 CHECK_MALLOC( li = malloc(sizeof(struct fd_list)) );232 fd_list_init( li, NULL);233 fd_list_move_end( li, &echo_list);243 CHECK_MALLOC( st = malloc(sizeof(struct sess_state)) ); 244 fd_list_init(&st->sentinel, NULL); 245 fd_list_move_end(&st->sentinel, &echo_list); 234 246 235 247 /* Save the list in the session */ 236 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, & li) );248 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &st ) ); 237 249 } 238 250 … … 243 255 static int ed_diam_ans( struct rgwp_config * cs, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli ) 244 256 { 245 struct fd_list * list = NULL;246 257 struct session * sess; 258 struct sess_state * st; 247 259 248 260 TRACE_ENTRY("%p %p %p %p", cs, diam_ans, rad_fw, cli); … … 258 270 259 271 /* Now try and retrieve any data from the session */ 260 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, & list ) );261 if ( list == NULL) {272 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &st ) ); 273 if (st == NULL) { 262 274 /* No attribute saved in the session, just return */ 263 275 return 0; … … 268 280 CHECK_PARAMS( rad_fw && *rad_fw); 269 281 270 while (! FD_IS_LIST_EMPTY( list) ) {271 struct ed_saved_attribute * esa = (struct ed_saved_attribute *)( list->next);282 while (! FD_IS_LIST_EMPTY(&st->sentinel) ) { 283 struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(st->sentinel.next); 272 284 273 285 fd_list_unlink(&esa->chain); … … 280 292 free(esa); 281 293 } 282 free( list);294 free(st); 283 295 284 296 return 0;
Note: See TracChangeset
for help on using the changeset viewer.