[asterisk-commits] kharwell: branch kharwell/pimp_sip_security r390357 - /team/kharwell/pimp_sip...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jun 3 11:19:16 CDT 2013
Author: kharwell
Date: Mon Jun 3 11:19:14 2013
New Revision: 390357
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390357
Log:
initialized fake auth & endpoint at load time
Modified:
team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c
Modified: team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c?view=diff&rev=390357&r1=390356&r2=390357
==============================================================================
--- team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c (original)
+++ team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c Mon Jun 3 11:19:14 2013
@@ -127,45 +127,49 @@
static struct ast_sip_auth *artificial_auth = NULL;
-struct ast_sip_auth *ast_sip_get_artificial_auth(void)
-{
- if (artificial_auth) {
- ao2_ref(artificial_auth, +1);
- return artificial_auth;
- }
-
+static void create_artificial_auth(void)
+{
if (!(artificial_auth = ast_sorcery_alloc(
ast_sip_get_sorcery(), SIP_SORCERY_AUTH_TYPE, "artificial"))) {
ast_log(LOG_ERROR, "Unable to create artificial auth\n");
- return NULL;
- }
-
+ return;
+ }
+
+ ao2_ref(artificial_auth, +1);
ast_string_field_set(artificial_auth, realm, "asterisk");
ast_string_field_set(artificial_auth, auth_user, "");
ast_string_field_set(artificial_auth, auth_pass, "");
artificial_auth->type = AST_SIP_AUTH_TYPE_ARTIFICIAL;
-
- ao2_ref(artificial_auth, +1);
+}
+
+struct ast_sip_auth *ast_sip_get_artificial_auth(void)
+{
+ if (artificial_auth) {
+ ao2_ref(artificial_auth, +1);
+ }
+
return artificial_auth;
}
static struct ast_sip_endpoint *artificial_endpoint = NULL;
+
+static void create_artificial_endpoint(void)
+{
+ if (!(artificial_endpoint = ast_sorcery_alloc(
+ ast_sip_get_sorcery(), "endpoint", NULL))) {
+ return;
+ }
+
+ ao2_ref(artificial_endpoint, +1);
+ artificial_endpoint->num_inbound_auths = 1;
+}
struct ast_sip_endpoint *ast_sip_get_artificial_endpoint(void)
{
if (artificial_endpoint) {
ao2_ref(artificial_endpoint, +1);
- return artificial_endpoint;
- }
-
- if (!(artificial_endpoint = ast_sorcery_alloc(
- ast_sip_get_sorcery(), "endpoint", NULL))) {
- return NULL;
- }
-
- artificial_endpoint->num_inbound_auths = 1;
-
- ao2_ref(artificial_endpoint, +1);
+ }
+
return artificial_endpoint;
}
@@ -302,15 +306,19 @@
if (ast_sip_register_service(&auth_mod)) {
return -1;
}
+
+ create_artificial_endpoint();
+ create_artificial_auth();
+
return 0;
}
void ast_sip_finalize_distributor(void)
{
+ ao2_cleanup(artificial_auth);
+ ao2_cleanup(artificial_endpoint);
+
ast_sip_unregister_service(&distributor_mod);
ast_sip_unregister_service(&endpoint_mod);
ast_sip_unregister_service(&auth_mod);
-
- ao2_cleanup(artificial_auth);
- ao2_cleanup(artificial_endpoint);
-}
+}
More information about the asterisk-commits
mailing list