Asterisk - The Open Source Telephony Project GIT-master-7921072
pjsip_configuration.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013, Digium, Inc.
5 *
6 * Matt Jordan <mjordan@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19#include "asterisk.h"
20
21#include <pjsip.h>
22#include <pjsip_ua.h>
23
25#include "asterisk/res_pjsip.h"
28#include "asterisk/acl.h"
29#include "asterisk/manager.h"
30#include "asterisk/astobj2.h"
31#include "asterisk/utils.h"
32#include "asterisk/sorcery.h"
33#include "asterisk/callerid.h"
34#include "asterisk/test.h"
35#include "asterisk/statsd.h"
36#include "asterisk/pbx.h"
37#include "asterisk/stream.h"
38#include "asterisk/stasis.h"
41
42/*! \brief Number of buckets for persistent endpoint information */
43#define PERSISTENT_BUCKETS 53
44
45/*! \brief Persistent endpoint information */
47 /*! \brief Asterisk endpoint itself */
49};
50
51/*! \brief Container for persistent endpoint information */
53
54static struct ast_sorcery *sip_sorcery;
55
57
58/*! \brief Hashing function for persistent endpoint information */
59static int persistent_endpoint_hash(const void *obj, const int flags)
60{
61 const struct sip_persistent_endpoint *persistent = obj;
62 const char *id = (flags & OBJ_KEY ? obj : ast_endpoint_get_resource(persistent->endpoint));
63
64 return ast_str_hash(id);
65}
66
67/*! \brief Comparison function for persistent endpoint information */
68static int persistent_endpoint_cmp(void *obj, void *arg, int flags)
69{
70 const struct sip_persistent_endpoint *persistent1 = obj;
71 const struct sip_persistent_endpoint *persistent2 = arg;
72 const char *id = (flags & OBJ_KEY ? arg : ast_endpoint_get_resource(persistent2->endpoint));
73
74 return !strcmp(ast_endpoint_get_resource(persistent1->endpoint), id) ? CMP_MATCH | CMP_STOP : 0;
75}
76
77static void endpoint_deleted_observer(const void *object)
78{
79 const struct ast_sip_endpoint *endpoint = object;
80
83}
84
87};
88
89static int endpoint_acl_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
90{
91 struct ast_sip_endpoint *endpoint = obj;
92 int error = 0;
93 int ignore;
94
95 if (ast_strlen_zero(var->value)) return 0;
96
97 if (!strncmp(var->name, "contact_", 8)) {
98 ast_append_acl(var->name + 8, var->value, &endpoint->contact_acl, &error, &ignore);
99 } else {
100 ast_append_acl(var->name, var->value, &endpoint->acl, &error, &ignore);
101 }
102
103 return error;
104}
105
106static int acl_to_str(const void *obj, const intptr_t *args, char **buf)
107{
108 const struct ast_sip_endpoint *endpoint = obj;
109 struct ast_acl_list *acl_list;
110 struct ast_acl *first_acl;
111
112 if (endpoint && !ast_acl_list_is_empty(acl_list=endpoint->acl)) {
113 AST_LIST_LOCK(acl_list);
114 first_acl = AST_LIST_FIRST(acl_list);
115 if (ast_strlen_zero(first_acl->name)) {
116 *buf = "deny/permit";
117 } else {
118 *buf = first_acl->name;
119 }
120 AST_LIST_UNLOCK(acl_list);
121 }
122
123 *buf = ast_strdup(*buf);
124 return 0;
125}
126
127static int contact_acl_to_str(const void *obj, const intptr_t *args, char **buf)
128{
129 const struct ast_sip_endpoint *endpoint = obj;
130 struct ast_acl_list *acl_list;
131 struct ast_acl *first_acl;
132
133 if (endpoint && !ast_acl_list_is_empty(acl_list=endpoint->contact_acl)) {
134 AST_LIST_LOCK(acl_list);
135 first_acl = AST_LIST_FIRST(acl_list);
136 if (ast_strlen_zero(first_acl->name)) {
137 *buf = "deny/permit";
138 } else {
139 *buf = first_acl->name;
140 }
141 AST_LIST_UNLOCK(acl_list);
142 }
143
144 *buf = ast_strdup(*buf);
145 return 0;
146}
147
148static int dtmf_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
149{
150 struct ast_sip_endpoint *endpoint = obj;
151 int dtmf = ast_sip_str_to_dtmf(var->value);
152
153 if (dtmf == -1) {
154 return -1;
155 }
156
157 endpoint->dtmf = dtmf;
158 return 0;
159}
160
161static int dtmf_to_str(const void *obj, const intptr_t *args, char **buf)
162{
163 const struct ast_sip_endpoint *endpoint = obj;
164 char dtmf_str[20];
165 int result = -1;
166
167 result = ast_sip_dtmf_to_str(endpoint->dtmf, dtmf_str, sizeof(dtmf_str));
168
169 if (result == 0) {
170 *buf = ast_strdup(dtmf_str);
171 } else {
172 *buf = ast_strdup("none");
173 }
174 return 0;
175}
176
177static int prack_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
178{
179 struct ast_sip_endpoint *endpoint = obj;
180
181 /* clear all */
182 endpoint->extensions.flags &= ~(PJSIP_INV_SUPPORT_100REL | PJSIP_INV_REQUIRE_100REL);
183
184 if (ast_true(var->value)) {
185 endpoint->extensions.flags |= PJSIP_INV_SUPPORT_100REL;
187 } else if (!strcasecmp(var->value, "peer_supported")) {
188 endpoint->extensions.flags |= PJSIP_INV_SUPPORT_100REL;
190 } else if (!strcasecmp(var->value, "required")) {
191 endpoint->extensions.flags |= PJSIP_INV_REQUIRE_100REL;
193 } else if (ast_false(var->value)) {
195 } else {
196 return -1;
197 }
198
199 return 0;
200}
201
202static int prack_to_str(const void *obj, const intptr_t *args, char **buf)
203{
204 const struct ast_sip_endpoint *endpoint = obj;
205
206 if (endpoint->rel100 == AST_SIP_100REL_SUPPORTED) {
207 *buf = "yes";
208 } else if (endpoint->rel100 == AST_SIP_100REL_PEER_SUPPORTED) {
209 *buf = "peer_supported";
210 } else if (endpoint->rel100 == AST_SIP_100REL_REQUIRED) {
211 *buf = "required";
212 } else {
213 *buf = "no";
214 }
215
216 *buf = ast_strdup(*buf);
217 return 0;
218}
219
220static int timers_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
221{
222 struct ast_sip_endpoint *endpoint = obj;
223
224 /* clear all */
225 endpoint->extensions.flags &= ~(PJSIP_INV_SUPPORT_TIMER | PJSIP_INV_REQUIRE_TIMER
226 | PJSIP_INV_ALWAYS_USE_TIMER);
227
228 /* set only the specified flag and let pjsip normalize if needed */
229 if (ast_true(var->value)) {
230 endpoint->extensions.flags |= PJSIP_INV_SUPPORT_TIMER;
231 } else if (!strcasecmp(var->value, "required")) {
232 endpoint->extensions.flags |= PJSIP_INV_REQUIRE_TIMER;
233 } else if (!strcasecmp(var->value, "always") || !strcasecmp(var->value, "forced")) {
234 endpoint->extensions.flags |= (PJSIP_INV_SUPPORT_TIMER | PJSIP_INV_ALWAYS_USE_TIMER);
235 } else if (!ast_false(var->value)) {
236 return -1;
237 }
238
239 return 0;
240}
241
242static int timers_to_str(const void *obj, const intptr_t *args, char **buf)
243{
244 const struct ast_sip_endpoint *endpoint = obj;
245
246 if (endpoint->extensions.flags & PJSIP_INV_ALWAYS_USE_TIMER) {
247 *buf = "always";
248 } else if (endpoint->extensions.flags & PJSIP_INV_REQUIRE_TIMER) {
249 *buf = "required";
250 } else if (endpoint->extensions.flags & PJSIP_INV_SUPPORT_TIMER) {
251 *buf = "yes";
252 } else {
253 *buf = "no";
254 }
255
256 *buf = ast_strdup(*buf);
257 return 0;
258}
259
260static int security_mechanism_to_str(const void *obj, const intptr_t *args, char **buf)
261{
262 const struct ast_sip_endpoint *endpoint = obj;
263
265}
266
267static int security_mechanism_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
268{
269 struct ast_sip_endpoint *endpoint = obj;
270
272}
273
274static const char *security_negotiation_map[] = {
276 [AST_SIP_SECURITY_NEG_MEDIASEC] = "mediasec",
277};
278
279static int security_negotiation_to_str(const void *obj, const intptr_t *args, char **buf)
280{
281 const struct ast_sip_endpoint *endpoint = obj;
284 }
285 return 0;
286}
287
289 if (!strcasecmp("no", val)) {
291 } else if (!strcasecmp("mediasec", val)) {
293 } else {
294 return -1;
295 }
296 return 0;
297}
298
299static int security_negotiation_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
300{
301 struct ast_sip_endpoint *endpoint = obj;
302
304}
305
307{
308 int i;
309 size_t size;
310
311 if (!auths) {
312 return;
313 }
314
315 size = AST_VECTOR_SIZE(auths);
316
317 for (i = 0; i < size; ++i) {
318 const char *name = AST_VECTOR_REMOVE_UNORDERED(auths, 0);
319 ast_free((char *) name);
320 }
321 AST_VECTOR_FREE(auths);
322}
323
325{
326 char *auth_names = ast_strdupa(value);
327 char *val;
328
329 ast_assert(auths != NULL);
330
331 if (AST_VECTOR_SIZE(auths)) {
333 }
334 if (AST_VECTOR_INIT(auths, 1)) {
335 return -1;
336 }
337
338 while ((val = ast_strip(strsep(&auth_names, ",")))) {
339 if (ast_strlen_zero(val)) {
340 continue;
341 }
342
343 val = ast_strdup(val);
344 if (!val) {
345 goto failure;
346 }
347 if (AST_VECTOR_APPEND(auths, val)) {
348 ast_free(val);
349
350 goto failure;
351 }
352 }
353 return 0;
354
355failure:
357 return -1;
358}
359
360static int inbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
361{
362 struct ast_sip_endpoint *endpoint = obj;
363
364 return ast_sip_auth_vector_init(&endpoint->inbound_auths, var->value);
365}
366
367static int outbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
368{
369 struct ast_sip_endpoint *endpoint = obj;
370
371 return ast_sip_auth_vector_init(&endpoint->outbound_auths, var->value);
372}
373
374int ast_sip_auths_to_str(const struct ast_sip_auth_vector *auths, char **buf)
375{
376 if (!auths || !AST_VECTOR_SIZE(auths)) {
377 return 0;
378 }
379
380 if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
381 return -1;
382 }
383
384 /* I feel like accessing the vector's elem array directly is cheating...*/
386 return 0;
387}
388
389static int inbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
390{
391 const struct ast_sip_endpoint *endpoint = obj;
392 return ast_sip_auths_to_str(&endpoint->inbound_auths, buf);
393}
394
395static int outbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
396{
397 const struct ast_sip_endpoint *endpoint = obj;
398 return ast_sip_auths_to_str(&endpoint->outbound_auths, buf);
399}
400
401/*!
402 * \internal
403 * \brief Convert identify_by method to string.
404 *
405 * \param method Method value to convert to string
406 *
407 * \return String representation.
408 */
410{
411 const char *str = "<unknown>";
412
413 switch (method) {
415 str = "username";
416 break;
418 str = "auth_username";
419 break;
421 str = "ip";
422 break;
424 str = "header";
425 break;
427 str = "request_uri";
428 break;
430 str = "transport";
431 break;
432 }
433 return str;
434}
435
436/*!
437 * \internal
438 * \brief Convert string to an endpoint identifier token.
439 *
440 * \param str String to convert
441 *
442 * \retval enum ast_sip_endpoint_identifier_type token value on success.
443 * \retval -1 on failure.
444 */
446{
447 int method;
448
449 if (!strcasecmp(str, "username")) {
451 } else if (!strcasecmp(str, "auth_username")) {
453 } else if (!strcasecmp(str, "ip")) {
455 } else if (!strcasecmp(str, "header")) {
457 } else if (!strcasecmp(str, "request_uri")) {
459 } else if (!strcasecmp(str, "transport")) {
461 } else {
462 method = -1;
463 }
464 return method;
465}
466
467static int ident_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
468{
469 struct ast_sip_endpoint *endpoint = obj;
470 char *idents = ast_strdupa(var->value);
471 char *val;
472 int method;
473
474 /*
475 * If there's already something in the vector when we get here,
476 * it's the default value so we need to clean it out.
477 */
478 if (AST_VECTOR_SIZE(&endpoint->ident_method_order)) {
480 endpoint->ident_method = 0;
481 }
482
483 while ((val = ast_strip(strsep(&idents, ",")))) {
484 if (ast_strlen_zero(val)) {
485 continue;
486 }
487
489 if (method == -1) {
490 ast_log(LOG_ERROR, "Unrecognized identification method %s specified for endpoint %s\n",
491 val, ast_sorcery_object_get_id(endpoint));
493 endpoint->ident_method = 0;
494 return -1;
495 }
496 if (endpoint->ident_method & method) {
497 /* We are already identifying by this method. No need to do it again. */
498 continue;
499 }
500
501 endpoint->ident_method |= method;
503 }
504
505 return 0;
506}
507
508static int ident_to_str(const void *obj, const intptr_t *args, char **buf)
509{
510 const struct ast_sip_endpoint *endpoint = obj;
511 int methods;
512 int idx;
513 int buf_used = 0;
514 int buf_size = MAX_OBJECT_FIELD;
515
517 if (!methods) {
518 return 0;
519 }
520
521 *buf = ast_malloc(buf_size);
522 if (!*buf) {
523 return -1;
524 }
525
526 for (idx = 0; idx < methods; ++idx) {
528 const char *method_str;
529
530 method = AST_VECTOR_GET(&endpoint->ident_method_order, idx);
532
533 /* Should never have an "<unknown>" method string */
534 ast_assert(strcmp(method_str, "<unknown>"));
535 if (!strcmp(method_str, "<unknown>")) {
536 continue;
537 }
538
539 buf_used += snprintf(*buf + buf_used, buf_size - buf_used, "%s%s",
540 method_str, idx < methods - 1 ? "," : "");
541 if (buf_size <= buf_used) {
542 /* Need more room than available, truncating. */
543 *(*buf + (buf_size - 1)) = '\0';
544 ast_log(LOG_WARNING, "Truncated identify_by string: %s\n", *buf);
545 break;
546 }
547 }
548
549 return 0;
550}
551
552static int media_address_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
553{
554 struct ast_sip_endpoint *endpoint = obj;
555 struct ast_sockaddr addr;
556
557 if (ast_sockaddr_parse(&addr, var->value, 0)) {
558 /* If we're able to parse as an IP, ensure it's formatted correctly for later */
559 ast_string_field_set(endpoint, media.address, ast_sockaddr_stringify_addr_remote(&addr));
560 } else {
561 /* If we weren't able to parse it as an IP, just assume it's a hostname */
562 ast_string_field_set(endpoint, media.address, var->value);
563 }
564
565 return 0;
566}
567
568static int media_address_to_str(const void *obj, const intptr_t *args, char **buf)
569{
570 const struct ast_sip_endpoint *endpoint = obj;
571 *buf = ast_strdup(endpoint->media.address);
572 return 0;
573}
574
575static int redirect_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
576{
577 struct ast_sip_endpoint *endpoint = obj;
578
579 if (!strcasecmp(var->value, "user")) {
581 } else if (!strcasecmp(var->value, "uri_core")) {
583 } else if (!strcasecmp(var->value, "uri_pjsip")) {
585 } else {
586 ast_log(LOG_ERROR, "Unrecognized redirect method %s specified for endpoint %s\n",
587 var->value, ast_sorcery_object_get_id(endpoint));
588 return -1;
589 }
590
591 return 0;
592}
593
594static int direct_media_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
595{
596 struct ast_sip_endpoint *endpoint = obj;
597
598 if (!strcasecmp(var->value, "invite") || !strcasecmp(var->value, "reinvite")) {
600 } else if (!strcasecmp(var->value, "update")) {
602 } else {
603 ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
604 var->value, var->name, ast_sorcery_object_get_id(endpoint));
605 return -1;
606 }
607 return 0;
608}
609
610static const char *id_configuration_refresh_methods[] = {
613};
614
615static int direct_media_method_to_str(const void *obj, const intptr_t *args, char **buf)
616{
617 const struct ast_sip_endpoint *endpoint = obj;
620 }
621 return 0;
622}
623
624static int connected_line_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
625{
626 struct ast_sip_endpoint *endpoint = obj;
627
628 if (!strcasecmp(var->value, "invite") || !strcasecmp(var->value, "reinvite")) {
630 } else if (!strcasecmp(var->value, "update")) {
632 } else {
633 ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
634 var->value, var->name, ast_sorcery_object_get_id(endpoint));
635 return -1;
636 }
637 return 0;
638}
639
640static int connected_line_method_to_str(const void *obj, const intptr_t *args, char **buf)
641{
642 const struct ast_sip_endpoint *endpoint = obj;
644 return 0;
645}
646
647static int direct_media_glare_mitigation_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
648{
649 struct ast_sip_endpoint *endpoint = obj;
650
651 if (!strcasecmp(var->value, "none")) {
653 } else if (!strcasecmp(var->value, "outgoing")) {
655 } else if (!strcasecmp(var->value, "incoming")) {
657 } else {
658 ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
659 var->value, var->name, ast_sorcery_object_get_id(endpoint));
660 return -1;
661 }
662
663 return 0;
664}
665
666static const char *direct_media_glare_mitigation_map[] = {
670};
671
672static int direct_media_glare_mitigation_to_str(const void *obj, const intptr_t *args, char **buf)
673{
674 const struct ast_sip_endpoint *endpoint = obj;
677 }
678
679 return 0;
680}
681
682static int caller_id_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
683{
684 struct ast_sip_endpoint *endpoint = obj;
685 char cid_name[80] = { '\0' };
686 char cid_num[80] = { '\0' };
687
688 ast_free(endpoint->id.self.name.str);
689 endpoint->id.self.name.str = NULL;
690 endpoint->id.self.name.valid = 0;
691 ast_free(endpoint->id.self.number.str);
692 endpoint->id.self.number.str = NULL;
693 endpoint->id.self.number.valid = 0;
694
695 ast_callerid_split(var->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
696 if (!ast_strlen_zero(cid_name)) {
697 endpoint->id.self.name.str = ast_strdup(cid_name);
698 if (!endpoint->id.self.name.str) {
699 return -1;
700 }
701 endpoint->id.self.name.valid = 1;
702 }
703 if (!ast_strlen_zero(cid_num)) {
704 endpoint->id.self.number.str = ast_strdup(cid_num);
705 if (!endpoint->id.self.number.str) {
706 return -1;
707 }
708 endpoint->id.self.number.valid = 1;
709 }
710 return 0;
711}
712
713static int caller_id_to_str(const void *obj, const intptr_t *args, char **buf)
714{
715 const struct ast_sip_endpoint *endpoint = obj;
716 const char *name = S_COR(endpoint->id.self.name.valid,
717 endpoint->id.self.name.str, NULL);
718 const char *number = S_COR(endpoint->id.self.number.valid,
719 endpoint->id.self.number.str, NULL);
720
721 /* make sure size is at least 10 - that should cover the "<unknown>"
722 case as well as any additional formatting characters added in
723 the name and/or number case. */
724 int size = 10;
725 size += name ? strlen(name) : 0;
726 size += number ? strlen(number) : 0;
727
728 if (!(*buf = ast_calloc(size + 1, sizeof(char)))) {
729 return -1;
730 }
731
732 ast_callerid_merge(*buf, size + 1, name, number, NULL);
733 return 0;
734}
735
736static int caller_id_privacy_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
737{
738 struct ast_sip_endpoint *endpoint = obj;
739 int callingpres = ast_parse_caller_presentation(var->value);
740 if (callingpres == -1 && sscanf(var->value, "%d", &callingpres) != 1) {
741 return -1;
742 }
743 endpoint->id.self.number.presentation = callingpres;
744 endpoint->id.self.name.presentation = callingpres;
745 return 0;
746}
747
748static int caller_id_privacy_to_str(const void *obj, const intptr_t *args, char **buf)
749{
750 const struct ast_sip_endpoint *endpoint = obj;
751 const char *presentation = ast_named_caller_presentation(
752 endpoint->id.self.name.presentation);
753
754 *buf = ast_strdup(presentation);
755 return 0;
756}
757
758static int caller_id_tag_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
759{
760 struct ast_sip_endpoint *endpoint = obj;
761
762 ast_free(endpoint->id.self.tag);
763 endpoint->id.self.tag = ast_strdup(var->value);
764
765 return endpoint->id.self.tag ? 0 : -1;
766}
767
768static int caller_id_tag_to_str(const void *obj, const intptr_t *args, char **buf)
769{
770 const struct ast_sip_endpoint *endpoint = obj;
771 *buf = ast_strdup(endpoint->id.self.tag);
772 return 0;
773}
774
775static int media_encryption_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
776{
777 struct ast_sip_endpoint *endpoint = obj;
778
779 if (!strcasecmp("no", var->value)) {
781 } else if (!strcasecmp("sdes", var->value)) {
783 } else if (!strcasecmp("dtls", var->value)) {
785 return ast_rtp_dtls_cfg_parse(&endpoint->media.rtp.dtls_cfg, "dtlsenable", "yes");
786 } else {
787 return -1;
788 }
789
790 return 0;
791}
792
793static const char *media_encryption_map[] = {
798};
799
800static int media_encryption_to_str(const void *obj, const intptr_t *args, char **buf)
801{
802 const struct ast_sip_endpoint *endpoint = obj;
805 endpoint->media.rtp.encryption]);
806 }
807 return 0;
808}
809
810static int stir_shaken_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
811{
812 struct ast_sip_endpoint *endpoint = obj;
813
814 ast_log(LOG_WARNING, "Endpoint %s: Option 'stir_shaken' is no longer supported. Use 'stir_shaken_profile' instead.\n",
815 ast_sorcery_object_get_id(endpoint));
816 endpoint->stir_shaken = 0;
817
818 return 0;
819}
820
821static int stir_shaken_to_str(const void *obj, const intptr_t *args, char **buf)
822{
823 *buf = ast_strdup("no");
824
825 return 0;
826}
827
828static int group_handler(const struct aco_option *opt,
829 struct ast_variable *var, void *obj)
830{
831 struct ast_sip_endpoint *endpoint = obj;
832
833 if (!strncmp(var->name, "call_group", 10)) {
834 endpoint->pickup.callgroup = ast_get_group(var->value);
835 } else if (!strncmp(var->name, "pickup_group", 12)) {
836 endpoint->pickup.pickupgroup = ast_get_group(var->value);
837 } else {
838 return -1;
839 }
840
841 return 0;
842}
843
844static int callgroup_to_str(const void *obj, const intptr_t *args, char **buf)
845{
846 const struct ast_sip_endpoint *endpoint = obj;
847
848 if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
849 return -1;
850 }
851
853 return 0;
854}
855
856static int pickupgroup_to_str(const void *obj, const intptr_t *args, char **buf)
857{
858 const struct ast_sip_endpoint *endpoint = obj;
859
860 if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
861 return -1;
862 }
863
865 return 0;
866}
867
868static int named_groups_handler(const struct aco_option *opt,
869 struct ast_variable *var, void *obj)
870{
871 struct ast_sip_endpoint *endpoint = obj;
872
873 if (!strncmp(var->name, "named_call_group", 16)) {
874 if (ast_strlen_zero(var->value)) {
875 endpoint->pickup.named_callgroups =
877 } else if (!(endpoint->pickup.named_callgroups =
878 ast_get_namedgroups(var->value))) {
879 return -1;
880 }
881 } else if (!strncmp(var->name, "named_pickup_group", 18)) {
882 if (ast_strlen_zero(var->value)) {
883 endpoint->pickup.named_pickupgroups =
885 } else if (!(endpoint->pickup.named_pickupgroups =
886 ast_get_namedgroups(var->value))) {
887 return -1;
888 }
889 } else {
890 return -1;
891 }
892
893 return 0;
894}
895
896static int named_callgroups_to_str(const void *obj, const intptr_t *args, char **buf)
897{
898 const struct ast_sip_endpoint *endpoint = obj;
900
903 return 0;
904}
905
906static int named_pickupgroups_to_str(const void *obj, const intptr_t *args, char **buf)
907{
908 const struct ast_sip_endpoint *endpoint = obj;
910
913 return 0;
914}
915
916static int dtls_handler(const struct aco_option *opt,
917 struct ast_variable *var, void *obj)
918{
919 struct ast_sip_endpoint *endpoint = obj;
920 char *name = ast_strdupa(var->name);
921 char *front = NULL;
922 char *back = NULL;
923 char *buf = name;
924
925 /* strip out underscores in the name */
926 front = strtok_r(buf, "_", &back);
927 while (front) {
928 int size = strlen(front);
929 ast_copy_string(buf, front, size + 1);
930 buf += size;
931 front = strtok_r(NULL, "_", &back);
932 }
933
934 return ast_rtp_dtls_cfg_parse(&endpoint->media.rtp.dtls_cfg, name, var->value);
935}
936
937static int dtlsverify_to_str(const void *obj, const intptr_t *args, char **buf)
938{
939 const struct ast_sip_endpoint *endpoint = obj;
941 return 0;
942}
943
944static int dtlsrekey_to_str(const void *obj, const intptr_t *args, char **buf)
945{
946 const struct ast_sip_endpoint *endpoint = obj;
947
948 return ast_asprintf(
949 buf, "%u", endpoint->media.rtp.dtls_cfg.rekey) >=0 ? 0 : -1;
950}
951
952static int dtlsautogeneratecert_to_str(const void *obj, const intptr_t *args, char **buf)
953{
954 const struct ast_sip_endpoint *endpoint = obj;
956 return 0;
957}
958
959static int dtlscertfile_to_str(const void *obj, const intptr_t *args, char **buf)
960{
961 const struct ast_sip_endpoint *endpoint = obj;
962 *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.certfile);
963 return 0;
964}
965
966static int dtlsprivatekey_to_str(const void *obj, const intptr_t *args, char **buf)
967{
968 const struct ast_sip_endpoint *endpoint = obj;
969 *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.pvtfile);
970 return 0;
971}
972
973static int dtlscipher_to_str(const void *obj, const intptr_t *args, char **buf)
974{
975 const struct ast_sip_endpoint *endpoint = obj;
976 *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.cipher);
977 return 0;
978}
979
980static int dtlscafile_to_str(const void *obj, const intptr_t *args, char **buf)
981{
982 const struct ast_sip_endpoint *endpoint = obj;
983 *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.cafile);
984 return 0;
985}
986
987static int dtlscapath_to_str(const void *obj, const intptr_t *args, char **buf)
988{
989 const struct ast_sip_endpoint *endpoint = obj;
990 *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.capath);
991 return 0;
992}
993
994static const char *ast_rtp_dtls_setup_map[] = {
995 [AST_RTP_DTLS_SETUP_ACTIVE] = "active",
996 [AST_RTP_DTLS_SETUP_PASSIVE] = "passive",
997 [AST_RTP_DTLS_SETUP_ACTPASS] = "actpass",
998 [AST_RTP_DTLS_SETUP_HOLDCONN] = "holdconn",
999};
1000
1001static int dtlssetup_to_str(const void *obj, const intptr_t *args, char **buf)
1002{
1003 const struct ast_sip_endpoint *endpoint = obj;
1006 }
1007 return 0;
1008}
1009
1010static const char *ast_rtp_dtls_fingerprint_map[] = {
1011 [AST_RTP_DTLS_HASH_SHA256] = "SHA-256",
1012 [AST_RTP_DTLS_HASH_SHA1] = "SHA-1",
1013};
1014
1015static int dtlsfingerprint_to_str(const void *obj, const intptr_t *args, char **buf)
1016{
1017 const struct ast_sip_endpoint *endpoint = obj;
1020 }
1021 return 0;
1022}
1023
1024static int t38udptl_ec_handler(const struct aco_option *opt,
1025 struct ast_variable *var, void *obj)
1026{
1027 struct ast_sip_endpoint *endpoint = obj;
1028
1029 if (!strcmp(var->value, "none")) {
1031 } else if (!strcmp(var->value, "fec")) {
1033 } else if (!strcmp(var->value, "redundancy")) {
1035 } else {
1036 return -1;
1037 }
1038
1039 return 0;
1040}
1041
1042static const char *ast_t38_ec_modes_map[] = {
1043 [UDPTL_ERROR_CORRECTION_NONE] = "none",
1045 [UDPTL_ERROR_CORRECTION_REDUNDANCY] = "redundancy"
1046};
1047
1048static int t38udptl_ec_to_str(const void *obj, const intptr_t *args, char **buf)
1049{
1050 const struct ast_sip_endpoint *endpoint = obj;
1053 endpoint->media.t38.error_correction]);
1054 }
1055 return 0;
1056}
1057
1058static int tos_handler(const struct aco_option *opt,
1059 struct ast_variable *var, void *obj)
1060{
1061 struct ast_sip_endpoint *endpoint = obj;
1062 unsigned int value;
1063
1064 if (ast_str2tos(var->value, &value)) {
1065 ast_log(LOG_ERROR, "Error configuring endpoint '%s' - Could not "
1066 "interpret '%s' value '%s'\n",
1067 ast_sorcery_object_get_id(endpoint), var->name, var->value);
1068 return -1;
1069 }
1070
1071 if (!strcmp(var->name, "tos_audio")) {
1072 endpoint->media.tos_audio = value;
1073 } else if (!strcmp(var->name, "tos_video")) {
1074 endpoint->media.tos_video = value;
1075 } else {
1076 /* If we reach this point, someone called the tos_handler when they shouldn't have. */
1077 ast_assert(0);
1078 return -1;
1079 }
1080 return 0;
1081}
1082
1083static int tos_audio_to_str(const void *obj, const intptr_t *args, char **buf)
1084{
1085 const struct ast_sip_endpoint *endpoint = obj;
1086
1087 if (ast_asprintf(buf, "%u", endpoint->media.tos_audio) == -1) {
1088 return -1;
1089 }
1090 return 0;
1091}
1092
1093static int tos_video_to_str(const void *obj, const intptr_t *args, char **buf)
1094{
1095 const struct ast_sip_endpoint *endpoint = obj;
1096
1097 if (ast_asprintf(buf, "%u", endpoint->media.tos_video) == -1) {
1098 return -1;
1099 }
1100 return 0;
1101}
1102
1103static int from_user_handler(const struct aco_option *opt,
1104 struct ast_variable *var, void *obj)
1105{
1106 struct ast_sip_endpoint *endpoint = obj;
1107 /* Valid non-alphanumeric characters for URI */
1108 char *valid_uri_marks = "-._~%!$&'()*+,;=:";
1109 const char *val;
1110
1111 for (val = var->value; *val; val++) {
1112 if (!isalpha(*val) && !isdigit(*val) && !strchr(valid_uri_marks, *val)) {
1113 ast_log(LOG_ERROR, "Error configuring endpoint '%s' - '%s' field "
1114 "contains invalid character '%c'\n",
1115 ast_sorcery_object_get_id(endpoint), var->name, *val);
1116 return -1;
1117 }
1118 }
1119
1120 ast_string_field_set(endpoint, fromuser, var->value);
1121
1122 return 0;
1123}
1124
1125static int from_user_to_str(const void *obj, const intptr_t *args, char **buf)
1126{
1127 const struct ast_sip_endpoint *endpoint = obj;
1128
1129 *buf = ast_strdup(endpoint->fromuser);
1130
1131 return 0;
1132}
1133
1134static int set_var_handler(const struct aco_option *opt,
1135 struct ast_variable *var, void *obj)
1136{
1137 struct ast_sip_endpoint *endpoint = obj;
1138 struct ast_variable *new_var;
1139 char *name;
1140 char *val;
1141
1142 if (ast_strlen_zero(var->value)) {
1143 return 0;
1144 }
1145
1146 name = ast_strdupa(var->value);
1147 val = strchr(name, '=');
1148
1149 if (!val) {
1150 return -1;
1151 }
1152
1153 *val++ = '\0';
1154
1155 if (!(new_var = ast_variable_new(name, val, ""))) {
1156 return -1;
1157 }
1158
1159 if (ast_variable_list_replace(&endpoint->channel_vars, new_var)) {
1160 ast_variable_list_append(&endpoint->channel_vars, new_var);
1161 }
1162
1163 return 0;
1164}
1165
1166static int set_var_to_str(const void *obj, const intptr_t *args, char **buf)
1167{
1169 const struct ast_sip_endpoint *endpoint = obj;
1170 struct ast_variable *var;
1171
1172 for (var = endpoint->channel_vars; var; var = var->next) {
1173 ast_str_append(&str, 0, "%s=%s,", var->name, var->value);
1174 }
1175
1177 ast_free(str);
1178 return 0;
1179}
1180
1181static int set_var_to_vl(const void *obj, struct ast_variable **fields)
1182{
1183 const struct ast_sip_endpoint *endpoint = obj;
1184 if (endpoint->channel_vars) {
1185 *fields = ast_variables_dup(endpoint->channel_vars);
1186 }
1187 return 0;
1188}
1189
1190static int voicemail_extension_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1191{
1192 struct ast_sip_endpoint *endpoint = obj;
1193
1196
1197 return endpoint->subscription.mwi.voicemail_extension ? 0 : -1;
1198}
1199
1200static int voicemail_extension_to_str(const void *obj, const intptr_t *args, char **buf)
1201{
1202 const struct ast_sip_endpoint *endpoint = obj;
1203
1205
1206 return 0;
1207}
1208
1209static int contact_user_handler(const struct aco_option *opt,
1210 struct ast_variable *var, void *obj)
1211{
1212 struct ast_sip_endpoint *endpoint = obj;
1213
1214 ast_free(endpoint->contact_user);
1215 endpoint->contact_user = ast_strdup(var->value);
1216
1217 return endpoint->contact_user ? 0 : -1;
1218}
1219
1220static int contact_user_to_str(const void *obj, const intptr_t *args, char **buf)
1221{
1222 const struct ast_sip_endpoint *endpoint = obj;
1223
1224 *buf = ast_strdup(endpoint->contact_user);
1225 if (!(*buf)) {
1226 return -1;
1227 }
1228
1229 return 0;
1230}
1231
1232static int call_offer_pref_handler(const struct aco_option *opt,
1233 struct ast_variable *var, void *obj)
1234{
1235 struct ast_sip_endpoint *endpoint = obj;
1236 struct ast_flags pref = { 0, };
1237 int outgoing = strcmp(var->name, "outgoing_call_offer_pref") == 0;
1238
1239 int res = ast_sip_call_codec_str_to_pref(&pref, var->value, outgoing);
1240 if (res != 0) {
1241 return -1;
1242 }
1243
1244 if (outgoing) {
1245 endpoint->media.outgoing_call_offer_pref = pref;
1246 } else {
1247 endpoint->media.incoming_call_offer_pref = pref;
1248 }
1249
1250 return 0;
1251}
1252
1253static int incoming_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
1254{
1255 const struct ast_sip_endpoint *endpoint = obj;
1256
1258 if (!(*buf)) {
1259 return -1;
1260 }
1261
1262 return 0;
1263}
1264
1265static int outgoing_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
1266{
1267 const struct ast_sip_endpoint *endpoint = obj;
1268
1270 if (!(*buf)) {
1271 return -1;
1272 }
1273
1274 return 0;
1275}
1276
1277static int codec_prefs_handler(const struct aco_option *opt,
1278 struct ast_variable *var, void *obj)
1279{
1280 struct ast_sip_endpoint *endpoint = obj;
1281 struct ast_stream_codec_negotiation_prefs *option_prefs;
1283 struct ast_str *error_message = ast_str_create(128);
1286 int res = 0;
1287
1288 res = ast_stream_codec_prefs_parse(var->value, &prefs, &error_message);
1289 if (res < 0) {
1290 ast_log(LOG_ERROR, "Endpoint '%s': %s for option '%s'\n",
1291 ast_sorcery_object_get_id(endpoint), ast_str_buffer(error_message), var->name);
1292 ast_free(error_message);
1293 return -1;
1294 }
1295 ast_free(error_message);
1296
1297 if (strcmp(var->name, "codec_prefs_incoming_offer") == 0) {
1299 ast_log(LOG_ERROR, "Endpoint '%s': Codec preference '%s' has invalid value '%s' for option: '%s'",
1300 ast_sorcery_object_get_id(endpoint),
1303 var->name);
1304 return -1;
1305 }
1306 option_prefs = &endpoint->media.codec_prefs_incoming_offer;
1307 default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1308 default_operation = CODEC_NEGOTIATION_OPERATION_INTERSECT;
1309 } else if (strcmp(var->name, "codec_prefs_outgoing_offer") == 0) {
1310 option_prefs = &endpoint->media.codec_prefs_outgoing_offer;
1311 default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1312 default_operation = CODEC_NEGOTIATION_OPERATION_UNION;
1313 } else if (strcmp(var->name, "codec_prefs_incoming_answer") == 0) {
1314 option_prefs = &endpoint->media.codec_prefs_incoming_answer;
1315 default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1316 default_operation = CODEC_NEGOTIATION_OPERATION_INTERSECT;
1317 } else if (strcmp(var->name, "codec_prefs_outgoing_answer") == 0) {
1318 option_prefs = &endpoint->media.codec_prefs_outgoing_answer;
1319 default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1320 default_operation = CODEC_NEGOTIATION_OPERATION_INTERSECT;
1321 } else {
1322 ast_log(LOG_ERROR, "Endpoint '%s': Unsupported option '%s'\n",
1323 ast_sorcery_object_get_id(endpoint),
1324 var->name);
1325 return -1;
1326 }
1327
1329 prefs.prefer = default_prefer;
1330 }
1331
1333 prefs.operation = default_operation;
1334 }
1335
1338 }
1339
1342 }
1343
1344 /* Now that defaults have been applied as needed we apply the full codec
1345 * preference configuration to the option.
1346 */
1347 *option_prefs = prefs;
1348
1349 return 0;
1350}
1351
1353 const void *obj, const intptr_t *args, char **buf)
1354{
1356
1357 if (!codecs) {
1358 return -1;
1359 }
1360
1363
1364 return 0;
1365}
1366
1367static int incoming_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1368{
1369 const struct ast_sip_endpoint *endpoint = obj;
1371}
1372
1373static int outgoing_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1374{
1375 const struct ast_sip_endpoint *endpoint = obj;
1377}
1378
1379static int incoming_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1380{
1381 const struct ast_sip_endpoint *endpoint = obj;
1383}
1384
1385static int outgoing_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1386{
1387 const struct ast_sip_endpoint *endpoint = obj;
1389}
1390
1391static void *sip_nat_hook_alloc(const char *name)
1392{
1393 return ast_sorcery_generic_alloc(sizeof(struct ast_sip_nat_hook), NULL);
1394}
1395
1396/*! \brief Destructor function for persistent endpoint information */
1397static void persistent_endpoint_destroy(void *obj)
1398{
1399 struct sip_persistent_endpoint *persistent = obj;
1400
1401 ast_endpoint_shutdown(persistent->endpoint);
1402}
1403
1404static int add_to_regcontext(void *obj, void *arg, int flags)
1405{
1406 struct sip_persistent_endpoint *persistent = obj;
1407 const char *regcontext = arg;
1408
1411 persistent->endpoint), 1, NULL)) {
1413 "Noop", ast_strdup(ast_endpoint_get_resource(persistent->endpoint)), ast_free_ptr, "PJSIP");
1414 }
1415 }
1416
1417 return 0;
1418}
1419
1421{
1423 return 0;
1424 }
1425
1426 /* Make sure the regcontext exists */
1428 ast_log(LOG_ERROR, "Failed to create regcontext '%s'\n", regcontext);
1429 return -1;
1430 }
1431
1432 /* Add any online endpoints */
1434 return 0;
1435}
1436
1438{
1439 struct sip_persistent_endpoint *persistent;
1440 struct ast_json *blob;
1441 char *regcontext;
1442
1443 persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1444 if (!persistent) {
1445 return -1;
1446 }
1447
1448 /* If there was no state change, don't publish anything. */
1449 if (ast_endpoint_get_state(persistent->endpoint) == state) {
1450 ao2_ref(persistent, -1);
1451 return 0;
1452 }
1453
1455
1456 if (state == AST_ENDPOINT_ONLINE) {
1458 blob = ast_json_pack("{s: s}", "peer_status", "Reachable");
1459
1463 "Noop", ast_strdup(ast_endpoint_get_resource(persistent->endpoint)), ast_free_ptr, "PJSIP");
1464 }
1465 }
1466
1467 ast_verb(2, "Endpoint %s is now Reachable\n", ast_endpoint_get_resource(persistent->endpoint));
1468 } else {
1470 blob = ast_json_pack("{s: s}", "peer_status", "Unreachable");
1471
1473 struct pbx_find_info q = { .stacklen = 0 };
1474
1477 }
1478 }
1479
1480 ast_verb(2, "Endpoint %s is now Unreachable\n", ast_endpoint_get_resource(persistent->endpoint));
1481 }
1482
1484
1486 ast_json_unref(blob);
1488
1489 ao2_ref(persistent, -1);
1490
1491 return 0;
1492}
1493
1494void ast_sip_persistent_endpoint_publish_contact_state(const char *endpoint_name, const struct ast_sip_contact_status *contact_status)
1495{
1496 struct sip_persistent_endpoint *persistent;
1497 struct ast_json *blob;
1498 char rtt[32];
1499
1500 persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1501 if (!persistent) {
1502 return;
1503 }
1504
1505 snprintf(rtt, sizeof(rtt), "%" PRId64, contact_status->rtt);
1506 blob = ast_json_pack("{s: s, s: s, s: s, s: s, s: s}",
1507 "contact_status", ast_sip_get_contact_status_label(contact_status->status),
1508 "aor", contact_status->aor,
1509 "uri", contact_status->uri,
1510 "roundtrip_usec", rtt,
1511 "endpoint_name", ast_endpoint_get_resource(persistent->endpoint));
1512 if (blob) {
1514 ast_json_unref(blob);
1515 }
1516
1517 ao2_ref(persistent, -1);
1518}
1519
1520/*! \brief Internal function which finds (or creates) persistent endpoint information */
1522{
1523 RAII_VAR(struct sip_persistent_endpoint *, persistent, NULL, ao2_cleanup);
1525
1528 if (!persistent) {
1529 persistent = ao2_alloc_options(sizeof(*persistent), persistent_endpoint_destroy,
1531 if (!persistent) {
1532 return NULL;
1533 }
1534
1535 persistent->endpoint = ast_endpoint_create("PJSIP",
1536 ast_sorcery_object_get_id(endpoint));
1537 if (!persistent->endpoint) {
1538 return NULL;
1539 }
1540
1541 ast_endpoint_set_state(persistent->endpoint, AST_ENDPOINT_OFFLINE);
1542
1544 }
1545
1546 ao2_ref(persistent->endpoint, +1);
1547 return persistent->endpoint;
1548}
1549
1550/*! \brief Callback function for when an object is finalized */
1551static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *obj)
1552{
1553 struct ast_sip_endpoint *endpoint = obj;
1554
1555 if (!(endpoint->persistent = persistent_endpoint_find_or_create(endpoint))) {
1556 return -1;
1557 }
1558
1559 if (endpoint->extensions.timer.min_se < 90) {
1560 ast_log(LOG_ERROR, "Session timer minimum expires time must be 90 or greater on endpoint '%s'\n",
1561 ast_sorcery_object_get_id(endpoint));
1562 return -1;
1563 } else if (endpoint->extensions.timer.sess_expires < endpoint->extensions.timer.min_se) {
1564 ast_log(LOG_ERROR, "Session timer expires must be greater than minimum session expires time on endpoint '%s'\n",
1565 ast_sorcery_object_get_id(endpoint));
1566 return -1;
1567 }
1568
1569 if (ast_rtp_dtls_cfg_validate(&endpoint->media.rtp.dtls_cfg)) {
1570 return -1;
1571 }
1572
1573 if (endpoint->preferred_codec_only) {
1575 ast_log(LOG_ERROR, "Setting both preferred_codec_only and incoming_call_offer_pref is not supported on endpoint '%s'\n",
1576 ast_sorcery_object_get_id(endpoint));
1577 return -1;
1578 }
1581 }
1582
1584 if (!endpoint->media.topology) {
1585 return -1;
1586 }
1587
1588 endpoint->media.rtcp_mux |= endpoint->media.bundle;
1589
1590 /*
1591 * If webrtc has been enabled then enable those attributes, and default
1592 * some, that are needed in order for webrtc to work.
1593 */
1594 endpoint->media.bundle |= endpoint->media.webrtc;
1595 endpoint->media.rtcp_mux |= endpoint->media.webrtc;
1596 endpoint->media.rtp.use_avpf |= endpoint->media.webrtc;
1597 endpoint->media.rtp.ice_support |= endpoint->media.webrtc;
1598 endpoint->media.rtp.use_received_transport |= endpoint->media.webrtc;
1599
1600 if (endpoint->media.webrtc) {
1602 endpoint->media.rtp.dtls_cfg.enabled = 1;
1605
1606 /* RFC8827 says: Implementations MUST NOT implement DTLS renegotiation
1607 * and MUST reject it with a "no_renegotiation" alert if offered. */
1608 if (endpoint->media.rtp.dtls_cfg.rekey) {
1609 ast_log(LOG_WARNING, "DTLS renegotiation is not supported with WebRTC. Disabling dtls_rekey.\n");
1610 endpoint->media.rtp.dtls_cfg.rekey = 0;
1611 }
1612
1613 if (ast_strlen_zero(endpoint->media.rtp.dtls_cfg.certfile)) {
1614 /* If no certificate has been specified, try to automatically create one */
1615 endpoint->media.rtp.dtls_cfg.ephemeral_cert = 1;
1616 }
1617 }
1618
1619 if (!ast_strlen_zero(endpoint->geoloc_incoming_call_profile) ||
1620 !ast_strlen_zero(endpoint->geoloc_outgoing_call_profile)) {
1621
1622 if (!ast_geoloc_is_loaded()) {
1623 ast_log(LOG_ERROR, "A geoloc incoming and/or outgoing call_profile was specified on endpoint '%s'"
1624 " but res_geolocation is not loaded.\n", ast_sorcery_object_get_id(endpoint));
1625 return -1;
1626 }
1627
1628 if (!ast_strlen_zero(endpoint->geoloc_incoming_call_profile)) {
1629 struct ast_geoloc_profile *profile = ast_geoloc_get_profile(endpoint->geoloc_incoming_call_profile);
1630 if (!profile) {
1631 ast_log(LOG_ERROR, "geoloc_incoming_call_profile '%s' on endpoint '%s' doesn't exist\n",
1632 endpoint->geoloc_incoming_call_profile, ast_sorcery_object_get_id(endpoint));
1633 return -1;
1634 }
1635 ao2_cleanup(profile);
1636 }
1637
1638 if (!ast_strlen_zero(endpoint->geoloc_outgoing_call_profile)) {
1639 struct ast_geoloc_profile *profile = ast_geoloc_get_profile(endpoint->geoloc_outgoing_call_profile);
1640 if (!profile) {
1641 ast_log(LOG_ERROR, "geoloc_outgoing_call_profile '%s' on endpoint '%s' doesn't exist\n",
1642 endpoint->geoloc_outgoing_call_profile, ast_sorcery_object_get_id(endpoint));
1643 return -1;
1644 }
1645 ao2_cleanup(profile);
1646 }
1647 }
1648
1649 return 0;
1650}
1651
1652const char *ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint)
1653{
1654 char device[MAX_OBJECT_FIELD];
1655
1656 snprintf(device, MAX_OBJECT_FIELD, "PJSIP/%s", ast_sorcery_object_get_id(endpoint));
1657 return ast_devstate2str(ast_device_state(device));
1658}
1659
1661 const struct ast_sip_endpoint *endpoint)
1662{
1666}
1667
1669 const struct ast_endpoint_snapshot *endpoint_snapshot,
1670 ao2_callback_fn on_channel_snapshot, void *arg)
1671{
1672 int num, num_channels = endpoint_snapshot->num_channels;
1673
1674 if (!on_channel_snapshot || !num_channels) {
1675 return 0;
1676 }
1677
1678 for (num = 0; num < num_channels; ++num) {
1679 RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
1680 int res;
1681
1682 snapshot = ast_channel_snapshot_get_latest(endpoint_snapshot->channel_ids[num]);
1683 if (!snapshot) {
1684 continue;
1685 }
1686
1687 res = on_channel_snapshot(snapshot, arg, 0);
1688 if (res) {
1689 return -1;
1690 }
1691 }
1692 return 0;
1693}
1694
1696 const struct ast_sip_endpoint *endpoint,
1697 ao2_callback_fn on_channel_snapshot, void *arg)
1698{
1699 RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup);
1700 return ast_sip_for_each_channel_snapshot(endpoint_snapshot, on_channel_snapshot, arg);
1701}
1702
1703static int active_channels_to_str_cb(void *object, void *arg, int flags)
1704{
1705 const struct ast_channel_snapshot *snapshot = object;
1706 struct ast_str **buf = arg;
1707 ast_str_append(buf, 0, "%s,", snapshot->base->name);
1708 return 0;
1709}
1710
1711static void active_channels_to_str(const struct ast_sip_endpoint *endpoint,
1712 struct ast_str **str)
1713{
1714
1715 RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot,
1717
1718 if (endpoint_snapshot) {
1719 return;
1720 }
1721
1722 ast_sip_for_each_channel_snapshot(endpoint_snapshot,
1724 ast_str_truncate(*str, -1);
1725}
1726
1727#define AMI_DEFAULT_STR_SIZE 512
1728
1729struct ast_str *ast_sip_create_ami_event(const char *event, struct ast_sip_ami *ami)
1730{
1732
1733 if (!(buf)) {
1734 astman_send_error_va(ami->s, ami->m, "Unable create event "
1735 "for %s\n", event);
1736 return NULL;
1737 }
1738
1739 ast_str_set(&buf, 0, "Event: %s\r\n", event);
1740 if (!ast_strlen_zero(ami->action_id)) {
1741 ast_str_append(&buf, 0, "ActionID: %s\r\n", ami->action_id);
1742 }
1743 return buf;
1744}
1745
1746static void sip_sorcery_object_ami_set_type_name(const void *obj, struct ast_str **buf)
1747{
1748 ast_str_append(buf, 0, "ObjectType: %s\r\n",
1750 ast_str_append(buf, 0, "ObjectName: %s\r\n",
1752}
1753
1754int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
1755{
1758 struct ast_variable *i;
1759
1760 if (!objset) {
1761 return -1;
1762 }
1763
1765
1766 for (i = objset; i; i = i->next) {
1767 RAII_VAR(char *, camel, ast_to_camel_case(i->name), ast_free);
1768 ast_str_append(buf, 0, "%s: %s\r\n", camel, i->value);
1769 }
1770
1771 return 0;
1772}
1773
1774static int sip_endpoints_aors_ami(void *obj, void *arg, int flags)
1775{
1776 struct ast_sip_aor *aor = obj;
1777 struct ast_str **buf = arg;
1778
1779 ast_str_append(buf, 0, "Contacts: ");
1781 ast_str_append(buf, 0, "\r\n");
1782
1783 return 0;
1784}
1785
1786static int sip_endpoint_to_ami(const struct ast_sip_endpoint *endpoint,
1787 struct ast_str **buf)
1788{
1789 if (ast_sip_sorcery_object_to_ami(endpoint, buf)) {
1790 return -1;
1791 }
1792
1793 ast_str_append(buf, 0, "DeviceState: %s\r\n",
1794 ast_sip_get_device_state(endpoint));
1795
1796 ast_str_append(buf, 0, "ActiveChannels: ");
1797 active_channels_to_str(endpoint, buf);
1798 ast_str_append(buf, 0, "\r\n");
1799
1800 return 0;
1801}
1802
1803static int format_ami_endpoint(const struct ast_sip_endpoint *endpoint,
1804 struct ast_sip_ami *ami)
1805{
1806 RAII_VAR(struct ast_str *, buf,
1807 ast_sip_create_ami_event("EndpointDetail", ami), ast_free);
1808
1809 if (!buf) {
1810 return -1;
1811 }
1812
1813 sip_endpoint_to_ami(endpoint, &buf);
1814 astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
1815 return 0;
1816}
1817
1818#define AMI_SHOW_ENDPOINTS "PJSIPShowEndpoints"
1819#define AMI_SHOW_ENDPOINT "PJSIPShowEndpoint"
1820
1821static int ami_show_endpoint(struct mansession *s, const struct message *m)
1822{
1823 struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"),
1824 .count = 0, };
1825 RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
1826 const char *endpoint_name = astman_get_header(m, "Endpoint");
1827 int count = 0;
1828
1829 if (ast_strlen_zero(endpoint_name)) {
1830 astman_send_error_va(s, m, "%s requires an endpoint name\n",
1832 return 0;
1833 }
1834
1835 if (!strncasecmp(endpoint_name, "pjsip/", 6)) {
1836 endpoint_name += 6;
1837 }
1838
1839 if (!(endpoint = ast_sorcery_retrieve_by_id(
1840 ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
1841 astman_send_error_va(s, m, "Unable to retrieve endpoint %s\n",
1842 endpoint_name);
1843 return 0;
1844 }
1845
1846 astman_send_listack(s, m, "Following are Events for each object associated with the Endpoint",
1847 "start");
1848
1849 /* the endpoint detail needs to always come first so apply as such */
1850 if (format_ami_endpoint(endpoint, &ami) ||
1851 ast_sip_format_endpoint_ami(endpoint, &ami, &count)) {
1852 astman_send_error_va(s, m, "Unable to format endpoint %s\n",
1853 endpoint_name);
1854 }
1855
1856 astman_send_list_complete_start(s, m, "EndpointDetailComplete", ami.count + 1);
1858
1859 return 0;
1860}
1861
1862static int format_str_append_auth(const struct ast_sip_auth_vector *auths,
1863 struct ast_str **buf)
1864{
1865 char *str = NULL;
1866 if (ast_sip_auths_to_str(auths, &str)) {
1867 return -1;
1868 }
1869 ast_str_append(buf, 0, "%s", str ? str : "");
1870 ast_free(str);
1871 return 0;
1872}
1873
1874static int format_ami_endpoints(void *obj, void *arg, int flags)
1875{
1876
1877 struct ast_sip_endpoint *endpoint = obj;
1878 struct ast_sip_ami *ami = arg;
1879 RAII_VAR(struct ast_str *, buf,
1880 ast_sip_create_ami_event("EndpointList", ami), ast_free);
1881
1882 if (!buf) {
1883 return CMP_STOP;
1884 }
1885
1887 ast_str_append(&buf, 0, "Transport: %s\r\n",
1888 endpoint->transport);
1889 ast_str_append(&buf, 0, "Aor: %s\r\n",
1890 endpoint->aors);
1891
1892 ast_str_append(&buf, 0, "Auths: ");
1894 ast_str_append(&buf, 0, "\r\n");
1895
1896 ast_str_append(&buf, 0, "OutboundAuths: ");
1898 ast_str_append(&buf, 0, "\r\n");
1899
1900 ast_sip_for_each_aor(endpoint->aors,
1902
1903 ast_str_append(&buf, 0, "DeviceState: %s\r\n",
1904 ast_sip_get_device_state(endpoint));
1905
1906 ast_str_append(&buf, 0, "ActiveChannels: ");
1907 active_channels_to_str(endpoint, &buf);
1908 ast_str_append(&buf, 0, "\r\n");
1909
1910 astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
1911 return 0;
1912}
1913
1914static int ami_show_endpoints(struct mansession *s, const struct message *m)
1915{
1916 struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
1918 int num;
1919
1921 if (!endpoints) {
1922 astman_send_error(s, m, "Could not get endpoints\n");
1923 return 0;
1924 }
1925
1926 if (!(num = ao2_container_count(endpoints))) {
1927 astman_send_error(s, m, "No endpoints found\n");
1928 return 0;
1929 }
1930
1931 astman_send_listack(s, m, "A listing of Endpoints follows, presented as EndpointList events",
1932 "start");
1933
1935
1936 astman_send_list_complete_start(s, m, "EndpointListComplete", num);
1938 return 0;
1939}
1940
1942{
1944 struct ao2_container *s_container;
1945
1947 if (!container) {
1948 return NULL;
1949 }
1950
1953 if (!s_container) {
1954 return NULL;
1955 }
1956
1957 if (ao2_container_dup(s_container, container, 0)) {
1958 ao2_ref(s_container, -1);
1959 return NULL;
1960 }
1961
1962 return s_container;
1963}
1964
1965static int cli_endpoint_iterate(void *obj, ao2_callback_fn callback, void *args)
1966{
1967 ao2_callback(obj, OBJ_NODATA, callback, args);
1968
1969 return 0;
1970}
1971
1972static void *cli_endpoint_retrieve_by_id(const char *id)
1973{
1974 return ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id);
1975}
1976
1978{
1979 RAII_VAR(struct ast_sip_cli_formatter_entry *, formatter_entry, NULL, ao2_cleanup);
1980
1981 formatter_entry = ast_sip_lookup_cli_formatter(type);
1982 if (formatter_entry) {
1983 formatter_entry->print_header(NULL, context, 0);
1984 }
1985}
1986
1987static int cli_endpoint_print_header(void *obj, void *arg, int flags)
1988{
1989 struct ast_sip_cli_context *context = arg;
1990
1991 ast_assert(context->output_buffer != NULL);
1992
1993 ast_str_append(&context->output_buffer, 0,
1994 " Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>\n");
1995
1996 if (context->recurse) {
1997 context->indent_level++;
2003 context->indent_level--;
2004 }
2005
2006 return 0;
2007}
2008
2009static void cli_endpoint_print_child_body(char *type, const void *obj, struct ast_sip_cli_context *context)
2010{
2011 RAII_VAR(struct ast_sip_cli_formatter_entry *, formatter_entry, NULL, ao2_cleanup);
2012
2013 formatter_entry = ast_sip_lookup_cli_formatter(type);
2014 if (formatter_entry) {
2015 formatter_entry->iterate((void *)obj, formatter_entry->print_body, context);
2016 }
2017}
2018
2019static int cli_endpoint_print_body(void *obj, void *arg, int flags)
2020{
2021 struct ast_sip_endpoint *endpoint = obj;
2022 RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup);
2023 struct ast_sip_cli_context *context = arg;
2024 const char *id = ast_sorcery_object_get_id(endpoint);
2025 char *print_name = NULL;
2026 int print_name_len;
2027 char *number = S_COR(endpoint->id.self.number.valid,
2028 endpoint->id.self.number.str, NULL);
2029 int indent;
2030 int flexwidth;
2031
2032 ast_assert(context->output_buffer != NULL);
2033
2034 if (number) {
2035 print_name_len = strlen(id) + strlen(number) + 2;
2036 print_name = ast_alloca(print_name_len);
2037 snprintf(print_name, print_name_len, "%s/%s", id, number);
2038 }
2039
2040 indent = CLI_INDENT_TO_SPACES(context->indent_level);
2041 flexwidth = CLI_LAST_TABSTOP - indent - 2;
2042
2043 ast_str_append(&context->output_buffer, 0, "%*s: %-*.*s %-12.12s %d of %.0f\n",
2044 indent, "Endpoint",
2045 flexwidth, flexwidth, print_name ? print_name : id,
2046 ast_sip_get_device_state(endpoint),
2047 endpoint_snapshot->num_channels,
2048 (double) endpoint->devicestate_busy_at ? endpoint->devicestate_busy_at :
2049 INFINITY
2050 );
2051
2052 if (context->recurse) {
2053 context->indent_level++;
2054
2055 context->auth_direction = "Out";
2057 context->auth_direction = "In";
2059
2060 cli_endpoint_print_child_body("aor", endpoint->aors, context);
2061 cli_endpoint_print_child_body("transport", endpoint, context);
2062 cli_endpoint_print_child_body("identify", endpoint, context);
2063 cli_endpoint_print_child_body("channel", endpoint, context);
2064
2065 context->indent_level--;
2066
2067 if (context->indent_level == 0) {
2068 ast_str_append(&context->output_buffer, 0, "\n");
2069 }
2070 }
2071
2072 if (context->show_details || (context->show_details_only_level_0 && context->indent_level == 0)) {
2073 ast_str_append(&context->output_buffer, 0, "\n");
2075 }
2076
2077 return 0;
2078}
2079
2080static struct ast_cli_entry cli_commands[] = {
2081 AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "List PJSIP Endpoints",
2082 .command = "pjsip list endpoints",
2083 .usage = "Usage: pjsip list endpoints [ like <pattern> ]\n"
2084 " List the configured PJSIP endpoints\n"
2085 " Optional regular expression pattern is used to filter the list.\n"),
2086 AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "Show PJSIP Endpoints",
2087 .command = "pjsip show endpoints",
2088 .usage = "Usage: pjsip show endpoints [ like <pattern> ]\n"
2089 " List(detailed) the configured PJSIP endpoints\n"
2090 " Optional regular expression pattern is used to filter the list.\n"),
2091 AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "Show PJSIP Endpoint",
2092 .command = "pjsip show endpoint",
2093 .usage = "Usage: pjsip show endpoint <id>\n"
2094 " Show the configured PJSIP endpoint\n"),
2095};
2096
2099
2100static void load_all_endpoints(void)
2101{
2102 struct ao2_container *endpoints;
2103
2106}
2107
2108static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub,
2109 struct stasis_message *message)
2110{
2112 return;
2113 }
2114
2116}
2117
2119{
2122 return -1;
2123 }
2124
2127 if (!persistent_endpoints) {
2128 return -1;
2129 }
2130
2131 if (!(sip_sorcery = ast_sorcery_open())) {
2132 ast_log(LOG_ERROR, "Failed to open SIP sorcery failed to open\n");
2133 return -1;
2134 }
2135
2137
2139 ast_log(LOG_ERROR, "Failed to register SIP authentication support\n");
2141 sip_sorcery = NULL;
2142 return -1;
2143 }
2144
2145 ast_sorcery_apply_default(sip_sorcery, "endpoint", "config", "pjsip.conf,criteria=type=endpoint");
2146 ast_sorcery_apply_default(sip_sorcery, "nat_hook", "memory", NULL);
2147
2149 ast_log(LOG_ERROR, "Failed to register SIP endpoint object with sorcery\n");
2151 sip_sorcery = NULL;
2152 return -1;
2153 }
2154
2156 ast_log(LOG_ERROR, "Failed to register nat_hook\n");
2157 }
2158
2159 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "type", "", OPT_NOOP_T, 0, 0);
2161 ast_sorcery_object_field_register_alias(sip_sorcery, "endpoint", "disallow", "", OPT_CODEC_T, 0, FLDSET(struct ast_sip_endpoint, media.codecs));
2162 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow", "", OPT_CODEC_T, 1, FLDSET(struct ast_sip_endpoint, media.codecs));
2163 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtmf_mode", "rfc4733", dtmf_handler, dtmf_to_str, NULL, 0, 0);
2164 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.ipv6));
2165 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_symmetric", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.symmetric));
2166 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ice_support", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.ice_support));
2167 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_ptime", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_ptime));
2168 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_rport", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, nat.force_rport));
2169 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rewrite_contact", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, nat.rewrite_contact));
2170 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "transport", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, transport));
2171 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, outbound_proxy));
2172 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "moh_suggest", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mohsuggest));
2175 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_min_se", "90", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, extensions.timer.min_se));
2176 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_sess_expires", "1800", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, extensions.timer.sess_expires));
2181 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bind_rtp_to_media_address", "no", OPT_BOOL_T, 1, STRFLDSET(struct ast_sip_endpoint, media.bind_rtp_to_media_address));
2182 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "identify_by", "username,ip", ident_handler, ident_to_str, NULL, 0, 0);
2183 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "direct_media", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.enabled));
2185 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_connected_line));
2186 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, id.send_connected_line));
2189 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "disable_direct_media_on_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.disable_on_nat));
2191 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_privacy", "allowed_not_screened", caller_id_privacy_handler, caller_id_privacy_to_str, NULL, 0, 0);
2193 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_inbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_inbound));
2194 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_outbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_outbound));
2195 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_pai", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_pai));
2196 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_rpid", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_rpid));
2197 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rpid_immediate", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.rpid_immediate));
2198 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_diversion", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_diversion));
2199 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_history_info", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_history_info));
2200 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.mailboxes));
2202 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "aggregate_mwi", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.aggregate));
2203 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_subscribe_replaces_unsolicited", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.subscribe_replaces_unsolicited));
2205 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_avpf", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_avpf));
2206 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_avp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.force_avp));
2207 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "media_use_received_transport", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_received_transport));
2208 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_keepalive", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.keepalive));
2209 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.timeout));
2210 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_timeout_hold", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.timeout_hold));
2211 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "one_touch_recording", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, info.recording.enabled));
2212 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "inband_progress", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, inband_progress));
2217 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "device_state_busy_at", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, devicestate_busy_at));
2218 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.enabled));
2220 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_maxdatagram", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.t38.maxdatagram));
2221 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, faxdetect));
2222 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, faxdetect_timeout));
2223 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.nat));
2224 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.ipv6));
2225 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_bind_udptl_to_media_address", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.bind_udptl_to_media_address));
2226 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tone_zone", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, zone));
2228 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "record_on_feature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.onfeature));
2229 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "record_off_feature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.offfeature));
2230 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_transfer", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allowtransfer));
2231 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "user_eq_phone", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, usereqphone));
2232 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "moh_passthrough", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, moh_passthrough));
2233 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_owner", "-", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpowner));
2234 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_session", "Asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpsession));
2237 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_audio", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_audio));
2238 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_video", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_video));
2239 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_subscribe", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.allow));
2240 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sub_min_expiry", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subscription.minexpiry));
2242 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "from_domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromdomain));
2243 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_from_user", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.fromuser));
2244 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_engine", "asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.rtp.engine));
2247 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_auto_generate_cert", "no", dtls_handler, dtlsautogeneratecert_to_str, NULL, 0, 0);
2255 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "srtp_tag_32", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.srtp_tag_32));
2256 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "media_encryption_optimistic", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.encryption_optimistic));
2257 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "g726_non_standard", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.g726_non_standard));
2258 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "redirect_method", "user", redirect_handler, NULL, NULL, 0, 0);
2260 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "message_context", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, message_context));
2265 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_deny", "", endpoint_acl_handler, NULL, NULL, 0, 0);
2266 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_permit", "", endpoint_acl_handler, NULL, NULL, 0, 0);
2268 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subscribe_context", "", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct ast_sip_endpoint, subscription.context));
2270 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "preferred_codec_only", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, preferred_codec_only));
2271 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "asymmetric_rtp_codec", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, asymmetric_rtp_codec));
2272 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtcp_mux", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtcp_mux));
2273 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_overlap", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_overlap));
2274 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "overlap_context", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, overlap_context));
2275 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "refer_blind_progress", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, refer_blind_progress));
2276 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "notify_early_inuse_ringing", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, notify_early_inuse_ringing));
2277 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_audio_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_audio_streams));
2278 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_video_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_video_streams));
2279 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bundle", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.bundle));
2280 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "webrtc", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, media.webrtc));
2281 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "incoming_mwi_mailbox", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, incoming_mwi_mailbox));
2282 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "follow_early_media_fork", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.follow_early_media_fork));
2283 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "accept_multiple_sdp_answers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.accept_multiple_sdp_answers));
2284 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "suppress_q850_reason_headers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, suppress_q850_reason_headers));
2285 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ignore_183_without_sdp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, ignore_183_without_sdp));
2286 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "incoming_call_offer_pref", "local",
2288 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "outgoing_call_offer_pref", "remote_merge",
2290 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_incoming_offer",
2291 "prefer: pending, operation: intersect, keep: all, transcode: allow",
2293 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_outgoing_offer",
2294 "prefer: pending, operation: union, keep: all, transcode: allow",
2296 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_incoming_answer",
2297 "prefer: pending, operation: intersect, keep: all",
2299 ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_outgoing_answer",
2300 "prefer: pending, operation: intersect, keep: all",
2303 "stir_shaken", 0, stir_shaken_handler, stir_shaken_to_str, NULL, 0, 0);
2304 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "stir_shaken_profile", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, stir_shaken_profile));
2305 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_unauthenticated_options", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_unauthenticated_options));
2306 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "geoloc_incoming_call_profile", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, geoloc_incoming_call_profile));
2307 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "geoloc_outgoing_call_profile", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, geoloc_outgoing_call_profile));
2310 ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_aoc", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, send_aoc));
2311
2313 ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
2315 sip_sorcery = NULL;
2316 return -1;
2317 }
2318
2320 ast_log(LOG_ERROR, "Failed to register SIP location support with sorcery\n");
2322 sip_sorcery = NULL;
2323 return -1;
2324 }
2325
2327
2329 ast_log(LOG_ERROR, "Failed to register SIP domain aliases support with sorcery\n");
2331 sip_sorcery = NULL;
2332 return -1;
2333 }
2334
2336 ast_log(LOG_ERROR, "Failed to register SIP Global support\n");
2338 sip_sorcery = NULL;
2339 return -1;
2340 }
2341
2343 if (!endpoint_formatter) {
2344 ast_log(LOG_ERROR, "Unable to allocate memory for endpoint_formatter\n");
2346 sip_sorcery = NULL;
2347 return -1;
2348 }
2349 endpoint_formatter->name = "endpoint";
2356
2359
2361
2363
2367
2368 return 0;
2369}
2370
2372{
2373 if (!sip_sorcery) {
2374 return;
2375 }
2376
2383 sip_sorcery = NULL;
2391}
2392
2394{
2395 if (sip_sorcery) {
2397 }
2398 return 0;
2399}
2400
2402{
2403 ast_string_field_free_memory(&subscription->mwi);
2404 ast_free(subscription->mwi.voicemail_extension);
2405}
2406
2408{
2410}
2411
2413{
2417}
2418
2419static void endpoint_destructor(void* obj)
2420{
2421 struct ast_sip_endpoint *endpoint = obj;
2422
2424
2425 ao2_cleanup(endpoint->media.codecs);
2428 info_configuration_destroy(&endpoint->info);
2432 ast_party_id_free(&endpoint->id.self);
2435 ao2_cleanup(endpoint->persistent);
2438 ast_free(endpoint->contact_user);
2439 ast_free_acl_list(endpoint->contact_acl);
2440 ast_free_acl_list(endpoint->acl);
2441}
2442
2444{
2446}
2447
2449{
2450 return ast_string_field_init(&info->recording, 32);
2451}
2452
2454{
2456}
2457
2459{
2460 struct ast_sip_endpoint *endpoint = ast_sorcery_generic_alloc(sizeof(*endpoint), endpoint_destructor);
2461 if (!endpoint) {
2462 return NULL;
2463 }
2464 if (ast_string_field_init(endpoint, 64)) {
2465 ao2_cleanup(endpoint);
2466 return NULL;
2467 }
2468
2469 if (ast_string_field_init_extended(endpoint, geoloc_incoming_call_profile) ||
2470 ast_string_field_init_extended(endpoint, geoloc_outgoing_call_profile)) {
2471 ao2_cleanup(endpoint);
2472 return NULL;
2473 }
2474 if (ast_string_field_init_extended(endpoint, overlap_context)) {
2475 ao2_cleanup(endpoint);
2476 return NULL;
2477 }
2478
2480 ao2_cleanup(endpoint);
2481 return NULL;
2482 }
2484 ao2_cleanup(endpoint);
2485 return NULL;
2486 }
2487 if (init_info_configuration(&endpoint->info)) {
2488 ao2_cleanup(endpoint);
2489 return NULL;
2490 }
2491 if (init_media_configuration(&endpoint->media)) {
2492 ao2_cleanup(endpoint);
2493 return NULL;
2494 }
2495
2496 ast_party_id_init(&endpoint->id.self);
2497 endpoint->id.self.tag = ast_strdup("");
2498
2499 if (AST_VECTOR_INIT(&endpoint->ident_method_order, 1)) {
2500 return NULL;
2501 }
2502
2503 return endpoint;
2504}
2505
2507{
2508 struct ao2_container *endpoints;
2509
2511
2512 return endpoints;
2513}
2514
2516{
2519 sip_sorcery, "endpoint", name);
2520}
2521
2523{
2524 int i;
2525
2526 for (i = 0; i < AST_VECTOR_SIZE(auths); ++i) {
2527 /* Using AST_VECTOR_GET is safe since the vector is immutable */
2528 const char *name = AST_VECTOR_GET(auths, i);
2530 if (!out[i]) {
2531 ast_log(LOG_NOTICE, "Couldn't find auth '%s'. Cannot authenticate\n", name);
2532 return -1;
2533 }
2534 }
2535
2536 return 0;
2537}
2538
2539void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths)
2540{
2541 int i;
2542 for (i = 0; i < num_auths; ++i) {
2543 ao2_cleanup(auths[i]);
2544 }
2545}
2546
2548 struct ast_sip_auth_objects_vector *auth_objects)
2549{
2550 int i;
2551
2552 for (i = 0; i < AST_VECTOR_SIZE(auth_ids); ++i) {
2553 /* Using AST_VECTOR_GET is safe since the vector is immutable */
2554 const char *name = AST_VECTOR_GET(auth_ids, i);
2556 if (!auth_object) {
2557 ast_log(LOG_WARNING, "Auth object '%s' could not be found\n", name);
2558 } else {
2559 AST_VECTOR_APPEND(auth_objects, auth_object);
2560 }
2561 }
2562
2563 return AST_VECTOR_SIZE(auth_objects) == AST_VECTOR_SIZE(auth_ids) ? 0 : -1;
2564}
2565
2567{
2568 return sip_sorcery;
2569}
Access Control of various sorts.
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
Definition: acl.c:966
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs
void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag)
Add a rule to an ACL struct.
Definition: acl.c:429
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
Definition: acl.c:540
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
Definition: acl.c:233
const char * str
Definition: app_jack.c:147
ast_mutex_t lock
Definition: app_sla.c:331
#define var
Definition: ast_expr2f.c:605
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
void ast_free_ptr(void *ptr)
free() wrapper
Definition: astmm.c:1739
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define ast_log
Definition: astobj2.c:42
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy all object references in the src container into the dest container.
@ CMP_MATCH
Definition: astobj2.h:1027
@ CMP_STOP
Definition: astobj2.h:1028
#define OBJ_KEY
Definition: astobj2.h:1151
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition: astobj2.h:367
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
Definition: astobj2.h:1226
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
Definition: astobj2.h:1554
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:404
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
Definition: astobj2.h:1063
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_UNLINK
Definition: astobj2.h:1039
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
Definition: astobj2.h:1327
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
Definition: callerid.c:1174
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1244
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1283
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1193
static PGresult * result
Definition: cel_pgsql.c:84
static char regcontext[AST_MAX_CONTEXT]
Definition: chan_iax2.c:325
static char language[MAX_LANGUAGE]
Definition: chan_iax2.c:324
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:473
static char mohsuggest[MAX_MUSICCLASS]
Definition: chan_iax2.c:475
static const char type[]
Definition: chan_ooh323.c:109
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups)
Print named call groups and named pickup groups.
Definition: channel.c:8055
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1757
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:1811
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call and pickup groups into buffer.
Definition: channel.c:8030
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
Definition: channel.c:7674
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7731
ast_group_t ast_get_group(const char *s)
Definition: channel.c:7617
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
#define AST_CLI_DEFINE(fn, txt,...)
Definition: cli.h:197
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static struct ao2_container * codecs
Registered codecs.
Definition: codec.c:48
int ast_sip_destroy_sorcery_auth(void)
Definition: config_auth.c:426
int ast_sip_initialize_sorcery_auth(void)
Initialize sorcery with auth support.
Definition: config_auth.c:370
int ast_sip_initialize_sorcery_domain_alias(void)
Initialize sorcery with domain alias support.
int ast_sip_destroy_sorcery_global(void)
int ast_sip_initialize_sorcery_global(void)
char * ast_sip_global_default_outbound_endpoint(void)
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
#define CHARFLDSET(type, field)
A helper macro to pass the appropriate arguments to aco_option_register for OPT_CHAR_ARRAY_T.
@ OPT_UINT_T
Type for default option handler for unsigned integers.
@ OPT_NOOP_T
Type for a default handler that should do nothing.
@ OPT_CODEC_T
Type for default option handler for format capabilities.
@ OPT_BOOL_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_CHAR_ARRAY_T
Type for default option handler for character array strings.
@ OPT_YESNO_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_STRINGFIELD_T
Type for default option handler for stringfields.
int ast_sip_initialize_sorcery_transport(void)
Initialize sorcery with transport support.
int ast_sip_destroy_sorcery_transport(void)
@ AST_DEVSTATE_CACHABLE
Definition: devicestate.h:70
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
Definition: devicestate.c:510
const char * ast_devstate2str(enum ast_device_state devstate) attribute_pure
Convert device state to text string for output.
Definition: devicestate.c:237
ast_device_state
Device States.
Definition: devicestate.h:52
@ AST_DEVICE_UNKNOWN
Definition: devicestate.h:53
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
ast_endpoint_state
Valid states for an endpoint.
Definition: endpoints.h:51
@ AST_ENDPOINT_OFFLINE
Definition: endpoints.h:55
@ AST_ENDPOINT_ONLINE
Definition: endpoints.h:57
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
const char * ast_endpoint_get_tech(const struct ast_endpoint *endpoint)
Gets the technology of the given endpoint.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
enum ast_endpoint_state ast_endpoint_get_state(const struct ast_endpoint *endpoint)
Gets the state of the given endpoint.
const char * ast_endpoint_get_resource(const struct ast_endpoint *endpoint)
Gets the resource name of the given endpoint.
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
@ E_MATCH
Definition: extconf.h:217
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
static const char name[]
Definition: format_mp3.c:68
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
Definition: manager.c:3423
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3381
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
Definition: manager.c:3386
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
Definition: manager.c:3459
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
Definition: manager.c:3042
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
Definition: manager.c:3467
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3302
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:8041
void ast_endpoint_blob_publish(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates and publishes a ast_endpoint_blob message.
struct stasis_message_type * ast_endpoint_contact_state_type(void)
Message type for endpoint contact state changes.
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
struct ast_endpoint_snapshot * ast_endpoint_latest_snapshot(const char *tech, const char *resource)
Retrieve the most recent snapshot for the endpoint with the given name.
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
#define INFINITY
char * strsep(char **str, const char *delims)
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
Definition: main/config.c:543
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
Definition: main/config.c:667
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
#define LOG_ERROR
#define ast_verb(level,...)
#define LOG_NOTICE
#define LOG_WARNING
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:421
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
Definition: lock.h:604
static struct ao2_container * endpoints
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define EVENT_FLAG_SYSTEM
Definition: manager.h:75
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:191
def ignore(key=None, val=None, section=None, pjsip=None, nmapped=None, type='endpoint')
Definition: sip_to_pjsip.py:48
def info(msg)
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Definition: netsock2.c:230
static char * ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition: netsock2.h:313
Core PBX routines and definitions.
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
Definition: pbx.c:6928
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4175
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
Definition: pbx.c:6149
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
Definition: pbx.c:4948
struct ast_exten * pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
Definition: ael_main.c:152
static int tos_video_to_str(const void *obj, const intptr_t *args, char **buf)
static void cli_endpoint_print_child_body(char *type, const void *obj, struct ast_sip_cli_context *context)
static void persistent_endpoint_destroy(void *obj)
Destructor function for persistent endpoint information.
static int t38udptl_ec_to_str(const void *obj, const intptr_t *args, char **buf)
static void cli_endpoint_print_child_header(char *type, struct ast_sip_cli_context *context)
static int connected_line_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int outgoing_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
static void media_configuration_destroy(struct ast_sip_endpoint_media_configuration *media)
static int codec_prefs_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static void load_all_endpoints(void)
static int format_ami_endpoint(const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami)
static int from_user_to_str(const void *obj, const intptr_t *args, char **buf)
static void * sip_nat_hook_alloc(const char *name)
void ast_sip_persistent_endpoint_publish_contact_state(const char *endpoint_name, const struct ast_sip_contact_status *contact_status)
Publish the change of state for a contact.
static int prack_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
int ast_sip_set_security_negotiation(enum ast_sip_security_negotiation *security_negotiation, const char *val)
Set the security negotiation based on a given string.
static int init_info_configuration(struct ast_sip_endpoint_info_configuration *info)
static int set_var_to_vl(const void *obj, struct ast_variable **fields)
static struct ast_cli_entry cli_commands[]
static int redirect_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
struct ast_sip_cli_formatter_entry * endpoint_formatter
static int media_address_to_str(const void *obj, const intptr_t *args, char **buf)
static int stir_shaken_to_str(const void *obj, const intptr_t *args, char **buf)
#define PERSISTENT_BUCKETS
Number of buckets for persistent endpoint information.
static int stir_shaken_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static void endpoint_deleted_observer(const void *object)
static int incoming_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
struct ao2_container * ast_sip_get_endpoints(void)
Retrieve any endpoints available to sorcery.
static int caller_id_privacy_to_str(const void *obj, const intptr_t *args, char **buf)
static int pickupgroup_to_str(const void *obj, const intptr_t *args, char **buf)
static int cli_endpoint_print_body(void *obj, void *arg, int flags)
void * ast_sip_endpoint_alloc(const char *name)
Allocate a new SIP endpoint.
static int contact_user_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int ident_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static struct stasis_subscription * acl_change_sub
static int tos_audio_to_str(const void *obj, const intptr_t *args, char **buf)
static int direct_media_method_to_str(const void *obj, const intptr_t *args, char **buf)
static struct ast_endpoint * persistent_endpoint_find_or_create(const struct ast_sip_endpoint *endpoint)
Internal function which finds (or creates) persistent endpoint information.
static void info_configuration_destroy(struct ast_sip_endpoint_info_configuration *info)
int ast_sip_for_each_channel_snapshot(const struct ast_endpoint_snapshot *endpoint_snapshot, ao2_callback_fn on_channel_snapshot, void *arg)
For every channel snapshot on an endpoint snapshot call the given 'on_channel_snapshot' handler.
void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths)
Clean up retrieved auth structures from memory.
static int call_offer_pref_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int dtlsverify_to_str(const void *obj, const intptr_t *args, char **buf)
static int codec_prefs_to_str(const struct ast_stream_codec_negotiation_prefs *prefs, const void *obj, const intptr_t *args, char **buf)
static const char * direct_media_glare_mitigation_map[]
static int dtls_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int media_encryption_to_str(const void *obj, const intptr_t *args, char **buf)
static int ami_show_endpoints(struct mansession *s, const struct message *m)
static int dtmf_to_str(const void *obj, const intptr_t *args, char **buf)
static int outbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static const struct ast_sorcery_observer endpoint_observers
static int group_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int ami_show_endpoint(struct mansession *s, const struct message *m)
static const char * ast_rtp_dtls_setup_map[]
static int outgoing_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
static int contact_user_to_str(const void *obj, const intptr_t *args, char **buf)
static int voicemail_extension_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_sip_auths_to_str(const struct ast_sip_auth_vector *auths, char **buf)
Converts an auths array to a string of comma separated values.
static int dtlscapath_to_str(const void *obj, const intptr_t *args, char **buf)
static int contact_acl_to_str(const void *obj, const intptr_t *args, char **buf)
static int set_var_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define AMI_SHOW_ENDPOINT
static int named_callgroups_to_str(const void *obj, const intptr_t *args, char **buf)
struct ast_endpoint_snapshot * ast_sip_get_endpoint_snapshot(const struct ast_sip_endpoint *endpoint)
Retrieve the endpoint snapshot for an endpoint.
static int security_negotiation_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
void ast_sip_auth_vector_destroy(struct ast_sip_auth_vector *auths)
Free contents of an auth vector.
static int active_channels_to_str_cb(void *object, void *arg, int flags)
static int dtlscipher_to_str(const void *obj, const intptr_t *args, char **buf)
static int t38udptl_ec_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
int ast_sip_retrieve_auths(const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out)
Retrieve relevant SIP auth structures from sorcery.
static int named_pickupgroups_to_str(const void *obj, const intptr_t *args, char **buf)
static int caller_id_tag_to_str(const void *obj, const intptr_t *args, char **buf)
static void sip_sorcery_object_ami_set_type_name(const void *obj, struct ast_str **buf)
static int caller_id_to_str(const void *obj, const intptr_t *args, char **buf)
static int incoming_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_res_pjsip_reload_configuration(void)
static int cli_endpoint_iterate(void *obj, ao2_callback_fn callback, void *args)
static int security_mechanism_to_str(const void *obj, const intptr_t *args, char **buf)
static int prack_to_str(const void *obj, const intptr_t *args, char **buf)
static int caller_id_tag_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int init_media_configuration(struct ast_sip_endpoint_media_configuration *media)
static int cli_endpoint_print_header(void *obj, void *arg, int flags)
static int format_str_append_auth(const struct ast_sip_auth_vector *auths, struct ast_str **buf)
static int dtlsfingerprint_to_str(const void *obj, const intptr_t *args, char **buf)
static int dtlsautogeneratecert_to_str(const void *obj, const intptr_t *args, char **buf)
static int voicemail_extension_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int callgroup_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_sip_persistent_endpoint_update_state(const char *endpoint_name, enum ast_endpoint_state state)
Change state of a persistent endpoint.
const char * ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint)
Retrieve the device state for an endpoint.
static int outbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
struct ast_sip_endpoint * ast_sip_default_outbound_endpoint(void)
Retrieve the default outbound endpoint.
struct ast_sip_cli_formatter_entry * channel_formatter
static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *obj)
Callback function for when an object is finalized.
static const char * id_configuration_refresh_methods[]
static int sip_endpoints_aors_ami(void *obj, void *arg, int flags)
static const char * ast_rtp_dtls_fingerprint_map[]
static const char * sip_endpoint_identifier_type2str(enum ast_sip_endpoint_identifier_type method)
int ast_sip_retrieve_auths_vector(const struct ast_sip_auth_vector *auth_ids, struct ast_sip_auth_objects_vector *auth_objects)
Retrieve relevant SIP auth structures from sorcery as a vector.
static int connected_line_method_to_str(const void *obj, const intptr_t *args, char **buf)
static int init_subscription_configuration(struct ast_sip_endpoint_subscription_configuration *subscription)
static int media_encryption_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int persistent_endpoint_cmp(void *obj, void *arg, int flags)
Comparison function for persistent endpoint information.
static void * cli_endpoint_retrieve_by_id(const char *id)
static int inbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
Converts a sorcery object to a string of object properties.
static int incoming_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
static int inbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_res_pjsip_initialize_configuration(void)
static const char * security_negotiation_map[]
static int dtlsrekey_to_str(const void *obj, const intptr_t *args, char **buf)
static int outgoing_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
static struct ast_sorcery * sip_sorcery
static int dtmf_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int endpoint_acl_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int from_user_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int set_var_to_str(const void *obj, const intptr_t *args, char **buf)
struct ast_str * ast_sip_create_ami_event(const char *event, struct ast_sip_ami *ami)
Creates a string to store AMI event data in.
static int security_negotiation_to_str(const void *obj, const intptr_t *args, char **buf)
static void subscription_configuration_destroy(struct ast_sip_endpoint_subscription_configuration *subscription)
void ast_res_pjsip_destroy_configuration(void)
static int sip_endpoint_to_ami(const struct ast_sip_endpoint *endpoint, struct ast_str **buf)
static void endpoint_destructor(void *obj)
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static int direct_media_glare_mitigation_to_str(const void *obj, const intptr_t *args, char **buf)
static const char * media_encryption_map[]
static int dtlssetup_to_str(const void *obj, const intptr_t *args, char **buf)
static int tos_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int caller_id_privacy_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
int ast_sip_auth_vector_init(struct ast_sip_auth_vector *auths, const char *value)
Initialize an auth vector with the configured values.
#define AMI_SHOW_ENDPOINTS
static int acl_to_str(const void *obj, const intptr_t *args, char **buf)
static int security_mechanism_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int media_address_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static void active_channels_to_str(const struct ast_sip_endpoint *endpoint, struct ast_str **str)
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.
static int direct_media_glare_mitigation_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int ident_to_str(const void *obj, const intptr_t *args, char **buf)
static struct ao2_container * persistent_endpoints
Container for persistent endpoint information.
static int sip_endpoint_identifier_str2type(const char *str)
static int dtlscafile_to_str(const void *obj, const intptr_t *args, char **buf)
static int dtlscertfile_to_str(const void *obj, const intptr_t *args, char **buf)
static int format_ami_endpoints(void *obj, void *arg, int flags)
#define AMI_DEFAULT_STR_SIZE
static int timers_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int direct_media_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
int ast_sip_persistent_endpoint_add_to_regcontext(const char *regcontext)
static struct ao2_container * cli_endpoint_get_container(const char *regex)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int dtlsprivatekey_to_str(const void *obj, const intptr_t *args, char **buf)
static int persistent_endpoint_hash(const void *obj, const int flags)
Hashing function for persistent endpoint information.
static int add_to_regcontext(void *obj, void *arg, int flags)
static int named_groups_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int caller_id_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static const char * ast_t38_ec_modes_map[]
static int timers_to_str(const void *obj, const intptr_t *args, char **buf)
struct stasis_forward * sub
Definition: res_corosync.c:240
struct ao2_container * container
Definition: res_fax.c:501
struct ast_geoloc_profile * ast_geoloc_get_profile(const char *id)
Retrieve a geolocation profile by id.
int ast_geoloc_is_loaded(void)
Check if res_geolocation is available.
static struct @450 methods[]
const char * method
Definition: res_pjsip.c:1279
ast_sip_endpoint_identifier_type
Different methods by which incoming requests can be matched to endpoints.
Definition: res_pjsip.h:609
@ AST_SIP_ENDPOINT_IDENTIFY_BY_HEADER
Definition: res_pjsip.h:617
@ AST_SIP_ENDPOINT_IDENTIFY_BY_TRANSPORT
Definition: res_pjsip.h:621
@ AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME
Definition: res_pjsip.h:611
@ AST_SIP_ENDPOINT_IDENTIFY_BY_REQUEST_URI
Definition: res_pjsip.h:619
@ AST_SIP_ENDPOINT_IDENTIFY_BY_IP
Definition: res_pjsip.h:615
@ AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME
Definition: res_pjsip.h:613
int ast_sip_call_codec_str_to_pref(struct ast_flags *pref, const char *pref_str, int is_outgoing)
Convert a call codec preference string to preference flags.
Definition: res_pjsip.c:2577
@ AST_SIP_REDIRECT_URI_CORE
Definition: res_pjsip.h:660
@ AST_SIP_REDIRECT_URI_PJSIP
Definition: res_pjsip.h:662
@ AST_SIP_REDIRECT_USER
Definition: res_pjsip.h:658
int ast_sip_for_each_contact(const struct ast_sip_aor *aor, ao2_callback_fn on_contact, void *arg)
For every contact on an AOR call the given 'on_contact' handler.
Definition: location.c:722
int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg)
For every aor in the comma separated aors string call the given 'on_aor' handler.
Definition: location.c:687
@ AST_SIP_MEDIA_ENCRYPT_SDES
Definition: res_pjsip.h:651
@ AST_SIP_MEDIA_TRANSPORT_INVALID
Definition: res_pjsip.h:647
@ AST_SIP_MEDIA_ENCRYPT_NONE
Definition: res_pjsip.h:649
@ AST_SIP_MEDIA_ENCRYPT_DTLS
Definition: res_pjsip.h:653
int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami, int *count)
Formats the endpoint and sends over AMI.
Definition: res_pjsip.c:501
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
const char * ast_sip_call_codec_pref_to_str(struct ast_flags pref)
Convert the call codec preference flags to a string.
Definition: res_pjsip.c:2554
int ast_sip_security_mechanisms_to_str(const struct ast_sip_security_mechanism_vector *security_mechanisms, int add_qvalue, char **buf)
Writes the security mechanisms of an endpoint into a buffer as a string and returns the buffer.
#define SIP_SORCERY_AUTH_TYPE
Definition: res_pjsip.h:577
ast_sip_security_negotiation
The kind of security negotiation.
Definition: res_pjsip.h:353
@ AST_SIP_SECURITY_NEG_MEDIASEC
Definition: res_pjsip.h:357
@ AST_SIP_SECURITY_NEG_NONE
Definition: res_pjsip.h:355
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
Definition: res_pjsip.c:2533
char * ast_sip_get_regcontext(void)
Retrieve the global regcontext setting.
@ AST_SIP_CALL_CODEC_PREF_ALL
Definition: res_pjsip.h:679
@ AST_SIP_CALL_CODEC_PREF_LOCAL
Definition: res_pjsip.h:685
@ AST_SIP_CALL_CODEC_PREF_FIRST
Definition: res_pjsip.h:681
@ AST_SIP_CALL_CODEC_PREF_INTERSECT
Definition: res_pjsip.h:673
int ast_sip_security_mechanism_vector_init(struct ast_sip_security_mechanism_vector *security_mechanism, const char *value)
Initialize security mechanism vector from string of security mechanisms.
const char * ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
translate ast_sip_contact_status_type to character string.
int ast_sip_contact_to_str(void *object, void *arg, int flags)
Handler used to convert a contact to a string.
Definition: location.c:770
@ AST_SIP_100REL_PEER_SUPPORTED
Definition: res_pjsip.h:535
@ AST_SIP_100REL_UNSUPPORTED
Definition: res_pjsip.h:531
@ AST_SIP_100REL_SUPPORTED
Definition: res_pjsip.h:533
@ AST_SIP_100REL_REQUIRED
Definition: res_pjsip.h:537
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE
Definition: res_pjsip.h:634
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING
Definition: res_pjsip.h:642
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_OUTGOING
Definition: res_pjsip.h:638
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
Definition: res_pjsip.h:629
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
Definition: res_pjsip.h:627
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
Definition: pjsip_cli.c:36
struct ast_sip_cli_formatter_entry * ast_sip_lookup_cli_formatter(const char *name)
Looks up a CLI formatter by type.
Definition: pjsip_cli.c:305
#define CLI_LAST_TABSTOP
Definition: res_pjsip_cli.h:27
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: pjsip_cli.c:109
#define CLI_INDENT_TO_SPACES(x)
Definition: res_pjsip_cli.h:29
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
static struct ast_sorcery * sorcery
void ast_sip_destroy_cli(void)
Definition: pjsip_cli.c:375
int ast_sip_initialize_sorcery_location(void)
Initialize sorcery with location support.
Definition: location.c:1369
int ast_sip_destroy_sorcery_location(void)
Definition: location.c:1471
int ast_sip_initialize_cli(void)
Definition: pjsip_cli.c:360
#define NULL
Definition: resample.c:96
@ AST_RTP_DTLS_SETUP_PASSIVE
Definition: rtp_engine.h:561
@ AST_RTP_DTLS_SETUP_HOLDCONN
Definition: rtp_engine.h:563
@ AST_RTP_DTLS_SETUP_ACTPASS
Definition: rtp_engine.h:562
@ AST_RTP_DTLS_SETUP_ACTIVE
Definition: rtp_engine.h:560
@ AST_RTP_DTLS_HASH_SHA1
Definition: rtp_engine.h:575
@ AST_RTP_DTLS_HASH_SHA256
Definition: rtp_engine.h:574
void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
Free contents of a DTLS configuration structure.
Definition: rtp_engine.c:3168
@ AST_RTP_DTLS_VERIFY_FINGERPRINT
Definition: rtp_engine.h:581
int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value)
Parse DTLS related configuration options.
Definition: rtp_engine.c:3057
int ast_rtp_dtls_cfg_validate(struct ast_rtp_dtls_cfg *dtls_cfg)
Validates DTLS related configuration options.
Definition: rtp_engine.c:3131
Security Event Reporting API.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
Sorcery Data Access Layer API.
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
Definition: sorcery.h:1500
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
@ AST_RETRIEVE_FLAG_MULTIPLE
Return all matching objects.
Definition: sorcery.h:120
@ AST_RETRIEVE_FLAG_ALL
Perform no matching, return all objects.
Definition: sorcery.h:123
void ast_sorcery_load(const struct ast_sorcery *sorcery)
Inform any wizards to load persistent objects.
Definition: sorcery.c:1377
#define ast_sorcery_object_field_register_alias(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object as an alias.
Definition: sorcery.h:971
const char * ast_sorcery_object_get_type(const void *object)
Get the type of a sorcery object.
Definition: sorcery.c:2324
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
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:837
void ast_sorcery_reload(const struct ast_sorcery *sorcery)
Inform any wizards to reload persistent objects.
Definition: sorcery.c:1408
struct ao2_container * ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex)
Retrieve multiple objects using a regular expression on their id.
Definition: sorcery.c:1949
int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Add an observer to a specific object type.
Definition: sorcery.c:2386
#define ast_sorcery_internal_object_register(sorcery, type, alloc, transform, apply)
Register an internal, hidden object type.
Definition: sorcery.h:867
#define ast_sorcery_object_field_register_custom(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers.
Definition: sorcery.h:1005
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
int ast_sorcery_object_id_compare(void *obj, void *arg, int flags)
ao2 object comparator based on sorcery id.
Definition: sorcery.c:2459
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
int ast_sorcery_object_id_sort(const void *obj, const void *arg, int flags)
ao2 object sorter based on sorcery id.
Definition: sorcery.c:2435
@ AST_HANDLER_ONLY_STRING
Use string handler only.
Definition: sorcery.h:137
void ast_sorcery_force_reload_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to reload persistent objects even if no changes determin...
Definition: sorcery.c:1457
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
Definition: sorcery.h:110
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:476
#define ast_sorcery_open()
Open a new sorcery structure.
Definition: sorcery.h:406
struct ast_variable * ast_sorcery_objectset_create2(const struct ast_sorcery *sorcery, const void *object, enum ast_sorcery_field_handler_flags flags)
Create an object set (KVP list) for an object.
Definition: sorcery.c:1511
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
Definition: sorcery.c:1897
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
Definition: stasis.h:297
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
Definition: stasis.c:1023
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
Definition: stasis.c:1077
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Definition: stasis.c:1134
#define stasis_subscribe(topic, callback, data)
Definition: stasis.h:649
Media Stream API.
#define AST_STREAM_MAX_CODEC_PREFS_LENGTH
Define for allocating buffer space for to_str() functions.
Definition: stream.h:307
ast_stream_codec_negotiation_prefs_operation_values
The "operation" values.
Definition: stream.h:159
@ CODEC_NEGOTIATION_OPERATION_UNSPECIFIED
Definition: stream.h:160
@ CODEC_NEGOTIATION_OPERATION_UNION
Definition: stream.h:164
@ CODEC_NEGOTIATION_OPERATION_INTERSECT
Definition: stream.h:162
@ CODEC_NEGOTIATION_KEEP_UNSPECIFIED
Definition: stream.h:178
@ CODEC_NEGOTIATION_KEEP_ALL
Definition: stream.h:180
int ast_stream_codec_prefs_parse(const char *pref_string, struct ast_stream_codec_negotiation_prefs *prefs, struct ast_str **error_message)
Parses a string representing the codec prefs into a ast_stream_codec_negotiation_pref structure.
Definition: stream.c:181
#define ast_stream_codec_operation_to_str(value)
Safely get the name of an "operation" parameter value.
Definition: stream.h:264
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
Definition: stream.c:743
const char * ast_stream_codec_prefs_to_str(const struct ast_stream_codec_negotiation_prefs *prefs, struct ast_str **buf)
Return a string representing the codec preferences.
Definition: stream.c:132
@ CODEC_NEGOTIATION_TRANSCODE_UNSPECIFIED
Definition: stream.h:192
@ CODEC_NEGOTIATION_TRANSCODE_ALLOW
Definition: stream.h:194
struct ast_stream_topology * ast_stream_topology_create_from_format_cap(struct ast_format_cap *cap)
A helper function that, given a format capabilities structure, creates a topology and separates the m...
Definition: stream.c:848
@ CODEC_NEGOTIATION_PARAM_OPERATION
Definition: stream.h:132
ast_stream_codec_negotiation_prefs_prefer_values
The "prefer" values.
Definition: stream.h:145
@ CODEC_NEGOTIATION_PREFER_UNSPECIFIED
Definition: stream.h:146
@ CODEC_NEGOTIATION_PREFER_PENDING
Definition: stream.h:148
#define ast_stream_codec_param_to_str(value)
Safely get the name of a preference parameter.
Definition: stream.h:244
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359
#define ast_string_field_init_extended(x, field)
Initialize an extended string field.
Definition: stringfields.h:401
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:374
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
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1259
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
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
Definition: utils.c:2216
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1113
#define AST_YESNO(x)
return Yes or No depending on the argument.
Definition: strings.h:143
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
#define ast_to_camel_case(s)
Attempts to convert the given string to camel case using an underscore as the specified delimiter.
Definition: strings.h:546
void ast_join_delim(char *s, size_t len, const char *const w[], unsigned int size, char delim)
Join an array of strings into a single string.
Definition: utils.c:2378
Generic container type.
Wrapper for an ast_acl linked list.
Definition: acl.h:76
an ast_acl is a linked list node of ast_ha structs which may have names.
Definition: acl.h:67
char name[ACL_NAME_LENGTH]
Definition: acl.h:71
const ast_string_field name
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_base * base
descriptor for a cli entry.
Definition: cli.h:171
char * command
Definition: cli.h:186
A snapshot of an endpoint's state.
Structure used to handle boolean flags.
Definition: utils.h:199
unsigned int flags
Definition: utils.h:200
Abstract JSON element (object, array, string, int, ...).
char * tag
User-set "tag".
Definition: channel.h:354
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:277
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
char * str
Subscriber name (Malloced)
Definition: channel.h:264
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
enum ast_rtp_dtls_setup default_setup
Definition: rtp_engine.h:603
enum ast_rtp_dtls_verify verify
Definition: rtp_engine.h:606
unsigned int rekey
Definition: rtp_engine.h:602
enum ast_rtp_dtls_hash hash
Definition: rtp_engine.h:605
unsigned int enabled
Definition: rtp_engine.h:601
unsigned int ephemeral_cert
Definition: rtp_engine.h:612
AMI variable container.
Definition: res_pjsip.h:3047
const char * action_id
Definition: res_pjsip.h:3053
struct mansession * s
Definition: res_pjsip.h:3049
void * arg
Definition: res_pjsip.h:3055
const struct message * m
Definition: res_pjsip.h:3051
A SIP address of record.
Definition: res_pjsip.h:478
const char ** elems
Definition: res_pjsip.h:604
CLI Formatter Context passed to all formatters.
Definition: res_pjsip_cli.h:34
CLI Formatter Registry Entry.
Definition: res_pjsip_cli.h:52
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
const char * name
Definition: res_pjsip_cli.h:58
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
A contact's status.
Definition: res_pjsip.h:451
const ast_string_field uri
Definition: res_pjsip.h:457
enum ast_sip_contact_status_type status
Definition: res_pjsip.h:468
const ast_string_field aor
Definition: res_pjsip.h:457
enum ast_sip_direct_media_glare_mitigation glare_mitigation
Definition: res_pjsip.h:882
enum ast_sip_session_refresh_method method
Definition: res_pjsip.h:880
struct ast_sip_timer_options timer
Definition: res_pjsip.h:721
struct ast_party_id self
Definition: res_pjsip.h:772
enum ast_sip_session_refresh_method refresh_method
Definition: res_pjsip.h:790
Endpoint configuration options for INFO packages.
Definition: res_pjsip.h:826
Media configuration for SIP endpoints.
Definition: res_pjsip.h:905
struct ast_sip_media_rtp_configuration rtp
Definition: res_pjsip.h:915
struct ast_stream_topology * topology
Definition: res_pjsip.h:923
struct ast_format_cap * codecs
Definition: res_pjsip.h:921
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_offer
Definition: res_pjsip.h:951
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_answer
Definition: res_pjsip.h:955
struct ast_sip_direct_media_configuration direct_media
Definition: res_pjsip.h:917
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_offer
Definition: res_pjsip.h:953
struct ast_flags incoming_call_offer_pref
Definition: res_pjsip.h:947
struct ast_flags outgoing_call_offer_pref
Definition: res_pjsip.h:949
struct ast_sip_t38_configuration t38
Definition: res_pjsip.h:919
const ast_string_field address
Definition: res_pjsip.h:913
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_answer
Definition: res_pjsip.h:957
struct ast_namedgroups * named_pickupgroups
Definition: res_pjsip.h:806
struct ast_namedgroups * named_callgroups
Definition: res_pjsip.h:804
Endpoint subscription configuration.
Definition: res_pjsip.h:745
struct ast_sip_mwi_configuration mwi
Definition: res_pjsip.h:751
An entity with which Asterisk communicates.
Definition: res_pjsip.h:963
struct ast_sip_auth_vector outbound_auths
Definition: res_pjsip.h:1010
enum ast_sip_endpoint_identifier_type ident_method
Definition: res_pjsip.h:1014
char * contact_user
Definition: res_pjsip.h:1042
struct ast_endpoint * persistent
Definition: res_pjsip.h:1020
enum ast_sip_session_redirect redirect_method
Definition: res_pjsip.h:1028
const ast_string_field transport
Definition: res_pjsip.h:992
struct ast_sip_endpoint_id_configuration id
Definition: res_pjsip.h:1002
const ast_string_field aors
Definition: res_pjsip.h:992
struct ast_sip_endpoint_pickup_configuration pickup
Definition: res_pjsip.h:1006
enum ast_sip_security_negotiation security_negotiation