Index: chan_sip.c =================================================================== --- chan_sip.c (revision 61667) +++ chan_sip.c (working copy) @@ -1408,7 +1408,9 @@ static int sip_show_subscriptions(int fd, int argc, char *argv[]); static char *complete_sipch(const char *line, const char *word, int pos, int state); static char *complete_sip_peer(const char *word, int state, int flags2); +static char *complete_sip_registered_peer(const char *word, int state, int flags2); static char *complete_sip_show_peer(const char *line, const char *word, int pos, int state); +static char *complete_sip_unregister(const char *line, const char *word, int pos, int state); static char *complete_sip_debug_peer(const char *line, const char *word, int pos, int state); static char *complete_sip_user(const char *word, int state, int flags2); static char *complete_sip_show_user(const char *line, const char *word, int pos, int state); @@ -11217,6 +11219,24 @@ return result; } +/*! \brief Do completion on registered peer name */ +static char *complete_sip_registered_peer(const char *word, int state, int flags2) +{ + char *result = NULL; + int wordlen = strlen(word); + int which = 0; + + ASTOBJ_CONTAINER_TRAVERSE(&peerl, !result, do { + ASTOBJ_WRLOCK(iterator); + if (!strncasecmp(word, iterator->name, wordlen) && + (!flags2 || ast_test_flag(&iterator->flags[1], flags2)) && + ++which > state && iterator->expire > 0) + result = ast_strdup(iterator->name); + ASTOBJ_UNLOCK(iterator); + } while(0) ); + return result; +} + /*! \brief Support routine for 'sip show peer' CLI */ static char *complete_sip_show_peer(const char *line, const char *word, int pos, int state) { @@ -11226,6 +11246,15 @@ return NULL; } +/*! \brief Support routine for 'sip unregister' CLI */ +static char *complete_sip_unregister(const char *line, const char *word, int pos, int state) +{ + if (pos == 2) + return complete_sip_registered_peer(word, state, 0); + + return NULL; +} + /*! \brief Support routine for 'sip debug peer' CLI */ static char *complete_sip_debug_peer(const char *line, const char *word, int pos, int state) { @@ -18091,7 +18120,7 @@ { { "sip", "unregister", NULL }, sip_unregister, "Unregister (force expiration) a SIP peer from the registery\n", - sip_unregister_usage }, + sip_unregister_usage, complete_sip_unregister }, { { "sip", "show", "settings", NULL }, sip_show_settings, "Show SIP global settings",