Asterisk - The Open Source Telephony Project GIT-master-57e2743
Loading...
Searching...
No Matches
Functions
dialplan_functions.h File Reference

PJSIP dialplan functions header file. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int pjsip_acf_channel_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 CHANNEL function read callback.
 
int pjsip_acf_dial_contacts_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 PJSIP_DIAL_CONTACTS function read callback.
 
int pjsip_acf_dtmf_mode_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 PJSIP_DTMF_MODE function read callback.
 
int pjsip_acf_dtmf_mode_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_DTMF_MODE function write callback.
 
int pjsip_acf_media_offer_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 PJSIP_MEDIA_OFFER function read callback.
 
int pjsip_acf_media_offer_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_MEDIA_OFFER function write callback.
 
int pjsip_acf_moh_passthrough_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 PJSIP_MOH_PASSTHROUGH function read callback.
 
int pjsip_acf_moh_passthrough_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_MOH_PASSTHROUGH function write callback.
 
int pjsip_acf_parse_uri_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 PJSIP_PARSE_URI function read callback.
 
int pjsip_acf_session_refresh_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_SEND_SESSION_REFRESH function write callback.
 
int pjsip_action_hangup (struct mansession *s, const struct message *m)
 Manager action to hang up an incoming PJSIP channel with a SIP response code.
 
int pjsip_app_hangup (struct ast_channel *chan, const char *data)
 Hang up an incoming PJSIP channel with a SIP response code.
 
int pjsip_transfer_handling_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_TRANSFER_HANDLING function write callback.
 

Detailed Description

PJSIP dialplan functions header file.

Definition in file dialplan_functions.h.

Function Documentation

◆ pjsip_acf_channel_read()

int pjsip_acf_channel_read ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)

CHANNEL function read callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on failure

Definition at line 356 of file dialplan_functions.c.

