Asterisk - The Open Source Telephony Project GIT-master-1f1c5bb
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. More...
 
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. More...
 
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. More...
 
int pjsip_acf_dtmf_mode_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_DTMF_MODE function write callback. More...
 
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. More...
 
int pjsip_acf_media_offer_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_MEDIA_OFFER function write callback. More...
 
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. More...
 
int pjsip_acf_moh_passthrough_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 PJSIP_MOH_PASSTHROUGH function write callback. More...
 
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. More...
 
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. More...
 
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. More...
 
int pjsip_app_hangup (struct ast_channel *chan, const char *data)
 Hang up an incoming PJSIP channel with a SIP response code. More...
 

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 443 of file dialplan_functions.c.

444{
445 struct pjsip_func_args func_args = { 0, };
446 struct ast_sip_channel_pvt *channel;
447 char *parse = ast_strdupa(data);
448
450 AST_APP_ARG(param);
452 AST_APP_ARG(field);
453 );
454
455 if (!chan) {
456 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
457 return -1;
458 }
459
460 /* Check for zero arguments */
461 if (ast_strlen_zero(parse)) {
462 ast_log(LOG_ERROR, "Cannot call %s without arguments\n", cmd);
463 return -1;
464 }
465
467
468 ast_channel_lock(chan);
469
470 /* Sanity check */
471 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
472 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
473 ast_channel_unlock(chan);
474 return 0;
475 }
476
477 channel = ast_channel_tech_pvt(chan);
478 if (!channel) {
479 ast_log(LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(chan));
480 ast_channel_unlock(chan);
481 return -1;
482 }
483
484 if (!channel->session) {
485 ast_log(LOG_WARNING, "Channel %s has no session\n", ast_channel_name(chan));
486 ast_channel_unlock(chan);
487 return -1;
488 }
489
490 func_args.session = ao2_bump(channel->session);
491 ast_channel_unlock(chan);
492
493 memset(buf, 0, len);
494
495 func_args.param = args.param;
496 func_args.type = args.type;
497 func_args.field = args.field;
498 func_args.buf = buf;
499 func_args.len = len;
501 ast_log(LOG_WARNING, "Unable to read properties of channel %s: failed to push task\n", ast_channel_name(chan));
502 ao2_ref(func_args.session, -1);
503 return -1;
504 }
505 ao2_ref(func_args.session, -1);
506
507 return func_args.ret;
508}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
static const char type[]
Definition: chan_ooh323.c:109
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:2922
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2923
static int read_pjsip(void *data)
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)
int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to the serializer and wait for it to complete.
Definition: res_pjsip.c:2179
#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 char * func_args(char *function)
return a pointer to the arguments of the function, and terminates the function name with '\0'
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Struct used to push function arguments to task processor.
const char * args

References ao2_bump, ao2_ref, args, AST_APP_ARG, ast_channel_lock, ast_channel_name(), ast_channel_tech(), ast_channel_tech_pvt(), 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, func_args(), len(), LOG_ERROR, LOG_WARNING, read_pjsip(), 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 510 of file dialplan_functions.c.

