예제 #1
0
void dnsrv_resend(xmlnode pkt, char *ip, char *to)
{
    if(ip != NULL)
    {
         pkt = xmlnode_wrap(pkt,"route");
         xmlnode_put_attrib(pkt, "to", to);
         xmlnode_put_attrib(pkt, "ip", ip);
    }else{
         jutil_error(pkt, (terror){502, "Unable to resolve hostname."});
         xmlnode_put_attrib(pkt, "iperror", "");
    }
    deliver(dpacket_new(pkt),NULL);
}
예제 #2
0
파일: mod_log.c 프로젝트: smokku/wpjabber
mreturn mod_log_archiver(mapi m, void *arg)
{
	jid svcs = (jid) arg;
	xmlnode x;
	char ts[101];
	struct tm now;
	unsigned long ltime;

	if (m->packet->type != JPACKET_MESSAGE)
		return M_IGNORE;

	log_debug("archiving message");

	/* get a copy wrapped w/ a route and stamp it w/ a type='archive' (why not?) */
	x = xmlnode_wrap(xmlnode_dup(m->packet->x), "route");
	xmlnode_put_attrib(x, "type", "archive");

	/* Mark the route with an direction attribute */
	switch (m->e) {
	case es_IN:
		xmlnode_put_attrib(x, "direction", "in");
		break;
	case es_OUT:
		xmlnode_put_attrib(x, "direction", "out");
		break;
	}

	/* Mark the route with a timeStamp attribute */
	time(&ltime);
#ifdef WIN32
	now = *localtime(&ltime);
#else
	localtime_r(&ltime, &now);
#endif

	strftime((char *) ts, 100, "%m/%d/%Y %H:%M:%S", &now);

	xmlnode_put_attrib(x, "stamp", ts);

	/* if there's more than one service, copy to the others */
	for (; svcs->next != NULL; svcs = svcs->next) {
		xmlnode_put_attrib(x, "to", jid_full(svcs));
		deliver(dpacket_new(xmlnode_dup(x)), NULL);
	}

	/* send off to the last (or only) one */
	xmlnode_put_attrib(x, "to", jid_full(svcs));
	deliver(dpacket_new(x), NULL);

	return M_PASS;
}
예제 #3
0
파일: sessions.c 프로젝트: smokku/wpjabber
/* delivers a route packet to all listeners for this session */
static void js_session_route(session s, xmlnode in)
{
	/* NULL means this is an error from the session ending */
	if (in == NULL) {
		in = xmlnode_new_tag("route");
		xmlnode_put_attrib(in, "type", "error");
		xmlnode_put_attrib(in, "error", "Disconnected");
	} else {
		in = xmlnode_wrap(in, "route");
	}

	xmlnode_put_attrib(in, "from", jid_full(s->route));
	xmlnode_put_attrib(in, "to", jid_full(s->sid));
	deliver(dpacket_new(in), s->si->i);
}