Asterisk - The Open Source Telephony Project GIT-master-f36a736
pjsip_session.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2017, CFWare, LLC
5 *
6 * Corey Farrell <git@cfware.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#include <pjlib.h>
24
25#include "asterisk/res_pjsip.h"
29#include "asterisk/lock.h"
30#include "asterisk/module.h"
31
32
34
36{
37 struct ast_sip_session_supplement *iter;
38 int inserted = 0;
40
41 ast_assert(supplement != NULL);
42
43 supplement->module = module;
44
45 if (!supplement->response_priority) {
47 }
48
50 if (iter->priority > supplement->priority) {
52 inserted = 1;
53 break;
54 }
55 }
57
58 if (!inserted) {
60 }
61}
62
64{
65 struct ast_sip_session_supplement *iter;
67
69 if (supplement == iter) {
71 break;
72 }
73 }
75}
76
78{
79 struct ast_sip_session_supplement *dst = ast_calloc(1, sizeof(*dst));
80
81 if (!dst) {
82 return NULL;
83 }
84 /* Will need to revisit if shallow copy becomes an issue */
85 *dst = *src;
86
87 return dst;
88}
89
91{
92 struct ast_sip_session_supplement *iter;
94
97
98 if (!copy) {
99 return -1;
100 }
101
102 /* referenced session created. increasing module reference. */
103 ast_module_ref(copy->module);
104
105 AST_LIST_INSERT_TAIL(&session->supplements, copy, next);
106 }
107
108 return 0;
109}
110
112{
113 struct ast_sip_session_supplement *iter;
114
115 if (!session) {
116 return;
117 }
118
119 /* free the supplements */
120 while ((iter = AST_LIST_REMOVE_HEAD(&session->supplements, next))) {
121 if (iter->module) {
122 /* referenced session closed. decreasing module reference. */
124 }
125
126 ast_free(iter);
127 }
128
129 return;
130}
131
ast_mutex_t lock
Definition: app_sla.c:331
static int copy(char *infile, char *outfile)
Utility function to copy a file.
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_free(a)
Definition: astmm.h:180
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
A set of macros to manage forward-linked lists.
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:570
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:545
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
Definition: linkedlists.h:333
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:617
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:494
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:741
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
#define AST_RWLIST_INSERT_BEFORE_CURRENT
Definition: linkedlists.h:610
Asterisk locking-related definitions:
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:583
Asterisk module definitions.
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:483
#define ast_module_ref(mod)
Hold a reference to the module.
Definition: module.h:457
void ast_sip_session_remove_supplements(struct ast_sip_session *session)
Remove supplements from a SIP session.
int ast_sip_session_add_supplements(struct ast_sip_session *session)
Add supplements to a SIP session.
Definition: pjsip_session.c:90
static struct ast_sip_session_supplement * supplement_dup(const struct ast_sip_session_supplement *src)
Definition: pjsip_session.c:77
void ast_sip_session_register_supplement_with_module(struct ast_module *module, struct ast_sip_session_supplement *supplement)
Register a supplement to SIP session processing.
Definition: pjsip_session.c:35
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
Definition: pjsip_session.c:63
@ AST_SIP_SESSION_BEFORE_MEDIA
#define NULL
Definition: resample.c:96
A supplement to SIP message processing.
struct ast_sip_session_supplement * next
enum ast_sip_session_response_priority response_priority
struct ast_module * module
enum ast_sip_supplement_priority priority
A structure describing a SIP session.
#define ast_assert(a)
Definition: utils.h:739