[asterisk-commits] kmoore: branch kmoore/pimp_sip_srtp r386433 - in /team/kmoore/pimp_sip_srtp: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 24 14:05:06 CDT 2013


Author: kmoore
Date: Wed Apr 24 14:05:01 2013
New Revision: 386433

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386433
Log:
Multiple revisions 386232,386266,386289,386352,386375

........
  r386232 | dlee | 2013-04-22 09:58:53 -0500 (Mon, 22 Apr 2013) | 20 lines
  
  This patch adds a RESTful HTTP interface to Asterisk.
  
  The API itself is documented using Swagger, a lightweight mechanism for
  documenting RESTful API's using JSON. This allows us to use swagger-ui
  to provide executable documentation for the API, generate client
  bindings in different languages, and generate a lot of the boilerplate
  code for implementing the RESTful bindings. The API docs live in the
  rest-api/ directory.
  
  The RESTful bindings are generated from the Swagger API docs using a set
  of Mustache templates.  The code generator is written in Python, and
  uses Pystache. Pystache has no dependencies, and be installed easily
  using pip. Code generation code lives in rest-api-templates/.
  
  The generated code reduces a lot of boilerplate when it comes to
  handling HTTP requests. It also helps us have greater consistency in the
  REST API.
  
  (closes issue ASTERISK-20891)
  Review: https://reviewboard.asterisk.org/r/2376/
........
  r386266 | lathama | 2013-04-22 11:22:00 -0500 (Mon, 22 Apr 2013) | 6 lines
  
  Doxygen - Markup Guidelines
  
  Expand on a commit by OEJ to use the Coding-Guidelines
  
  (issue ASTERISK-20259)