357{
358 struct ast_sip_channel_pvt *channel;
359 char *parse = ast_strdupa(data);
360 int res = 0;
361
363 AST_APP_ARG(param);
365 AST_APP_ARG(field);
366 );
367
368 if (!chan) {
369 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
370 return -1;
371 }
372
373 /* Check for zero arguments */
374 if (ast_strlen_zero(parse)) {
375 ast_log(LOG_ERROR, "Cannot call %s without arguments\n", cmd);
376 return -1;
377 }
378
379 if (!len) {
380 ast_log(LOG_ERROR, "Cannot call %s without an output buffer\n", cmd);
381 return -1;
382 }
383
385
386 ast_channel_lock(chan);
387
388 /* Sanity check */
389 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
390 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
391 ast_channel_unlock(chan);
392 return 0;
393 }
394
395 channel = ast_channel_tech_pvt(chan);
396 if (!channel) {
397 ast_log(LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(chan));
398 ast_channel_unlock(chan);
399 return -1;
400 }
401
402 if (!channel->session) {
403 ast_log(LOG_WARNING, "Channel %s has no session\n", ast_channel_name(chan));
404 ast_channel_unlock(chan);
405 return -1;
406 }
407
408 memset(buf, 0, len);
409
410 if (!strcmp(args.param, "endpoint")) {
411 if (!channel->session->endpoint) {
412 res = -1;
413 } else {
415 }
416 } else if (!strcmp(args.param, "contact")) {
417 if (channel->session->contact) {
419 }
420 } else if (!strcmp(args.param, "aor")) {
421 if (channel->session->aor) {
423 }
424 } else if (!strcmp(args.param, "pjsip")) {
425 res = channel_read_pjsip(chan, channel->session, args.type, buf, len);
426 } else if (!strcmp(args.param, "rtp") || !strcmp(args.param, "rtcp")) {
427 const struct pjsip_channel_info *info = pjsip_channel_info_get(chan);
428 struct ast_rtp_instance *rtp;
429 struct ast_sip_session_media *media;
430 struct ast_sockaddr no_address = { { 0, } };
431 const struct ast_sockaddr *direct_media_addr;
432 unsigned int secure;
433 unsigned int held;
434 int video = !strcmp(S_OR(args.field, "audio"), "video");
435
436 if (!info) {
437 res = -1;
438 } else {
439 /* The channel lock keeps these retained instances alive throughout the read. */
440 rtp = video ? info->video_rtp : info->audio_rtp;
441 media = channel->session->active_media_state
444 direct_media_addr = media ? &media->direct_media_addr : &no_address;
445 secure = video ? info->video_secure : info->audio_secure;
446 held = video ? info->video_held : info->audio_held;
447 if (!strcmp(args.param, "rtp")) {
448 res = channel_read_rtp(chan, rtp, direct_media_addr, secure, held,
449 args.type, args.field, buf, len);
450 } else {
451 res = channel_read_rtcp(chan, rtp, args.type, args.field, buf, len);
452 }
453 }
454 } else {
455 res = -1;
456 }
457 ast_channel_unlock(chan);
458 return res;
459}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
#define ast_log
Definition astobj2.c:42
static const char type[]
const char * ast_channel_name(const struct ast_channel *chan)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition channel.h:2983
#define ast_channel_unlock(chan)
Definition channel.h:2984
struct pjsip_channel_info * pjsip_channel_info_get(struct ast_channel *chan)
Find the channel's information, or NULL if it has none.
@ AST_MEDIA_TYPE_AUDIO
Definition codec.h:32
@ AST_MEDIA_TYPE_VIDEO
Definition codec.h:33
static int channel_read_rtcp(struct ast_channel *chan, struct ast_rtp_instance *rtp, const char *type, const char *field, char *buf, size_t buflen)
static int channel_read_pjsip(struct ast_channel *chan, struct ast_sip_session *session, const char *type, char *buf, size_t len)
static int channel_read_rtp(struct ast_channel *chan, struct ast_rtp_instance *rtp, const struct ast_sockaddr *direct_media_addr, unsigned int secure, unsigned int held, const char *type, const char *field, char *buf, size_t buflen)
char buf[BUFSIZE]
Definition eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_ERROR
#define LOG_WARNING
static struct @523 args
#define NULL
Definition resample.c:96
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition sorcery.c:2381
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition strings.h:80
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
struct ast_sip_session_media * default_session[AST_MEDIA_TYPE_END]
Default media sessions for each type.
A structure containing SIP session media information.
struct ast_sockaddr direct_media_addr
Direct media address.
struct ast_sip_contact * contact
struct ast_sip_endpoint * endpoint
struct ast_sip_session_media_state * active_media_state
struct ast_sip_aor * aor
Socket address structure.
Definition netsock2.h:97

References ast_sip_session::active_media_state, ast_sip_session::aor, args, AST_APP_ARG, ast_channel_lock, ast_channel_name(), ast_channel_tech_pvt(), ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, ast_sorcery_object_get_id(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), buf, channel_read_pjsip(), channel_read_rtcp(), channel_read_rtp(), ast_sip_session::contact, ast_sip_session_media_state::default_session, ast_sip_session_media::direct_media_addr, ast_sip_session::endpoint, len(), LOG_ERROR, LOG_WARNING, NULL, pjsip_channel_info_get(), S_OR, ast_sip_channel_pvt::session, and type.

◆ pjsip_acf_dial_contacts_read()

int pjsip_acf_dial_contacts_read ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)

PJSIP_DIAL_CONTACTS function read callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on failure

Definition at line 461 of file dialplan_functions.c.

