[asterisk-commits] mmichelson: branch group/pimp_my_sip r378782 - in /team/group/pimp_my_sip: in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 9 14:30:44 CST 2013
Author: mmichelson
Date: Wed Jan 9 14:30:28 2013
New Revision: 378782
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378782
Log:
Fill in auth functions a bit and stub out others so I can compile.
This now compiles! It doesn't really do anything interesting yet though.
*sad face*
Modified:
team/group/pimp_my_sip/include/asterisk/res_sip.h
team/group/pimp_my_sip/res/res_sip.c
Modified: team/group/pimp_my_sip/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip.h?view=diff&rev=378782&r1=378781&r2=378782
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip.h Wed Jan 9 14:30:28 2013
@@ -30,6 +30,7 @@
* \brief Opaque structure representing related SIP tasks
*/
struct ast_sip_work;
+struct ast_sip_endpoint;
/*!
* \brief Data used for creating authentication challenges.
@@ -108,7 +109,7 @@
* \brief Get digest authentication details
* See ast_sip_get_authentication_credentials for more details
*/
- int (*get_authentication_credentials)(struct ast_sip_endpoint *endpoint, struct sip_digest_challenge_data *challenge);
+ int (*get_authentication_credentials)(struct ast_sip_endpoint *endpoint, struct ast_sip_digest_challenge_data *challenge);
};
/*!
@@ -328,20 +329,15 @@
* \param rdata The request to potentially authenticate
* \return The result of checking authentication.
*/
-ast_sip_check_authentication(struct ast_sip_endpoint *endpoint, struct pjsip_rxdata *rdata);
-
-/*!
- * \brief Challenge an inbound SIP request with a 401
- *
- *
- * This method will send an authentication challenge based on the details
- * given in its parameter
+enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata);
+
+/*!
+ * \brief Add digest information to an authentication challenge
*
* \param challenge Details to help in constructing a WWW-Authenticate header
- * \retval 0 Success
- * \retval -1 Failure
- */
-int ast_sip_challenge_request(struct sip_digest_challenge_data *challenge);
+ * \param tdata The challenge to add the digest to
+ */
+void ast_sip_add_digest_to_challenge(struct ast_sip_digest_challenge_data *challenge, struct pjsip_tx_data *tdata);
/*!
* \brief Determine the endpoint that has sent a SIP message
@@ -392,7 +388,7 @@
* \retval 0 Success
* \retval -1 Failure
*/
-int ast_sip_add_body(struct pjsip_tx_data *tdata, const char *bodies[]);
+int ast_sip_add_body_mutipart(struct pjsip_tx_data *tdata, const char *bodies[]);
/*!
* \brief Append body data to a SIP message
Modified: team/group/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.c?view=diff&rev=378782&r1=378781&r2=378782
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.c (original)
+++ team/group/pimp_my_sip/res/res_sip.c Wed Jan 9 14:30:28 2013
@@ -17,10 +17,17 @@
*/
#include "asterisk.h"
+#undef bzero
+#define bzero bzero
#include "pjsip.h"
#include "pjlib.h"
#include "asterisk/res_sip.h"
+#include "asterisk/linkedlists.h"
+#include "asterisk/logger.h"
+#include "asterisk/lock.h"
+#include "asterisk/utils.h"
+#include "asterisk/astobj2.h"
static pjsip_endpoint *ast_pjsip_endpoint;
@@ -31,10 +38,10 @@
return -1;
}
if (pjsip_endpt_register_module(ast_pjsip_endpoint, module) != PJ_SUCCESS) {
- ast_log(LOG_ERROR, "Unable to register module %.*s\n", pj_strlen(module->name), pj_strbuf(module->name));
- return -1;
- }
- ast_debug(1, "Registered SIP service %.*s\n", pj_strlen(module->name), pj_strbuf(module->name));
+ ast_log(LOG_ERROR, "Unable to register module %.*s\n", pj_strlen(&module->name), pj_strbuf(&module->name));
+ return -1;
+ }
+ ast_debug(1, "Registered SIP service %.*s\n", pj_strlen(&module->name), pj_strbuf(&module->name));
return 0;
}
@@ -44,7 +51,7 @@
return;
}
pjsip_endpt_unregister_module(ast_pjsip_endpoint, module);
- ast_debug(1, "Unregistered SIP service %.*s\n", pj_strlen(module->name), pj_strbuf(module->name));
+ ast_debug(1, "Unregistered SIP service %.*s\n", pj_strlen(&module->name), pj_strbuf(&module->name));
}
AO2_GLOBAL_OBJ_STATIC(registered_authenticator);
@@ -96,7 +103,7 @@
}
int ast_sip_get_authentication_credentials(struct ast_sip_endpoint *endpoint,
- struct sip_digest_challenge_data *challenge)
+ struct ast_sip_digest_challenge_data *challenge)
{
RAII_VAR(struct ast_sip_authenticator *, reg, ao2_global_obj_ref(registered_authenticator), ao2_cleanup);
if (!reg) {
@@ -104,15 +111,34 @@
return -1;
}
- return reg->authenticate_request(endpoint, rdata);
+ return reg->get_authentication_credentials(endpoint, challenge);
+}
+
+static pjsip_auth_srv *challenge_data_to_auth_srv(struct ast_sip_digest_challenge_data *challenge)
+{
+ /* XXX stub. Needs to set the realm, username, and password.*/
+ return NULL;
+}
+
+void ast_sip_add_digest_to_challenge(struct ast_sip_digest_challenge_data *challenge, pjsip_tx_data *tdata)
+{
+ pjsip_auth_srv *auth_server = challenge_data_to_auth_srv(challenge);
+ /* XXX Just using NULL nonce, qop, and opaque. Change later */
+ pjsip_auth_srv_challenge(auth_server, NULL, NULL, NULL, PJ_FALSE, tdata);
+}
+
+enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
+{
+ /* XXX Stub */
+ return AST_SIP_AUTHENTICATION_SUCCESS;
}
struct endpoint_identifier_list {
struct ast_sip_endpoint_identifier *identifier;
AST_RWLIST_ENTRY(endpoint_identifier_list) list;
-}
-
-AST_RWLIST_HEAD_STATIC(endpoint_identifiers, endpoint_identifier_list);
+};
+
+static AST_RWLIST_HEAD_STATIC(endpoint_identifiers, endpoint_identifier_list);
int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
{
@@ -128,6 +154,7 @@
AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
ast_debug(1, "Registered endpoint identifier %p\n", identifier);
+ return 0;
}
void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
@@ -148,7 +175,7 @@
struct ast_sip_endpoint *ast_sip_identify_endpoint(struct pjsip_rx_data *rdata)
{
struct endpoint_identifier_list *iter;
- struct ast_sip_endpoint *endpoint;
+ struct ast_sip_endpoint *endpoint = NULL;
SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
AST_RWLIST_TRAVERSE(&endpoint_identifiers, iter, list) {
ast_assert(iter->identifier->identify_endpoint != NULL);
@@ -159,3 +186,44 @@
}
return endpoint;
}
+
+int ast_sip_add_header(struct pjsip_tx_data *tdata, const char *name, const char *value)
+{
+ /* XXX Stub */
+ return 0;
+}
+
+int ast_sip_add_body(struct pjsip_tx_data *tdata, const char *body)
+{
+ /* XXX stub */
+ return 0;
+}
+
+int ast_sip_add_body_mutipart(struct pjsip_tx_data *tdata, const char *bodies[])
+{
+ /* XXX stub */
+ return 0;
+}
+
+int ast_sip_append_body(struct pjsip_tx_data *tdata, const char *body)
+{
+ /* XXX stub */
+ return 0;
+}
+
+struct ast_sip_work *ast_sip_create_work(void)
+{
+ /* XXX stub */
+ return NULL;
+}
+
+void ast_sip_destroy_work(struct ast_sip_work *work)
+{
+ /* XXX stub */
+}
+
+int ast_sip_push_task(struct ast_sip_work *work, int (*sip_task)(void *), void *task_data)
+{
+ /* XXX stub */
+ return 0;
+}
More information about the asterisk-commits
mailing list