........
  r386289 | rmudgett | 2013-04-22 11:44:21 -0500 (Mon, 22 Apr 2013) | 20 lines
  
  Fix crash when AMI redirect action redirects two channels out of a bridge.
  
  The two party bridging loops were changing the bridge peer pointers
  without the channel locks held.  Thus when ast_channel_massquerade()
  tested and used the pointer there is a small window of opportunity for the
  pointers to become NULL even though the masquerade code has the channels
  locked.
  
  (closes issue ASTERISK-21356)
  Reported by: William luke
  Patches:
        jira_asterisk_21356_v11.patch (license #5621) patch uploaded by rmudgett
  Tested by: William luke
  ........
  
  Merged revisions 386256 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 386286 from http://svn.asterisk.org/svn/asterisk/branches/11
........
  r386352 | kmoore | 2013-04-23 13:57:00 -0500 (Tue, 23 Apr 2013) | 4 lines
  
  Fix some bad whitespace
  
  This crept in with the RESTful HTTP interface merge.
........
  r386375 | rmudgett | 2013-04-23 15:18:44 -0500 (Tue, 23 Apr 2013) | 9 lines
  
  confbridge: Make search the conference bridges container using OBJ_KEY.
  
  * Make confbridge config parsing user profile, bridge profile, and menu
  container hash/cmp functions correctly check the OBJ_POINTER, OBJ_KEY, and
  OBJ_PARTIAL_KEY flags.
  
  * Made confbridge load_module()/unload_module() free all resources on
  failure conditions.
........

Merged revisions 386232,386266,386289,386352,386375 from http://svn.asterisk.org/svn/asterisk/trunk

Added:
    team/kmoore/pimp_sip_srtp/configs/stasis_http.conf.sample
      - copied unchanged from r386375, trunk/configs/stasis_http.conf.sample
    team/kmoore/pimp_sip_srtp/include/asterisk/stasis_http.h
      - copied unchanged from r386375, trunk/include/asterisk/stasis_http.h
    team/kmoore/pimp_sip_srtp/res/res_stasis_http.c
      - copied unchanged from r386375, trunk/res/res_stasis_http.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http.exports.in
      - copied unchanged from r386375, trunk/res/res_stasis_http.exports.in
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_asterisk.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_asterisk.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_bridges.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_bridges.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_channels.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_channels.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_endpoints.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_endpoints.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_events.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_events.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_playback.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_playback.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_recordings.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_recordings.c
    team/kmoore/pimp_sip_srtp/res/res_stasis_http_sounds.c
      - copied unchanged from r386375, trunk/res/res_stasis_http_sounds.c
    team/kmoore/pimp_sip_srtp/res/stasis_http/   (props changed)
      - copied from r386375, trunk/res/stasis_http/
    team/kmoore/pimp_sip_srtp/res/stasis_http.make
      - copied unchanged from r386375, trunk/res/stasis_http.make
    team/kmoore/pimp_sip_srtp/rest-api/
      - copied from r386375, trunk/rest-api/
    team/kmoore/pimp_sip_srtp/rest-api-templates/   (props changed)
      - copied from r386375, trunk/rest-api-templates/
    team/kmoore/pimp_sip_srtp/tests/test_stasis_http.c
      - copied unchanged from r386375, trunk/tests/test_stasis_http.c
Modified:
    team/kmoore/pimp_sip_srtp/   (props changed)
    team/kmoore/pimp_sip_srtp/Makefile
    team/kmoore/pimp_sip_srtp/apps/app_confbridge.c
    team/kmoore/pimp_sip_srtp/apps/confbridge/conf_config_parser.c
    team/kmoore/pimp_sip_srtp/include/asterisk/http.h
    team/kmoore/pimp_sip_srtp/include/asterisk/json.h
    team/kmoore/pimp_sip_srtp/include/asterisk/srv.h
    team/kmoore/pimp_sip_srtp/include/asterisk/stasis_app.h
    team/kmoore/pimp_sip_srtp/include/asterisk/strings.h
    team/kmoore/pimp_sip_srtp/main/channel.c
    team/kmoore/pimp_sip_srtp/main/http.c
    team/kmoore/pimp_sip_srtp/main/json.c
    team/kmoore/pimp_sip_srtp/res/Makefile
    team/kmoore/pimp_sip_srtp/res/res_stasis.c
    team/kmoore/pimp_sip_srtp/tests/test_stasis.c
    team/kmoore/pimp_sip_srtp/tests/test_strings.c

Propchange: team/kmoore/pimp_sip_srtp/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/kmoore/pimp_sip_srtp/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Apr 24 14:05:01 2013
@@ -1,1 +1,1 @@
-/trunk:1-386218
+/trunk:1-386431

Modified: team/kmoore/pimp_sip_srtp/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/Makefile?view=diff&rev=386433&r1=386432&r2=386433
==============================================================================
--- team/kmoore/pimp_sip_srtp/Makefile (original)
+++ team/kmoore/pimp_sip_srtp/Makefile Wed Apr 24 14:05:01 2013
@@ -453,6 +453,9 @@
 		$(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
 	done
 	$(MAKE) -C sounds install
+	find rest-api -name "*.json" | while read x; do \
+		$(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
+	done
 
 ifneq ($(GREP),)
   XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
@@ -537,8 +540,8 @@
 	"$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
 	"$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
 	"$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
-	"$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/static-http" "$(ASTDATADIR)/sounds" \
-	"$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
+	"$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/rest-api" "$(ASTDATADIR)/static-http" \
+	"$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
 
 installdirs:
 	@for i in $(INSTALLDIRS); do \
@@ -958,6 +961,19 @@
 	@cat sounds/sounds.xml >> $@
 	@echo "</menu>" >> $@
 
+# We don't want to require Python or Pystache for every build, so this is its
+# own target.
+stasis-stubs:
+ifeq ($(PYTHON),:)
+	@echo "--------------------------------------------------------------------------"
+	@echo "---        Please install python to build Stasis HTTP stubs            ---"
+	@echo "--------------------------------------------------------------------------"
+	@false
+else
+	$(PYTHON) rest-api-templates/make_stasis_http_stubs.py \
+		rest-api/resources.json res/
+endif
+
 .PHONY: menuselect
 .PHONY: main
 .PHONY: sounds
@@ -977,6 +993,7 @@
 .PHONY: installdirs
 .PHONY: validate-docs
 .PHONY: _clean
+.PHONY: stasis-stubs
 .PHONY: $(SUBDIRS_INSTALL)
 .PHONY: $(SUBDIRS_DIST_CLEAN)
 .PHONY: $(SUBDIRS_CLEAN)

Modified: team/kmoore/pimp_sip_srtp/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/apps/app_confbridge.c?view=diff&rev=386433&r1=386432&r2=386433
==============================================================================
--- team/kmoore/pimp_sip_srtp/apps/app_confbridge.c (original)
+++ team/kmoore/pimp_sip_srtp/apps/app_confbridge.c Wed Apr 24 14:05:01 2013
@@ -317,14 +317,47 @@
 static int conference_bridge_hash_cb(const void *obj, const int flags)
 {
 	const struct confbridge_conference *conference = obj;
-	return ast_str_case_hash(conference->name);
+	const char *name = obj;
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = conference->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
 }
 
 /*! \brief Comparison function used for conference bridges container */
 static int conference_bridge_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct confbridge_conference *conference0 = obj, *conference1 = arg;
-	return (!strcasecmp(conference0->name, conference1->name) ? CMP_MATCH | CMP_STOP : 0);
+	const struct confbridge_conference *left = obj;
+	const struct confbridge_conference *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
 }
 
 const char *conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
@@ -1233,12 +1266,9 @@
  */
 static struct confbridge_conference *join_conference_bridge(const char *conference_name, struct confbridge_user *user)
 {
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	struct post_join_action *action;
-	struct confbridge_conference tmp;
 	int max_members_reached = 0;
-
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
 
 	/* We explictly lock the conference bridges container ourselves so that other callers can not create duplicate conferences at the same */
 	ao2_lock(conference_bridges);
@@ -1246,8 +1276,7 @@
 	ast_debug(1, "Trying to find conference bridge '%s'\n", conference_name);
 
 	/* Attempt to find an existing conference bridge */
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
-
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (conference && conference->b_profile.max_members) {
 		max_members_reached = conference->b_profile.max_members > conference->activeusers ? 0 : 1;
 	}
@@ -2225,7 +2254,7 @@
 static char *complete_confbridge_name(const char *line, const char *word, int pos, int state)
 {
 	int which = 0;
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	char *res = NULL;
 	int wordlen = strlen(word);
 	struct ao2_iterator iter;
@@ -2244,17 +2273,15 @@
 	return res;
 }
 
-static char *complete_confbridge_participant(const char *bridge_name, const char *line, const char *word, int pos, int state)
+static char *complete_confbridge_participant(const char *conference_name, const char *line, const char *word, int pos, int state)
 {
 	int which = 0;
 	RAII_VAR(struct confbridge_conference *, conference, NULL, ao2_cleanup);
-	struct confbridge_conference tmp;
 	struct confbridge_user *user;
 	char *res = NULL;
 	int wordlen = strlen(word);
 
-	ast_copy_string(tmp.name, bridge_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return NULL;
 	}
@@ -2280,8 +2307,7 @@
 
 static char *handle_cli_confbridge_kick(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -2304,8 +2330,7 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[2], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 		return CLI_SUCCESS;
@@ -2395,10 +2420,8 @@
 
 	if (a->argc == 3) {
 		struct confbridge_user *user;
-		struct confbridge_conference tmp;
-
-		ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
-		conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+
+		conference = ao2_find(conference_bridges, a->argv[2], OBJ_KEY);
 		if (!conference) {
 			ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 			return CLI_SUCCESS;
@@ -2428,12 +2451,10 @@
  */
 static int generic_lock_unlock_helper(int lock, const char *conference_name)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int res = 0;
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return -1;
 	}
@@ -2455,12 +2476,11 @@
  */
 static int generic_mute_unmute_helper(int mute, const char *conference_name, const char *chan_name)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
-	struct confbridge_user *user = NULL;
+	struct confbridge_conference *conference;
+	struct confbridge_user *user;
 	int res = 0;
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return -1;
 	}
@@ -2607,8 +2627,7 @@
 static char *handle_cli_confbridge_start_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	const char *rec_file = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -2633,8 +2652,7 @@
 		rec_file = a->argv[4];
 	}
 
-	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[3], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "Conference not found.\n");
 		return CLI_FAILURE;
@@ -2665,8 +2683,7 @@
 
 static char *handle_cli_confbridge_stop_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int ret;
 
 	switch (cmd) {
@@ -2686,8 +2703,7 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[3], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "Conference not found.\n");
 		return CLI_SUCCESS;
@@ -2754,7 +2770,6 @@
 	const char *conference_name = astman_get_header(m, "Conference");
 	struct confbridge_user *user;
 	struct confbridge_conference *conference;
-	struct confbridge_conference tmp;
 	char id_text[80];
 	int total = 0;
 
@@ -2770,8 +2785,7 @@
 		astman_send_error(s, m, "No active conferences.");
 		return 0;
 	}
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -2804,7 +2818,7 @@
 static int action_confbridgelistrooms(struct mansession *s, const struct message *m)
 {
 	const char *actionid = astman_get_header(m, "ActionID");
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	struct ao2_iterator iter;
 	char id_text[512] = "";
 	int totalitems = 0;
@@ -2930,8 +2944,7 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *channel = astman_get_header(m, "Channel");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int found = 0;
 
 	if (ast_strlen_zero(conference_name)) {
@@ -2943,8 +2956,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -2965,8 +2977,7 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *recordfile = astman_get_header(m, "RecordFile");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -2977,8 +2988,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3011,8 +3021,7 @@
 static int action_confbridgestoprecord(struct mansession *s, const struct message *m)
 {
 	const char *conference_name = astman_get_header(m, "Conference");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -3023,8 +3032,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3048,9 +3056,8 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *channel = astman_get_header(m, "Channel");
-	struct confbridge_user *user = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_user *user;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -3065,8 +3072,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3095,10 +3101,9 @@
 
 static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
-	char *parse = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_user *user = NULL;
-	struct confbridge_conference tmp;
+	char *parse;
+	struct confbridge_conference *conference;
+	struct confbridge_user *user;
 	int count = 0;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(type);
@@ -3114,12 +3119,7 @@
 	if (ast_strlen_zero(args.confno) || ast_strlen_zero(args.type)) {
 		return -1;
 	}
-	if (!ao2_container_count(conference_bridges)) {
-		snprintf(buf, len, "0");
-		return 0;
-	}
-	ast_copy_string(tmp.name, args.confno, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, args.confno, OBJ_KEY);
 	if (!conference) {
 		snprintf(buf, len, "0");
 		return 0;
@@ -3210,33 +3210,34 @@
 /*! \brief Called when module is being unloaded */
 static int unload_module(void)
 {
-	int res = ast_unregister_application(app);
+	ast_unregister_application(app);
 
 	ast_custom_function_unregister(&confbridge_function);
 	ast_custom_function_unregister(&confbridge_info_function);
 
-	ast_cli_unregister_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+	ast_cli_unregister_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));
+
+	ast_manager_unregister("ConfbridgeList");
+	ast_manager_unregister("ConfbridgeListRooms");
+	ast_manager_unregister("ConfbridgeMute");
+	ast_manager_unregister("ConfbridgeUnmute");
+	ast_manager_unregister("ConfbridgeKick");
+	ast_manager_unregister("ConfbridgeUnlock");
+	ast_manager_unregister("ConfbridgeLock");
+	ast_manager_unregister("ConfbridgeStartRecord");
+	ast_manager_unregister("ConfbridgeStopRecord");
+	ast_manager_unregister("ConfbridgeSetSingleVideoSrc");
 
 	/* Get rid of the conference bridges container. Since we only allow dynamic ones none will be active. */
-	ao2_ref(conference_bridges, -1);
+	ao2_cleanup(conference_bridges);
+	conference_bridges = NULL;
 
 	conf_destroy_config();
 
 	ast_channel_unregister(&record_tech);
 	record_tech.capabilities = ast_format_cap_destroy(record_tech.capabilities);
 
-	res |= ast_manager_unregister("ConfbridgeList");
-	res |= ast_manager_unregister("ConfbridgeListRooms");
-	res |= ast_manager_unregister("ConfbridgeMute");
-	res |= ast_manager_unregister("ConfbridgeUnmute");
-	res |= ast_manager_unregister("ConfbridgeKick");
-	res |= ast_manager_unregister("ConfbridgeUnlock");
-	res |= ast_manager_unregister("ConfbridgeLock");
-	res |= ast_manager_unregister("ConfbridgeStartRecord");
-	res |= ast_manager_unregister("ConfbridgeStopRecord");
-	res |= ast_manager_unregister("ConfbridgeSetSingleVideoSrc");
-
-	return res;
+	return 0;
 }
 
 /*!
@@ -3257,30 +3258,33 @@
 		ast_log(LOG_ERROR, "Unable to load config. Not loading module.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if ((ast_custom_function_register(&confbridge_function))) {
-		return AST_MODULE_LOAD_FAILURE;
-	}
-	if ((ast_custom_function_register(&confbridge_info_function))) {
-		return AST_MODULE_LOAD_FAILURE;
-	}
+
 	if (!(record_tech.capabilities = ast_format_cap_alloc())) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all(record_tech.capabilities);
 	if (ast_channel_register(&record_tech)) {
 		ast_log(LOG_ERROR, "Unable to register ConfBridge recorder.\n");
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
+
 	/* Create a container to hold the conference bridges */
-	if (!(conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS, conference_bridge_hash_cb, conference_bridge_cmp_cb))) {
+	conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS,
+		conference_bridge_hash_cb, conference_bridge_cmp_cb);
+	if (!conference_bridges) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	if (ast_register_application_xml(app, confbridge_exec)) {
-		ao2_ref(conference_bridges, -1);
-		return AST_MODULE_LOAD_FAILURE;
-	}
-
-	res |= ast_cli_register_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+
+	res |= ast_register_application_xml(app, confbridge_exec);
+
+	res |= ast_custom_function_register(&confbridge_function);
+	res |= ast_custom_function_register(&confbridge_info_function);
+
+	res |= ast_cli_register_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));
+
 	res |= ast_manager_register_xml("ConfbridgeList", EVENT_FLAG_REPORTING, action_confbridgelist);
 	res |= ast_manager_register_xml("ConfbridgeListRooms", EVENT_FLAG_REPORTING, action_confbridgelistrooms);
 	res |= ast_manager_register_xml("ConfbridgeMute", EVENT_FLAG_CALL, action_confbridgemute);
@@ -3292,6 +3296,7 @@
 	res |= ast_manager_register_xml("ConfbridgeStopRecord", EVENT_FLAG_CALL, action_confbridgestoprecord);
 	res |= ast_manager_register_xml("ConfbridgeSetSingleVideoSrc", EVENT_FLAG_CALL, action_confbridgesetsinglevideosrc);
 	if (res) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
 

Modified: team/kmoore/pimp_sip_srtp/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/apps/confbridge/conf_config_parser.c?view=diff&rev=386433&r1=386432&r2=386433
==============================================================================
--- team/kmoore/pimp_sip_srtp/apps/confbridge/conf_config_parser.c (original)
+++ team/kmoore/pimp_sip_srtp/apps/confbridge/conf_config_parser.c Wed Apr 24 14:05:01 2013
@@ -648,32 +648,95 @@
 /*! bridge profile container functions */
 static int bridge_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct bridge_profile *entry1 = obj, *entry2 = arg;
-	const char *name = arg;
-	return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
-		CMP_MATCH | CMP_STOP : 0;
-}
+	const struct bridge_profile *left = obj;
+	const struct bridge_profile *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
+}
+
 static int bridge_hash_cb(const void *obj, const int flags)
 {
 	const struct bridge_profile *b_profile = obj;
 	const char *name = obj;
-	return ast_str_case_hash(flags & OBJ_KEY ? name : b_profile->name);
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = b_profile->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
 }
 
 /*! menu container functions */
 static int menu_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct conf_menu *entry1 = obj, *entry2 = arg;
