[asterisk-commits] mmichelson: branch group/pimp_my_sip r380095 - /team/group/pimp_my_sip/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jan 25 09:25:07 CST 2013
Author: mmichelson
Date: Fri Jan 25 09:25:04 2013
New Revision: 380095
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380095
Log:
Add an endpoint identifier that gets an endpoint based on the username in the From header.
Added:
team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c (with props)
Modified:
team/group/pimp_my_sip/res/Makefile
Modified: team/group/pimp_my_sip/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/Makefile?view=diff&rev=380095&r1=380094&r2=380095
==============================================================================
--- team/group/pimp_my_sip/res/Makefile (original)
+++ team/group/pimp_my_sip/res/Makefile Fri Jan 25 09:25:04 2013
@@ -96,3 +96,4 @@
res_sip_sdp_audio.o: _ASTCFLAGS+=$(PJ_CFLAGS)
res_sip_endpoint_identifier_constant.o: _ASTCFLAGS+=$(PJ_CFLAGS)
res_sip_logger.o: _ASTCFLAGS+=$(PJ_CFLAGS)
+res_sip_endpoint_identifier_user.o: _ASTCFLAGS+=$(PJ_CFLAGS)
Added: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c?view=auto&rev=380095
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c (added)
+++ team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c Fri Jan 25 09:25:04 2013
@@ -1,0 +1,75 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*** MODULEINFO
+ <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+#undef bzero
+#define bzero bzero
+#include <pjsip.h>
+
+#include "asterisk/res_sip.h"
+#include "asterisk/module.h"
+
+static int get_endpoint_name(pjsip_rx_data *rdata, char *endpoint, size_t size)
+{
+ pjsip_uri *from = rdata->msg_info.from->uri;
+ pjsip_sip_uri *sip_from;
+ if (!PJSIP_URI_SCHEME_IS_SIP(from) && !PJSIP_URI_SCHEME_IS_SIPS(from)) {
+ return -1;
+ }
+ sip_from = (pjsip_sip_uri *) pjsip_uri_get_uri(from);
+ ast_copy_pj_str(endpoint, &sip_from->user, size);
+ return 0;
+}
+
+static struct ast_sip_endpoint *constant_identify(pjsip_rx_data *rdata)
+{
+ char endpoint_name[64];
+ struct ast_sip_endpoint *endpoint;
+ if (get_endpoint_name(rdata, endpoint_name, sizeof(endpoint))) {
+ return NULL;
+ }
+ endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name);
+ return endpoint;
+}
+
+static struct ast_sip_endpoint_identifier username_identifier = {
+ .identify_endpoint = constant_identify,
+};
+
+static int load_module(void)
+{
+ ast_sip_register_endpoint_identifier(&username_identifier);
+ return AST_MODULE_LOAD_SUCCESS;
+}
+
+static int unload_module(void)
+{
+ ast_sip_unregister_endpoint_identifier(&username_identifier);
+ return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SIP username endpoint identifier",
+ .load = load_module,
+ .unload = unload_module,
+ .load_pri = AST_MODPRI_APP_DEPEND,
+ );
Propchange: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_user.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list