Asterisk - The Open Source Telephony Project  GIT-master-a24979a
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 
24 #include "asterisk/res_pjsip.h"
26 #include "asterisk/res_pjsip_cli.h"
27 #include "asterisk/acl.h"
28 #include "asterisk/manager.h"
29 #include "asterisk/astobj2.h"
30 #include "asterisk/utils.h"
31 #include "asterisk/sorcery.h"
32 #include "asterisk/callerid.h"
33 #include "asterisk/test.h"
34 #include "asterisk/statsd.h"
35 #include "asterisk/pbx.h"
36 #include "asterisk/stream.h"
37 #include "asterisk/stasis.h"
39 
40 /*! \brief Number of buckets for persistent endpoint information */
41 #define PERSISTENT_BUCKETS 53
42 
43 /*! \brief Persistent endpoint information */
45  /*! \brief Asterisk endpoint itself */
47 };
48 
49 /*! \brief Container for persistent endpoint information */
51 
52 static struct ast_sorcery *sip_sorcery;
53 
55 
56 /*! \brief Hashing function for persistent endpoint information */
57 static int persistent_endpoint_hash(const void *obj, const int flags)
58 {
59  const struct sip_persistent_endpoint *persistent = obj;
60  const char *id = (flags & OBJ_KEY ? obj : ast_endpoint_get_resource(persistent->endpoint));
61 
62  return ast_str_hash(id);
63 }
64 
65 /*! \brief Comparison function for persistent endpoint information */
66 static int persistent_endpoint_cmp(void *obj, void *arg, int flags)
67 {
68  const struct sip_persistent_endpoint *persistent1 = obj;
69  const struct sip_persistent_endpoint *persistent2 = arg;
70  const char *id = (flags & OBJ_KEY ? arg : ast_endpoint_get_resource(persistent2->endpoint));
71 
72  return !strcmp(ast_endpoint_get_resource(persistent1->endpoint), id) ? CMP_MATCH | CMP_STOP : 0;
73 }
74 
75 static void endpoint_deleted_observer(const void *object)
76 {
77  const struct ast_sip_endpoint *endpoint = object;
78 
81 }
82 
83 static const struct ast_sorcery_observer endpoint_observers = {
85 };
86 
87 static int endpoint_acl_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
88 {
89  struct ast_sip_endpoint *endpoint = obj;
90  int error = 0;
91  int ignore;
92 
93  if (ast_strlen_zero(var->value)) return 0;
94 
95  if (!strncmp(var->name, "contact_", 8)) {
96  ast_append_acl(var->name + 8, var->value, &endpoint->contact_acl, &error, &ignore);
97  } else {
98  ast_append_acl(var->name, var->value, &endpoint->acl, &error, &ignore);
99  }
100 
101  return error;
102 }
103 
104 static int acl_to_str(const void *obj, const intptr_t *args, char **buf)
105 {
106  const struct ast_sip_endpoint *endpoint = obj;
107  struct ast_acl_list *acl_list;
108  struct ast_acl *first_acl;
109 
110  if (endpoint && !ast_acl_list_is_empty(acl_list=endpoint->acl)) {
111  AST_LIST_LOCK(acl_list);
112  first_acl = AST_LIST_FIRST(acl_list);
113  if (ast_strlen_zero(first_acl->name)) {
114  *buf = "deny/permit";
115  } else {
116  *buf = first_acl->name;
117  }
118  AST_LIST_UNLOCK(acl_list);
119  }
120 
121  *buf = ast_strdup(*buf);
122  return 0;
123 }
124 
125 static int contact_acl_to_str(const void *obj, const intptr_t *args, char **buf)
126 {
127  const struct ast_sip_endpoint *endpoint = obj;
128  struct ast_acl_list *acl_list;
129  struct ast_acl *first_acl;
130 
131  if (endpoint && !ast_acl_list_is_empty(acl_list=endpoint->contact_acl)) {
132  AST_LIST_LOCK(acl_list);
133  first_acl = AST_LIST_FIRST(acl_list);
134  if (ast_strlen_zero(first_acl->name)) {
135  *buf = "deny/permit";
136  } else {
137  *buf = first_acl->name;
138  }
139  AST_LIST_UNLOCK(acl_list);
140  }
141 
142  *buf = ast_strdup(*buf);
143  return 0;
144 }
145 
146 static int dtmf_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
147 {
148  struct ast_sip_endpoint *endpoint = obj;
149  int dtmf = ast_sip_str_to_dtmf(var->value);
150 
151  if (dtmf == -1) {
152  return -1;
153  }
154 
155  endpoint->dtmf = dtmf;
156  return 0;
157 }
158 
159 static int dtmf_to_str(const void *obj, const intptr_t *args, char **buf)
160 {
161  const struct ast_sip_endpoint *endpoint = obj;
162  char dtmf_str[20];
163  int result = -1;
164 
165  result = ast_sip_dtmf_to_str(endpoint->dtmf, dtmf_str, sizeof(dtmf_str));
166 
167  if (result == 0) {
168  *buf = ast_strdup(dtmf_str);
169  } else {
170  *buf = ast_strdup("none");
171  }
172  return 0;
173 }
174 
175 static int prack_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
176 {
177  struct ast_sip_endpoint *endpoint = obj;
178 
179  /* clear all */
180  endpoint->extensions.flags &= ~(PJSIP_INV_SUPPORT_100REL | PJSIP_INV_REQUIRE_100REL);
181 
182  if (ast_true(var->value)) {
183  endpoint->extensions.flags |= PJSIP_INV_SUPPORT_100REL;
184  } else if (!strcasecmp(var->value, "required")) {
185  endpoint->extensions.flags |= PJSIP_INV_REQUIRE_100REL;
186  } else if (!ast_false(var->value)){
187  return -1;
188  }
189 
190  return 0;
191 }
192 
193 static int prack_to_str(const void *obj, const intptr_t *args, char **buf)
194 {
195  const struct ast_sip_endpoint *endpoint = obj;
196 
197  if (endpoint->extensions.flags & PJSIP_INV_REQUIRE_100REL) {
198  *buf = "required";
199  } else if (endpoint->extensions.flags & PJSIP_INV_SUPPORT_100REL) {
200  *buf = "yes";
201  } else {
202  *buf = "no";
203  }
204 
205  *buf = ast_strdup(*buf);
206  return 0;
207 }
208 
209 static int timers_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
210 {
211  struct ast_sip_endpoint *endpoint = obj;
212 
213  /* clear all */
214  endpoint->extensions.flags &= ~(PJSIP_INV_SUPPORT_TIMER | PJSIP_INV_REQUIRE_TIMER
215  | PJSIP_INV_ALWAYS_USE_TIMER);
216 
217  /* set only the specified flag and let pjsip normalize if needed */
218  if (ast_true(var->value)) {
219  endpoint->extensions.flags |= PJSIP_INV_SUPPORT_TIMER;
220  } else if (!strcasecmp(var->value, "required")) {
221  endpoint->extensions.flags |= PJSIP_INV_REQUIRE_TIMER;
222  } else if (!strcasecmp(var->value, "always") || !strcasecmp(var->value, "forced")) {
223  endpoint->extensions.flags |= PJSIP_INV_ALWAYS_USE_TIMER;
224  } else if (!ast_false(var->value)) {
225  return -1;
226  }
227 
228  return 0;
229 }
230 
231 static int timers_to_str(const void *obj, const intptr_t *args, char **buf)
232 {
233  const struct ast_sip_endpoint *endpoint = obj;
234 
235  if (endpoint->extensions.flags & PJSIP_INV_ALWAYS_USE_TIMER) {
236  *buf = "always";
237  } else if (endpoint->extensions.flags & PJSIP_INV_REQUIRE_TIMER) {
238  *buf = "required";
239  } else if (endpoint->extensions.flags & PJSIP_INV_SUPPORT_TIMER) {
240  *buf = "yes";
241  } else {
242  *buf = "no";
243  }
244 
245  *buf = ast_strdup(*buf);
246  return 0;
247 }
248 
250 {
251  int i;
252  size_t size;
253 
254  if (!auths) {
255  return;
256  }
257 
258  size = AST_VECTOR_SIZE(auths);
259 
260  for (i = 0; i < size; ++i) {
261  const char *name = AST_VECTOR_REMOVE_UNORDERED(auths, 0);
262  ast_free((char *) name);
263  }
264  AST_VECTOR_FREE(auths);
265 }
266 
267 int ast_sip_auth_vector_init(struct ast_sip_auth_vector *auths, const char *value)
268 {
269  char *auth_names = ast_strdupa(value);
270  char *val;
271 
272  ast_assert(auths != NULL);
273 
274  if (AST_VECTOR_SIZE(auths)) {
276  }
277  if (AST_VECTOR_INIT(auths, 1)) {
278  return -1;
279  }
280 
281  while ((val = ast_strip(strsep(&auth_names, ",")))) {
282  if (ast_strlen_zero(val)) {
283  continue;
284  }
285 
286  val = ast_strdup(val);
287  if (!val) {
288  goto failure;
289  }
290  if (AST_VECTOR_APPEND(auths, val)) {
291  ast_free(val);
292 
293  goto failure;
294  }
295  }
296  return 0;
297 
298 failure:
300  return -1;
301 }
302 
303 static int inbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
304 {
305  struct ast_sip_endpoint *endpoint = obj;
306 
307  return ast_sip_auth_vector_init(&endpoint->inbound_auths, var->value);
308 }
309 
310 static int outbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
311 {
312  struct ast_sip_endpoint *endpoint = obj;
313 
314  return ast_sip_auth_vector_init(&endpoint->outbound_auths, var->value);
315 }
316 
317 int ast_sip_auths_to_str(const struct ast_sip_auth_vector *auths, char **buf)
318 {
319  if (!auths || !AST_VECTOR_SIZE(auths)) {
320  return 0;
321  }
322 
323  if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
324  return -1;
325  }
326 
327  /* I feel like accessing the vector's elem array directly is cheating...*/
328  ast_join_delim(*buf, MAX_OBJECT_FIELD, auths->elems, AST_VECTOR_SIZE(auths), ',');
329  return 0;
330 }
331 
332 static int inbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
333 {
334  const struct ast_sip_endpoint *endpoint = obj;
335  return ast_sip_auths_to_str(&endpoint->inbound_auths, buf);
336 }
337 
338 static int outbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
339 {
340  const struct ast_sip_endpoint *endpoint = obj;
341  return ast_sip_auths_to_str(&endpoint->outbound_auths, buf);
342 }
343 
344 /*!
345  * \internal
346  * \brief Convert identify_by method to string.
347  *
348  * \param method Method value to convert to string
349  *
350  * \return String representation.
351  */
353 {
354  const char *str = "<unknown>";
355 
356  switch (method) {
358  str = "username";
359  break;
361  str = "auth_username";
362  break;
364  str = "ip";
365  break;
367  str = "header";
368  break;
369  }
370  return str;
371 }
372 
373 /*!
374  * \internal
375  * \brief Convert string to an endpoint identifier token.
376  *
377  * \param str String to convert
378  *
379  * \retval enum ast_sip_endpoint_identifier_type token value on success.
380  * \retval -1 on failure.
381  */
382 static int sip_endpoint_identifier_str2type(const char *str)
383 {
384  int method;
385 
386  if (!strcasecmp(str, "username")) {
388  } else if (!strcasecmp(str, "auth_username")) {
390  } else if (!strcasecmp(str, "ip")) {
392  } else if (!strcasecmp(str, "header")) {
394  } else {
395  method = -1;
396  }
397  return method;
398 }
399 
400 static int ident_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
401 {
402  struct ast_sip_endpoint *endpoint = obj;
403  char *idents = ast_strdupa(var->value);
404  char *val;
405  int method;
406 
407  /*
408  * If there's already something in the vector when we get here,
409  * it's the default value so we need to clean it out.
410  */
411  if (AST_VECTOR_SIZE(&endpoint->ident_method_order)) {
413  endpoint->ident_method = 0;
414  }
415 
416  while ((val = ast_strip(strsep(&idents, ",")))) {
417  if (ast_strlen_zero(val)) {
418  continue;
419  }
420 
422  if (method == -1) {
423  ast_log(LOG_ERROR, "Unrecognized identification method %s specified for endpoint %s\n",
424  val, ast_sorcery_object_get_id(endpoint));
426  endpoint->ident_method = 0;
427  return -1;
428  }
429  if (endpoint->ident_method & method) {
430  /* We are already identifying by this method. No need to do it again. */
431  continue;
432  }
433 
434  endpoint->ident_method |= method;
436  }
437 
438  return 0;
439 }
440 
441 static int ident_to_str(const void *obj, const intptr_t *args, char **buf)
442 {
443  const struct ast_sip_endpoint *endpoint = obj;
444  int methods;
445  int idx;
446  int buf_used = 0;
447  int buf_size = MAX_OBJECT_FIELD;
448 
450  if (!methods) {
451  return 0;
452  }
453 
454  *buf = ast_malloc(buf_size);
455  if (!*buf) {
456  return -1;
457  }
458 
459  for (idx = 0; idx < methods; ++idx) {
461  const char *method_str;
462 
463  method = AST_VECTOR_GET(&endpoint->ident_method_order, idx);
465 
466  /* Should never have an "<unknown>" method string */
467  ast_assert(strcmp(method_str, "<unknown>"));
468  if (!strcmp(method_str, "<unknown>")) {
469  continue;
470  }
471 
472  buf_used += snprintf(*buf + buf_used, buf_size - buf_used, "%s%s",
473  method_str, idx < methods - 1 ? "," : "");
474  if (buf_size <= buf_used) {
475  /* Need more room than available, truncating. */
476  *(*buf + (buf_size - 1)) = '\0';
477  ast_log(LOG_WARNING, "Truncated identify_by string: %s\n", *buf);
478  break;
479  }
480  }
481 
482  return 0;
483 }
484 
485 static int redirect_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
486 {
487  struct ast_sip_endpoint *endpoint = obj;
488 
489  if (!strcasecmp(var->value, "user")) {
491  } else if (!strcasecmp(var->value, "uri_core")) {
493  } else if (!strcasecmp(var->value, "uri_pjsip")) {
495  } else {
496  ast_log(LOG_ERROR, "Unrecognized redirect method %s specified for endpoint %s\n",
497  var->value, ast_sorcery_object_get_id(endpoint));
498  return -1;
499  }
500 
501  return 0;
502 }
503 
504 static int direct_media_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
505 {
506  struct ast_sip_endpoint *endpoint = obj;
507 
508  if (!strcasecmp(var->value, "invite") || !strcasecmp(var->value, "reinvite")) {
510  } else if (!strcasecmp(var->value, "update")) {
512  } else {
513  ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
514  var->value, var->name, ast_sorcery_object_get_id(endpoint));
515  return -1;
516  }
517  return 0;
518 }
519 
520 static const char *id_configuration_refresh_methods[] = {
523 };
524 
525 static int direct_media_method_to_str(const void *obj, const intptr_t *args, char **buf)
526 {
527  const struct ast_sip_endpoint *endpoint = obj;
530  }
531  return 0;
532 }
533 
534 static int connected_line_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
535 {
536  struct ast_sip_endpoint *endpoint = obj;
537 
538  if (!strcasecmp(var->value, "invite") || !strcasecmp(var->value, "reinvite")) {
540  } else if (!strcasecmp(var->value, "update")) {
542  } else {
543  ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
544  var->value, var->name, ast_sorcery_object_get_id(endpoint));
545  return -1;
546  }
547  return 0;
548 }
549 
550 static int connected_line_method_to_str(const void *obj, const intptr_t *args, char **buf)
551 {
552  const struct ast_sip_endpoint *endpoint = obj;
554  return 0;
555 }
556 
557 static int direct_media_glare_mitigation_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
558 {
559  struct ast_sip_endpoint *endpoint = obj;
560 
561  if (!strcasecmp(var->value, "none")) {
563  } else if (!strcasecmp(var->value, "outgoing")) {
565  } else if (!strcasecmp(var->value, "incoming")) {
567  } else {
568  ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
569  var->value, var->name, ast_sorcery_object_get_id(endpoint));
570  return -1;
571  }
572 
573  return 0;
574 }
575 
576 static const char *direct_media_glare_mitigation_map[] = {
580 };
581 
582 static int direct_media_glare_mitigation_to_str(const void *obj, const intptr_t *args, char **buf)
583 {
584  const struct ast_sip_endpoint *endpoint = obj;
587  }
588 
589  return 0;
590 }
591 
592 static int caller_id_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
593 {
594  struct ast_sip_endpoint *endpoint = obj;
595  char cid_name[80] = { '\0' };
596  char cid_num[80] = { '\0' };
597 
598  ast_free(endpoint->id.self.name.str);
599  endpoint->id.self.name.str = NULL;
600  endpoint->id.self.name.valid = 0;
601  ast_free(endpoint->id.self.number.str);
602  endpoint->id.self.number.str = NULL;
603  endpoint->id.self.number.valid = 0;
604 
605  ast_callerid_split(var->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
606  if (!ast_strlen_zero(cid_name)) {
607  endpoint->id.self.name.str = ast_strdup(cid_name);
608  if (!endpoint->id.self.name.str) {
609  return -1;
610  }
611  endpoint->id.self.name.valid = 1;
612  }
613  if (!ast_strlen_zero(cid_num)) {
614  endpoint->id.self.number.str = ast_strdup(cid_num);
615  if (!endpoint->id.self.number.str) {
616  return -1;
617  }
618  endpoint->id.self.number.valid = 1;
619  }
620  return 0;
621 }
622 
623 static int caller_id_to_str(const void *obj, const intptr_t *args, char **buf)
624 {
625  const struct ast_sip_endpoint *endpoint = obj;
626  const char *name = S_COR(endpoint->id.self.name.valid,
627  endpoint->id.self.name.str, NULL);
628  const char *number = S_COR(endpoint->id.self.number.valid,
629  endpoint->id.self.number.str, NULL);
630 
631  /* make sure size is at least 10 - that should cover the "<unknown>"
632  case as well as any additional formatting characters added in
633  the name and/or number case. */
634  int size = 10;
635  size += name ? strlen(name) : 0;
636  size += number ? strlen(number) : 0;
637 
638  if (!(*buf = ast_calloc(size + 1, sizeof(char)))) {
639  return -1;
640  }
641 
642  ast_callerid_merge(*buf, size + 1, name, number, NULL);
643  return 0;
644 }
645 
646 static int caller_id_privacy_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
647 {
648  struct ast_sip_endpoint *endpoint = obj;
649  int callingpres = ast_parse_caller_presentation(var->value);
650  if (callingpres == -1 && sscanf(var->value, "%d", &callingpres) != 1) {
651  return -1;
652  }
653  endpoint->id.self.number.presentation = callingpres;
654  endpoint->id.self.name.presentation = callingpres;
655  return 0;
656 }
657 
658 static int caller_id_privacy_to_str(const void *obj, const intptr_t *args, char **buf)
659 {
660  const struct ast_sip_endpoint *endpoint = obj;
661  const char *presentation = ast_named_caller_presentation(
662  endpoint->id.self.name.presentation);
663 
664  *buf = ast_strdup(presentation);
665  return 0;
666 }
667 
668 static int caller_id_tag_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
669 {
670  struct ast_sip_endpoint *endpoint = obj;
671 
672  ast_free(endpoint->id.self.tag);
673  endpoint->id.self.tag = ast_strdup(var->value);
674 
675  return endpoint->id.self.tag ? 0 : -1;
676 }
677 
678 static int caller_id_tag_to_str(const void *obj, const intptr_t *args, char **buf)
679 {
680  const struct ast_sip_endpoint *endpoint = obj;
681  *buf = ast_strdup(endpoint->id.self.tag);
682  return 0;
683 }
684 
685 static int media_encryption_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
686 {
687  struct ast_sip_endpoint *endpoint = obj;
688 
689  if (!strcasecmp("no", var->value)) {
691  } else if (!strcasecmp("sdes", var->value)) {
693  } else if (!strcasecmp("dtls", var->value)) {
695  return ast_rtp_dtls_cfg_parse(&endpoint->media.rtp.dtls_cfg, "dtlsenable", "yes");
696  } else {
697  return -1;
698  }
699 
700  return 0;
701 }
702 
703 static const char *media_encryption_map[] = {
704  [AST_SIP_MEDIA_TRANSPORT_INVALID] = "invalid",
706  [AST_SIP_MEDIA_ENCRYPT_SDES] = "sdes",
707  [AST_SIP_MEDIA_ENCRYPT_DTLS] = "dtls",
708 };
709 
710 static int media_encryption_to_str(const void *obj, const intptr_t *args, char **buf)
711 {
712  const struct ast_sip_endpoint *endpoint = obj;
715  endpoint->media.rtp.encryption]);
716  }
717  return 0;
718 }
719 
720 static int stir_shaken_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
721 {
722  struct ast_sip_endpoint *endpoint = obj;
723 
724  if (!strcasecmp("off", var->value)) {
726  } else if (!strcasecmp("attest", var->value)) {
728  } else if (!strcasecmp("verify", var->value)) {
730  } else if (!strcasecmp("on", var->value)) {
732  } else {
733  ast_log(LOG_WARNING, "'%s' is not a valid value for option "
734  "'stir_shaken' for endpoint %s\n",
735  var->value, ast_sorcery_object_get_id(endpoint));
736  return -1;
737  }
738 
739  return 0;
740 }
741 
742 static const char *stir_shaken_map[] = {
743  [AST_SIP_STIR_SHAKEN_OFF] = "off",
744  [AST_SIP_STIR_SHAKEN_ATTEST] = "attest",
745  [AST_SIP_STIR_SHAKEN_VERIFY] = "verify",
746  [AST_SIP_STIR_SHAKEN_ON] = "on",
747 };
748 
749 static int stir_shaken_to_str(const void *obj, const intptr_t *args, char **buf)
750 {
751  const struct ast_sip_endpoint *endpoint = obj;
752  if (ARRAY_IN_BOUNDS(endpoint->stir_shaken, stir_shaken_map)) {
753  *buf = ast_strdup(stir_shaken_map[endpoint->stir_shaken]);
754  }
755  return 0;
756 }
757 
758 static int group_handler(const struct aco_option *opt,
759  struct ast_variable *var, void *obj)
760 {
761  struct ast_sip_endpoint *endpoint = obj;
762 
763  if (!strncmp(var->name, "call_group", 10)) {
764  endpoint->pickup.callgroup = ast_get_group(var->value);
765  } else if (!strncmp(var->name, "pickup_group", 12)) {
766  endpoint->pickup.pickupgroup = ast_get_group(var->value);
767  } else {
768  return -1;
769  }
770 
771  return 0;
772 }
773 
774 static int callgroup_to_str(const void *obj, const intptr_t *args, char **buf)
775 {
776  const struct ast_sip_endpoint *endpoint = obj;
777 
778  if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
779  return -1;
780  }
781 
783  return 0;
784 }
785 
786 static int pickupgroup_to_str(const void *obj, const intptr_t *args, char **buf)
787 {
788  const struct ast_sip_endpoint *endpoint = obj;
789 
790  if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
791  return -1;
792  }
793 
795  return 0;
796 }
797 
798 static int named_groups_handler(const struct aco_option *opt,
799  struct ast_variable *var, void *obj)
800 {
801  struct ast_sip_endpoint *endpoint = obj;
802 
803  if (!strncmp(var->name, "named_call_group", 16)) {
804  if (ast_strlen_zero(var->value)) {
805  endpoint->pickup.named_callgroups =
807  } else if (!(endpoint->pickup.named_callgroups =
808  ast_get_namedgroups(var->value))) {
809  return -1;
810  }
811  } else if (!strncmp(var->name, "named_pickup_group", 18)) {
812  if (ast_strlen_zero(var->value)) {
813  endpoint->pickup.named_pickupgroups =
815  } else if (!(endpoint->pickup.named_pickupgroups =
816  ast_get_namedgroups(var->value))) {
817  return -1;
818  }
819  } else {
820  return -1;
821  }
822 
823  return 0;
824 }
825 
826 static int named_callgroups_to_str(const void *obj, const intptr_t *args, char **buf)
827 {
828  const struct ast_sip_endpoint *endpoint = obj;
830 
833  return 0;
834 }
835 
836 static int named_pickupgroups_to_str(const void *obj, const intptr_t *args, char **buf)
837 {
838  const struct ast_sip_endpoint *endpoint = obj;
840 
843  return 0;
844 }
845 
846 static int dtls_handler(const struct aco_option *opt,
847  struct ast_variable *var, void *obj)
848 {
849  struct ast_sip_endpoint *endpoint = obj;
850  char *name = ast_strdupa(var->name);
851  char *front = NULL;
852  char *back = NULL;
853  char *buf = name;
854 
855  /* strip out underscores in the name */
856  front = strtok_r(buf, "_", &back);
857  while (front) {
858  int size = strlen(front);
859  ast_copy_string(buf, front, size + 1);
860  buf += size;
861  front = strtok_r(NULL, "_", &back);
862  }
863 
864  return ast_rtp_dtls_cfg_parse(&endpoint->media.rtp.dtls_cfg, name, var->value);
865 }
866 
867 static int dtlsverify_to_str(const void *obj, const intptr_t *args, char **buf)
868 {
869  const struct ast_sip_endpoint *endpoint = obj;
871  return 0;
872 }
873 
874 static int dtlsrekey_to_str(const void *obj, const intptr_t *args, char **buf)
875 {
876  const struct ast_sip_endpoint *endpoint = obj;
877 
878  return ast_asprintf(
879  buf, "%u", endpoint->media.rtp.dtls_cfg.rekey) >=0 ? 0 : -1;
880 }
881 
882 static int dtlsautogeneratecert_to_str(const void *obj, const intptr_t *args, char **buf)
883 {
884  const struct ast_sip_endpoint *endpoint = obj;
886  return 0;
887 }
888 
889 static int dtlscertfile_to_str(const void *obj, const intptr_t *args, char **buf)
890 {
891  const struct ast_sip_endpoint *endpoint = obj;
892  *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.certfile);
893  return 0;
894 }
895 
896 static int dtlsprivatekey_to_str(const void *obj, const intptr_t *args, char **buf)
897 {
898  const struct ast_sip_endpoint *endpoint = obj;
899  *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.pvtfile);
900  return 0;
901 }
902 
903 static int dtlscipher_to_str(const void *obj, const intptr_t *args, char **buf)
904 {
905  const struct ast_sip_endpoint *endpoint = obj;
906  *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.cipher);
907  return 0;
908 }
909 
910 static int dtlscafile_to_str(const void *obj, const intptr_t *args, char **buf)
911 {
912  const struct ast_sip_endpoint *endpoint = obj;
913  *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.cafile);
914  return 0;
915 }
916 
917 static int dtlscapath_to_str(const void *obj, const intptr_t *args, char **buf)
918 {
919  const struct ast_sip_endpoint *endpoint = obj;
920  *buf = ast_strdup(endpoint->media.rtp.dtls_cfg.capath);
921  return 0;
922 }
923 
924 static const char *ast_rtp_dtls_setup_map[] = {
925  [AST_RTP_DTLS_SETUP_ACTIVE] = "active",
926  [AST_RTP_DTLS_SETUP_PASSIVE] = "passive",
927  [AST_RTP_DTLS_SETUP_ACTPASS] = "actpass",
928  [AST_RTP_DTLS_SETUP_HOLDCONN] = "holdconn",
929 };
930 
931 static int dtlssetup_to_str(const void *obj, const intptr_t *args, char **buf)
932 {
933  const struct ast_sip_endpoint *endpoint = obj;
936  }
937  return 0;
938 }
939 
940 static const char *ast_rtp_dtls_fingerprint_map[] = {
941  [AST_RTP_DTLS_HASH_SHA256] = "SHA-256",
942  [AST_RTP_DTLS_HASH_SHA1] = "SHA-1",
943 };
944 
945 static int dtlsfingerprint_to_str(const void *obj, const intptr_t *args, char **buf)
946 {
947  const struct ast_sip_endpoint *endpoint = obj;
950  }
951  return 0;
952 }
953 
954 static int t38udptl_ec_handler(const struct aco_option *opt,
955  struct ast_variable *var, void *obj)
956 {
957  struct ast_sip_endpoint *endpoint = obj;
958 
959  if (!strcmp(var->value, "none")) {
961  } else if (!strcmp(var->value, "fec")) {
963  } else if (!strcmp(var->value, "redundancy")) {
965  } else {
966  return -1;
967  }
968 
969  return 0;
970 }
971 
972 static const char *ast_t38_ec_modes_map[] = {
973  [UDPTL_ERROR_CORRECTION_NONE] = "none",
974  [UDPTL_ERROR_CORRECTION_FEC] = "fec",
975  [UDPTL_ERROR_CORRECTION_REDUNDANCY] = "redundancy"
976 };
977 
978 static int t38udptl_ec_to_str(const void *obj, const intptr_t *args, char **buf)
979 {
980  const struct ast_sip_endpoint *endpoint = obj;
983  endpoint->media.t38.error_correction]);
984  }
985  return 0;
986 }
987 
988 static int tos_handler(const struct aco_option *opt,
989  struct ast_variable *var, void *obj)
990 {
991  struct ast_sip_endpoint *endpoint = obj;
992  unsigned int value;
993 
994  if (ast_str2tos(var->value, &value)) {
995  ast_log(LOG_ERROR, "Error configuring endpoint '%s' - Could not "
996  "interpret '%s' value '%s'\n",
997  ast_sorcery_object_get_id(endpoint), var->name, var->value);
998  return -1;
999  }
1000 
1001  if (!strcmp(var->name, "tos_audio")) {
1002  endpoint->media.tos_audio = value;
1003  } else if (!strcmp(var->name, "tos_video")) {
1004  endpoint->media.tos_video = value;
1005  } else {
1006  /* If we reach this point, someone called the tos_handler when they shouldn't have. */
1007  ast_assert(0);
1008  return -1;
1009  }
1010  return 0;
1011 }
1012 
1013 static int tos_audio_to_str(const void *obj, const intptr_t *args, char **buf)
1014 {
1015  const struct ast_sip_endpoint *endpoint = obj;
1016 
1017  if (ast_asprintf(buf, "%u", endpoint->media.tos_audio) == -1) {
1018  return -1;
1019  }
1020  return 0;
1021 }
1022 
1023 static int tos_video_to_str(const void *obj, const intptr_t *args, char **buf)
1024 {
1025  const struct ast_sip_endpoint *endpoint = obj;
1026 
1027  if (ast_asprintf(buf, "%u", endpoint->media.tos_video) == -1) {
1028  return -1;
1029  }
1030  return 0;
1031 }
1032 
1033 static int from_user_handler(const struct aco_option *opt,
1034  struct ast_variable *var, void *obj)
1035 {
1036  struct ast_sip_endpoint *endpoint = obj;
1037  /* Valid non-alphanumeric characters for URI */
1038  char *valid_uri_marks = "-._~%!$&'()*+,;=:";
1039  const char *val;
1040 
1041  for (val = var->value; *val; val++) {
1042  if (!isalpha(*val) && !isdigit(*val) && !strchr(valid_uri_marks, *val)) {
1043  ast_log(LOG_ERROR, "Error configuring endpoint '%s' - '%s' field "
1044  "contains invalid character '%c'\n",
1045  ast_sorcery_object_get_id(endpoint), var->name, *val);
1046  return -1;
1047  }
1048  }
1049 
1050  ast_string_field_set(endpoint, fromuser, var->value);
1051 
1052  return 0;
1053 }
1054 
1055 static int from_user_to_str(const void *obj, const intptr_t *args, char **buf)
1056 {
1057  const struct ast_sip_endpoint *endpoint = obj;
1058 
1059  *buf = ast_strdup(endpoint->fromuser);
1060 
1061  return 0;
1062 }
1063 
1064 static int set_var_handler(const struct aco_option *opt,
1065  struct ast_variable *var, void *obj)
1066 {
1067  struct ast_sip_endpoint *endpoint = obj;
1068  struct ast_variable *new_var;
1069  char *name;
1070  char *val;
1071 
1072  if (ast_strlen_zero(var->value)) {
1073  return 0;
1074  }
1075 
1076  name = ast_strdupa(var->value);
1077  val = strchr(name, '=');
1078 
1079  if (!val) {
1080  return -1;
1081  }
1082 
1083  *val++ = '\0';
1084 
1085  if (!(new_var = ast_variable_new(name, val, ""))) {
1086  return -1;
1087  }
1088 
1089  if (ast_variable_list_replace(&endpoint->channel_vars, new_var)) {
1090  ast_variable_list_append(&endpoint->channel_vars, new_var);
1091  }
1092 
1093  return 0;
1094 }
1095 
1096 static int set_var_to_str(const void *obj, const intptr_t *args, char **buf)
1097 {
1099  const struct ast_sip_endpoint *endpoint = obj;
1100  struct ast_variable *var;
1101 
1102  for (var = endpoint->channel_vars; var; var = var->next) {
1103  ast_str_append(&str, 0, "%s=%s,", var->name, var->value);
1104  }
1105 
1107  ast_free(str);
1108  return 0;
1109 }
1110 
1111 static int set_var_to_vl(const void *obj, struct ast_variable **fields)
1112 {
1113  const struct ast_sip_endpoint *endpoint = obj;
1114  if (endpoint->channel_vars) {
1115  *fields = ast_variables_dup(endpoint->channel_vars);
1116  }
1117  return 0;
1118 }
1119 
1120 static int voicemail_extension_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
1121 {
1122  struct ast_sip_endpoint *endpoint = obj;
1123 
1125  endpoint->subscription.mwi.voicemail_extension = ast_strdup(var->value);
1126 
1127  return endpoint->subscription.mwi.voicemail_extension ? 0 : -1;
1128 }
1129 
1130 static int voicemail_extension_to_str(const void *obj, const intptr_t *args, char **buf)
1131 {
1132  const struct ast_sip_endpoint *endpoint = obj;
1133 
1135 
1136  return 0;
1137 }
1138 
1139 static int contact_user_handler(const struct aco_option *opt,
1140  struct ast_variable *var, void *obj)
1141 {
1142  struct ast_sip_endpoint *endpoint = obj;
1143 
1144  ast_free(endpoint->contact_user);
1145  endpoint->contact_user = ast_strdup(var->value);
1146 
1147  return endpoint->contact_user ? 0 : -1;
1148 }
1149 
1150 static int contact_user_to_str(const void *obj, const intptr_t *args, char **buf)
1151 {
1152  const struct ast_sip_endpoint *endpoint = obj;
1153 
1154  *buf = ast_strdup(endpoint->contact_user);
1155  if (!(*buf)) {
1156  return -1;
1157  }
1158 
1159  return 0;
1160 }
1161 
1162 static int call_offer_pref_handler(const struct aco_option *opt,
1163  struct ast_variable *var, void *obj)
1164 {
1165  struct ast_sip_endpoint *endpoint = obj;
1166  struct ast_flags pref = { 0, };
1167  int outgoing = strcmp(var->name, "outgoing_call_offer_pref") == 0;
1168 
1169  int res = ast_sip_call_codec_str_to_pref(&pref, var->value, outgoing);
1170  if (res != 0) {
1171  return -1;
1172  }
1173 
1174  if (outgoing) {
1175  endpoint->media.outgoing_call_offer_pref = pref;
1176  } else {
1177  endpoint->media.incoming_call_offer_pref = pref;
1178  }
1179 
1180  return 0;
1181 }
1182 
1183 static int incoming_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
1184 {
1185  const struct ast_sip_endpoint *endpoint = obj;
1186 
1188  if (!(*buf)) {
1189  return -1;
1190  }
1191 
1192  return 0;
1193 }
1194 
1195 static int outgoing_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
1196 {
1197  const struct ast_sip_endpoint *endpoint = obj;
1198 
1200  if (!(*buf)) {
1201  return -1;
1202  }
1203 
1204  return 0;
1205 }
1206 
1207 static int codec_prefs_handler(const struct aco_option *opt,
1208  struct ast_variable *var, void *obj)
1209 {
1210  struct ast_sip_endpoint *endpoint = obj;
1211  struct ast_stream_codec_negotiation_prefs *option_prefs;
1213  struct ast_str *error_message = ast_str_create(128);
1216  int res = 0;
1217 
1218  res = ast_stream_codec_prefs_parse(var->value, &prefs, &error_message);
1219  if (res < 0) {
1220  ast_log(LOG_ERROR, "Endpoint '%s': %s for option '%s'\n",
1221  ast_sorcery_object_get_id(endpoint), ast_str_buffer(error_message), var->name);
1222  ast_free(error_message);
1223  return -1;
1224  }
1225  ast_free(error_message);
1226 
1227  if (strcmp(var->name, "codec_prefs_incoming_offer") == 0) {
1229  ast_log(LOG_ERROR, "Endpoint '%s': Codec preference '%s' has invalid value '%s' for option: '%s'",
1230  ast_sorcery_object_get_id(endpoint),
1233  var->name);
1234  return -1;
1235  }
1236  option_prefs = &endpoint->media.codec_prefs_incoming_offer;
1237  default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1238  default_operation = CODEC_NEGOTIATION_OPERATION_INTERSECT;
1239  } else if (strcmp(var->name, "codec_prefs_outgoing_offer") == 0) {
1240  option_prefs = &endpoint->media.codec_prefs_outgoing_offer;
1241  default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1242  default_operation = CODEC_NEGOTIATION_OPERATION_UNION;
1243  } else if (strcmp(var->name, "codec_prefs_incoming_answer") == 0) {
1244  option_prefs = &endpoint->media.codec_prefs_incoming_answer;
1245  default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1246  default_operation = CODEC_NEGOTIATION_OPERATION_INTERSECT;
1247  } else if (strcmp(var->name, "codec_prefs_outgoing_answer") == 0) {
1248  option_prefs = &endpoint->media.codec_prefs_outgoing_answer;
1249  default_prefer = CODEC_NEGOTIATION_PREFER_PENDING;
1250  default_operation = CODEC_NEGOTIATION_OPERATION_INTERSECT;
1251  } else {
1252  ast_log(LOG_ERROR, "Endpoint '%s': Unsupported option '%s'\n",
1253  ast_sorcery_object_get_id(endpoint),
1254  var->name);
1255  return -1;
1256  }
1257 
1259  prefs.prefer = default_prefer;
1260  }
1261 
1263  prefs.operation = default_operation;
1264  }
1265 
1268  }
1269 
1272  }
1273 
1274  /* Now that defaults have been applied as needed we apply the full codec
1275  * preference configuration to the option.
1276  */
1277  *option_prefs = prefs;
1278 
1279  return 0;
1280 }
1281 
1283  const void *obj, const intptr_t *args, char **buf)
1284 {
1286 
1287  if (!codecs) {
1288  return -1;
1289  }
1290 
1292  ast_free(codecs);
1293 
1294  return 0;
1295 }
1296 
1297 static int incoming_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1298 {
1299  const struct ast_sip_endpoint *endpoint = obj;
1300  return codec_prefs_to_str(&endpoint->media.codec_prefs_incoming_offer, obj, args, buf);
1301 }
1302 
1303 static int outgoing_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1304 {
1305  const struct ast_sip_endpoint *endpoint = obj;
1306  return codec_prefs_to_str(&endpoint->media.codec_prefs_outgoing_offer, obj, args, buf);
1307 }
1308 
1309 static int incoming_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1310 {
1311  const struct ast_sip_endpoint *endpoint = obj;
1312  return codec_prefs_to_str(&endpoint->media.codec_prefs_incoming_answer, obj, args, buf);
1313 }
1314 
1315 static int outgoing_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
1316 {
1317  const struct ast_sip_endpoint *endpoint = obj;
1318  return codec_prefs_to_str(&endpoint->media.codec_prefs_outgoing_answer, obj, args, buf);
1319 }
1320 
1321 static void *sip_nat_hook_alloc(const char *name)
1322 {
1323  return ast_sorcery_generic_alloc(sizeof(struct ast_sip_nat_hook), NULL);
1324 }
1325 
1326 /*! \brief Destructor function for persistent endpoint information */
1327 static void persistent_endpoint_destroy(void *obj)
1328 {
1329  struct sip_persistent_endpoint *persistent = obj;
1330 
1331  ast_endpoint_shutdown(persistent->endpoint);
1332 }
1333 
1334 static int add_to_regcontext(void *obj, void *arg, int flags)
1335 {
1336  struct sip_persistent_endpoint *persistent = obj;
1337  const char *regcontext = arg;
1338 
1339  if (ast_endpoint_get_state(persistent->endpoint) == AST_ENDPOINT_ONLINE) {
1341  persistent->endpoint), 1, NULL)) {
1343  "Noop", ast_strdup(ast_endpoint_get_resource(persistent->endpoint)), ast_free_ptr, "PJSIP");
1344  }
1345  }
1346 
1347  return 0;
1348 }
1349 
1351 {
1352  if (ast_strlen_zero(regcontext)) {
1353  return 0;
1354  }
1355 
1356  /* Make sure the regcontext exists */
1357  if (!ast_context_find_or_create(NULL, NULL, regcontext, "PJSIP")) {
1358  ast_log(LOG_ERROR, "Failed to create regcontext '%s'\n", regcontext);
1359  return -1;
1360  }
1361 
1362  /* Add any online endpoints */
1364  return 0;
1365 }
1366 
1368 {
1369  struct sip_persistent_endpoint *persistent;
1370  struct ast_json *blob;
1371  char *regcontext;
1372 
1373  persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1374  if (!persistent) {
1375  return -1;
1376  }
1377 
1378  /* If there was no state change, don't publish anything. */
1379  if (ast_endpoint_get_state(persistent->endpoint) == state) {
1380  ao2_ref(persistent, -1);
1381  return 0;
1382  }
1383 
1385 
1386  if (state == AST_ENDPOINT_ONLINE) {
1388  blob = ast_json_pack("{s: s}", "peer_status", "Reachable");
1389 
1390  if (!ast_strlen_zero(regcontext)) {
1393  "Noop", ast_strdup(ast_endpoint_get_resource(persistent->endpoint)), ast_free_ptr, "PJSIP");
1394  }
1395  }
1396 
1397  ast_verb(2, "Endpoint %s is now Reachable\n", ast_endpoint_get_resource(persistent->endpoint));
1398  } else {
1400  blob = ast_json_pack("{s: s}", "peer_status", "Unreachable");
1401 
1402  if (!ast_strlen_zero(regcontext)) {
1403  struct pbx_find_info q = { .stacklen = 0 };
1404 
1407  }
1408  }
1409 
1410  ast_verb(2, "Endpoint %s is now Unreachable\n", ast_endpoint_get_resource(persistent->endpoint));
1411  }
1412 
1414 
1416  ast_json_unref(blob);
1418 
1419  ao2_ref(persistent, -1);
1420 
1421  return 0;
1422 }
1423 
1424 void ast_sip_persistent_endpoint_publish_contact_state(const char *endpoint_name, const struct ast_sip_contact_status *contact_status)
1425 {
1426  struct sip_persistent_endpoint *persistent;
1427  struct ast_json *blob;
1428  char rtt[32];
1429 
1430  persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1431  if (!persistent) {
1432  return;
1433  }
1434 
1435  snprintf(rtt, sizeof(rtt), "%" PRId64, contact_status->rtt);
1436  blob = ast_json_pack("{s: s, s: s, s: s, s: s, s: s}",
1437  "contact_status", ast_sip_get_contact_status_label(contact_status->status),
1438  "aor", contact_status->aor,
1439  "uri", contact_status->uri,
1440  "roundtrip_usec", rtt,
1441  "endpoint_name", ast_endpoint_get_resource(persistent->endpoint));
1442  if (blob) {
1444  ast_json_unref(blob);
1445  }
1446 
1447  ao2_ref(persistent, -1);
1448 }
1449 
1450 /*! \brief Internal function which finds (or creates) persistent endpoint information */
1452 {
1453  RAII_VAR(struct sip_persistent_endpoint *, persistent, NULL, ao2_cleanup);
1455 
1458  if (!persistent) {
1459  persistent = ao2_alloc_options(sizeof(*persistent), persistent_endpoint_destroy,
1461  if (!persistent) {
1462  return NULL;
1463  }
1464 
1465  persistent->endpoint = ast_endpoint_create("PJSIP",
1466  ast_sorcery_object_get_id(endpoint));
1467  if (!persistent->endpoint) {
1468  return NULL;
1469  }
1470 
1471  ast_endpoint_set_state(persistent->endpoint, AST_ENDPOINT_OFFLINE);
1472 
1474  }
1475 
1476  ao2_ref(persistent->endpoint, +1);
1477  return persistent->endpoint;
1478 }
1479 
1480 /*! \brief Callback function for when an object is finalized */
1481 static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *obj)
1482 {
1483  struct ast_sip_endpoint *endpoint = obj;
1484 
1485  if (!(endpoint->persistent = persistent_endpoint_find_or_create(endpoint))) {
1486  return -1;
1487  }
1488 
1489  if (endpoint->extensions.timer.min_se < 90) {
1490  ast_log(LOG_ERROR, "Session timer minimum expires time must be 90 or greater on endpoint '%s'\n",
1491  ast_sorcery_object_get_id(endpoint));
1492  return -1;
1493  } else if (endpoint->extensions.timer.sess_expires < endpoint->extensions.timer.min_se) {
1494  ast_log(LOG_ERROR, "Session timer expires must be greater than minimum session expires time on endpoint '%s'\n",
1495  ast_sorcery_object_get_id(endpoint));
1496  return -1;
1497  }
1498 
1499  if (ast_rtp_dtls_cfg_validate(&endpoint->media.rtp.dtls_cfg)) {
1500  return -1;
1501  }
1502 
1503  if (endpoint->preferred_codec_only) {
1505  ast_log(LOG_ERROR, "Setting both preferred_codec_only and incoming_call_offer_pref is not supported on endpoint '%s'\n",
1506  ast_sorcery_object_get_id(endpoint));
1507  return -1;
1508  }
1511  }
1512 
1514  if (!endpoint->media.topology) {
1515  return -1;
1516  }
1517 
1518  endpoint->media.rtcp_mux |= endpoint->media.bundle;
1519 
1520  /*
1521  * If webrtc has been enabled then enable those attributes, and default
1522  * some, that are needed in order for webrtc to work.
1523  */
1524  endpoint->media.bundle |= endpoint->media.webrtc;
1525  endpoint->media.rtcp_mux |= endpoint->media.webrtc;
1526  endpoint->media.rtp.use_avpf |= endpoint->media.webrtc;
1527  endpoint->media.rtp.ice_support |= endpoint->media.webrtc;
1528  endpoint->media.rtp.use_received_transport |= endpoint->media.webrtc;
1529 
1530  if (endpoint->media.webrtc) {
1532  endpoint->media.rtp.dtls_cfg.enabled = 1;
1535 
1536  if (ast_strlen_zero(endpoint->media.rtp.dtls_cfg.certfile)) {
1537  /* If no certificate has been specified, try to automatically create one */
1538  endpoint->media.rtp.dtls_cfg.ephemeral_cert = 1;
1539  }
1540  }
1541 
1542  return 0;
1543 }
1544 
1545 const char *ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint)
1546 {
1547  char device[MAX_OBJECT_FIELD];
1548 
1549  snprintf(device, MAX_OBJECT_FIELD, "PJSIP/%s", ast_sorcery_object_get_id(endpoint));
1550  return ast_devstate2str(ast_device_state(device));
1551 }
1552 
1554  const struct ast_sip_endpoint *endpoint)
1555 {
1557  ast_endpoint_get_tech(endpoint->persistent),
1559 }
1560 
1562  const struct ast_endpoint_snapshot *endpoint_snapshot,
1563  ao2_callback_fn on_channel_snapshot, void *arg)
1564 {
1565  int num, num_channels = endpoint_snapshot->num_channels;
1566 
1567  if (!on_channel_snapshot || !num_channels) {
1568  return 0;
1569  }
1570 
1571  for (num = 0; num < num_channels; ++num) {
1572  RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
1573  int res;
1574 
1575  snapshot = ast_channel_snapshot_get_latest(endpoint_snapshot->channel_ids[num]);
1576  if (!snapshot) {
1577  continue;
1578  }
1579 
1580  res = on_channel_snapshot(snapshot, arg, 0);
1581  if (res) {
1582  return -1;
1583  }
1584  }
1585  return 0;
1586 }
1587 
1589  const struct ast_sip_endpoint *endpoint,
1590  ao2_callback_fn on_channel_snapshot, void *arg)
1591 {
1592  RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup);
1593  return ast_sip_for_each_channel_snapshot(endpoint_snapshot, on_channel_snapshot, arg);
1594 }
1595 
1596 static int active_channels_to_str_cb(void *object, void *arg, int flags)
1597 {
1598  const struct ast_channel_snapshot *snapshot = object;
1599  struct ast_str **buf = arg;
1600  ast_str_append(buf, 0, "%s,", snapshot->base->name);
1601  return 0;
1602 }
1603 
1604 static void active_channels_to_str(const struct ast_sip_endpoint *endpoint,
1605  struct ast_str **str)
1606 {
1607 
1608  RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot,
1610 
1611  if (endpoint_snapshot) {
1612  return;
1613  }
1614 
1615  ast_sip_for_each_channel_snapshot(endpoint_snapshot,
1617  ast_str_truncate(*str, -1);
1618 }
1619 
1620 #define AMI_DEFAULT_STR_SIZE 512
1621 
1622 struct ast_str *ast_sip_create_ami_event(const char *event, struct ast_sip_ami *ami)
1623 {
1625 
1626  if (!(buf)) {
1627  astman_send_error_va(ami->s, ami->m, "Unable create event "
1628  "for %s\n", event);
1629  return NULL;
1630  }
1631 
1632  ast_str_set(&buf, 0, "Event: %s\r\n", event);
1633  if (!ast_strlen_zero(ami->action_id)) {
1634  ast_str_append(&buf, 0, "ActionID: %s\r\n", ami->action_id);
1635  }
1636  return buf;
1637 }
1638 
1639 static void sip_sorcery_object_ami_set_type_name(const void *obj, struct ast_str **buf)
1640 {
1641  ast_str_append(buf, 0, "ObjectType: %s\r\n",
1643  ast_str_append(buf, 0, "ObjectName: %s\r\n",
1645 }
1646 
1647 int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
1648 {
1651  struct ast_variable *i;
1652 
1653  if (!objset) {
1654  return -1;
1655  }
1656 
1658 
1659  for (i = objset; i; i = i->next) {
1660  RAII_VAR(char *, camel, ast_to_camel_case(i->name), ast_free);
1661  ast_str_append(buf, 0, "%s: %s\r\n", camel, i->value);
1662  }
1663 
1664  return 0;
1665 }
1666 
1667 static int sip_endpoints_aors_ami(void *obj, void *arg, int flags)
1668 {
1669  struct ast_sip_aor *aor = obj;
1670  struct ast_str **buf = arg;
1671 
1672  ast_str_append(buf, 0, "Contacts: ");
1674  ast_str_append(buf, 0, "\r\n");
1675 
1676  return 0;
1677 }
1678 
1679 static int sip_endpoint_to_ami(const struct ast_sip_endpoint *endpoint,
1680  struct ast_str **buf)
1681 {
1682  if (ast_sip_sorcery_object_to_ami(endpoint, buf)) {
1683  return -1;
1684  }
1685 
1686  ast_str_append(buf, 0, "DeviceState: %s\r\n",
1687  ast_sip_get_device_state(endpoint));
1688 
1689  ast_str_append(buf, 0, "ActiveChannels: ");
1690  active_channels_to_str(endpoint, buf);
1691  ast_str_append(buf, 0, "\r\n");
1692 
1693  return 0;
1694 }
1695 
1696 static int format_ami_endpoint(const struct ast_sip_endpoint *endpoint,
1697  struct ast_sip_ami *ami)
1698 {
1699  RAII_VAR(struct ast_str *, buf,
1700  ast_sip_create_ami_event("EndpointDetail", ami), ast_free);
1701 
1702  if (!buf) {
1703  return -1;
1704  }
1705 
1706  sip_endpoint_to_ami(endpoint, &buf);
1707  astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
1708  return 0;
1709 }
1710 
1711 #define AMI_SHOW_ENDPOINTS "PJSIPShowEndpoints"
1712 #define AMI_SHOW_ENDPOINT "PJSIPShowEndpoint"
1713 
1714 static int ami_show_endpoint(struct mansession *s, const struct message *m)
1715 {
1716  struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"),
1717  .count = 0, };
1718  RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
1719  const char *endpoint_name = astman_get_header(m, "Endpoint");
1720  int count = 0;
1721 
1722  if (ast_strlen_zero(endpoint_name)) {
1723  astman_send_error_va(s, m, "%s requires an endpoint name\n",
1725  return 0;
1726  }
1727 
1728  if (!strncasecmp(endpoint_name, "pjsip/", 6)) {
1729  endpoint_name += 6;
1730  }
1731 
1732  if (!(endpoint = ast_sorcery_retrieve_by_id(
1733  ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
1734  astman_send_error_va(s, m, "Unable to retrieve endpoint %s\n",
1735  endpoint_name);
1736  return 0;
1737  }
1738 
1739  astman_send_listack(s, m, "Following are Events for each object associated with the Endpoint",
1740  "start");
1741 
1742  /* the endpoint detail needs to always come first so apply as such */
1743  if (format_ami_endpoint(endpoint, &ami) ||
1744  ast_sip_format_endpoint_ami(endpoint, &ami, &count)) {
1745  astman_send_error_va(s, m, "Unable to format endpoint %s\n",
1746  endpoint_name);
1747  }
1748 
1749  astman_send_list_complete_start(s, m, "EndpointDetailComplete", ami.count + 1);
1751 
1752  return 0;
1753 }
1754 
1755 static int format_str_append_auth(const struct ast_sip_auth_vector *auths,
1756  struct ast_str **buf)
1757 {
1758  char *str = NULL;
1759  if (ast_sip_auths_to_str(auths, &str)) {
1760  return -1;
1761  }
1762  ast_str_append(buf, 0, "%s", str ? str : "");
1763  ast_free(str);
1764  return 0;
1765 }
1766 
1767 static int format_ami_endpoints(void *obj, void *arg, int flags)
1768 {
1769 
1770  struct ast_sip_endpoint *endpoint = obj;
1771  struct ast_sip_ami *ami = arg;
1772  RAII_VAR(struct ast_str *, buf,
1773  ast_sip_create_ami_event("EndpointList", ami), ast_free);
1774 
1775  if (!buf) {
1776  return CMP_STOP;
1777  }
1778 
1780  ast_str_append(&buf, 0, "Transport: %s\r\n",
1781  endpoint->transport);
1782  ast_str_append(&buf, 0, "Aor: %s\r\n",
1783  endpoint->aors);
1784 
1785  ast_str_append(&buf, 0, "Auths: ");
1787  ast_str_append(&buf, 0, "\r\n");
1788 
1789  ast_str_append(&buf, 0, "OutboundAuths: ");
1791  ast_str_append(&buf, 0, "\r\n");
1792 
1793  ast_sip_for_each_aor(endpoint->aors,
1795 
1796  ast_str_append(&buf, 0, "DeviceState: %s\r\n",
1797  ast_sip_get_device_state(endpoint));
1798 
1799  ast_str_append(&buf, 0, "ActiveChannels: ");
1800  active_channels_to_str(endpoint, &buf);
1801  ast_str_append(&buf, 0, "\r\n");
1802 
1803  astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
1804  return 0;
1805 }
1806 
1807 static int ami_show_endpoints(struct mansession *s, const struct message *m)
1808 {
1809  struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
1811  int num;
1812 
1814  if (!endpoints) {
1815  astman_send_error(s, m, "Could not get endpoints\n");
1816  return 0;
1817  }
1818 
1819  if (!(num = ao2_container_count(endpoints))) {
1820  astman_send_error(s, m, "No endpoints found\n");
1821  return 0;
1822  }
1823 
1824  astman_send_listack(s, m, "A listing of Endpoints follows, presented as EndpointList events",
1825  "start");
1826 
1828 
1829  astman_send_list_complete_start(s, m, "EndpointListComplete", num);
1831  return 0;
1832 }
1833 
1835 {
1837  struct ao2_container *s_container;
1838 
1840  if (!container) {
1841  return NULL;
1842  }
1843 
1846  if (!s_container) {
1847  return NULL;
1848  }
1849 
1850  if (ao2_container_dup(s_container, container, 0)) {
1851  ao2_ref(s_container, -1);
1852  return NULL;
1853  }
1854 
1855  return s_container;
1856 }
1857 
1858 static int cli_endpoint_iterate(void *obj, ao2_callback_fn callback, void *args)
1859 {
1860  ao2_callback(obj, OBJ_NODATA, callback, args);
1861 
1862  return 0;
1863 }
1864 
1865 static void *cli_endpoint_retrieve_by_id(const char *id)
1866 {
1867  return ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id);
1868 }
1869 
1871 {
1872  RAII_VAR(struct ast_sip_cli_formatter_entry *, formatter_entry, NULL, ao2_cleanup);
1873 
1874  formatter_entry = ast_sip_lookup_cli_formatter(type);
1875  if (formatter_entry) {
1876  formatter_entry->print_header(NULL, context, 0);
1877  }
1878 }
1879 
1880 static int cli_endpoint_print_header(void *obj, void *arg, int flags)
1881 {
1882  struct ast_sip_cli_context *context = arg;
1883 
1884  ast_assert(context->output_buffer != NULL);
1885 
1886  ast_str_append(&context->output_buffer, 0,
1887  " Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>\n");
1888 
1889  if (context->recurse) {
1890  context->indent_level++;
1896  context->indent_level--;
1897  }
1898 
1899  return 0;
1900 }
1901 
1902 static void cli_endpoint_print_child_body(char *type, const void *obj, struct ast_sip_cli_context *context)
1903 {
1904  RAII_VAR(struct ast_sip_cli_formatter_entry *, formatter_entry, NULL, ao2_cleanup);
1905 
1906  formatter_entry = ast_sip_lookup_cli_formatter(type);
1907  if (formatter_entry) {
1908  formatter_entry->iterate((void *)obj, formatter_entry->print_body, context);
1909  }
1910 }
1911 
1912 static int cli_endpoint_print_body(void *obj, void *arg, int flags)
1913 {
1914  struct ast_sip_endpoint *endpoint = obj;
1915  RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup);
1916  struct ast_sip_cli_context *context = arg;
1917  const char *id = ast_sorcery_object_get_id(endpoint);
1918  char *print_name = NULL;
1919  int print_name_len;
1920  char *number = S_COR(endpoint->id.self.number.valid,
1921  endpoint->id.self.number.str, NULL);
1922  int indent;
1923  int flexwidth;
1924 
1925  ast_assert(context->output_buffer != NULL);
1926 
1927  if (number) {
1928  print_name_len = strlen(id) + strlen(number) + 2;
1929  print_name = ast_alloca(print_name_len);
1930  snprintf(print_name, print_name_len, "%s/%s", id, number);
1931  }
1932 
1933  indent = CLI_INDENT_TO_SPACES(context->indent_level);
1934  flexwidth = CLI_LAST_TABSTOP - indent - 2;
1935 
1936  ast_str_append(&context->output_buffer, 0, "%*s: %-*.*s %-12.12s %d of %.0f\n",
1937  indent, "Endpoint",
1938  flexwidth, flexwidth, print_name ? print_name : id,
1939  ast_sip_get_device_state(endpoint),
1940  endpoint_snapshot->num_channels,
1941  (double) endpoint->devicestate_busy_at ? endpoint->devicestate_busy_at :
1942  INFINITY
1943  );
1944 
1945  if (context->recurse) {
1946  context->indent_level++;
1947 
1948  context->auth_direction = "Out";
1950  context->auth_direction = "In";
1952 
1953  cli_endpoint_print_child_body("aor", endpoint->aors, context);
1954  cli_endpoint_print_child_body("transport", endpoint, context);
1955  cli_endpoint_print_child_body("identify", endpoint, context);
1956  cli_endpoint_print_child_body("channel", endpoint, context);
1957 
1958  context->indent_level--;
1959 
1960  if (context->indent_level == 0) {
1961  ast_str_append(&context->output_buffer, 0, "\n");
1962  }
1963  }
1964 
1965  if (context->show_details || (context->show_details_only_level_0 && context->indent_level == 0)) {
1966  ast_str_append(&context->output_buffer, 0, "\n");
1968  }
1969 
1970  return 0;
1971 }
1972 
1973 static struct ast_cli_entry cli_commands[] = {
1974  AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "List PJSIP Endpoints",
1975  .command = "pjsip list endpoints",
1976  .usage = "Usage: pjsip list endpoints [ like <pattern> ]\n"
1977  " List the configured PJSIP endpoints\n"
1978  " Optional regular expression pattern is used to filter the list.\n"),
1979  AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "Show PJSIP Endpoints",
1980  .command = "pjsip show endpoints",
1981  .usage = "Usage: pjsip show endpoints [ like <pattern> ]\n"
1982  " List(detailed) the configured PJSIP endpoints\n"
1983  " Optional regular expression pattern is used to filter the list.\n"),
1984  AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "Show PJSIP Endpoint",
1985  .command = "pjsip show endpoint",
1986  .usage = "Usage: pjsip show endpoint <id>\n"
1987  " Show the configured PJSIP endpoint\n"),
1988 };
1989 
1992 
1993 static void load_all_endpoints(void)
1994 {
1995  struct ao2_container *endpoints;
1996 
1999 }
2000 
2001 static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub,
2002  struct stasis_message *message)
2003 {
2005  return;
2006  }
2007 
2009 }
2010 
2012 {
2015  return -1;
2016  }
2017 
2020  if (!persistent_endpoints) {
2021  return -1;
2022  }
2023 
2024  if (!(sip_sorcery = ast_sorcery_open())) {
2025  ast_log(LOG_ERROR, "Failed to open SIP sorcery failed to open\n");
2026  return -1;
2027  }
2028 
2030 
2032  ast_log(LOG_ERROR, "Failed to register SIP authentication support\n");
2034  sip_sorcery = NULL;
2035  return -1;
2036  }
2037 
2038  ast_sorcery_apply_default(sip_sorcery, "endpoint", "config", "pjsip.conf,criteria=type=endpoint");
2039  ast_sorcery_apply_default(sip_sorcery, "nat_hook", "memory", NULL);
2040 
2042  ast_log(LOG_ERROR, "Failed to register SIP endpoint object with sorcery\n");
2044  sip_sorcery = NULL;
2045  return -1;
2046  }
2047 
2049  ast_log(LOG_ERROR, "Failed to register nat_hook\n");
2050  }
2051 
2052  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "type", "", OPT_NOOP_T, 0, 0);
2053  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "context", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, context));
2054  ast_sorcery_object_field_register_alias(sip_sorcery, "endpoint", "disallow", "", OPT_CODEC_T, 0, FLDSET(struct ast_sip_endpoint, media.codecs));
2055  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow", "", OPT_CODEC_T, 1, FLDSET(struct ast_sip_endpoint, media.codecs));
2056  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtmf_mode", "rfc4733", dtmf_handler, dtmf_to_str, NULL, 0, 0);
2057  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.ipv6));
2058  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_symmetric", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.symmetric));
2059  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ice_support", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.ice_support));
2060  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_ptime", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_ptime));
2061  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_rport", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, nat.force_rport));
2062  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rewrite_contact", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, nat.rewrite_contact));
2063  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "transport", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, transport));
2064  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, outbound_proxy));
2065  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "moh_suggest", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mohsuggest));
2068  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));
2069  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));
2073  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "media_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.address));
2074  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));
2075  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "identify_by", "username,ip", ident_handler, ident_to_str, NULL, 0, 0);
2076  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "direct_media", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.enabled));
2078  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));
2079  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));
2082  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));
2084  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);
2086  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_inbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_inbound));
2087  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_outbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_outbound));
2088  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_pai", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_pai));
2089  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_rpid", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_rpid));
2090  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rpid_immediate", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.rpid_immediate));
2091  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_diversion", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_diversion));
2092  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));
2093  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.mailboxes));
2095  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "aggregate_mwi", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.aggregate));
2096  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));
2098  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_avpf", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_avpf));
2099  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_avp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.force_avp));
2100  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));
2101  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_keepalive", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.keepalive));
2102  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.timeout));
2103  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));
2104  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "one_touch_recording", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, info.recording.enabled));
2105  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "inband_progress", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, inband_progress));
2110  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));
2111  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.enabled));
2113  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_maxdatagram", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.t38.maxdatagram));
2114  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, faxdetect));
2115  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, faxdetect_timeout));
2116  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.nat));
2117  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.ipv6));
2118  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));
2119  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tone_zone", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, zone));
2121  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "record_on_feature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.onfeature));
2122  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "record_off_feature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.offfeature));
2123  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_transfer", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allowtransfer));
2124  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "user_eq_phone", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, usereqphone));
2125  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "moh_passthrough", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, moh_passthrough));
2126  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_owner", "-", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpowner));
2127  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_session", "Asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpsession));
2130  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_audio", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_audio));
2131  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_video", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_video));
2132  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_subscribe", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.allow));
2133  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sub_min_expiry", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subscription.minexpiry));
2135  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "from_domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromdomain));
2136  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_from_user", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.fromuser));
2137  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_engine", "asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.rtp.engine));
2138  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_verify", "no", dtls_handler, dtlsverify_to_str, NULL, 0, 0);
2140  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_auto_generate_cert", "no", dtls_handler, dtlsautogeneratecert_to_str, NULL, 0, 0);
2142  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_private_key", "", dtls_handler, dtlsprivatekey_to_str, NULL, 0, 0);
2148  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));
2149  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));
2150  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));
2151  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "redirect_method", "user", redirect_handler, NULL, NULL, 0, 0);
2153  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "message_context", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, message_context));
2158  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_deny", "", endpoint_acl_handler, NULL, NULL, 0, 0);
2159  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_permit", "", endpoint_acl_handler, NULL, NULL, 0, 0);
2161  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subscribe_context", "", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct ast_sip_endpoint, subscription.context));
2163  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "preferred_codec_only", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, preferred_codec_only));
2164  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "asymmetric_rtp_codec", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, asymmetric_rtp_codec));
2165  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtcp_mux", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtcp_mux));
2166  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_overlap", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_overlap));
2167  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "refer_blind_progress", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, refer_blind_progress));
2168  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));
2169  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));
2170  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));
2171  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bundle", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.bundle));
2172  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "webrtc", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, media.webrtc));
2173  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "incoming_mwi_mailbox", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, incoming_mwi_mailbox));
2174  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));
2175  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));
2176  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));
2177  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));
2178  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "incoming_call_offer_pref", "local",
2180  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "outgoing_call_offer_pref", "remote_merge",
2182  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_incoming_offer",
2183  "prefer: pending, operation: intersect, keep: all, transcode: allow",
2185  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_outgoing_offer",
2186  "prefer: pending, operation: union, keep: all, transcode: allow",
2188  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_incoming_answer",
2189  "prefer: pending, operation: intersect, keep: all",
2191  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_outgoing_answer",
2192  "prefer: pending, operation: intersect, keep: all",
2196  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_unauthenticated_options", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_unauthenticated_options));
2197 
2199  ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
2201  sip_sorcery = NULL;
2202  return -1;
2203  }
2204 
2206  ast_log(LOG_ERROR, "Failed to register SIP location support with sorcery\n");
2208  sip_sorcery = NULL;
2209  return -1;
2210  }
2211 
2213 
2215  ast_log(LOG_ERROR, "Failed to register SIP domain aliases support with sorcery\n");
2217  sip_sorcery = NULL;
2218  return -1;
2219  }
2220 
2222  ast_log(LOG_ERROR, "Failed to register SIP Global support\n");
2224  sip_sorcery = NULL;
2225  return -1;
2226  }
2227 
2229  if (!endpoint_formatter) {
2230  ast_log(LOG_ERROR, "Unable to allocate memory for endpoint_formatter\n");
2232  sip_sorcery = NULL;
2233  return -1;
2234  }
2235  endpoint_formatter->name = "endpoint";
2242 
2245 
2247 
2249 
2251 
2255 
2256  return 0;
2257 }
2258 
2260 {
2261  if (!sip_sorcery) {
2262  return;
2263  }
2264 
2271  sip_sorcery = NULL;
2279 }
2280 
2282 {
2283  if (sip_sorcery) {
2285  }
2286  return 0;
2287 }
2288 
2290 {
2291  ast_string_field_free_memory(&subscription->mwi);
2292  ast_free(subscription->mwi.voicemail_extension);
2293 }
2294 
2296 {
2297  ast_string_field_free_memory(&info->recording);
2298 }
2299 
2301 {
2305 }
2306 
2307 static void endpoint_destructor(void* obj)
2308 {
2309  struct ast_sip_endpoint *endpoint = obj;
2310 
2311  ast_string_field_free_memory(endpoint);
2312 
2313  ao2_cleanup(endpoint->media.codecs);
2316  info_configuration_destroy(&endpoint->info);
2317  media_configuration_destroy(&endpoint->media);
2320  ast_party_id_free(&endpoint->id.self);
2323  ao2_cleanup(endpoint->persistent);
2325  AST_VECTOR_FREE(&endpoint->ident_method_order);
2326  ast_free(endpoint->contact_user);
2327  ast_free_acl_list(endpoint->contact_acl);
2328  ast_free_acl_list(endpoint->acl);
2329 }
2330 
2332 {
2333  return ast_string_field_init(&subscription->mwi, 64);
2334 }
2335 
2337 {
2338  return ast_string_field_init(&info->recording, 32);
2339 }
2340 
2342 {
2344 }
2345 
2346 void *ast_sip_endpoint_alloc(const char *name)
2347 {
2348  struct ast_sip_endpoint *endpoint = ast_sorcery_generic_alloc(sizeof(*endpoint), endpoint_destructor);
2349  if (!endpoint) {
2350  return NULL;
2351  }
2352  if (ast_string_field_init(endpoint, 64)) {
2353  ao2_cleanup(endpoint);
2354  return NULL;
2355  }
2356 
2358  ao2_cleanup(endpoint);
2359  return NULL;
2360  }
2362  ao2_cleanup(endpoint);
2363  return NULL;
2364  }
2365  if (init_info_configuration(&endpoint->info)) {
2366  ao2_cleanup(endpoint);
2367  return NULL;
2368  }
2369  if (init_media_configuration(&endpoint->media)) {
2370  ao2_cleanup(endpoint);
2371  return NULL;
2372  }
2373 
2374  ast_party_id_init(&endpoint->id.self);
2375  endpoint->id.self.tag = ast_strdup("");
2376 
2377  if (AST_VECTOR_INIT(&endpoint->ident_method_order, 1)) {
2378  return NULL;
2379  }
2380 
2381  return endpoint;
2382 }
2383 
2385 {
2386  struct ao2_container *endpoints;
2387 
2389 
2390  return endpoints;
2391 }
2392 
2394 {
2397  sip_sorcery, "endpoint", name);
2398 }
2399 
2401 {
2402  int i;
2403 
2404  for (i = 0; i < AST_VECTOR_SIZE(auths); ++i) {
2405  /* Using AST_VECTOR_GET is safe since the vector is immutable */
2406  const char *name = AST_VECTOR_GET(auths, i);
2408  if (!out[i]) {
2409  ast_log(LOG_NOTICE, "Couldn't find auth '%s'. Cannot authenticate\n", name);
2410  return -1;
2411  }
2412  }
2413 
2414  return 0;
2415 }
2416 
2417 void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths)
2418 {
2419  int i;
2420  for (i = 0; i < num_auths; ++i) {
2421  ao2_cleanup(auths[i]);
2422  }
2423 }
2424 
2426  struct ast_sip_auth_objects_vector *auth_objects)
2427 {
2428  int i;
2429 
2430  for (i = 0; i < AST_VECTOR_SIZE(auth_ids); ++i) {
2431  /* Using AST_VECTOR_GET is safe since the vector is immutable */
2432  const char *name = AST_VECTOR_GET(auth_ids, i);
2434  if (!auth_object) {
2435  ast_log(LOG_WARNING, "Auth object '%s' could not be found\n", name);
2436  } else {
2437  AST_VECTOR_APPEND(auth_objects, auth_object);
2438  }
2439  }
2440 
2441  return AST_VECTOR_SIZE(auth_objects) == AST_VECTOR_SIZE(auth_ids) ? 0 : -1;
2442 }
2443 
2445 {
2446  return sip_sorcery;
2447 }
Access Control of various sorts.
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
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
Definition: acl.c:967
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:430
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
Definition: acl.c:233
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:541
const char * str
Definition: app_jack.c:147
ast_mutex_t lock
Definition: app_meetme.c:1093
#define var
Definition: ast_expr2f.c:614
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...
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1143
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
Definition: callerid.c:1073
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1182
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1092
static PGresult * result
Definition: cel_pgsql.c:84
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:121
static char regcontext[AST_MAX_CONTEXT]
Definition: chan_iax2.c:318
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:425
static char mohsuggest[MAX_MUSICCLASS]
Definition: chan_iax2.c:427
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:167
static int nat
Definition: chan_mgcp.c:171
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:168
static const char type[]
Definition: chan_ooh323.c:109
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call and pickup groups into buffer.
Definition: channel.c:8114
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1751
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups)
Print named call groups and named pickup groups.
Definition: channel.c:8139
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:1805
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7815
ast_group_t ast_get_group(const char *s)
Definition: channel.c:7701
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
Definition: channel.c:7758
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.
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
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.
@ E_MATCH
Definition: extconf.h:218
@ 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:3208
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3166
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:3171
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:3244
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
Definition: manager.c:3252
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3087
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
Definition: manager.c:2827
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7268
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 stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint 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.
char * strsep(char **str, const char *delims)
#define INFINITY
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
Definition: main/config.c:543
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
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:666
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
Security Event Reporting API.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
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:591
#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:602
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)
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.
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:4182
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
Definition: pbx.c:4955
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.
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 const char * stir_shaken_map[]
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)
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)
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[]
const char * ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint)
Retrieve the device state for an endpoint.
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 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)
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 void info_configuration_destroy(struct ast_sip_endpoint_info_configuration *info)
static struct ao2_container * cli_endpoint_get_container(const char *regex)
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 struct ast_endpoint * persistent_endpoint_find_or_create(const struct ast_sip_endpoint *endpoint)
Internal function which finds (or creates) persistent endpoint information.
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)
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
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)
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 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)
void * ast_sip_endpoint_alloc(const char *name)
Allocate a new SIP endpoint.
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 const char * sip_endpoint_identifier_type2str(enum ast_sip_endpoint_identifier_type method)
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)
struct ast_sip_endpoint * ast_sip_default_outbound_endpoint(void)
Retrieve the default outbound endpoint.
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.
static int outbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
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[]
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 void * cli_endpoint_retrieve_by_id(const char *id)
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 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 int dtlsrekey_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 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)
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)
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 void active_channels_to_str(const struct ast_sip_endpoint *endpoint, struct ast_str **str)
static void * sip_nat_hook_alloc(const char *name)
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 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
static struct @485 methods[]
const char * method
Definition: res_pjsip.c:1130
ast_sip_endpoint_identifier_type
Different methods by which incoming requests can be matched to endpoints.
Definition: res_pjsip.h:493
@ AST_SIP_ENDPOINT_IDENTIFY_BY_HEADER
Definition: res_pjsip.h:501
@ AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME
Definition: res_pjsip.h:495
@ AST_SIP_ENDPOINT_IDENTIFY_BY_IP
Definition: res_pjsip.h:499
@ AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME
Definition: res_pjsip.h:497
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:2380
@ AST_SIP_REDIRECT_URI_CORE
Definition: res_pjsip.h:540
@ AST_SIP_REDIRECT_URI_PJSIP
Definition: res_pjsip.h:542
@ AST_SIP_REDIRECT_USER
Definition: res_pjsip.h:538
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
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:2357
@ AST_SIP_MEDIA_ENCRYPT_SDES
Definition: res_pjsip.h:531
@ AST_SIP_MEDIA_TRANSPORT_INVALID
Definition: res_pjsip.h:527
@ AST_SIP_MEDIA_ENCRYPT_NONE
Definition: res_pjsip.h:529
@ AST_SIP_MEDIA_ENCRYPT_DTLS
Definition: res_pjsip.h:533
char * ast_sip_get_regcontext(void)
Retrieve the global regcontext setting.
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:494
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:2307
@ AST_SIP_STIR_SHAKEN_ATTEST
Definition: res_pjsip.h:549
@ AST_SIP_STIR_SHAKEN_OFF
Definition: res_pjsip.h:547
@ AST_SIP_STIR_SHAKEN_ON
Definition: res_pjsip.h:553
@ AST_SIP_STIR_SHAKEN_VERIFY
Definition: res_pjsip.h:551
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.
#define SIP_SORCERY_AUTH_TYPE
Definition: res_pjsip.h:461
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
Definition: res_pjsip.c:2336
@ AST_SIP_CALL_CODEC_PREF_ALL
Definition: res_pjsip.h:570
@ AST_SIP_CALL_CODEC_PREF_LOCAL
Definition: res_pjsip.h:576
@ AST_SIP_CALL_CODEC_PREF_FIRST
Definition: res_pjsip.h:572
@ AST_SIP_CALL_CODEC_PREF_INTERSECT
Definition: res_pjsip.h:564
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
void ast_sip_location_prune_boot_contacts(void)
Prune the prune_on_boot contacts.
Definition: location.c:469
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE
Definition: res_pjsip.h:514
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING
Definition: res_pjsip.h:522
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_OUTGOING
Definition: res_pjsip.h:518
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
Definition: res_pjsip.h:509
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
Definition: res_pjsip.h:507
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: pjsip_cli.c:109
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
#define CLI_LAST_TABSTOP
Definition: res_pjsip_cli.h:27
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_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:515
@ AST_RTP_DTLS_SETUP_HOLDCONN
Definition: rtp_engine.h:517
@ AST_RTP_DTLS_SETUP_ACTPASS
Definition: rtp_engine.h:516
@ AST_RTP_DTLS_SETUP_ACTIVE
Definition: rtp_engine.h:514
@ AST_RTP_DTLS_HASH_SHA1
Definition: rtp_engine.h:529
@ AST_RTP_DTLS_HASH_SHA256
Definition: rtp_engine.h:528
void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
Free contents of a DTLS configuration structure.
Definition: rtp_engine.c:3123
@ AST_RTP_DTLS_VERIFY_FINGERPRINT
Definition: rtp_engine.h:535
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:3012
int ast_rtp_dtls_cfg_validate(struct ast_rtp_dtls_cfg *dtls_cfg)
Validates DTLS related configuration options.
Definition: rtp_engine.c:3086
Sorcery Data Access Layer API.
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
Definition: sorcery.h:1500
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
@ 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
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
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
#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
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
int ast_sorcery_object_id_compare(void *obj, void *arg, int flags)
ao2 object comparator based on sorcery id.
Definition: sorcery.c:2459
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
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
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
const char * ast_sorcery_object_get_type(const void *object)
Get the type of a sorcery object.
Definition: sorcery.c:2324
#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
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Definition: stasis.c:1136
@ 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:1025
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:1079
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
#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
@ CODEC_NEGOTIATION_TRANSCODE_UNSPECIFIED
Definition: stream.h:192
@ CODEC_NEGOTIATION_TRANSCODE_ALLOW
Definition: stream.h:194
@ CODEC_NEGOTIATION_PARAM_OPERATION
Definition: stream.h:132
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
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
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_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:764
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:1117
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:739
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1237
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: main/utils.c:2097
#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: main/utils.c:2114
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:640
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:1091
#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:406
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:527
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: main/utils.c:2276
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:557
enum ast_rtp_dtls_verify verify
Definition: rtp_engine.h:560
unsigned int rekey
Definition: rtp_engine.h:556
enum ast_rtp_dtls_hash hash
Definition: rtp_engine.h:559
unsigned int enabled
Definition: rtp_engine.h:555
unsigned int ephemeral_cert
Definition: rtp_engine.h:566
AMI variable container.
Definition: res_pjsip.h:2819
const char * action_id
Definition: res_pjsip.h:2825
struct mansession * s
Definition: res_pjsip.h:2821
void * arg
Definition: res_pjsip.h:2827
const struct message * m
Definition: res_pjsip.h:2823
A SIP address of record.
Definition: res_pjsip.h:376
const char ** elems
Definition: res_pjsip.h:488
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
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
const char * name
Definition: res_pjsip_cli.h:58
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
A contact's status.
Definition: res_pjsip.h:356
const ast_string_field uri
Definition: res_pjsip.h:362
enum ast_sip_contact_status_type status
Definition: res_pjsip.h:366
const ast_string_field aor
Definition: res_pjsip.h:362
enum ast_sip_direct_media_glare_mitigation glare_mitigation
Definition: res_pjsip.h:773
enum ast_sip_session_refresh_method method
Definition: res_pjsip.h:771
struct ast_sip_timer_options timer
Definition: res_pjsip.h:612
struct ast_party_id self
Definition: res_pjsip.h:663
enum ast_sip_session_refresh_method refresh_method
Definition: res_pjsip.h:681
Endpoint configuration options for INFO packages.
Definition: res_pjsip.h:717
Media configuration for SIP endpoints.
Definition: res_pjsip.h:796
struct ast_sip_media_rtp_configuration rtp
Definition: res_pjsip.h:806
struct ast_stream_topology * topology
Definition: res_pjsip.h:814
struct ast_format_cap * codecs
Definition: res_pjsip.h:812
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_offer
Definition: res_pjsip.h:842
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_answer
Definition: res_pjsip.h:846
struct ast_sip_direct_media_configuration direct_media
Definition: res_pjsip.h:808
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_offer
Definition: res_pjsip.h:844
struct ast_flags incoming_call_offer_pref
Definition: res_pjsip.h:838
struct ast_flags outgoing_call_offer_pref
Definition: res_pjsip.h:840
struct ast_sip_t38_configuration t38
Definition: res_pjsip.h:810
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_answer
Definition: res_pjsip.h:848
struct ast_namedgroups * named_pickupgroups
Definition: res_pjsip.h:697
struct ast_namedgroups * named_callgroups
Definition: res_pjsip.h:695
Endpoint subscription configuration.
Definition: res_pjsip.h:636
struct ast_sip_mwi_configuration mwi
Definition: res_pjsip.h:642
An entity with which Asterisk communicates.
Definition: res_pjsip.h:854
struct ast_sip_auth_vector outbound_auths
Definition: res_pjsip.h:901
enum ast_sip_endpoint_identifier_type ident_method
Definition: res_pjsip.h:905
char * contact_user
Definition: res_pjsip.h:933
struct ast_endpoint * persistent
Definition: res_pjsip.h:911
enum ast_sip_session_redirect redirect_method
Definition: res_pjsip.h:919
const ast_string_field transport
Definition: res_pjsip.h:883
struct ast_sip_endpoint_id_configuration id
Definition: res_pjsip.h:893
const ast_string_field aors
Definition: res_pjsip.h:883
struct ast_sip_endpoint_pickup_configuration pickup
Definition: res_pjsip.h:897
unsigned int preferred_codec_only
Definition: res_pjsip.h:935
struct ast_sip_identify_by_vector ident_method_order
Definition: res_pjsip.h:907
struct ast_sip_endpoint_extensions extensions
Definition: res_pjsip.h:885
struct ast_sip_auth_vector inbound_auths
Definition: res_pjsip.h:899
const ast_string_field context
Definition: res_pjsip.h:883
struct ast_sip_endpoint_media_configuration media
Definition: res_pjsip.h:887
unsigned int stir_shaken
Definition: res_pjsip.h:949
struct ast_acl_list * contact_acl
Definition: res_pjsip.h:929
enum ast_sip_dtmf_mode dtmf
Definition: res_pjsip.h:903
struct ast_acl_list * acl
Definition: res_pjsip.h:927
const ast_string_field fromuser
Definition: res_pjsip.h:883
struct ast_sip_endpoint_subscription_configuration subscription
Definition: res_pjsip.h:889
struct ast_sip_endpoint_nat_configuration nat
Definition: res_pjsip.h:891
struct ast_sip_endpoint_info_configuration info
Definition: res_pjsip.h:895
unsigned int devicestate_busy_at
Definition: res_pjsip.h:913
struct ast_variable * channel_vars
Definition: res_pjsip.h:921
struct ast_rtp_dtls_cfg dtls_cfg
DTLS-SRTP configuration information.
Definition: res_pjsip.h:745
unsigned int use_received_transport
Definition: res_pjsip.h:743
enum ast_sip_session_media_encryption encryption
Definition: res_pjsip.h:749
Structure for SIP nat hook information.
Definition: res_pjsip.h:287
enum ast_t38_ec_modes error_correction
Definition: res_pjsip.h:782
unsigned int sess_expires
Definition: res_pjsip.h:599
unsigned int min_se
Definition: res_pjsip.h:597
Interface for a sorcery object type observer.
Definition: sorcery.h:332
void(* deleted)(const void *object)
Callback for when an object is deleted.
Definition: sorcery.h:340
Full structure for sorcery.
Definition: sorcery.c:230
Support for dynamic strings.
Definition: strings.h:604
enum ast_stream_codec_negotiation_prefs_transcode_values transcode
Definition: stream.h:300
enum ast_stream_codec_negotiation_prefs_operation_values operation
Definition: stream.h:296
enum ast_stream_codec_negotiation_prefs_keep_values keep
Definition: stream.h:298
enum ast_stream_codec_negotiation_prefs_prefer_values prefer
Definition: stream.h:294
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Definition: astman.c:222
In case you didn't read that giant block of text above the mansession_session struct,...
Definition: manager.c:1632
Number structure.
Definition: app_followme.c:154
int stacklen
Definition: extconf.h:238
Persistent endpoint information.
struct ast_endpoint * endpoint
Asterisk endpoint itself.
Definition: ast_expr2.c:325
int value
Definition: syslog.c:37
Test Framework API.
const char * args
@ UDPTL_ERROR_CORRECTION_FEC
Definition: udptl.h:39
@ UDPTL_ERROR_CORRECTION_NONE
Definition: udptl.h:38
@ UDPTL_ERROR_CORRECTION_REDUNDANCY
Definition: udptl.h:40
FILE * out
Definition: utils/frame.c:33
int error(const char *format,...)
Definition: utils/frame.c:999
char * usage
Definition: utils/frame.c:37
Utility functions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:936
#define ast_assert(a)
Definition: utils.h:734
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
Definition: utils.h:682
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define ARRAY_LEN(a)
Definition: utils.h:661
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition: vector.h:625
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
Definition: vector.h:571
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
#define AST_VECTOR_REMOVE_UNORDERED(vec, idx)
Remove an element from an unordered vector by index.
Definition: vector.h:438
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680