-	const char *name = arg;
-	return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
-		CMP_MATCH | CMP_STOP : 0;
-}
+	const struct conf_menu *left = obj;
+	const struct conf_menu *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
+}
+
 static int menu_hash_cb(const void *obj, const int flags)
 {
 	const struct conf_menu *menu = obj;
 	const char *name = obj;
-	return ast_str_case_hash(flags & OBJ_KEY ? name : menu->name);
-}
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = menu->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
+}
+
 static void menu_destructor(void *obj)
 {
 	struct conf_menu *menu = obj;
@@ -688,16 +751,47 @@
 /*! User profile container functions */
 static int user_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct user_profile *entry1 = obj, *entry2 = arg;
-	const char *name = arg;
-	return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
-		CMP_MATCH | CMP_STOP : 0;
-}
+	const struct user_profile *left = obj;
+	const struct user_profile *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
+}
+
 static int user_hash_cb(const void *obj, const int flags)
 {
 	const struct user_profile *u_profile = obj;
 	const char *name = obj;
-	return ast_str_case_hash(flags & OBJ_KEY ? name : u_profile->name);
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = u_profile->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
 }
 
 /*! Bridge Profile Sounds functions */

Modified: team/kmoore/pimp_sip_srtp/include/asterisk/http.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/include/asterisk/http.h?view=diff&rev=386433&r1=386432&r2=386433
==============================================================================
--- team/kmoore/pimp_sip_srtp/include/asterisk/http.h (original)
+++ team/kmoore/pimp_sip_srtp/include/asterisk/http.h Wed Apr 24 14:05:01 2013
@@ -58,7 +58,10 @@
 	AST_HTTP_GET = 0,
 	AST_HTTP_POST,
 	AST_HTTP_HEAD,