511{
512 RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
513 RAII_VAR(struct ast_str *, dial, NULL, ast_free_ptr);
514 const char *aor_name;
515 char *rest;
516
518 AST_APP_ARG(endpoint_name);
519 AST_APP_ARG(aor_name);
520 AST_APP_ARG(request_user);
521 );
522
524
525 if (ast_strlen_zero(args.endpoint_name)) {
526 ast_log(LOG_WARNING, "An endpoint name must be specified when using the '%s' dialplan function\n", cmd);
527 return -1;
528 } else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", args.endpoint_name))) {
529 ast_log(LOG_WARNING, "Specified endpoint '%s' was not found\n", args.endpoint_name);
530 return -1;
531 }
532
533 aor_name = S_OR(args.aor_name, endpoint->aors);
534
535 if (ast_strlen_zero(aor_name)) {
536 ast_log(LOG_WARNING, "No AOR has been provided and no AORs are configured on endpoint '%s'\n", args.endpoint_name);
537 return -1;
538 } else if (!(dial = ast_str_create(len))) {
539 ast_log(LOG_WARNING, "Could not get enough buffer space for dialing contacts\n");
540 return -1;
541 } else if (!(rest = ast_strdupa(aor_name))) {
542 ast_log(LOG_WARNING, "Could not duplicate provided AORs\n");
543 return -1;
544 }
545
546 while ((aor_name = ast_strip(strsep(&rest, ",")))) {
548 RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
549 struct ao2_iterator it_contacts;
550 struct ast_sip_contact *contact;
551
552 if (!aor) {
553 /* If the AOR provided is not found skip it, there may be more */
554 continue;
556 /* No contacts are available, skip it as well */
557 continue;
558 } else if (!ao2_container_count(contacts)) {
559 /* We were given a container but no contacts are in it... */
560 continue;
561 }
562
563 it_contacts = ao2_iterator_init(contacts, 0);
564 for (; (contact = ao2_iterator_next(&it_contacts)); ao2_ref(contact, -1)) {
565 ast_str_append(&dial, -1, "PJSIP/");
566
567 if (!ast_strlen_zero(args.request_user)) {
568 ast_str_append(&dial, -1, "%s@", args.request_user);
569 }
570 ast_str_append(&dial, -1, "%s/%s&", args.endpoint_name, contact->uri);
571 }
572 ao2_iterator_destroy(&it_contacts);
573 }
574
575 /* Trim the '&' at the end off */
576 ast_str_truncate(dial, ast_str_strlen(dial) - 1);
577
579
580 return 0;
581}
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.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
char * strsep(char **str, const char *delims)
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:1306
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
#define NULL
Definition: resample.c:96
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:1853
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
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#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
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
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:478
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:963
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:941

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 956 of file dialplan_functions.c.

957{
958 struct ast_sip_channel_pvt *channel;
959
960 if (!chan) {
961 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
962 return -1;
963 }
964
965 ast_channel_lock(chan);
966 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
967 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
968 ast_channel_unlock(chan);
969 return -1;
970 }
971
972 channel = ast_channel_tech_pvt(chan);
973
974 if (ast_sip_dtmf_to_str(channel->session->dtmf, buf, len) < 0) {
975 ast_log(LOG_WARNING, "Unknown DTMF mode %d on PJSIP channel %s\n", channel->session->dtmf, ast_channel_name(chan));
976 ast_channel_unlock(chan);
977 return -1;
978 }
979
980 ast_channel_unlock(chan);
981 return 0;
982}
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:2504
enum ast_sip_dtmf_mode dtmf

References ast_channel_lock, ast_channel_name(), ast_channel_tech(), 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 1057 of file dialplan_functions.c.

