59 const char *right_key = arg;
67 cmp = strcmp(left_obj->
base->
name, right_key);
70 cmp = strncmp(left_obj->
base->
name, right_key, strlen(right_key));
84 const char *right_key = arg;
96 cmp = strcmp(left_obj->
base->
name, right_key);
99 cmp = strncmp(left_obj->
base->
name, right_key, strlen(right_key));
113 const char *right_key = arg;
121 if (strcmp(left_obj->
base->
name, right_key) == 0) {
126 if (strncmp(left_obj->
base->
name, right_key, strlen(right_key)) == 0) {
142 const char *right_key = arg;
153 if (strcmp(left_obj->
base->
name, right_key) == 0) {
158 if (strncmp(left_obj->
base->
name, right_key, strlen(right_key)) == 0) {
175 if (!strcmp(snapshot->
base->
type,
"PJSIP")) {
186 regex_t *regexbuf = arg;
202 if (!parent_container) {
207 if (!child_container) {
214 if (regcomp(®exbuf, regex, REG_EXTENDED | REG_NOSUB)) {
222 return child_container;
256 "%*s: <ChannelId%*.*s> <State.....> <Time.....>\n",
263 "%*s: <DialedExten%*.*s> CLCID: <ConnectedLineCID.......>\n",
275 char *print_name =
NULL;
279 char *print_time = alloca(32);
284 print_name = alloca(print_name_len);
296 flexwidth, flexwidth,
307 "%*s: %-*.*s CLCID: \"%s\" <%s>\n",
309 flexwidth, flexwidth,
330 " ...........Receive......... .........Transmit..........\n" 331 " BridgeId ChannelId ........ UpTime.. Codec. Count Lost Pct Jitter Count Lost Pct Jitter RTT....\n" 332 " =================");
346 char *print_name =
NULL;
347 char *print_time = alloca(32);
348 char codec_in_use[7];
370 if (!media || !media->
rtp) {
377 codec_in_use[0] =
'\0';
392 if (stats_res == -1) {
396 " %8.8s %-18.18s %-8.8s %-6.6s %6u%s %6u%s %3u %7.3f %6u%s %6u%s %3u %7.3f %7.3f\n",
402 stats.
rxcount > 100000 ?
"K":
" ",
404 stats.
rxploss > 100000 ?
"K":
" ",
408 stats.
txcount > 100000 ?
"K":
" ",
410 stats.
txploss > 100000 ?
"K":
" ",
424 .
command =
"pjsip list channels",
425 .
usage =
"Usage: pjsip list channels [ like <pattern> ]\n" 426 " List the active PJSIP channels\n" 427 " Optional regular expression pattern is used to filter the list.\n"),
429 .
command =
"pjsip show channels",
430 .
usage =
"Usage: pjsip show channels [ like <pattern> ]\n" 431 " List(detailed) the active PJSIP channels\n" 432 " Optional regular expression pattern is used to filter the list.\n"),
434 .
command =
"pjsip show channel",
435 .
usage =
"Usage: pjsip show channel\n" 436 " List(detailed) the active PJSIP channel\n"),
439 .
command =
"pjsip show channelstats",
440 .
usage =
"Usage: pjsip show channelstats [ like <pattern> ]\n" 441 " List(detailed) the active PJSIP channel stats\n" 442 " Optional regular expression pattern is used to filter the list.\n"),
451 if (!channel_formatter) {
455 channel_formatter->
name =
"channel";
464 if (!channelstats_formatter) {
465 ao2_ref(channel_formatter, -1);
466 ast_log(
LOG_ERROR,
"Unable to allocate memory for channelstats_formatter\n");
469 channelstats_formatter->
name =
"channelstat";
struct ast_str * output_buffer
struct ao2_container * ast_channel_cache_by_name(void)
Secondary channel cache, indexed by name.
struct ao2_container *(* get_container)(const char *regex)
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
static struct ao2_container * cli_channelstats_get_container(const char *regex)
struct ast_channel_snapshot_base * base
Asterisk main include file. File version handling, generic pbx functions.
static int cli_channel_iterate(void *endpoint, ao2_callback_fn callback, void *arg)
static int cli_channelstats_print_body(void *obj, void *arg, int flags)
static int cli_channel_print_header(void *obj, void *arg, int flags)
int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
static int cli_message_to_snapshot(void *obj, void *arg, int flags)
The arg parameter is a search key, but is not an object.
Time-related functions and macros.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
descriptor for a cli entry.
#define ao2_callback(c, flags, cb_fn, arg)
static void * cli_channel_retrieve_by_id(const char *id)
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Structure representing a snapshot of channel state.
int() ao2_sort_fn(const void *obj_left, const void *obj_right, int flags)
Type of generic container sort function.
int ast_sip_for_each_channel(const struct ast_sip_endpoint *endpoint, ao2_callback_fn on_channel_snapshot, void *arg)
For every channel snapshot on an endpoint all the given 'on_channel_snapshot' handler.
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int cli_channel_sort(const void *obj, const void *arg, int flags)
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
const ast_string_field type
struct ast_channel_snapshot_dialplan * dialplan
A structure describing a SIP session.
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_strlen_zero(foo)
struct ast_sip_session_media_state * active_media_state
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
struct ast_sip_cli_formatter_entry * channel_formatter
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
struct ast_channel_snapshot * ast_channel_snapshot_get_latest_by_name(const char *name)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object...
General Asterisk PBX channel definitions.
const ast_string_field appl
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define CLI_INDENT_TO_SPACES(x)
static struct ast_mansession session
static struct ao2_container * cli_channel_get_container(const char *regex)
void pjsip_channel_cli_unregister(void)
Unregisters the channel cli commands.
#define ao2_ref(o, delta)
const ast_string_field exten
struct timeval creationtime
#define ast_strdupa(s)
duplicate a string in memory from the stack
void *(* retrieve_by_id)(const char *id)
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
static struct ast_cli_entry cli_commands[]
#define CLI_HEADER_FILLER
static int cli_channel_compare(void *obj, void *arg, int flags)
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
static int cli_channelstats_sort(const void *obj, const void *arg, int flags)
#define ao2_alloc(data_size, destructor_fn)
#define ast_channel_unlock(chan)
static int cli_channelstats_iterate(void *endpoint, ao2_callback_fn callback, void *arg)
PJSIP Channel Driver shared data structures.
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
enum ast_channel_state state
const char *(* get_id)(const void *obj)
struct ast_sip_cli_formatter_entry * channelstats_formatter
int pjsip_channel_cli_register(void)
Registers the channel cli commands.
The arg parameter is an object of the same type.
static int cli_filter_channels(void *obj, void *arg, int flags)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
struct ast_channel_snapshot_bridge * bridge
static int cli_channelstats_compare(void *obj, void *arg, int flags)
ao2_callback_fn * print_header
Search option field mask.
void ast_format_duration_hh_mm_ss(int duration, char *buf, size_t length)
Formats a duration into HH:MM:SS.
static char context[AST_MAX_CONTEXT]
static int cli_channel_print_body(void *obj, void *arg, int flags)
ao2_callback_fn * print_body
static const char * cli_channel_get_id(const void *obj)
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
struct ast_channel_snapshot_connected * connected
PJSIP CLI functions header file.
static int cli_channelstats_print_header(void *obj, void *arg, int flags)
const ast_string_field name
static struct ao2_container * get_container(const char *regex, ao2_sort_fn sort_fn, ao2_callback_fn compare_fn)
#define ao2_link(container, obj)