|
@@ -31,6 +31,7 @@
|
|
|
#include "../../core/pvar.h"
|
|
|
#include "../../core/fmsg.h"
|
|
|
#include "../../core/kemi.h"
|
|
|
+#include "../../core/str_list.h"
|
|
|
#include "../../core/events.h"
|
|
|
#include "../../core/onsend.h"
|
|
|
#include "../../core/dns_cache.h"
|
|
@@ -83,6 +84,10 @@ static int mod_init(void);
|
|
|
static int child_init(int);
|
|
|
static void mod_destroy(void);
|
|
|
|
|
|
+static str_list_t *corex_dns_cache_list = NULL;
|
|
|
+
|
|
|
+static int corex_dns_cache_param_add(str *pval);
|
|
|
+
|
|
|
static int corex_sip_reply_out(sr_event_param_t *evp);
|
|
|
|
|
|
static pv_export_t mod_pvs[] = {
|
|
@@ -186,6 +191,8 @@ struct module_exports exports = {
|
|
|
*/
|
|
|
static int mod_init(void)
|
|
|
{
|
|
|
+ str_list_t *sit;
|
|
|
+
|
|
|
if(corex_init_rpc()<0)
|
|
|
{
|
|
|
LM_ERR("failed to register RPC commands\n");
|
|
@@ -204,6 +211,13 @@ static int mod_init(void)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+ for(sit = corex_dns_cache_list; sit!=NULL; sit=sit->next) {
|
|
|
+ if(corex_dns_cache_param_add(&sit->s)<0) {
|
|
|
+ LM_ERR("failed to add record: %.*s\n", sit->s.len, sit->s.s);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if((nio_intercept > 0) && (nio_intercept_init() < 0))
|
|
|
{
|
|
|
LM_ERR("failed to register network io intercept callback\n");
|
|
@@ -336,6 +350,29 @@ error:
|
|
|
}
|
|
|
|
|
|
int corex_dns_cache_param(modparam_t type, void *val)
|
|
|
+{
|
|
|
+ str_list_t *sit;
|
|
|
+
|
|
|
+ if(val==NULL || ((str*)val)->s==NULL || ((str*)val)->len==0) {
|
|
|
+ LM_ERR("invalid parameter\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ sit = (str_list_t*)pkg_mallocxz(sizeof(str_list_t));
|
|
|
+ if(sit==NULL) {
|
|
|
+ PKG_MEM_ERROR;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ sit->s = *((str*)val);
|
|
|
+ if(corex_dns_cache_list!=NULL) {
|
|
|
+ sit->next = corex_dns_cache_list;
|
|
|
+ }
|
|
|
+ corex_dns_cache_list = sit;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int corex_dns_cache_param_add(str *pval)
|
|
|
{
|
|
|
str sval;
|
|
|
param_t* params_list = NULL;
|
|
@@ -347,11 +384,11 @@ int corex_dns_cache_param(modparam_t type, void *val)
|
|
|
int dns_ttl = 0;
|
|
|
int dns_flags = 0;
|
|
|
|
|
|
- if(val==NULL) {
|
|
|
+ if(pval==NULL) {
|
|
|
LM_ERR("invalid parameter\n");
|
|
|
goto error;
|
|
|
}
|
|
|
- sval = *((str*)val);
|
|
|
+ sval = *pval;
|
|
|
if(sval.s==NULL || sval.len<=0) {
|
|
|
LM_ERR("invalid parameter value\n");
|
|
|
goto error;
|