462{
463 RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
464 RAII_VAR(struct ast_str *, dial, NULL, ast_free_ptr);
465 const char *aor_name;
466 char *rest;
467
469 AST_APP_ARG(endpoint_name);
470 AST_APP_ARG(aor_name);
471 AST_APP_ARG(request_user);
472 );
473
475
476 if (ast_strlen_zero(args.endpoint_name)) {
477 ast_log(LOG_WARNING, "An endpoint name must be specified when using the '%s' dialplan function\n", cmd);
478 return -1;
479 } else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", args.endpoint_name))) {
480 ast_log(LOG_WARNING, "Specified endpoint '%s' was not found\n", args.endpoint_name);
481 return -1;
482 }
483
484 aor_name = S_OR(args.aor_name, endpoint->aors);
485
486 if (ast_strlen_zero(aor_name)) {
487 ast_log(LOG_WARNING, "No AOR has been provided and no AORs are configured on endpoint '%s'\n", args.endpoint_name);
488 return -1;
489 } else if (!(dial = ast_str_create(len))) {
490 ast_log(LOG_WARNING, "Could not get enough buffer space for dialing contacts\n");
491 return -1;
492 } else if (!(rest = ast_strdupa(aor_name))) {
493 ast_log(LOG_WARNING, "Could not duplicate provided AORs\n");
494 return -1;
495 }
496
497 while ((aor_name = ast_strip(strsep(&rest, ",")))) {
499 RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
500 struct ao2_iterator it_contacts;
501 struct ast_sip_contact *contact;
502
503 if (!aor) {
504 /* If the AOR provided is not found skip it, there may be more */
505 continue;
507 /* No contacts are available, skip it as well */
508 continue;
509 } else if (!ao2_container_count(contacts)) {
510 /* We were given a container but no contacts are in it... */
511 continue;
512 }
513
514 it_contacts = ao2_iterator_init(contacts, 0);
515 for (; (contact = ao2_iterator_next(&it_contacts)); ao2_ref(contact, -1)) {
516 ast_str_append(&dial, -1, "PJSIP/");
517
518 if (!ast_strlen_zero(args.request_user)) {
519 ast_str_append(&dial, -1, "%s@", args.request_user);
520 }
521 ast_str_append(&dial, -1, "%s/%s&", args.endpoint_name, contact->uri);
522 }
523 ao2_iterator_destroy(&it_contacts);
524 }
525
526 /* Trim the '&' at the end off */
527 ast_str_truncate(dial, ast_str_strlen(dial) - 1);
528
530
531 return 0;
532}
char * strsep(char **str, const char *delims)
void ast_free_ptr(void *ptr)
free() wrapper
Definition astmm.c:1739
#define ao2_iterator_next(iter)
Definition astobj2.h:1911
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_cleanup(obj)
Definition astobj2.h:1934
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition location.c:147
@ AST_SIP_CONTACT_FILTER_REACHABLE
Return only reachable or unknown contacts.
Definition res_pjsip.h:1443
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
struct ao2_container * ast_sip_location_retrieve_aor_contacts_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve all contacts currently available for an AOR and filter based on flags.
Definition location.c:252
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition sorcery.c:1917
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
Definition strings.h:786
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition strings.h:730
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition strings.h:223
Generic container type.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition astobj2.h:1821
A SIP address of record.
Definition res_pjsip.h:480
Contact associated with an address of record.
Definition res_pjsip.h:392
const ast_string_field uri
Definition res_pjsip.h:414
const ast_string_field aor
Definition res_pjsip.h:414
An entity with which Asterisk communicates.
Definition res_pjsip.h:1067
Support for dynamic strings.
Definition strings.h:623
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981

References ao2_cleanup, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_sip_contact::aor, args, AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_free_ptr(), ast_log, AST_SIP_CONTACT_FILTER_REACHABLE, ast_sip_get_sorcery(), ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_aor_contacts_filtered(), ast_sorcery_retrieve_by_id(), AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_strlen(), ast_str_truncate(), ast_strdupa, ast_strip(), ast_strlen_zero(), buf, len(), LOG_WARNING, NULL, RAII_VAR, S_OR, strsep(), and ast_sip_contact::uri.

◆ pjsip_acf_dtmf_mode_read()

int pjsip_acf_dtmf_mode_read ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)

PJSIP_DTMF_MODE function read callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on failure

Definition at line 929 of file dialplan_functions.c.

