Index: chan_sip.c =================================================================== --- chan_sip.c (revision 19672) +++ chan_sip.c (working copy) @@ -826,6 +826,7 @@ int refresh; /*!< How often to refresh */ struct sip_pvt *call; /*!< create a sip_pvt structure for each outbound "registration call" in progress */ int regstate; /*!< Registration state (see above) */ + time_t regtime; /*!< Last registration time */ int callid_valid; /*!< 0 means we haven't chosen callid for this registry yet. */ char callid[80]; /*!< Global CallID for this registry */ unsigned int ocseq; /*!< Sequence number we got to for REGISTERs for this registry */ @@ -8131,17 +8132,26 @@ /*! \brief sip_show_registry: Show SIP Registry (registrations with other SIP proxies ---*/ static int sip_show_registry(int fd, int argc, char *argv[]) { -#define FORMAT2 "%-30.30s %-12.12s %8.8s %-20.20s\n" -#define FORMAT "%-30.30s %-12.12s %8d %-20.20s\n" +#define FORMAT2 "%-30.30s %-12.12s %8.8s %-20.20s %-25.25s\n" +#define FORMAT "%-30.30s %-12.12s %8d %-20.20s %-25.25s\n" char host[80]; + char tmpdat[256]; + struct tm tm; + if (argc != 3) return RESULT_SHOWUSAGE; - ast_cli(fd, FORMAT2, "Host", "Username", "Refresh", "State"); + ast_cli(fd, FORMAT2, "Host", "Username", "Refresh", "State", "Reg.Time"); ASTOBJ_CONTAINER_TRAVERSE(®l, 1, do { ASTOBJ_RDLOCK(iterator); snprintf(host, sizeof(host), "%s:%d", iterator->hostname, iterator->portno ? iterator->portno : DEFAULT_SIP_PORT); - ast_cli(fd, FORMAT, host, iterator->username, iterator->refresh, regstate2str(iterator->regstate)); + if (iterator->regtime) { + gmtime_r(&iterator->regtime, &tm); + strftime(tmpdat, sizeof(tmpdat), "%a, %d %b %Y %T GMT", &tm); + } else { + tmpdat[0] = 0; + } + ast_cli(fd, FORMAT, host, iterator->username, iterator->refresh, regstate2str(iterator->regstate), tmpdat); ASTOBJ_UNLOCK(iterator); } while(0)); return RESULT_SUCCESS; @@ -9636,6 +9646,7 @@ } r->regstate=REG_STATE_REGISTERED; + time(&r->regtime); manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate)); r->regattempts = 0; ast_log(LOG_DEBUG, "Registration successful\n");