Changeset 256:042af0000c0a in freeDiameter for extensions/app_radgw/rgw_plugins.c
- Timestamp:
- Apr 16, 2010, 4:57:39 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_radgw/rgw_plugins.c
r255 r256 54 54 unsigned char *cc; /* array of command codes, or NULL for all cc */ 55 55 size_t cc_len; /* size of the previous array */ 56 57 char *plgname; /* basename of the plugin, for debug messages. To be freed when object is detroyed */58 char *conffile; /* configuration file passed to the extension, or "(null)". To be freed when object is destroyed */59 56 }; 60 57 … … 177 174 struct plg_descr * new; 178 175 int ret = 0; 179 char * tmp;180 176 181 177 TRACE_ENTRY("%p %p %d %p %zi", plgfile, conffile, type, codes_array, codes_sz); 182 178 183 179 CHECK_PARAMS( plgfile && type && codes_array && (cache_started == 0) ); 184 185 CHECK_MALLOC( tmp = strdup(plgfile) );186 180 187 181 CHECK_MALLOC( new = malloc(sizeof(struct plg_descr)) ); … … 189 183 190 184 fd_list_init(&new->chain, new); 191 192 /* Copy names, for debug */193 CHECK_MALLOC( new->plgname = strdup(basename(tmp)) ); /* basename is a stupid function :( */194 free(tmp);195 CHECK_MALLOC( new->conffile = conffile ?: strdup("(null)") );196 185 197 186 /* Try and load the plugin */ … … 212 201 } 213 202 214 /* Now parse the configuration file, this will initialize all extension states and store it in the returned pointer (the subextensions must be re-entrant) */ 203 TRACE_DEBUG(FULL, "Plugin '%s' found in file '%s'", new->descriptor->rgwp_name, plgfile); 204 205 /* Now parse the configuration file, this will initialize all plugin states and store it in the "cs" pointer (the plugin must be re-entrant, so no global state) */ 215 206 if (new->descriptor->rgwp_conf_parse) { 216 TRACE_DEBUG(FULL, "Parsing plugin conf file: %s", new->conffile ); 217 new->cs = (*(new->descriptor->rgwp_conf_parse))(conffile); 218 if (new->cs == NULL) { 219 fd_log_debug("An error occurred while parsing configuration file '%s' in plugin '%s', aborting...\n", new->conffile, new->plgname); 220 goto error; 221 } 222 TRACE_DEBUG(INFO, "RADIUS/Diameter gateway plugin '%s%s%s%s' initialized.", new->plgname, conffile ? " (" : "", conffile ? new->conffile : "", conffile ? ")" : ""); 207 CHECK_FCT_DO( (*(new->descriptor->rgwp_conf_parse))(conffile, &new->cs), 208 { 209 fd_log_debug("An error occurred while parsing configuration file '%s' in plugin '%s', aborting...\n", conffile, plgfile); 210 goto error; 211 } ); 223 212 } 224 213 … … 283 272 plg = (struct plg_descr *)ptr; 284 273 285 fd_log_debug(" %-25s ( % -25s) - types: %s%s, codes: ",286 plg-> plgname,287 basename(plg->conffile),274 fd_log_debug(" %-25s ( %p ) - types: %s%s, codes: ", 275 plg->descriptor->rgwp_name, 276 plg->cs, 288 277 plg->type & RGW_PLG_TYPE_AUTH ? "Au" : " ", 289 278 plg->type & RGW_PLG_TYPE_ACCT ? "Ac" : " "); … … 317 306 for (ptr = accel->plugins.next; ptr != &accel->plugins; ptr = ptr->next) { 318 307 struct plg_accel_item * item = (struct plg_accel_item *)ptr; 319 fd_log_debug(" %-15s (% s)\n", item->plg->plgname, basename(item->plg->conffile));308 fd_log_debug(" %-15s (%p)\n", item->plg->descriptor->rgwp_name, item->plg->cs); 320 309 } 321 310 } … … 326 315 for (ptr = accel->plugins.next; ptr != &accel->plugins; ptr = ptr->next) { 327 316 struct plg_accel_item * item = (struct plg_accel_item *)ptr; 328 fd_log_debug(" %-15s (% s)\n", item->plg->plgname, basename(item->plg->conffile));317 fd_log_debug(" %-15s (%p)\n", item->plg->descriptor->rgwp_name, item->plg->cs); 329 318 } 330 319 } … … 359 348 360 349 if (plg->descriptor->rgwp_rad_req) { 361 TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg-> plgname);350 TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg->descriptor->rgwp_name); 362 351 ret = (*plg->descriptor->rgwp_rad_req)(plg->cs, *session, &(*rad)->radius, &rad_ans, diam_msg, cli); 363 352 if (ret) 364 353 break; 365 354 } else { 366 TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg-> plgname);355 TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg->descriptor->rgwp_name); 367 356 } 368 357 } … … 420 409 421 410 if (plg->descriptor->rgwp_diam_ans) { 422 TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg-> plgname);411 TRACE_DEBUG(ANNOYING, "Calling next plugin: %s", plg->descriptor->rgwp_name); 423 412 ret = (*plg->descriptor->rgwp_diam_ans)(plg->cs, session, diam_ans, rad_ans, (void *)cli); 424 413 if (ret) 425 414 break; 426 415 } else { 427 TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg-> plgname);416 TRACE_DEBUG(ANNOYING, "Skipping extension '%s' (NULL callback)", plg->descriptor->rgwp_name); 428 417 } 429 418 } … … 493 482 struct plg_descr * plg = (struct plg_descr *) plg_list.next; 494 483 fd_list_unlink(&plg->chain); 495 free(plg->conffile);496 484 free(plg->cc); 497 if (plg-> cs && plg->descriptor && plg->descriptor->rgwp_conf_free ) {498 TRACE_DEBUG(INFO, "RADIUS/Diameter gateway plugin '%s' cleaning up...", plg-> plgname);485 if (plg->descriptor && plg->descriptor->rgwp_conf_free ) { 486 TRACE_DEBUG(INFO, "RADIUS/Diameter gateway plugin '%s' cleaning up...", plg->descriptor->rgwp_name); 499 487 (*plg->descriptor->rgwp_conf_free)(plg->cs); 500 488 } 501 free(plg->plgname);502 dlclose(plg->dlo);489 if (plg->dlo) 490 dlclose(plg->dlo); 503 491 free(plg); 504 492 }
Note: See TracChangeset
for help on using the changeset viewer.