930{
931 struct ast_sip_channel_pvt *channel;
932
933 if (!chan) {
934 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
935 return -1;
936 }
937
938 ast_channel_lock(chan);
939 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
940 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
941 ast_channel_unlock(chan);
942 return -1;
943 }
944
945 channel = ast_channel_tech_pvt(chan);
946
947 if (ast_sip_dtmf_to_str(channel->session->dtmf, buf, len) < 0) {
948 ast_log(LOG_WARNING, "Unknown DTMF mode %d on PJSIP channel %s\n", channel->session->dtmf, ast_channel_name(chan));
949 ast_channel_unlock(chan);
950 return -1;
951 }
952
953 ast_channel_unlock(chan);
954 return 0;
955}
int ast_sip_dtmf_to_str(const enum ast_sip_dtmf_mode dtmf, char *buf, size_t buf_len)
Convert the DTMF mode enum value into a string.
Definition res_pjsip.c:2524
enum ast_sip_dtmf_mode dtmf

References ast_channel_lock, ast_channel_name(), ast_channel_tech_pvt(), ast_channel_unlock, ast_log, ast_sip_dtmf_to_str(), buf, ast_sip_session::dtmf, len(), LOG_WARNING, ast_sip_channel_pvt::session, and type.

◆ pjsip_acf_dtmf_mode_write()

int pjsip_acf_dtmf_mode_write ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_DTMF_MODE function write callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on failure

Definition at line 1030 of file dialplan_functions.c.

1031{
1032 struct ast_sip_channel_pvt *channel;
1033 struct ast_sip_session_media *media;
1034 int dsp_features = 0;
1035 int dtmf = -1;
1036 struct refresh_data rdata = {
1038 };
1039
1040 if (!chan) {
1041 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1042 return -1;
1043 }
1044
1045 ast_channel_lock(chan);
1046 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1047 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1048 ast_channel_unlock(chan);
1049 return -1;
1050 }
1051
1052 channel = ast_channel_tech_pvt(chan);
1053 rdata.session = channel->session;
1054
1055 dtmf = ast_sip_str_to_dtmf(value);
1056
1057 if (dtmf == -1) {
1058 ast_log(LOG_WARNING, "Cannot set DTMF mode to '%s' on channel '%s' as value is invalid.\n", value,
1059 ast_channel_name(chan));
1060 ast_channel_unlock(chan);
1061 return -1;
1062 }
1063
1064 if (channel->session->dtmf == dtmf) {
1065 /* DTMF mode unchanged, nothing to do! */
1066 ast_channel_unlock(chan);
1067 return 0;
1068 }
1069
1070 channel->session->dtmf = dtmf;
1071
1073
1074 if (media && media->rtp) {
1075 if (channel->session->dtmf == AST_SIP_DTMF_RFC_4733) {
1078 } else if (channel->session->dtmf == AST_SIP_DTMF_INFO) {
1081 } else if (channel->session->dtmf == AST_SIP_DTMF_INBAND) {
1084 } else if (channel->session->dtmf == AST_SIP_DTMF_NONE) {
1087 } else if (channel->session->dtmf == AST_SIP_DTMF_AUTO) {
1089 /* no RFC4733 negotiated, enable inband */
1091 }
1092 } else if (channel->session->dtmf == AST_SIP_DTMF_AUTO_INFO) {
1095 /* if inband, switch to INFO */
1097 }
1098 }
1099 }
1100
1101 if (channel->session->dsp) {
1102 dsp_features = ast_dsp_get_features(channel->session->dsp);
1103 }
1104 if (channel->session->dtmf == AST_SIP_DTMF_INBAND ||
1105 channel->session->dtmf == AST_SIP_DTMF_AUTO) {
1106 dsp_features |= DSP_FEATURE_DIGIT_DETECT;
1107 } else {
1108 dsp_features &= ~DSP_FEATURE_DIGIT_DETECT;
1109 }
1110 if (dsp_features) {
1111 if (!channel->session->dsp) {
1112 if (!(channel->session->dsp = ast_dsp_new())) {
1113 ast_channel_unlock(chan);
1114 return 0;
1115 }
1116 }
1117 ast_dsp_set_features(channel->session->dsp, dsp_features);
1118 } else if (channel->session->dsp) {
1119 ast_dsp_free(channel->session->dsp);
1120 channel->session->dsp = NULL;
1121 }
1122
1123 ast_channel_unlock(chan);
1124
1126}
static int dtmf_mode_refresh_cb(void *obj)
void ast_dsp_free(struct ast_dsp *dsp)
Definition dsp.c:1968
#define DSP_FEATURE_DIGIT_DETECT
Definition dsp.h:28
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
Definition dsp.c:1962
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
Definition dsp.c:1953
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
Definition dsp.c:1943
#define ast_sip_push_task_wait_serializer(serializer, sip_task, task_data)
Definition res_pjsip.h:2221
@ AST_SIP_DTMF_NONE
Definition res_pjsip.h:549
@ AST_SIP_DTMF_AUTO_INFO
Definition res_pjsip.h:560
@ AST_SIP_DTMF_AUTO
Definition res_pjsip.h:558
@ AST_SIP_DTMF_INBAND
Definition res_pjsip.h:554
@ AST_SIP_DTMF_INFO
Definition res_pjsip.h:556
@ AST_SIP_DTMF_RFC_4733
Definition res_pjsip.h:552
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
Definition res_pjsip.c:2553
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
Definition res_pjsip.h:717
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
@ AST_RTP_DTMF_MODE_RFC2833
Definition rtp_engine.h:155
@ AST_RTP_DTMF_MODE_INBAND
Definition rtp_engine.h:157
@ AST_RTP_DTMF_MODE_NONE
Definition rtp_engine.h:153
int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Set the DTMF mode that should be used.
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
Definition rtp_engine.c:756
@ AST_RTP_PROPERTY_DTMF
Definition rtp_engine.h:120
struct ast_rtp_instance * rtp
RTP instance itself.
struct ast_dsp * dsp
struct ast_taskprocessor * serializer
struct ast_sip_session * session
enum ast_sip_session_refresh_method method
int value
Definition syslog.c:37

