Index: gastman.c =================================================================== RCS file: /usr/cvsroot/gastman/gastman.c,v retrieving revision 1.17 diff -u -r1.17 gastman.c --- gastman.c 18 Jan 2005 22:01:17 -0000 1.17 +++ gastman.c 21 Mar 2005 23:15:55 -0000 @@ -156,9 +156,9 @@ { char copy[80]; char tech[80]; - char *s; + char *s, *t; strncpy(copy, real, sizeof(copy)); - strncpy(tech, real, sizeof(copy)); + strncpy(tech, real, sizeof(tech)); s = strchr(tech, '/'); if (s) *s = '\0'; @@ -188,21 +188,25 @@ if (!strcasecmp(pat, copy)) return 1; return 0; - } else if (!strncasecmp(tech, "IAX2[", 5)) { - s = strchr(copy, '/'); - if (s) + } else if (!strncasecmp(tech, "IAX2", 4)) { + /* HEAD */ + s = strrchr(copy, '-'); + /* 1_0 */ + t = strrchr(copy, '/'); + + if (s && s > t) { *s = '\0'; - if (!strcasecmp(pat, copy)) { - return 1; + } else if (t) { + *t = '\0'; } - } else if (!strncasecmp(tech, "IAX2", 4)) { - s = strchr(copy, '/'); - if (s) { - s = strchr(s + 1, '/'); - if (s) { - *s = '\0'; - } + + /* If the pattern doesn't contain an @, then match only against the host portion */ + if ((s=strchr(copy, '@')) && (strchr(pat,'@') == NULL)) { + char newcopy[80] = "IAX2/"; + strncat(newcopy, s + 1, sizeof(newcopy) - 5); + strncpy(copy, newcopy, sizeof(copy)); } + if (!strcasecmp(pat, copy)) { return 1; } @@ -1522,10 +1526,28 @@ if (!m) { gui_show_message("Hangup Failed", "Timeout waiting for response"); } else if (strcasecmp(get_header(m, "Response"), "Success")) { - gui_show_message("Hangup Failed", get_header(m, "Message")); + if (strcasecmp(get_header(m, "Message"), "Channel not existant")) { + /* A hangup occurred, but we missed it. */ + char tmp[80]; + snprintf(tmp, sizeof(tmp), "Ouch. %s doesn't exist on the server?", chan->name); + del_chan(chan->name); + gui_status(tmp); + /* + * What this really calls for here is to have a ast_reliable_write, not ast_careful_write + * on the server. That is, the data needs to go to the manager client, even if the manager + * client is not quite ready to receive it. This calls for creating a separate event queue + * and thread for each manager client, thus allowing every event to be reliably received. + * + * However, the goal here is to fix gastman, so that it works even when we miss an event, + * so the Asterisk fix will have to wait until later. + * + * Tilghman (Corydon76) 2005-03-21 + */ + } else { + gui_show_message("Hangup Failed", get_header(m, "Message")); + } } } - } void gastman_double_click(void *data)