1058{
1059 struct ast_sip_channel_pvt *channel;
1060 struct ast_sip_session_media *media;
1061 int dsp_features = 0;
1062 int dtmf = -1;
1063 struct refresh_data rdata = {
1065 };
1066
1067 if (!chan) {
1068 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1069 return -1;
1070 }
1071
1072 ast_channel_lock(chan);
1073 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1074 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1075 ast_channel_unlock(chan);
1076 return -1;
1077 }
1078
1079 channel = ast_channel_tech_pvt(chan);
1080 rdata.session = channel->session;
1081
1082 dtmf = ast_sip_str_to_dtmf(value);
1083
1084 if (dtmf == -1) {
1085 ast_log(LOG_WARNING, "Cannot set DTMF mode to '%s' on channel '%s' as value is invalid.\n", value,
1086 ast_channel_name(chan));
1087 ast_channel_unlock(chan);
1088 return -1;
1089 }
1090
1091 if (channel->session->dtmf == dtmf) {
1092 /* DTMF mode unchanged, nothing to do! */
1093 ast_channel_unlock(chan);
1094 return 0;
1095 }
1096
1097 channel->session->dtmf = dtmf;
1098
1100
1101 if (media && media->rtp) {
1102 if (channel->session->dtmf == AST_SIP_DTMF_RFC_4733) {
1105 } else if (channel->session->dtmf == AST_SIP_DTMF_INFO) {
1108 } else if (channel->session->dtmf == AST_SIP_DTMF_INBAND) {
1111 } else if (channel->session->dtmf == AST_SIP_DTMF_NONE) {
1114 } else if (channel->session->dtmf == AST_SIP_DTMF_AUTO) {
1116 /* no RFC4733 negotiated, enable inband */
1118 }
1119 } else if (channel->session->dtmf == AST_SIP_DTMF_AUTO_INFO) {
1122 /* if inband, switch to INFO */
1124 }
1125 }
1126 }
1127
1128 if (channel->session->dsp) {
1129 dsp_features = ast_dsp_get_features(channel->session->dsp);
1130 }
1131 if (channel->session->dtmf == AST_SIP_DTMF_INBAND ||
1132 channel->session->dtmf == AST_SIP_DTMF_AUTO) {
1133 dsp_features |= DSP_FEATURE_DIGIT_DETECT;
1134 } else {
1135 dsp_features &= ~DSP_FEATURE_DIGIT_DETECT;
1136 }
1137 if (dsp_features) {
1138 if (!channel->session->dsp) {
1139 if (!(channel->session->dsp = ast_dsp_new())) {
1140 ast_channel_unlock(chan);
1141 return 0;
1142 }
1143 }
1144 ast_dsp_set_features(channel->session->dsp, dsp_features);
1145 } else if (channel->session->dsp) {
1146 ast_dsp_free(channel->session->dsp);
1147 channel->session->dsp = NULL;
1148 }
1149
1150 ast_channel_unlock(chan);
1151
1153}
@ AST_MEDIA_TYPE_AUDIO
Definition: codec.h:32
static int dtmf_mode_refresh_cb(void *obj)
void ast_dsp_free(struct ast_dsp *dsp)
Definition: dsp.c:1783
#define DSP_FEATURE_DIGIT_DETECT
Definition: dsp.h:28
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
Definition: dsp.c:1777
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
Definition: dsp.c:1768
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
Definition: dsp.c:1758
@ AST_SIP_DTMF_NONE
Definition: res_pjsip.h:545
@ AST_SIP_DTMF_AUTO_INFO
Definition: res_pjsip.h:556
@ AST_SIP_DTMF_AUTO
Definition: res_pjsip.h:554
@ AST_SIP_DTMF_INBAND
Definition: res_pjsip.h:550
@ AST_SIP_DTMF_INFO
Definition: res_pjsip.h:552
@ AST_SIP_DTMF_RFC_4733
Definition: res_pjsip.h:548
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
Definition: res_pjsip.c:2533
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
Definition: res_pjsip.h:627
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
Definition: rtp_engine.c:2150
@ AST_RTP_DTMF_MODE_RFC2833
Definition: rtp_engine.h:152
@ AST_RTP_DTMF_MODE_INBAND
Definition: rtp_engine.h:154
@ AST_RTP_DTMF_MODE_NONE
Definition: rtp_engine.h:150
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.
Definition: rtp_engine.c:2136
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:726
@ AST_RTP_PROPERTY_DTMF
Definition: rtp_engine.h:117
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_rtp_instance * rtp
RTP instance itself.
struct ast_sip_session_media_state * active_media_state
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(), 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 899 of file dialplan_functions.c.

900{
901 struct ast_sip_channel_pvt *channel;
902
903 if (!chan) {
904 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
905 return -1;
906 }
907
908 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
909 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
910 return -1;
911 }
912
913 channel = ast_channel_tech_pvt(chan);
914
915 if (!strcmp(data, "audio")) {
917 } else if (!strcmp(data, "video")) {
919 } else {
920 /* Ensure that the buffer is empty */
921 buf[0] = '\0';
922 }
923
924 return 0;
925}
@ AST_MEDIA_TYPE_VIDEO
Definition: codec.h:33
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(), 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 927 of file dialplan_functions.c.

928{
929 struct ast_sip_channel_pvt *channel;
930 struct media_offer_data mdata = {
931 .value = value
932 };
933
934 if (!chan) {
935 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
936 return -1;
937 }
938
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 return -1;
942 }
943
944 channel = ast_channel_tech_pvt(chan);
945 mdata.session = channel->session;
946
947 if (!strcmp(data, "audio")) {
949 } else if (!strcmp(data, "video")) {
951 }
952
954}
static int media_offer_write_av(void *obj)
enum ast_media_type media_type
struct ast_sip_session * session

