Module: sip-router
Branch: master
Commit: a9f1019eea67956117677bb2566106db07128c86
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a9f1019…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Aug 27 11:20:29 2009 +0300
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
---
modules_k/domain/domain.c | 6 ++++++
modules_k/domain/domain.h | 2 ++
modules_k/domain/domain_mod.c | 6 ++++++
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/modules_k/domain/domain.c b/modules_k/domain/domain.c
index 302b248..3b217c7 100644
--- a/modules_k/domain/domain.c
+++ b/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
diff --git a/modules_k/domain/domain.h b/modules_k/domain/domain.h
index 6f1d8da..34fc1ce 100644
--- a/modules_k/domain/domain.h
+++ b/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);
diff --git a/modules_k/domain/domain_mod.c b/modules_k/domain/domain_mod.c
index 431f5ab..afefee5 100644
--- a/modules_k/domain/domain_mod.c
+++ b/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);