-	AST_HTTP_PUT,            /*!< Not supported in Asterisk */
+	AST_HTTP_PUT,
+	AST_HTTP_DELETE,
+	AST_HTTP_OPTIONS,
+	AST_HTTP_MAX_METHOD, /*!< Last entry in ast_http_method enum */
 };
 
 struct ast_http_uri;

Modified: team/kmoore/pimp_sip_srtp/include/asterisk/json.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/include/asterisk/json.h?view=diff&rev=386433&r1=386432&r2=386433
==============================================================================
--- team/kmoore/pimp_sip_srtp/include/asterisk/json.h (original)
+++ team/kmoore/pimp_sip_srtp/include/asterisk/json.h Wed Apr 24 14:05:01 2013
@@ -586,16 +586,33 @@
 /*!@{*/
 
 /*!
+ * \brief Encoding format type.
+ * \since 12.0.0
+ */
+enum ast_json_encoding_format
+{
+	/*! Compact format, low human readability */
+	AST_JSON_COMPACT,
+	/*! Formatted for human readability */
+	AST_JSON_PRETTY,
+};
+
+#define ast_json_dump_string(root) ast_json_dump_string_format(root, AST_JSON_COMPACT)
+
+/*!
  * \brief Encode a JSON value to a string.
  * \since 12.0.0
  *
  * Returned string must be freed by calling ast_free().
  *
- * \param JSON value.
+ * \param root JSON value.
+ * \param format encoding format type.
  * \return String encoding of \a root.
  * \return \c NULL on error.
  */
