ari: expose channel driver's unique id to ARI channel resource

This change exposes the channel driver's unique id (i.e. the Call-ID
for chan_sip/chan_pjsip based channels) to ARI channel resources
as `protocol_id`.

ASTERISK-30027
Reported by: Moritz Fain
Tested by: Moritz Fain

Change-Id: I7cc6e7a9d29efe74bc27811d788dac20fe559b87
This commit is contained in:
Moritz Fain
2022-04-26 00:40:49 +02:00
committed by Joshua Colp
parent 8d7819482c
commit 4bf2473ac4
9 changed files with 44 additions and 5 deletions

View File

@@ -587,6 +587,9 @@ void *ast_channel_tech_pvt(const struct ast_channel *chan)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
{
chan->tech_pvt = value;
if (value != NULL) {
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
}
}
void *ast_channel_timingdata(const struct ast_channel *chan)
{

View File

@@ -273,7 +273,7 @@ static struct ast_channel_snapshot_base *channel_snapshot_base_create(struct ast
return NULL;
}
if (ast_string_field_init(snapshot, 256)) {
if (ast_string_field_init(snapshot, 256) || ast_string_field_init_extended(snapshot, protocol_id)) {
ao2_ref(snapshot, -1);
return NULL;
}
@@ -288,6 +288,10 @@ static struct ast_channel_snapshot_base *channel_snapshot_base_create(struct ast
snapshot->creationtime = ast_channel_creationtime(chan);
snapshot->tech_properties = ast_channel_tech(chan)->properties;
if (ast_channel_tech(chan)->get_pvt_uniqueid) {
ast_string_field_set(snapshot, protocol_id, ast_channel_tech(chan)->get_pvt_uniqueid(chan));
}
return snapshot;
}
@@ -1266,14 +1270,15 @@ struct ast_json *ast_channel_snapshot_to_json(
}
json_chan = ast_json_pack(
/* Broken up into groups of three for readability */
"{ s: s, s: s, s: s,"
/* Broken up into groups for readability */
"{ s: s, s: s, s: s, s: s,"
" s: o, s: o, s: s,"
" s: o, s: o, s: s }",
/* First line */
"id", snapshot->base->uniqueid,
"name", snapshot->base->name,
"state", ast_state2str(snapshot->state),
"protocol_id", snapshot->base->protocol_id,
/* Second line */
"caller", ast_json_name_number(
snapshot->caller->name, snapshot->caller->number),