References ast_channel_tech(), 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 984 of file dialplan_functions.c.

985{
986 struct ast_sip_channel_pvt *channel;
987
988 if (!chan) {
989 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
990 return -1;
991 }
992
993 if (len < 3) {
994 ast_log(LOG_WARNING, "%s: buffer too small\n", cmd);
995 return -1;
996 }
997
998 ast_channel_lock(chan);
999 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1000 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1001 ast_channel_unlock(chan);
1002 return -1;
1003 }
1004
1005 channel = ast_channel_tech_pvt(chan);
1006 strncpy(buf, AST_YESNO(channel->session->moh_passthrough), len);
1007
1008 ast_channel_unlock(chan);
1009 return 0;
1010}
#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(), 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 1155 of file dialplan_functions.c.

1156{
1157 struct ast_sip_channel_pvt *channel;
1158
1159 if (!chan) {
1160 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1161 return -1;
1162 }
1163
1164 ast_channel_lock(chan);
1165 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1166 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1167 ast_channel_unlock(chan);
1168 return -1;
1169 }
1170
1171 channel = ast_channel_tech_pvt(chan);
1173
1174 ast_channel_unlock(chan);
1175
1176 return 0;
1177}
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:2199

References ast_channel_lock, ast_channel_tech(), 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 724 of file dialplan_functions.c.

725{
726 struct parse_uri_args func_args = { 0, };
727
729 AST_APP_ARG(uri_str);
731 );
732
734
735 if (ast_strlen_zero(args.uri_str)) {
736 ast_log(LOG_WARNING, "An URI must be specified when using the '%s' dialplan function\n", cmd);
737 return -1;
738 }
739
740 if (ast_strlen_zero(args.type)) {
741 ast_log(LOG_WARNING, "A type part of the URI must be specified when using the '%s' dialplan function\n", cmd);
742 return -1;
743 }
744
745 memset(buf, 0, buflen);
746
747 func_args.uri = args.uri_str;
748 func_args.type = args.type;
749 func_args.buf = buf;
750 func_args.buflen = buflen;
752 ast_log(LOG_WARNING, "Unable to parse URI: failed to push task\n");
753 return -1;
754 }
755
756 return func_args.ret;
757}
static int parse_uri_cb(void *data)
Struct used to push PJSIP_PARSE_URI function arguments to task processor.

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

◆ 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 1198 of file dialplan_functions.c.

1199{
1200 struct ast_sip_channel_pvt *channel;
1201 struct refresh_data rdata = {
1203 };
1204
1205 if (!chan) {
1206 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1207 return -1;
1208 }
1209
1210 if (ast_channel_state(chan) != AST_STATE_UP) {
1211 ast_log(LOG_WARNING, "'%s' not allowed on unanswered channel '%s'.\n", cmd, ast_channel_name(chan));
1212 return -1;
1213 }
1214
1215 if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1216 ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1217 return -1;
1218 }
1219
1220 channel = ast_channel_tech_pvt(chan);
1221 rdata.session = channel->session;
1222
1223 if (!strcmp(value, "invite")) {
1225 } else if (!strcmp(value, "update")) {
1227 }
1228
1230}
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
static int refresh_write_cb(void *obj)
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
Definition: res_pjsip.h:629

References ast_channel_name(), ast_channel_tech(), 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 1344 of file dialplan_functions.c.

1345{
1346 return ast_manager_hangup_helper(s, m,
1348}
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:4762

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 1324 of file dialplan_functions.c.

1325{
1326 int response_code;
1327 const char *tag = ast_channel_name(chan);
1328
1329 if (ast_strlen_zero(data)) {
1330 ast_log(LOG_WARNING, "%s: Missing response code parameter\n", tag);
1331 return -1;
1332 }
1333
1334 response_code = response_code_validator(tag, data);
1335
1336 pjsip_app_hangup_handler(chan, response_code);
1337
1338 return -1;
1339}

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().