[Asterisk-code-review] frame.c: Make debugging easier (asterisk[17])

Friendly Automation asteriskteam at digium.com
Tue Jul 7 15:00:42 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14650 )

Change subject: frame.c:  Make debugging easier
......................................................................

frame.c:  Make debugging easier

 * ast_frame_subclass2str() and ast_frame_type2str() now return
   a pointer to the buffer that was passed in instead of void.
   This makes it easier to use these functions inline in
   printf-style debugging statements.

 * Added many missing control frame entries in
   ast_frame_subclass2str.

Change-Id: Ifd0d6578e758cd644c96d17a5383ff2128c572fc
---
M include/asterisk/frame.h
M main/frame.c
2 files changed, 89 insertions(+), 4 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 56ceb7f..8892765 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -633,9 +633,10 @@
  * \param slen Length of subclass buffer
  * \param moreinfo Buffer to fill with additional information
  * \param mlen Length of moreinfo buffer
+ * \return Pointer to subclass
  * \since 11
  */
-void ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen);
+char *ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen);
 
 /*!
  * \brief Copy the discription of a frame type into the provided string
@@ -643,9 +644,10 @@
  * \param frame_type The frame type to be described
  * \param ftype Buffer to fill with frame type description
  * \param len Length of subclass buffer
+ * \return Pointer to ftype
  * \since 11
  */
-void ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len);
+char *ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
diff --git a/main/frame.c b/main/frame.c
index b2c5040..3518133 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -391,7 +391,7 @@
 		dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
 }
 
-void ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
+char *ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
 {
 	switch(f->frametype) {
 	case AST_FRAME_DTMF_BEGIN:
@@ -474,6 +474,85 @@
 			snprintf(subclass, slen, "T38_Parameters/%s", message);
 			break;
 		}
+
+		case AST_CONTROL_STREAM_STOP:
+			ast_copy_string(subclass, "Stop stream", slen);
+			break;
+		case AST_CONTROL_STREAM_SUSPEND:
+			ast_copy_string(subclass, "Suspend stream", slen);
+			break;
+		case AST_CONTROL_STREAM_RESTART:
+			ast_copy_string(subclass, "Restart stream", slen);
+			break;
+		case AST_CONTROL_STREAM_REVERSE:
+			ast_copy_string(subclass, "Reverse stream", slen);
+			break;
+		case AST_CONTROL_STREAM_FORWARD:
+			ast_copy_string(subclass, "Forward stream", slen);
+			break;
+		case AST_CONTROL_RECORD_CANCEL:
+			ast_copy_string(subclass, "Cancel stream", slen);
+			break;
+		case AST_CONTROL_RECORD_STOP:
+			ast_copy_string(subclass, "Record stop", slen);
+			break;
+		case AST_CONTROL_RECORD_SUSPEND:
+			ast_copy_string(subclass, "Record suspend", slen);
+			break;
+		case AST_CONTROL_RECORD_MUTE:
+			ast_copy_string(subclass, "Record mute", slen);
+			break;
+		case AST_CONTROL_SRCUPDATE:
+			ast_copy_string(subclass, "Media source update", slen);
+			break;
+		case AST_CONTROL_TRANSFER:
+			ast_copy_string(subclass, "Transfer", slen);
+			break;
+		case AST_CONTROL_CONNECTED_LINE:
+			ast_copy_string(subclass, "Connected line update", slen);
+			break;
+		case AST_CONTROL_REDIRECTING:
+			ast_copy_string(subclass, "Redirect", slen);
+			break;
+		case AST_CONTROL_CC:
+			ast_copy_string(subclass, "CC", slen);
+			break;
+		case AST_CONTROL_SRCCHANGE:
+			ast_copy_string(subclass, "Media SSRC change", slen);
+			break;
+		case AST_CONTROL_READ_ACTION:
+			ast_copy_string(subclass, "Read action", slen);
+			break;
+		case AST_CONTROL_AOC:
+			ast_copy_string(subclass, "AOC", slen);
+			break;
+		case AST_CONTROL_END_OF_Q:
+			ast_copy_string(subclass, "Endof Q", slen);
+			break;
+		case AST_CONTROL_INCOMPLETE:
+			ast_copy_string(subclass, "Incomplete", slen);
+			break;
+		case AST_CONTROL_MCID:
+			ast_copy_string(subclass, "MCID", slen);
+			break;
+		case AST_CONTROL_UPDATE_RTP_PEER:
+			ast_copy_string(subclass, "Update RTP peer", slen);
+			break;
+		case AST_CONTROL_PVT_CAUSE_CODE:
+			ast_copy_string(subclass, "Private Cause Code", slen);
+			break;
+		case AST_CONTROL_MASQUERADE_NOTIFY:
+			ast_copy_string(subclass, "Masquerade notify", slen);
+			break;
+		case AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE:
+			ast_copy_string(subclass, "Stream topology request change", slen);
+			break;
+		case AST_CONTROL_STREAM_TOPOLOGY_CHANGED:
+			ast_copy_string(subclass, "Stream topology changed", slen);
+			break;
+		case AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED:
+			ast_copy_string(subclass, "Stream topology source changed", slen);
+			break;
 		case -1:
 			ast_copy_string(subclass, "Stop generators", slen);
 			break;
@@ -564,9 +643,11 @@
 		ast_copy_string(subclass, "Unknown Subclass", slen);
 		break;
 	}
+
+	return subclass;
 }
 
-void ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
+char *ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
 {
 	switch (frame_type) {
 	case AST_FRAME_DTMF_BEGIN:
@@ -621,6 +702,8 @@
 		snprintf(ftype, len, "Unknown Frametype '%u'", frame_type);
 		break;
 	}
+
+	return ftype;
 }
 
 /*! Dump a frame for debugging purposes */

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14650
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 17
Gerrit-Change-Id: Ifd0d6578e758cd644c96d17a5383ff2128c572fc
Gerrit-Change-Number: 14650
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200707/57253887/attachment.html>


More information about the asterisk-code-review mailing list