References ast_sip_session::active_media_state, ast_channel_lock, ast_channel_name(), ast_channel_tech_pvt(), ast_channel_unlock, ast_dsp_free(), ast_dsp_get_features(), ast_dsp_new(), ast_dsp_set_features(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_RTP_DTMF_MODE_INBAND, AST_RTP_DTMF_MODE_NONE, AST_RTP_DTMF_MODE_RFC2833, ast_rtp_instance_dtmf_mode_get(), ast_rtp_instance_dtmf_mode_set(), ast_rtp_instance_set_prop(), AST_RTP_PROPERTY_DTMF, AST_SIP_DTMF_AUTO, AST_SIP_DTMF_AUTO_INFO, AST_SIP_DTMF_INBAND, AST_SIP_DTMF_INFO, AST_SIP_DTMF_NONE, AST_SIP_DTMF_RFC_4733, ast_sip_push_task_wait_serializer, AST_SIP_SESSION_REFRESH_METHOD_INVITE, ast_sip_str_to_dtmf(), ast_sip_session_media_state::default_session, ast_sip_session::dsp, DSP_FEATURE_DIGIT_DETECT, ast_sip_session::dtmf, dtmf_mode_refresh_cb(), LOG_WARNING, refresh_data::method, NULL, ast_sip_session_media::rtp, ast_sip_session::serializer, refresh_data::session, ast_sip_channel_pvt::session, type, and value.

◆ pjsip_acf_media_offer_read()

int pjsip_acf_media_offer_read ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)

PJSIP_MEDIA_OFFER function read callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on failure

Definition at line 872 of file dialplan_functions.c.

