various utilities mainly for handling xmlnodes containing stanzas More...
#include <jabberdlib.h>Defines | |
| #define | KEYBUF 100 |
Functions | |
| xmlnode | jutil_presnew (int type, char const *to, char const *status) |
| xmlnode | jutil_iqnew (int type, char *ns) |
| xmlnode | jutil_msgnew (char const *type, char const *to, char const *subj, char const *body) |
| int | jutil_priority (xmlnode x) |
| void | jutil_tofrom (xmlnode x) |
| xmlnode | jutil_iqresult (xmlnode x) |
| char * | jutil_timestamp (void) |
| char * | jutil_timestamp_ms (char buffer[25]) |
| void | jutil_error_map (terror old, xterror *mapped) |
| void | jutil_error_xmpp (xmlnode x, xterror E) |
| void | jutil_error (xmlnode x, terror E) |
| void | jutil_delay (xmlnode msg, char *reason) |
| char * | jutil_regkey (char *key, char *seed) |
various utilities mainly for handling xmlnodes containing stanzas
| #define KEYBUF 100 |
Referenced by jutil_regkey().
| void jutil_delay | ( | xmlnode | msg, | |
| char * | reason | |||
| ) |
add a delayed delivery (XEP-0091) element to a message using the present timestamp. If a reason is given, this reason will be added as CDATA to the inserted element
| msg | the message where the element should be added | |
| reason | plain text information why the delayed delivery information has been added |
References jutil_timestamp(), messages_get(), NS_DELAY, xmlnode_get_attrib_ns(), xmlnode_get_lang(), xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), and xmlnode_put_attrib_ns().
wrapper around jutil_error_xmpp for compatibility with modules for jabberd up to version 1.4.3
| x | the xmlnode that should become an stanza error message | |
| E | the strucutre that holds the error information |
References jutil_error_map(), and jutil_error_xmpp().
map a terror structure to a xterror structure
terror structures have been used in jabberd14 up to version 1.4.3 but are not able to hold XMPP compliant stanza errors. The xterror structure has been introduced to be XMPP compliant. This function is to ease writting wrappers that accept terror structures and call the real functions that require now xterror structures
| old | the terror struct that should be converted | |
| mapped | pointer to the xterror struct that should be filled with the converted error |
References terror_struct::code, xterror_struct::code, xterror_struct::condition, xterror_struct::msg, terror_struct::msg, and xterror_struct::type.
Referenced by jutil_error().
update an xmlnode to be the error stanza for itself
| x | the xmlnode that should become an stanza error message | |
| E | the structure that holds the error information |
References xterror_struct::code, xterror_struct::condition, jutil_tofrom(), messages_get(), xterror_struct::msg, NS_SERVER, NS_XMPP_STANZAS, xterror_struct::type, xmlnode_get_lang(), xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), and xmlnode_put_attrib_ns().
Referenced by _js_authreg_auth(), _js_authreg_register(), _js_session_from(), xmppd::instance_base::bounce_stanza(), deliver_fail(), dnsrv_resend(), js_authreg(), js_bounce_xmpp(), and jutil_error().
| xmlnode jutil_iqnew | ( | int | type, | |
| char * | ns | |||
| ) |
utility for making IQ stanzas, that contain a <query/> element in a different namespace
| type | the type of the iq stanza (one of JPACKET__GET, JPACKET__SET, JPACKET__RESULT, JPACKET__ERROR) | |
| ns | the namespace of the <query/> element |
References JPACKET__ERROR, JPACKET__GET, JPACKET__RESULT, JPACKET__SET, NS_SERVER, xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), and xmlnode_put_attrib_ns().
change and xmlnode to be the result xmlnode for the original iq query
| x | the xmlnode that should become the result for itself |
References jutil_tofrom(), xmlnode_get_firstchild(), xmlnode_get_nextsibling(), xmlnode_hide(), and xmlnode_put_attrib_ns().
Referenced by js_bounce_xmpp(), and js_mapi_create_additional_iq_result().
| xmlnode jutil_msgnew | ( | char const * | type, | |
| char const * | to, | |||
| char const * | subj, | |||
| char const * | body | |||
| ) |
utility for making message stanzas
| type | the type of the message (as a string!) | |
| to | the recipient of the message | |
| subj | the subject of the message (NULL for no subject element) | |
| body | the body of the message |
References j_strlen(), NS_SERVER, xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), and xmlnode_put_attrib_ns().
| xmlnode jutil_presnew | ( | int | type, | |
| char const * | to, | |||
| char const * | status | |||
| ) |
utility for making presence stanzas
| type | the type of the presence (one of the JPACKET__* contants) | |
| to | to whom the presence should be sent, NULL for a broadcast presence | |
| status | optional status (CDATA for the <status/> element, NULL for no <status/> element) |
References j_strlen(), JPACKET__INVISIBLE, JPACKET__PROBE, JPACKET__SUBSCRIBE, JPACKET__SUBSCRIBED, JPACKET__UNAVAILABLE, JPACKET__UNSUBSCRIBE, JPACKET__UNSUBSCRIBED, NS_SERVER, xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), and xmlnode_put_attrib_ns().
Referenced by js_sc_session_new(), js_session_end(), and js_session_new().
| int jutil_priority | ( | xmlnode | x | ) |
returns the priority on an available presence packet
| x | the xmlnode containing the presence packet |
References NS_SERVER, xhash_free(), xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_get_data(), xmlnode_get_list_item(), and xmlnode_get_tags().
| char* jutil_regkey | ( | char * | key, | |
| char * | seed | |||
| ) |
create or validate a key value for stone-age jabber protocols
Before dialback had been introduced for s2s (and therefore only in jabberd 1.0), Jabber used these keys to protect some iq requests. A client first had to request a key with a IQ get and use it inside the IQ set request. By being able to receive the key in the IQ get response, the client (more or less) proved to be who he claimed to be.
The implementation of this function uses a static array with KEYBUF entries (default value of KEYBUF is 100). Therefore a key gets invalid at the 100th key that is created afterwards. It is also invalidated after it has been validated once.
| key | for validation the key the client sent, for generation of a new key NULL | |
| seed | the seed for generating the key, must stay the same for the same user |
References j_strcmp(), KEYBUF, and shahash().
| char* jutil_timestamp | ( | void | ) |
get the present time as a textual timestamp in the format YYYYMMDDTHH:MM:SS
Referenced by jutil_delay().
| char* jutil_timestamp_ms | ( | char | buffer[25] | ) |
get the present time as a textual timestamp in the format YYYY-MM-DDTHH:MM:SS.MMMZ
| buffer | place where the timestamp should be written |
| void jutil_tofrom | ( | xmlnode | x | ) |
reverse sender and destination of a packet
| x | the xmlnode where sender and receiver should be exchanged |
References xmlnode_get_attrib_ns(), and xmlnode_put_attrib_ns().
Referenced by _js_authreg_auth(), _js_authreg_register(), _js_routed_session_control_packet(), _js_routed_session_packet(), deliver_fail(), dialback_in_read_db(), dialback_out_connection_cleanup(), dialback_out_packet(), jutil_error_xmpp(), and jutil_iqresult().
1.6.1