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

Channel-locked PJSIP information interface. More...

#include <pjsip.h>
#include "asterisk/channel.h"
#include "asterisk/res_pjsip_session.h"
Include dependency graph for channel_info.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pjsip_channel_info
 
struct  pjsip_channel_uri
 

Functions

int pjsip_channel_info_create (struct ast_channel *chan, struct ast_sip_session *session)
 Create channel-owned PJSIP information before channel publication.
 
struct pjsip_channel_info * pjsip_channel_info_get (struct ast_channel *chan)
 Find the channel's information, or NULL if it has none.
 
void pjsip_channel_info_register (void)
 Register the channel information session supplement.
 
void pjsip_channel_info_schedule_update (struct ast_sip_session *session)
 Schedule a refresh from any thread without waiting for the serializer.
 
void pjsip_channel_info_unregister (void)
 Unregister the channel information session supplement.
 
void pjsip_channel_info_update (struct ast_sip_session *session)
 Refresh channel information under the channel lock.
 

Detailed Description

Channel-locked PJSIP information interface.

Definition in file channel_info.h.

Function Documentation

◆ pjsip_channel_info_create()

int pjsip_channel_info_create ( struct ast_channel *  chan,
struct ast_sip_session *  session 
)

Create channel-owned PJSIP information before channel publication.

Precondition
The caller holds the channel lock and executes in the session serializer.
Return values
0on success
-1on failure

Definition at line 187 of file channel_info.c.

189{
190 struct ast_datastore *datastore;
191 struct pjsip_channel_info *info;
192
194 if (!datastore) {
195 return -1;
196 }
197 info = ast_calloc(1, sizeof(*info));
198 if (!info) {
200 return -1;
201 }
202 info->datastore = datastore;
203 info->secure = -1;
205
206 /* The caller holds the channel lock and is running in the serializer. */
209 return 0;
210}
static struct ast_mansession session
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2376
static const struct ast_datastore_info channel_info_datastore
static void channel_info_update_locked(struct pjsip_channel_info *info, struct ast_sip_session *session)
#define ast_datastore_alloc(info, uid)
Definition datastore.h:85
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition datastore.c:68
#define NULL
Definition resample.c:96
Structure for a data store object.
Definition datastore.h:64
void * data
Definition datastore.h:66
struct ast_datastore * datastore

References ast_calloc, ast_channel_datastore_add(), ast_datastore_alloc, ast_datastore_free(), channel_info_datastore, channel_info_update_locked(), ast_datastore::data, pjsip_channel_info::datastore, NULL, and session.

Referenced by chan_pjsip_new().

◆ pjsip_channel_info_get()

struct pjsip_channel_info * pjsip_channel_info_get ( struct ast_channel *  chan)

Find the channel's information, or NULL if it has none.

Precondition
The caller holds the channel lock.
Note
The result is borrowed and may only be used while the channel is locked. Do not release it with ao2_cleanup(). The channel datastore owns its lifetime.

Definition at line 89 of file channel_info.c.

90{
91 struct ast_datastore *datastore;
92
94 return datastore ? datastore->data : NULL;
95}
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition channel.c:2390

References ast_channel_datastore_find(), channel_info_datastore, ast_datastore::data, and NULL.

Referenced by channel_read_pjsip(), pjsip_acf_channel_read(), and pjsip_channel_info_update().

◆ pjsip_channel_info_register()

void pjsip_channel_info_register ( void  )

Register the channel information session supplement.

Definition at line 289 of file channel_info.c.

290{
292}
static struct ast_sip_session_supplement channel_info_supplement
#define ast_sip_session_register_supplement(supplement)

References ast_sip_session_register_supplement, and channel_info_supplement.

Referenced by load_module().

◆ pjsip_channel_info_schedule_update()

void pjsip_channel_info_schedule_update ( struct ast_sip_session *  session)

Schedule a refresh from any thread without waiting for the serializer.

Definition at line 238 of file channel_info.c.

239{
240 /*
241 * Capture changes made after supplements or from an outgoing transport
242 * callback outside the serializer. Never wait for the queued refresh.
243 */
245 ao2_bump(session))) {
246 ast_log(LOG_WARNING, "Unable to queue PJSIP channel information refresh for %s\n",
248 ao2_ref(session, -1);
249 }
250}
#define ast_log
Definition astobj2.c:42
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480
static int channel_info_update_task(void *data)
#define ast_sip_push_task(serializer, sip_task, task_data)
Definition res_pjsip.h:2126
#define LOG_WARNING
const char * ast_sip_session_get_name(const struct ast_sip_session *session)
Get the channel or endpoint name associated with the session.

References ao2_bump, ao2_ref, ast_log, ast_sip_push_task, ast_sip_session_get_name(), channel_info_update_task(), LOG_WARNING, and session.

Referenced by channel_info_incoming_request(), channel_info_incoming_response(), channel_info_outgoing_request(), and channel_info_outgoing_response().

◆ pjsip_channel_info_unregister()

void pjsip_channel_info_unregister ( void  )

Unregister the channel information session supplement.

Definition at line 294 of file channel_info.c.

295{
297}
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.

References ast_sip_session_unregister_supplement(), and channel_info_supplement.

Referenced by load_module(), and unload_module().

◆ pjsip_channel_info_update()

void pjsip_channel_info_update ( struct ast_sip_session *  session)

Refresh channel information under the channel lock.

Precondition
The caller executes in the session serializer.

Definition at line 212 of file channel_info.c.

213{
214 struct ast_channel *chan = session->channel;
215 struct pjsip_channel_info *info;
216
217 /* Serializer execution stabilizes session->channel across a masquerade. */
218 if (!chan) {
219 return;
220 }
221 ast_channel_lock(chan);
223 if (info) {
225 }
226 ast_channel_unlock(chan);
227}
#define ast_channel_lock(chan)
Definition channel.h:2983
#define ast_channel_unlock(chan)
Definition channel.h:2984
struct pjsip_channel_info * pjsip_channel_info_get(struct ast_channel *chan)
Find the channel's information, or NULL if it has none.
Main Channel structure associated with a channel.

References ast_channel_lock, ast_channel_unlock, channel_info_update_locked(), pjsip_channel_info_get(), and session.

Referenced by channel_info_incoming_request(), channel_info_incoming_response(), channel_info_update_task(), and send_direct_media_request().