873{
874 struct ast_sip_channel_pvt *channel;
875
876 if (!chan) {
877 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
878 return -1;
879 }
880
881 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
882 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
883 return -1;
884 }
885
886 channel = ast_channel_tech_pvt(chan);
887
888 if (!strcmp(data, "audio")) {
890 } else if (!strcmp(data, "video")) {
892 } else {
893 /* Ensure that the buffer is empty */
894 buf[0] = '\0';
895 }
896
897 return 0;
898}
static int media_offer_read_av(struct ast_sip_session *session, char *buf, size_t len, enum ast_media_type media_type)

References ast_channel_tech_pvt(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, buf, len(), LOG_WARNING, media_offer_read_av(), ast_sip_channel_pvt::session, and type.

◆ pjsip_acf_media_offer_write()

int pjsip_acf_media_offer_write ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_MEDIA_OFFER function write callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on failure

Definition at line 900 of file dialplan_functions.c.

901{
902 struct ast_sip_channel_pvt *channel;
903 struct media_offer_data mdata = {
904 .value = value
905 };
906
907 if (!chan) {
908 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
909 return -1;
910 }
911
912 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
913 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
914 return -1;
915 }
916
917 channel = ast_channel_tech_pvt(chan);
918 mdata.session = channel->session;
919
920 if (!strcmp(data, "audio")) {
922 } else if (!strcmp(data, "video")) {
924 }
925
927}
static int media_offer_write_av(void *obj)
enum ast_media_type media_type
struct ast_sip_session * session

References ast_channel_tech_pvt(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, ast_sip_push_task_wait_serializer, LOG_WARNING, media_offer_write_av(), media_offer_data::media_type, ast_sip_session::serializer, media_offer_data::session, ast_sip_channel_pvt::session, type, media_offer_data::value, and value.

◆ pjsip_acf_moh_passthrough_read()

int pjsip_acf_moh_passthrough_read ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)

PJSIP_MOH_PASSTHROUGH function read callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on failure

Definition at line 957 of file dialplan_functions.c.

958{
959 struct ast_sip_channel_pvt *channel;
960
961 if (!chan) {
962 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
963 return -1;
964 }
965
966 if (len < 3) {
967 ast_log(LOG_WARNING, "%s: buffer too small\n", cmd);
968 return -1;
969 }
970
971 ast_channel_lock(chan);
972 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
973 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
974 ast_channel_unlock(chan);
975 return -1;
976 }
977
978 channel = ast_channel_tech_pvt(chan);
979 strncpy(buf, AST_YESNO(channel->session->moh_passthrough), len);
980
981 ast_channel_unlock(chan);
982 return 0;
983}
#define AST_YESNO(x)
return Yes or No depending on the argument.
Definition strings.h:143
unsigned int moh_passthrough

References ast_channel_lock, ast_channel_tech_pvt(), ast_channel_unlock, ast_log, AST_YESNO, buf, len(), LOG_WARNING, ast_sip_session::moh_passthrough, ast_sip_channel_pvt::session, and type.

◆ pjsip_acf_moh_passthrough_write()

int pjsip_acf_moh_passthrough_write ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_MOH_PASSTHROUGH function write callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on failure

Definition at line 1128 of file dialplan_functions.c.

1129{
1130 struct ast_sip_channel_pvt *channel;
1131
1132 if (!chan) {
1133 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1134 return -1;
1135 }
1136
1137 ast_channel_lock(chan);
1138 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1139 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1140 ast_channel_unlock(chan);
1141 return -1;
1142 }
1143
1144 channel = ast_channel_tech_pvt(chan);
1146
1147 ast_channel_unlock(chan);
1148
1149 return 0;
1150}
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition utils.c:2233

References ast_channel_lock, ast_channel_tech_pvt(), ast_channel_unlock, ast_log, ast_true(), LOG_WARNING, ast_sip_session::moh_passthrough, ast_sip_channel_pvt::session, type, and value.

◆ pjsip_acf_parse_uri_read()

int pjsip_acf_parse_uri_read ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)