-char *ast_json_dump_string(struct ast_json *root);
+char *ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format);
+
+#define ast_json_dump_str(root, dst) ast_json_dump_str_format(root, dst, AST_JSON_COMPACT)
 
 /*!
  * \brief Encode a JSON value to an \ref ast_str.
@@ -605,10 +622,13 @@
  *
  * \param root JSON value.
  * \param dst \ref ast_str to store JSON encoding.
+ * \param format encoding format type.
  * \return 0 on success.
  * \return -1 on error. The contents of \a dst are undefined.
  */
-int ast_json_dump_str(struct ast_json *root, struct ast_str **dst);
+int ast_json_dump_str_format(struct ast_json *root, struct ast_str **dst, enum ast_json_encoding_format format);
+
+#define ast_json_dump_file(root, output) ast_json_dump_file_format(root, output, AST_JSON_COMPACT)
 
 /*!
  * \brief Encode a JSON value to a \c FILE.
@@ -616,10 +636,13 @@
  *
  * \param root JSON value.
  * \param output File to write JSON encoding to.
+ * \param format encoding format type.
  * \return 0 on success.
  * \return -1 on error. The contents of \a output are undefined.
  */
-int ast_json_dump_file(struct ast_json *root, FILE *output);
+int ast_json_dump_file_format(struct ast_json *root, FILE *output, enum ast_json_encoding_format format);
+
+#define ast_json_dump_new_file(root, path) ast_json_dump_new_file_format(root, path, AST_JSON_COMPACT)
 
 /*!
  * \brief Encode a JSON value to a file at the given location.
@@ -627,10 +650,11 @@
  *
  * \param root JSON value.
  * \param path Path to file to write JSON encoding to.
+ * \param format encoding format type.
  * \return 0 on success.
  * \return -1 on error. The contents of \a output are undefined.
  */
