Module: sip-router Branch: master Commit: dd5490500f006f86e520958c5ca2646a1e3a96b7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dd549050...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Fri Jul 17 00:15:39 2009 +0200
domain: API framework to be used by other modules
Add a new data structure and function bind_domain that can be used by other modules to gain access to internal functions of domain module.
Implement inline function load_domain_api that does everything that is necessary to make the API of the domain module available to the caller.
---
modules_s/domain/domain_api.c | 35 ++++++++++++++++++++++++++ modules_s/domain/domain_api.h | 54 +++++++++++++++++++++++++++++++++++++++++ modules_s/domain/domain_mod.c | 2 + 3 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/modules_s/domain/domain_api.c b/modules_s/domain/domain_api.c new file mode 100644 index 0000000..c88e5c8 --- /dev/null +++ b/modules_s/domain/domain_api.c @@ -0,0 +1,35 @@ +/* + * Domain module internal API + * + * Copyright (C) 2002-2003 Juha Heinanen + * + * This file is part of sip-router, a free SIP server. + * + * sip-router is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version + * + * sip-router is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "domain_api.h" +#include "../../dprint.h" +#include "domain.h" + + +int bind_domain(domain_api_t* api) +{ + if (api == NULL) { + ERR("Invalid parameter value\n"); + return -1; + } + return 0; +} diff --git a/modules_s/domain/domain_api.h b/modules_s/domain/domain_api.h new file mode 100644 index 0000000..16ddd1f --- /dev/null +++ b/modules_s/domain/domain_api.h @@ -0,0 +1,54 @@ +/* + * Domain module internal API + * + * Copyright (C) 2002-2003 Juha Heinanen + * + * This file is part of sip-router, a free SIP server. + * + * sip-router is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version + * + * sip-router is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _DOMAIN_API_H +#define _DOMAIN_API_H + +#include "../../sr_module.h" +#include "../../dprint.h" + +typedef struct domain_api { + +} domain_api_t; + +typedef int (*bind_domain_f)(domain_api_t* api); +int bind_domain(domain_api_t* api); + +static inline int load_domain_api(domain_api_t* api) +{ + bind_domain_f bind_domain; + + bind_domain = (bind_domain_f)find_export("bind_domain", 0, 0); + + if (bind_domain == NULL) { + ERR("Cannot import bind_domain function from domain module\n"); + return -1; + } + + if (bind_domain(api) == -1) { + return -1; + } + return 0; +} + + +#endif /* _DOMAIN_API_H */ diff --git a/modules_s/domain/domain_mod.c b/modules_s/domain/domain_mod.c index 957973f..c7e0515 100644 --- a/modules_s/domain/domain_mod.c +++ b/modules_s/domain/domain_mod.c @@ -38,6 +38,7 @@ #include "../../parser/parse_from.h" #include "../../parser/parse_uri.h" #include "../../usr_avp.h" +#include "domain_api.h" #include "domain_rpc.h" #include "hash.h" #include "domain.h" @@ -124,6 +125,7 @@ static cmd_export_t cmds[] = { {"lookup_domain", lookup_domain, 2, lookup_domain_fixup, REQUEST_ROUTE|FAILURE_ROUTE }, {"get_did", (cmd_function)get_did, 0, 0, 0}, + {"bind_domain", (cmd_function)bind_domain, 0, 0, 0}, {0, 0, 0, 0, 0} };
Hi Jan,
On 17.07.2009 11:37 Uhr, Jan Janak wrote:
Module: sip-router Branch: master Commit: dd5490500f006f86e520958c5ca2646a1e3a96b7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dd549050...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Fri Jul 17 00:15:39 2009 +0200
domain: API framework to be used by other modules
just wondering if worth to extend core a bit so that modules can register callbacks for is_myself check. Therefore, if (uri==myself) can match entries in the domain module.
Architecturally, the core function goes like now and if no match, then executes the eventual callbacks. This way does not matter if domain is db only/cache mode or other modules do checks against other storages (radius, web app, etc).
Cheers, Daniel
On 17-07 13:15, Daniel-Constantin Mierla wrote:
Hi Jan,
On 17.07.2009 11:37 Uhr, Jan Janak wrote:
Module: sip-router Branch: master Commit: dd5490500f006f86e520958c5ca2646a1e3a96b7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dd549050...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Fri Jul 17 00:15:39 2009 +0200
domain: API framework to be used by other modules
just wondering if worth to extend core a bit so that modules can register callbacks for is_myself check. Therefore, if (uri==myself) can match entries in the domain module.
Architecturally, the core function goes like now and if no match, then executes the eventual callbacks. This way does not matter if domain is db only/cache mode or other modules do checks against other storages (radius, web app, etc).
Yes, I think this would be a good thing to do, I also thought about something like this. I was thinking about extending the data structures in the core so that the domain module can add entries from the database there.
In other words, there would be no callbacks, but the domain module would update the list of local domains in the core, instead of keeping them in its own memory. In the script we would then just call is_myself.
Your callback approach is probably more flexible because it leaves the decision whether to cache or not up to the module.
Either way, I think that integrating the core domain list with the list of domains kept in the domain module would be a good thing to do. Maybe we should document it as "to be done" somewhere in the wiki?
Jan.
On 17.07.2009 14:25 Uhr, Jan Janak wrote:
On 17-07 13:15, Daniel-Constantin Mierla wrote:
Hi Jan,
On 17.07.2009 11:37 Uhr, Jan Janak wrote:
Module: sip-router Branch: master Commit: dd5490500f006f86e520958c5ca2646a1e3a96b7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dd549050...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Fri Jul 17 00:15:39 2009 +0200
domain: API framework to be used by other modules
just wondering if worth to extend core a bit so that modules can register callbacks for is_myself check. Therefore, if (uri==myself) can match entries in the domain module.
Architecturally, the core function goes like now and if no match, then executes the eventual callbacks. This way does not matter if domain is db only/cache mode or other modules do checks against other storages (radius, web app, etc).
Yes, I think this would be a good thing to do, I also thought about something like this. I was thinking about extending the data structures in the core so that the domain module can add entries from the database there.
In other words, there would be no callbacks, but the domain module would update the list of local domains in the core, instead of keeping them in its own memory. In the script we would then just call is_myself.
Your callback approach is probably more flexible because it leaves the decision whether to cache or not up to the module.
Either way, I think that integrating the core domain list with the list of domains kept in the domain module would be a good thing to do. Maybe we should document it as "to be done" somewhere in the wiki?
yes, it is needed. I thought also about a list to be kept in core, but then there has to be a way of synchronization when doing reload -- adding/removing entries as domain or other module updates its records -- callback is easier. I think also is more flexible, e.g., if one needs to match all subdomains, can easily implement a module and register just a callback instead all subdomains.
Cheers, Daniel