PJSIP_PARSE_URI function read callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on failure

Definition at line 675 of file dialplan_functions.c.

676{
677 struct parse_uri_args func_args = { 0, };
678 int reading_uri_from_var;
679
681 AST_APP_ARG(uri_str);
683 );
684
686
687 reading_uri_from_var = !strcasecmp(cmd, "PJSIP_PARSE_URI_FROM");
688
689 if (reading_uri_from_var) {
690 const char *var;
691
692 if (ast_strlen_zero(args.uri_str)) {
693 ast_log(LOG_WARNING, "The name of a variable containing a URI must be specified when using the '%s' dialplan function\n", cmd);
694 return -1;
695 }
696
697 ast_channel_lock(chan);
698 if ((var = pbx_builtin_getvar_helper(chan, args.uri_str))) {
699 args.uri_str = ast_strdupa(var);
700 }
701 ast_channel_unlock(chan);
702 }
703
704 if (ast_strlen_zero(args.uri_str)) {
705 if (reading_uri_from_var) {
706 ast_log(LOG_WARNING, "The variable provided to the '%s' dialplan function must contain a URI\n", cmd);
707 } else {
708 ast_log(LOG_WARNING, "A URI must be specified when using the '%s' dialplan function\n", cmd);
709 }
710 return -1;
711 }
712
713 if (ast_strlen_zero(args.type)) {
714 ast_log(LOG_WARNING, "A type part of the URI must be specified when using the '%s' dialplan function\n", cmd);
715 return -1;
716 }
717
718 memset(buf, 0, buflen);
719
720 func_args.uri = args.uri_str;
721 func_args.type = args.type;
722 func_args.buf = buf;
723 func_args.buflen = buflen;
725 ast_log(LOG_WARNING, "Unable to parse URI: failed to push task\n");
726 return -1;
727 }
728
729 return func_args.ret;
730}
#define var
Definition ast_expr2f.c:605
static int parse_uri_cb(void *data)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static char * func_args(char *function)
return a pointer to the arguments of the function, and terminates the function name with '\0'
Struct used to push PJSIP_PARSE_URI function arguments to task processor.

References args, AST_APP_ARG, ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, ast_log, ast_sip_push_task_wait_serializer, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), buf, parse_uri_args::buflen, func_args(), LOG_WARNING, NULL, parse_uri_cb(), pbx_builtin_getvar_helper(), type, and var.

◆ pjsip_acf_session_refresh_write()

int pjsip_acf_session_refresh_write ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_SEND_SESSION_REFRESH function write callback.

Parameters
chanThe channel the function is called on
cmdthe Name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on failure

Definition at line 1171 of file dialplan_functions.c.

1172{
1173 struct ast_sip_channel_pvt *channel;
1174 struct refresh_data rdata = {
1176 };
1177
1178 if (!chan) {
1179 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1180 return -1;
1181 }
1182
1183 if (ast_channel_state(chan) != AST_STATE_UP) {
1184 ast_log(LOG_WARNING, "'%s' not allowed on unanswered channel '%s'.\n", cmd, ast_channel_name(chan));
1185 return -1;
1186 }
1187
1188 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1189 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1190 return -1;
1191 }
1192
1193 channel = ast_channel_tech_pvt(chan);
1194 rdata.session = channel->session;
1195
1196 if (!strcmp(value, "invite")) {
1198 } else if (!strcmp(value, "update")) {
1200 }
1201
1203}
ast_channel_state
ast_channel states
@ AST_STATE_UP
static int refresh_write_cb(void *obj)
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
Definition res_pjsip.h:719

References ast_channel_name(), ast_channel_tech_pvt(), ast_log, ast_sip_push_task_wait_serializer, AST_SIP_SESSION_REFRESH_METHOD_INVITE, AST_SIP_SESSION_REFRESH_METHOD_UPDATE, AST_STATE_UP, LOG_WARNING, refresh_data::method, refresh_write_cb(), ast_sip_session::serializer, refresh_data::session, ast_sip_channel_pvt::session, type, and value.