-int ast_json_dump_new_file(struct ast_json *root, const char *path);
+int ast_json_dump_new_file_format(struct ast_json *root, const char *path, enum ast_json_encoding_format format);
 
 #define AST_JSON_ERROR_TEXT_LENGTH    160
 #define AST_JSON_ERROR_SOURCE_LENGTH   80

Modified: team/kmoore/pimp_sip_srtp/include/asterisk/srv.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/include/asterisk/srv.h?view=diff&rev=386433&r1=386432&r2=386433
==============================================================================
--- team/kmoore/pimp_sip_srtp/include/asterisk/srv.h (original)
+++ team/kmoore/pimp_sip_srtp/include/asterisk/srv.h Wed Apr 24 14:05:01 2013
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2013, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -23,41 +23,47 @@
 #ifndef _ASTERISK_SRV_H
 #define _ASTERISK_SRV_H
 
-/*!
-  \file srv.h
-  \brief Support for DNS SRV records, used in to locate SIP services.
-  \note Note: This SRV record support will respect the priority and
-        weight elements of the records that are returned, but there are
-	no provisions for retrying or failover between records.
-*/
+/*! \file srv.h
+ *
+ * \brief Support for DNS SRV records, used in to locate SIP services.
+ *
+ * \note Note: This SRV record support will respect the priority and weight
+ *	elements of the records that are returned, but there are no provisions
+ * 	for retrying or failover between records.
+ */
 
