@@ -392,6 +392,8 @@ struct sip_outbound_registration_client_state {
392392 char * transport_name ;
393393 /*! \brief The name of the registration sorcery object */
394394 char * registration_name ;
395+ /*! \brief Expected time of registration lapse/expiration */
396+ unsigned int registration_expires ;
395397};
396398
397399/*! \brief Outbound registration state information (persists for lifetime that registration should exist) */
@@ -738,6 +740,7 @@ static void schedule_registration(struct sip_outbound_registration_client_state
738740 (int ) info .client_uri .slen , info .client_uri .ptr );
739741 ao2_ref (client_state , -1 );
740742 }
743+ client_state -> registration_expires = ((int ) time (NULL )) + seconds ;
741744}
742745
743746static void update_client_state_status (struct sip_outbound_registration_client_state * client_state , enum sip_outbound_registration_status status )
@@ -2261,7 +2264,7 @@ static int cli_print_header(void *obj, void *arg, int flags)
22612264 ast_assert (context -> output_buffer != NULL );
22622265
22632266 ast_str_append (& context -> output_buffer , 0 ,
2264- " <Registration/ServerURI..............................> <Auth..........> <Status.......>\n" );
2267+ " <Registration/ServerURI..............................> <Auth.................... > <Status.......>\n" );
22652268
22662269 return 0 ;
22672270}
@@ -2272,19 +2275,22 @@ static int cli_print_body(void *obj, void *arg, int flags)
22722275 struct ast_sip_cli_context * context = arg ;
22732276 const char * id = ast_sorcery_object_get_id (registration );
22742277 struct sip_outbound_registration_state * state = get_state (id );
2278+ int expsecs ;
22752279#define REGISTRATION_URI_FIELD_LEN 53
22762280
22772281 ast_assert (context -> output_buffer != NULL );
2282+ expsecs = state ? state -> client_state -> registration_expires - ((int ) time (NULL )) : 0 ;
22782283
2279- ast_str_append (& context -> output_buffer , 0 , " %-s/%-*.*s %-16s %-16s\n" ,
2284+ ast_str_append (& context -> output_buffer , 0 , " %-s/%-*.*s %-26s %-16s %s%d%s \n" ,
22802285 id ,
22812286 (int ) (REGISTRATION_URI_FIELD_LEN - strlen (id )),
22822287 (int ) (REGISTRATION_URI_FIELD_LEN - strlen (id )),
22832288 registration -> server_uri ,
22842289 AST_VECTOR_SIZE (& registration -> outbound_auths )
22852290 ? AST_VECTOR_GET (& registration -> outbound_auths , 0 )
22862291 : "n/a" ,
2287- (state ? sip_outbound_registration_status_str (state -> client_state -> status ) : "Unregistered" ));
2292+ (state ? sip_outbound_registration_status_str (state -> client_state -> status ) : "Unregistered" ),
2293+ state ? " (exp. " : "" , abs (expsecs ), state ? (expsecs < 0 ? "s ago)" : "s)" ) : "" );
22882294 ao2_cleanup (state );
22892295
22902296 if (context -> show_details
0 commit comments