◆ pjsip_action_hangup()

int pjsip_action_hangup ( struct mansession *  s,
const struct message *  m 
)

Manager action to hang up an incoming PJSIP channel with a SIP response code.

Parameters
ssession
mmessage
Return values
0on success
-1on failure

Manager action to hang up an incoming PJSIP channel with a SIP response code.

Definition at line 1317 of file dialplan_functions.c.

1318{
1319 return ast_manager_hangup_helper(s, m,
1321}
static int response_code_validator(const char *channel_name, const char *response)
Callback that validates the response code.
static void pjsip_app_hangup_handler(struct ast_channel *chan, int response_code)
Called by pjsip_app_hangup and pjsip_action_hangup to actually perform the hangup.
int ast_manager_hangup_helper(struct mansession *s, const struct message *m, manager_hangup_handler_t handler, manager_hangup_cause_validator_t cause_validator)
A manager helper function that hangs up a channel using a supplied channel type specific hangup funct...
Definition manager.c:3469

References ast_manager_hangup_helper(), pjsip_app_hangup_handler(), and response_code_validator().

Referenced by load_module().

◆ pjsip_app_hangup()

int pjsip_app_hangup ( struct ast_channel *  chan,
const char *  data 
)

Hang up an incoming PJSIP channel with a SIP response code.

Parameters
chanThe channel the function is called on
dataSIP response code or name
Return values
0on success
-1on failure

Hang up an incoming PJSIP channel with a SIP response code.

Definition at line 1297 of file dialplan_functions.c.

1298{
1299 int response_code;
1300 const char *tag = ast_channel_name(chan);
1301
1302 if (ast_strlen_zero(data)) {
1303 ast_log(LOG_WARNING, "%s: Missing response code parameter\n", tag);
1304 return -1;
1305 }
1306
1307 response_code = response_code_validator(tag, data);
1308
1309 pjsip_app_hangup_handler(chan, response_code);
1310
1311 return -1;
1312}

References ast_channel_name(), ast_log, ast_strlen_zero(), hangup_data::chan, LOG_WARNING, pjsip_app_hangup_handler(), hangup_data::response_code, and response_code_validator().

Referenced by load_module().

◆ pjsip_transfer_handling_write()

int pjsip_transfer_handling_write ( struct ast_channel *  chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_TRANSFER_HANDLING function write callback.

Parameters
chanThe channel the function is called on
cmdthe Name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on failure

Definition at line 1323 of file dialplan_functions.c.

1324{
1325 struct ast_sip_channel_pvt *channel;
1326 int ret = 0;
1327
1328 if (!chan) {
1329 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1330 return -1;
1331 }
1332
1333 ast_channel_lock(chan);
1334 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1335 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel %s\n", cmd, ast_channel_name(chan));
1336 ast_channel_unlock(chan);
1337 return -1;
1338 }
1339
1340 channel = ast_channel_tech_pvt(chan);
1341
1342 if (ast_strlen_zero(value) || !strcmp(value, "core")) {
1343 channel->session->transferhandling_ari = 0;
1344 } else if (!strcmp(value, "ari-only")) {
1345 channel->session->transferhandling_ari = 1;
1346 } else {
1347 ast_log(AST_LOG_WARNING, "Cannot set unknown transfer handling '%s' on channel '%s', transfer handling will remain unchanged.",
1348 value, ast_channel_name(chan));
1349 ret = -1;
1350 }
1351
1352 ast_channel_unlock(chan);
1353 return ret;
1354}
#define AST_LOG_WARNING
unsigned int transferhandling_ari

References ast_channel_lock, ast_channel_name(), ast_channel_tech_pvt(), ast_channel_unlock, ast_log, AST_LOG_WARNING, ast_strlen_zero(), LOG_WARNING, ast_sip_channel_pvt::session, ast_sip_session::transferhandling_ari, type, and value.