-/*!\brief An opaque type, for lookup usage */
+/*! \brief An opaque type, for lookup usage */
 struct srv_context;
 
-/*!\brief Retrieve set of SRV lookups, in order
+/*! \brief Retrieve set of SRV lookups, in order
+ *
  * \param[in] context A pointer in which to hold the result
  * \param[in] service The service name to look up
  * \param[out] host Result host
  * \param[out] port Associated TCP portnum
+ *
  * \retval -1 Query failed
  * \retval 0 Result exists in host and port
  * \retval 1 No more results
  */
 extern int ast_srv_lookup(struct srv_context **context, const char *service, const char **host, unsigned short *port);
 
-/*!\brief Cleanup resources associated with ast_srv_lookup
+/*! \brief Cleanup resources associated with ast_srv_lookup
+ *
  * \param context Pointer passed into ast_srv_lookup
  */
 void ast_srv_cleanup(struct srv_context **context);
 
-/*! Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup 
-	Only do SRV record lookup if you get a domain without a port. If you get a port #, it's a DNS host name.
-!	\param	chan Ast channel
-	\param	host host name (return value)
-	\param	hostlen Length of string "host"
-	\param	port Port number (return value)
-	\param service Service tag for SRV lookup (like "_sip._udp" or "_stun._udp"
-*/
+/*! \brief Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup 
+ *
+ * Only do SRV record lookup if you get a domain without a port. If you get a port #, it's a DNS host name.
+ *
+ * \param chan Ast channel
+ * \param host host name (return value)
+ * \param hostlen Length of string "host"
+ * \param port Port number (return value)
+ * \param service Service tag for SRV lookup (like "_sip._udp" or "_stun._udp"
+ */
 extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service);
 
 /*!
@@ -69,6 +75,7 @@
  * SRV lookup.
  *
  * \param context The context returned by ast_srv_lookup
+ *
  * \return Number of records in context
  */
 unsigned int ast_srv_get_record_count(struct srv_context *context);
