From: Dwayne M. Hubbard Date: Fri, 13 Apr 2007 21:23:10 +0000 (+0000) Subject: added CLI 'sip unregister ' for issue 9326. thanks eliel X-Git-Tag: 1.6.0-beta1~3^2~2836 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34469a8707f0a377f2ef8779ce8507896f2b7a2e;p=thirdparty%2Fasterisk.git added CLI 'sip unregister ' for issue 9326. thanks eliel git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61660 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 77f13f6c2b..28ae6a386a 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1399,6 +1399,7 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, const struct m static int sip_show_peer(int fd, int argc, char *argv[]); static int sip_show_user(int fd, int argc, char *argv[]); static int sip_show_registry(int fd, int argc, char *argv[]); +static int sip_unregister(int fd, int argc, char *argv[]); static int sip_show_settings(int fd, int argc, char *argv[]); static const char *subscription_type2str(enum subscriptiontype subtype) attribute_pure; static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype); @@ -10942,6 +10943,25 @@ static int sip_show_registry(int fd, int argc, char *argv[]) #undef FORMAT2 } +/*! \brief Unregister (force expiration) a SIP peer in the registry via CLI */ +static int sip_unregister(int fd, int argc, char *argv[]) +{ + struct sip_peer *peer; + int load_realtime = 0; + + if (argc != 3) + return RESULT_SHOWUSAGE; + + if ((peer = find_peer(argv[2], NULL, load_realtime))) { + expire_register(peer); + ast_cli(fd, "Unregistered peer \'%s\'\n\n", argv[2]); + } else { + ast_cli(fd, "Attempted to unregister an unknown peer \'%s\' via CLI\n", argv[2]); + } + + return 0; +} + /*! \brief List global settings for the SIP channel */ static int sip_show_settings(int fd, int argc, char *argv[]) { @@ -11942,6 +11962,10 @@ static const char show_reg_usage[] = "Usage: sip show registry\n" " Lists all registration requests and status.\n"; +static const char sip_unregister_usage[] = +"Usage: sip unregister \n" +" Unregister (force expiration) a SIP peer from the registry\n"; + static const char debug_usage[] = "Usage: sip debug\n" " Enables dumping of SIP packets for debugging purposes\n\n" @@ -18065,6 +18089,10 @@ static struct ast_cli_entry cli_sip[] = { sip_show_registry, "List SIP registration status", show_reg_usage }, + { { "sip", "unregister", NULL }, + sip_unregister, "Unregister (force expiration) a SIP peer from the registery\n", + sip_unregister_usage }, + { { "sip", "show", "settings", NULL }, sip_show_settings, "Show SIP global settings", show_settings_usage },