94{
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];
106
107 if (!local || !remote || !state_data->
datastores) {
108 return -1;
109 }
110
112 if (!datastore) {
114
116 if (!datastore) {
117 return -1;
118 }
119
123 return -1;
124 }
125 datastore_state = datastore->
data;
126
127 if (state_data->
sub) {
129 }
130
131 if (version_json) {
134 } else {
136 }
137 } else {
138 datastore_state = datastore->
data;
140 }
141
144
148 }
150 &pidfstate, &pidfnote, &local_state, notify_early_inuse_ringing);
151
153
154 snprintf(version_str,
sizeof(version_str),
"%u", datastore_state->
version);
156
157 if (state_data->
sub) {
159 }
160
163
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;
171
173
176 }
177
178 if (callee) {
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 char remote_target[PJSIP_MAX_URL_SIZE + 32];
187 char dlg_remote_uri[PJSIP_MAX_URL_SIZE];
188 char *from_domain_stripped;
189 char from_domain_sanitized[PJSIP_MAX_URL_SIZE];
190 pj_xml_node *remote_node, *remote_identity_node, *remote_target_node;
191
192
195 ast_sip_sanitize_xml(from_domain_stripped, from_domain_sanitized,
sizeof(from_domain_sanitized));
196
198
199
200
201
206
210 S_COR(remote_connected_num_restricted, anonymous,
212
213 snprintf(remote_target, sizeof(remote_target), "sip:%s@%s", remote_connected_num,
214 remote_connected_num_restricted ? invalid : from_domain_sanitized);
215
216
217
218
223
224 snprintf(local_target, sizeof(local_target), "sip:%s@%s", local_caller_num,
225 from_domain_sanitized);
226
229
233
234 pj_strdup2(state_data->
pool, &remote_identity_node->content, remote_target);
236 char display_sanitized[PJSIP_MAX_URL_SIZE];
237
240 }
242 }
243
248
249
250 pj_strdup2(state_data->
pool, &local_identity_node->content,
S_OR(local_target, sanitized));
252 char display_sanitized[PJSIP_MAX_URL_SIZE];
253
256 }
257
259 }
260 }
261
263 pj_strdup2(state_data->
pool, &
state->content, statestring);
264
266 pj_xml_node *local_node, *target, *param;
267
274 }
275
277
278 return 0;
279}
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define AST_PRES_RESTRICTED
#define AST_PRES_RESTRICTION
#define ast_channel_lock(chan)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define ast_channel_unlock(chan)
int ast_datastores_add(struct ao2_container *datastores, struct ast_datastore *datastore)
Add a data store to a container.
struct ast_datastore * ast_datastores_find(struct ao2_container *datastores, const char *name)
Find a data store in a container.
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.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
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.
const pj_str_t * ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri)
Get the host portion of the pjsip_uri.
static struct ast_channel * find_ringing_channel(struct ao2_container *device_state_info)
static const struct ast_datastore_info dialog_info_xml_datastore
Datastore for attaching dialog-info+xml state information.
void ast_sip_sanitize_xml(const char *input, char *output, size_t len)
Replace offensive XML characters with XML entities.
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.
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.
struct ast_sip_endpoint * ast_sip_subscription_get_endpoint(struct ast_sip_subscription *sub)
Get the endpoint that is associated with this subscription.
const struct ast_json * ast_sip_subscription_get_persistence_data(const struct ast_sip_subscription *subscription)
Retrieve persistence data for a subscription.
void ast_sip_subscription_set_persistence_data(struct ast_sip_subscription *subscription, struct ast_json *persistence_data)
Set persistence data for a subscription.
pjsip_dialog * ast_sip_subscription_get_dialog(struct ast_sip_subscription *sub)
Get the pjsip dialog that is associated with this subscription.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
Main Channel structure associated with a channel.
Structure for a data store object.
Abstract JSON element (object, array, string, int, ...).
struct ast_party_id id
Connected party ID.
struct ast_party_number number
Subscriber phone number.
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
An entity with which Asterisk communicates.
unsigned int notify_early_inuse_ringing
char local[PJSIP_MAX_URL_SIZE]
struct ast_sip_subscription * sub
enum ast_extension_states exten_state
struct ao2_container * device_state_info
struct ao2_container * datastores
char remote[PJSIP_MAX_URL_SIZE]
Structure which contains dialog-info+xml state information.
unsigned int version
Version to place into the next NOTIFY.