فهرست منبع

domain(k): register check self function

- list of domains handled by module match now the 'myself' condition
- the module register a callback function for 'myself' checks
- port and proto are ignored since it has only domain names
Daniel-Constantin Mierla 16 سال پیش
والد
کامیت
a9f1019eea
3فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 6 0
      modules_k/domain/domain.c
  2. 2 0
      modules_k/domain/domain.h
  3. 6 0
      modules_k/domain/domain_mod.c

+ 6 - 0
modules_k/domain/domain.c

@@ -220,6 +220,12 @@ int w_is_domain_local(struct sip_msg* _msg, char* _sp, char* _s2)
     }
 }
 
+int domain_check_self(str* host, unsigned short port, unsigned short proto)
+{
+	if(is_domain_local(host)>0)
+		return 1;
+	return 0;
+}
 
 /*
  * Reload domain table to new hash table and when done, make new hash table

+ 2 - 0
modules_k/domain/domain.h

@@ -54,6 +54,8 @@ int w_is_domain_local(struct sip_msg* _msg, char* _s1, char* _s2);
 
 int is_domain_local(str* domain);
 
+int domain_check_self(str* host, unsigned short port, unsigned short proto);
+
 int domain_db_bind(const str* db_url);
 int domain_db_init(const str* db_url);
 void domain_db_close(void);

+ 6 - 0
modules_k/domain/domain_mod.c

@@ -40,6 +40,7 @@
 #include "../../mem/mem.h"
 #include "../../sr_module.h"
 #include "../../pvar.h"
+#include "../../forward.h"
 #include "../../mod_fix.h"
 #include "domain.h"
 #include "mi.h"
@@ -153,6 +154,11 @@ static int mod_init(void)
 		LM_ERR("failed to register MI commands\n");
 		return -1;
 	}
+	if(register_check_self_func(domain_check_self)<0)
+	{
+		LM_ERR("failed to register check self function\n");
+		return -1;
+	}
 
 	db_url.len = strlen(db_url.s);
 	domain_table.len = strlen(domain_table.s);