Changeset 1387:d70f5f6cb306 in freeDiameter
- Timestamp:
- Oct 15, 2019, 11:25:47 PM (5 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- extensions/rt_ereg
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rt_ereg/rtereg.c
r1338 r1387 94 94 struct fd_list * c; 95 95 96 TRACE_DEBUG(ANNOYING, "Attemptpattern matching of '%.*s' with rule '%s'", (int)len, value, r->pattern);96 LOG_D("[rt_ereg] attempting pattern matching of '%.*s' with rule '%s'", (int)len, value, r->pattern); 97 97 98 98 #ifdef HAVE_REG_STARTEND … … 119 119 120 120 /* Error while compiling the regex */ 121 TRACE_DEBUG(INFO, "Error while executing the regular expression '%s':", r->pattern);121 LOG_E("[rt_ereg] error while executing the regular expression '%s':", r->pattern); 122 122 123 123 /* Get the error message size */ … … 129 129 /* Get the error message content */ 130 130 regerror(err, &r->preg, errstr, bl); 131 TRACE_DEBUG(INFO,"\t%s", errstr);131 LOG_E("\t%s", errstr); 132 132 133 133 /* Free the buffer, return the error */ … … 138 138 139 139 /* From this point, the expression matched the AVP value */ 140 TRACE_DEBUG(FULL, "[rt_ereg] Match: '%s' to value '%.*s' => '%s' += %d", 141 r->pattern, 142 (int)len, 143 value, 144 r->server, 145 r->score); 140 LOG_D("[rt_ereg] Match: '%s' to value '%.*s' => '%s' += %d", r->pattern, (int)len, value, r->server, r->score); 146 141 147 142 for (c = candidates->next; c != candidates; c = c->next) { … … 168 163 // for (i = 0; i<rtereg_conf[j].level; i++) { 169 164 if (level > rtereg_conf[conf_index].level) { 170 TRACE_DEBUG(INFO,"internal error, dug too deep");165 LOG_E("internal error, dug too deep"); 171 166 return 1; 172 167 } … … 179 174 if ((avp_hdr->avp_code == dictdata.avp_code) && (avp_hdr->avp_vendor == dictdata.avp_vendor)) { 180 175 if (level != rtereg_conf[conf_index].level - 1) { 181 TRACE_DEBUG(INFO,"[rt_ereg] found grouped AVP %d (vendor %d), digging deeper", avp_hdr->avp_code, avp_hdr->avp_vendor);176 LOG_D("[rt_ereg] found grouped AVP %d (vendor %d), digging deeper", avp_hdr->avp_code, avp_hdr->avp_vendor); 182 177 CHECK_FCT(find_avp(nextavp, conf_index, level+1, candidates)); 183 178 } else { 184 TRACE_DEBUG(INFO, "[rt_ereg] found AVP %d (vendor %d)", avp_hdr->avp_code, avp_hdr->avp_vendor); 179 struct dictionary * dict; 180 LOG_D("[rt_ereg] found AVP %d (vendor %d)", avp_hdr->avp_code, avp_hdr->avp_vendor); 181 CHECK_FCT(fd_dict_getdict(what, &dict)); 182 CHECK_FCT_DO(fd_msg_parse_dict(nextavp, dict, NULL), /* nothing */); 185 183 if (avp_hdr->avp_value != NULL) { 184 LOG_A("avp_hdr->avp_value NOT NULL, matching"); 186 185 #ifndef HAVE_REG_STARTEND 187 186 int ret; … … 224 223 int j, ret; 225 224 226 TRACE_ENTRY("%p %p %p", cbdata, *pmsg, candidates);225 LOG_A("[rt_ereg] rtereg_out arguments: %p %p %p", cbdata, *pmsg, candidates); 227 226 228 227 CHECK_PARAMS(pmsg && *pmsg && candidates); … … 239 238 for (j=0; j<rtereg_conf_size; j++) { 240 239 where = *pmsg; 241 TRACE_DEBUG(INFO,"[rt_ereg] iterating over AVP group %d", j);240 LOG_D("[rt_ereg] iterating over AVP group %d", j); 242 241 if ((ret=find_avp(where, j, 0, candidates)) != 0) { 243 242 break; … … 302 301 static int rtereg_entry(char * conffile) 303 302 { 304 TRACE_ENTRY("%p", conffile);303 LOG_A("[rt_ereg] started with conffile '%p'", conffile); 305 304 306 305 rt_ereg_config_file = conffile; 307 306 308 307 if (rtereg_init() != 0) { 309 308 return 1; 310 309 } 311 310 … … 322 321 /* Initialize the configuration */ 323 322 if ((rtereg_conf=malloc(sizeof(*rtereg_conf))) == NULL) { 324 TRACE_DEBUG(INFO, "malloc failured");325 323 LOG_E("[rt_ereg] malloc failured"); 324 return 1; 326 325 } 327 326 rtereg_conf_size = 1; … … 367 366 static void rtereg_fini(void) 368 367 { 369 TRACE_ENTRY();370 371 368 /* Unregister the cb */ 372 369 CHECK_FCT_DO( fd_rt_out_unregister ( rtereg_hdl, NULL ), /* continue */ ); 373 370 371 #ifndef HAVE_REG_STARTEND 372 free(buf); 373 buf = NULL; 374 #endif /* HAVE_REG_STARTEND */ 375 376 if (pthread_rwlock_wrlock(&rte_lock) != 0) { 377 fd_log_error("%s: write-locking failed in fini, giving up", MODULE_NAME); 378 return; 379 } 374 380 /* Destroy the data */ 375 381 rtereg_conf_free(rtereg_conf, rtereg_conf_size); 376 382 rtereg_conf = NULL; 377 383 rtereg_conf_size = 0; 378 #ifndef HAVE_REG_STARTEND 379 free(buf); 380 buf = NULL; 381 #endif /* HAVE_REG_STARTEND */ 384 385 if (pthread_rwlock_unlock(&rte_lock) != 0) { 386 fd_log_error("%s: write-unlocking failed in fini", MODULE_NAME); 387 return; 388 } 382 389 383 390 /* Done */ -
extensions/rt_ereg/rtereg_conf.l
r1127 r1387 81 81 CHECK_MALLOC_DO( yylval->string = strdup(yytext+1), 82 82 { 83 TRACE_DEBUG(INFO, "Unable to copy the string '%s': %s", yytext, strerror(errno));83 LOG_E("[rt_ereg] unable to copy the string '%s': %s", yytext, strerror(errno)); 84 84 return LEX_ERROR; /* trig an error in yacc parser */ 85 85 } ); -
extensions/rt_ereg/rtereg_conf.y
r1342 r1387 62 62 int ret; 63 63 64 TRACE_ENTRY("%p", conffile); 65 66 TRACE_DEBUG (FULL, "Parsing configuration file: %s...", conffile); 64 LOG_D("[rt_ereg] parsing configuration file '%s'", conffile); 67 65 68 66 rtereg_confin = fopen(conffile, "r"); … … 70 68 ret = errno; 71 69 fd_log_debug("Unable to open extension configuration file %s for reading: %s", conffile, strerror(ret)); 72 TRACE_DEBUG (INFO, "rt_ereg:error occurred, message logged -- configuration file.");70 LOG_E("[rt_ereg] error occurred, message logged -- configuration file."); 73 71 return ret; 74 72 } … … 80 78 81 79 if (rtereg_conf[rtereg_conf_size-1].finished == 0) { 82 TRACE_DEBUG(INFO, "rt_ereg:configuration invalid, AVP ended without OCTETSTRING AVP");80 LOG_E("[rt_ereg] configuration invalid, AVP ended without OCTETSTRING AVP"); 83 81 return EINVAL; 84 82 } 85 83 86 84 if (ret != 0) { 87 TRACE_DEBUG(INFO, "rt_ereg:unable to parse the configuration file.");85 LOG_E("[rt_ereg] unable to parse the configuration file."); 88 86 return EINVAL; 89 87 } else { … … 92 90 sum += rtereg_conf[i].rules_nb; 93 91 } 94 TRACE_DEBUG(FULL,"[rt-ereg] Added %d rules successfully.", sum);92 LOG_D("[rt-ereg] Added %d rules successfully.", sum); 95 93 } 96 94 … … 105 103 if (rtereg_conf[rtereg_conf_size-1].finished) { 106 104 if ((ret = realloc(rtereg_conf, sizeof(*rtereg_conf)*(rtereg_conf_size+1))) == NULL) { 107 TRACE_DEBUG(INFO, "rt_ereg:realloc failed");105 LOG_E("[rt_ereg] realloc failed"); 108 106 return -1; 109 107 } … … 111 109 rtereg_conf = ret; 112 110 memset(&rtereg_conf[rtereg_conf_size-1], 0, sizeof(*rtereg_conf)); 113 TRACE_DEBUG(INFO, "rt_ereg:New AVP group found starting with %s", name);111 LOG_D("[rt_ereg] New AVP group found starting with %s", name); 114 112 } 115 113 level = rtereg_conf[rtereg_conf_size-1].level + 1; 116 114 117 115 if ((ret = realloc(rtereg_conf[rtereg_conf_size-1].avps, sizeof(*rtereg_conf[rtereg_conf_size-1].avps)*level)) == NULL) { 118 TRACE_DEBUG(INFO, "rt_ereg:realloc failed");116 LOG_E("[rt_ereg] realloc failed"); 119 117 return -1; 120 118 } … … 123 121 CHECK_FCT_DO( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, name, &rtereg_conf[rtereg_conf_size-1].avps[level-1], ENOENT ), 124 122 { 125 TRACE_DEBUG(INFO, "rt_ereg:Unable to find '%s' AVP in the loaded dictionaries.", name);123 LOG_E("[rt_ereg] Unable to find '%s' AVP in the loaded dictionaries.", name); 126 124 return -1; 127 125 } ); … … 134 132 rtereg_conf[rtereg_conf_size-1].finished = 1; 135 133 } else if (data.avp_basetype != AVP_TYPE_GROUPED) { 136 TRACE_DEBUG(INFO, "rt_ereg:'%s' AVP is not an OCTETSTRING nor GROUPED AVP (%d).", name, data.avp_basetype);134 LOG_E("[rt_ereg] '%s' AVP is not an OCTETSTRING nor GROUPED AVP (%d).", name, data.avp_basetype); 137 135 return -1; 138 136 } … … 148 146 void yyerror (YYLTYPE *ploc, char * conffile, char const *s) 149 147 { 150 TRACE_DEBUG(INFO, "rt_ereg:error in configuration parsing");148 LOG_E("[rt_ereg] error in configuration parsing"); 151 149 152 150 if (ploc->first_line != ploc->last_line) … … 223 221 224 222 /* Error while compiling the regex */ 225 TRACE_DEBUG(INFO, "rt_ereg:error while compiling the regular expression '%s':", new->pattern);223 LOG_E("[rt_ereg] error while compiling the regular expression '%s':", new->pattern); 226 224 227 225 /* Get the error message size */ … … 233 231 /* Get the error message content */ 234 232 regerror(err, &new->preg, buf, bl); 235 TRACE_DEBUG(INFO,"\t%s", buf);233 LOG_E("\t%s", buf); 236 234 237 235 /* Free the buffer, return the error */
Note: See TracChangeset
for help on using the changeset viewer.