@@ -89,8 +96,9 @@
  * \param[out] port The port portion of the record
  * \param[out] priority The priority portion of the record
  * \param[out] weight The weight portion of the record
- * \retval -1 Failed to retrieve information. Likely due to an out of
- * range record_num
+ *
+ * \retval -1 Failed to retrieve information. 
+ * 	Likely due to an out of range record_num
  * \retval 0 Success
  */
 int ast_srv_get_nth_record(struct srv_context *context, int record_num, const char **host,

Modified: team/kmoore/pimp_sip_srtp/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pimp_sip_srtp/include/asterisk/stasis_app.h?view=diff&rev=386433&r1=386432&r2=386433
==============================================================================
--- team/kmoore/pimp_sip_srtp/include/asterisk/stasis_app.h (original)
+++ team/kmoore/pimp_sip_srtp/include/asterisk/stasis_app.h Wed Apr 24 14:05:01 2013
@@ -66,7 +66,7 @@
  * \param argv Arguments for the application.
  */
 int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc,
-		    char *argv[]);
+	char *argv[]);
 
 /*! @} */
 
@@ -126,22 +126,50 @@
 struct stasis_app_control;
 
 /*!
- * \brief Returns the handler for the given channel
+ * \brief Returns the handler for the given channel.
  * \param chan Channel to handle.
- * \return NULL channel not in Stasis application
- * \return Pointer to stasis handler.
+ * \return NULL channel not in Stasis application.
+ * \return Pointer to \c res_stasis handler.
  */
 struct stasis_app_control *stasis_app_control_find_by_channel(
 	const struct ast_channel *chan);
 
 /*!
- * \brief Exit \c app_stasis and continue execution in the dialplan.
+ * \brief Returns the handler for the channel with the given id.
+ * \param channel_id Uniqueid of the channel.
+ * \return NULL channel not in Stasis application, or channel does not exist.
+ * \return Pointer to \c res_stasis handler.
+ */
+struct stasis_app_control *stasis_app_control_find_by_channel_id(
+	const char *channel_id);
+
+/*!
+ * \brief Exit \c res_stasis and continue execution in the dialplan.
  *
- * If the channel is no longer in \c app_stasis, this function does nothing.
+ * If the channel is no longer in \c res_stasis, this function does nothing.
  *
- * \param handler Handler for \c app_stasis
+ * \param control Control for \c res_stasis
  */
-void stasis_app_control_continue(struct stasis_app_control *handler);
+void stasis_app_control_continue(struct stasis_app_control *control);
+
+/*!
+ * \brief Answer the channel associated with this control.
+ * \param control Control for \c res_stasis.
+ * \return 0 for success.
+ * \return -1 for error.
+ */
+int stasis_app_control_answer(struct stasis_app_control *control);
+
+/*! @} */
+
+/*! @{ */
+
+/*!
+ * \brief Build a JSON object from a \ref ast_channel_snapshot.
+ * \return JSON object representing channel snapshot.
+ * \return \c NULL on error
+ */
+struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot);
 
 /*! @} */
 

Modified: team/kmoore/pimp_sip_srtp/include/asterisk/strings.h

[... 764 lines stripped ...]



More information about the asterisk-commits mailing list