[Home]

Summary:ASTERISK-07447: Improve strings reported by ast_state2str
Reporter:Jon Hirst (jonty)Labels:
Date Opened:2006-08-02 15:25:19Date Closed:2006-08-05 15:59:30
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:The function ast_state2str does not report the AST_STATE_DIALING_OFFHOOK and AST_STATE_PRERING as strings.  Instead it reports them as 'Unknown (8)' and 'Unknown (9)'.

Also, the 'Unknown (%d)\n' message includes a newline character which breaks the AMI when these codes are reported in events.

****** ADDITIONAL INFORMATION ******

Near line 526 in channel.c change:

-        case AST_STATE_UP:
-                return "Up";
-        case AST_STATE_BUSY:
-                return "Busy";
-        default:
-                pthread_once(&state2str_buf_once, state2str_buf_key_create);
-                if (!(buf = pthread_getspecific(state2str_buf_key))) {
-                        if (!(buf = ast_malloc(STATE2STR_BUFSIZE)))
-                                return NULL;
-                        pthread_setspecific(state2str_buf_key, buf);
-                }
-                snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)\n", state);
-                return buf;

to:

+        case AST_STATE_UP:
+                return "Up";
+        case AST_STATE_BUSY:
+                return "Busy";
+        case AST_STATE_DIALING_OFFHOOK:
+                return "Dialing offhook";
+        case AST_STATE_PRERING:
+                return "Prering";
+        default:
+                pthread_once(&state2str_buf_once, state2str_buf_key_create);
+                if (!(buf = pthread_getspecific(state2str_buf_key))) {
+                        if (!(buf = ast_malloc(STATE2STR_BUFSIZE)))
+                                return NULL;
+                        pthread_setspecific(state2str_buf_key, buf);
+                }
+                snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state);
+                return buf;
Comments:By: Serge Vecher (serge-v) 2006-08-02 15:43:43

1. Can you please get a disclaimer on file (see bottom http://bugs.digium.com/main_page.php)
2. Confirm as a note when done.
3. Upload your change as a patch file  http://www.asterisk.org/developers/Patch_Howto

By: Russell Bryant (russell) 2006-08-05 15:59:30

I went ahead and made these changes manually in the trunk in revision 39032, thanks!