29 #include <pjsip_simple.h> 53 .
type =
"dialog-info+xml",
73 struct timeval tv = {0,};
95 pj_xml_node *dialog_info = body, *dialog, *
state;
101 char *pidfstate =
NULL, *pidfnote =
NULL;
103 char version_str[32], sanitized[PJSIP_MAX_URL_SIZE];
107 if (!local || !remote || !state_data->
datastores) {
125 datastore_state = datastore->
data;
127 if (state_data->
sub) {
138 datastore_state = datastore->
data;
150 &pidfstate, &pidfnote, &local_state, notify_early_inuse_ringing);
154 snprintf(version_str,
sizeof(version_str),
"%u", datastore_state->
version);
157 if (state_data->
sub) {
168 char local_target[PJSIP_MAX_URL_SIZE + 32] =
"";
169 char *local_cid_name =
NULL;
170 pj_xml_node *local_node, *local_identity_node, *local_target_node;
179 static char *anonymous =
"anonymous";
180 static char *invalid =
"anonymous.invalid";
181 char *remote_cid_name;
182 char *remote_connected_num;
183 int remote_connected_num_restricted;
184 char *local_caller_num;
186 pjsip_sip_uri *dlg_remote_fromhdr = pjsip_uri_get_uri(dlg->local.info->uri);
187 char remote_target[PJSIP_MAX_URL_SIZE + 32];
188 char dlg_remote_uri[PJSIP_MAX_URL_SIZE];
189 char *from_domain_stripped;
190 char from_domain_sanitized[PJSIP_MAX_URL_SIZE];
191 pj_xml_node *remote_node, *remote_identity_node, *remote_target_node;
194 ast_copy_pj_str(dlg_remote_uri, &dlg_remote_fromhdr->host,
sizeof(dlg_remote_uri));
196 ast_sip_sanitize_xml(from_domain_stripped, from_domain_sanitized,
sizeof(from_domain_sanitized));
211 S_COR(remote_connected_num_restricted, anonymous,
214 snprintf(remote_target,
sizeof(remote_target),
"sip:%s@%s", remote_connected_num,
215 remote_connected_num_restricted ? invalid : from_domain_sanitized);
225 snprintf(local_target,
sizeof(local_target),
"sip:%s@%s", local_caller_num,
226 from_domain_sanitized);
235 pj_strdup2(state_data->
pool, &remote_identity_node->content, remote_target);
248 pj_strdup2(state_data->
pool, &local_identity_node->content,
S_OR(local_target, sanitized));
257 pj_strdup2(state_data->
pool, &state->content, statestring);
260 pj_xml_node *local_node, *target, *param;
278 #define MAX_STRING_GROWTHS 6 282 pj_xml_node *dialog_info = body;
303 .
type =
"application",
304 .subtype =
"dialog-info+xml",
332 .requires =
"res_pjsip,res_pjsip_pubsub",
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
static const struct ast_datastore_info dialog_info_xml_datastore
Datastore for attaching dialog-info+xml state information.
enum sip_cc_notify_state state
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
static void dialog_info_to_string(void *body, struct ast_str **str)
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
struct ast_party_id id
Connected party ID.
#define ast_channel_unref(c)
Decrease channel reference count.
const char * type
Content type In "plain/text", "plain" is the type.
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
#define ast_str_make_space(buf, new_len)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static void * dialog_info_allocate_body(void *data)
pj_xml_attr * ast_sip_presence_xml_create_attr(pj_pool_t *pool, pj_xml_node *node, const char *name, const char *value)
Create XML attribute.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
int ast_datastores_add(struct ao2_container *datastores, struct ast_datastore *datastore)
Add a data store to a container.
char remote[PJSIP_MAX_URL_SIZE]
Structure for a data store type.
Structure which contains dialog-info+xml state information.
enum ast_extension_states exten_state
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
Structure for a data store object.
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
int ast_sip_pubsub_register_body_generator(struct ast_sip_pubsub_body_generator *generator)
Register a body generator with the pubsub core.
struct ast_sip_subscription * sub
static int dialog_info_generate_body_content(void *body, void *data)
struct ao2_container * datastores
#define AST_PRES_RESTRICTED
struct ast_datastore * ast_datastores_find(struct ao2_container *datastores, const char *name)
Find a data store in a container.
#define ast_strlen_zero(foo)
#define AST_SIP_EXTEN_STATE_DATA
struct ast_channel * causing_channel
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
void ast_sip_subscription_set_persistence_data(struct ast_sip_subscription *subscription, struct ast_json *persistence_data)
Set persistence data for a subscription.
void ast_sip_presence_exten_state_to_str(int state, char **statestring, char **pidfstate, char **pidfnote, enum ast_sip_pidf_state *local_state, unsigned int notify_early_inuse_ringing)
Convert extension state to relevant PIDF strings.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define ao2_ref(o, delta)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
unsigned int notify_early_inuse_ringing
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define MAX_STRING_GROWTHS
enum ast_device_state device_state
struct ast_datastore * ast_datastores_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Allocate a datastore for use with the datastores container.
An entity with which Asterisk communicates.
#define AST_PJSIP_XML_PROLOG_LEN
Length of the XML prolog when printing presence or other XML in PJSIP.
struct ao2_container * device_state_info
char local[PJSIP_MAX_URL_SIZE]
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define ao2_iterator_next(iter)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
#define ast_channel_unlock(chan)
#define ast_calloc(num, len)
A wrapper for calloc()
static struct ast_sip_pubsub_body_generator dialog_info_body_generator
pj_xml_node * ast_sip_presence_xml_create_node(pj_pool_t *pool, pj_xml_node *parent, const char *name)
Create XML node.
Module has failed to load, may be in an inconsistent state.
void ast_sip_sanitize_xml(const char *input, char *output, size_t len)
Replace offensive XML characters with XML entities.
static struct ast_channel * find_ringing_channel(struct ao2_container *device_state_info)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static int unload_module(void)
#define AST_PRES_RESTRICTION
struct ast_sip_endpoint * ast_sip_subscription_get_endpoint(struct ast_sip_subscription *sub)
Get the endpoint that is associated with this subscription.
pjsip_dialog * ast_sip_subscription_get_dialog(struct ast_sip_subscription *sub)
Get the pjsip dialog that is associated with this subscription.
static int load_module(void)
structure used for presence XML bodies
#define ast_channel_ref(c)
Increase channel reference count.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Abstract JSON element (object, array, string, int, ...).
const struct ast_json * ast_sip_subscription_get_persistence_data(const struct ast_sip_subscription *subscription)
Retrieve persistence data for a subscription.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static void dialog_info_xml_state_destroy(void *obj)
Destructor for dialog-info+xml information.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
unsigned int version
Version to place into the next NOTIFY.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ast_sip_pubsub_unregister_body_generator(struct ast_sip_pubsub_body_generator *generator)
Unregister a body generator with the pubsub core.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
struct ast_party_number number
Subscriber phone number.