MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / in_stream_node_callback

Function in_stream_node_callback

modules/xmpp/xmpp_server.c:291–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static void in_stream_node_callback(int type, xode node, void *arg)
292{
293 struct xmpp_connection *conn = (struct xmpp_connection *) arg;
294 char *tag;
295 xode x;
296
297 LM_DBG("instream callback: %d: %s\n",
298 type, node ? xode_get_name(node) : "n/a");
299 switch (type) {
300 case XODE_STREAM_ROOT:
301 conn->stream_id = strdup(random_secret());
302 net_printf(conn->fd,
303 "<?xml version='1.0'?>"
304 "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:server' version='1.0'"
305 " xmlns:db='jabber:server:dialback' id='%s' from='%s'>", conn->stream_id, xmpp_domain);
306 net_printf(conn->fd,"<stream:features xmlns:stream='http://etherx.jabber.org/streams'/>");
307 break;
308 case XODE_STREAM_NODE:
309 tag = xode_get_name(node);
310
311 if (!strcmp(tag, "db:result")) {
312 char *from = xode_get_attrib(node, "from");
313 char *to = xode_get_attrib(node, "to");
314 /* char *id = xode_get_attrib(node, "id"); */
315 char *type = xode_get_attrib(node, "type");
316 char *cdata = xode_get_data(node);
317
318 if (!type) {
319 if (conn->domain) {
320 LM_DBG("connection %d has old domain '%s'\n",conn->fd,
321 conn->domain);
322 free(conn->domain);
323 }
324 conn->domain = strdup(from);
325 LM_DBG("connection %d set domain '%s'\n",
326 conn->fd, conn->domain);
327
328 /* it's a request; send verification over outgoing connection */
329 x = xode_new_tag("db:verify");
330 xode_put_attrib(x, "xmlns:db", "jabber:server:dialback");
331 xode_put_attrib(x, "from", to);
332 xode_put_attrib(x, "to", from);
333 //xode_put_attrib(x, "id", "someid"); /* XXX fix ID */
334 xode_put_attrib(x, "id", conn->stream_id);
335 xode_insert_cdata(x, cdata, -1);
336 xode_send_domain(from, x);
337 }
338 } else if (!strcmp(tag, "db:verify")) {
339 char *from = xode_get_attrib(node, "from");
340 char *to = xode_get_attrib(node, "to");
341 char *id = xode_get_attrib(node, "id");
342 char *type = xode_get_attrib(node, "type");
343 char *cdata = xode_get_data(node);
344
345 if (!type) {
346 /* it's a request */
347 x = xode_new_tag("db:verify");
348 xode_put_attrib(x, "xmlns:db", "jabber:server:dialback");

Callers

nothing calls this directly

Calls 14

random_secretFunction · 0.85
net_printfFunction · 0.85
xode_send_domainFunction · 0.85
db_keyFunction · 0.85
xmpp_send_sip_msgFunction · 0.85
xode_get_nameFunction · 0.70
xode_get_attribFunction · 0.70
xode_get_dataFunction · 0.70
xode_new_tagFunction · 0.70
xode_put_attribFunction · 0.70
xode_insert_cdataFunction · 0.70
xode_sendFunction · 0.70

Tested by

no test coverage detected