31 if(pkt == NULL)
return NULL;
47 if(pkt->
to == NULL && pkt->
rto != NULL)
60 if(pkt == NULL)
return NULL;
77 if(pkt->
rfrom != NULL)
87 if(pkt == NULL)
return NULL;
99 }
else if(pkt->
to != NULL)
105 }
else if(pkt->
from != NULL)
146 else if(
NAD_AVAL_L(nad, attr) == 9 && strncmp(
"broadcast",
NAD_AVAL(nad, attr), 9) == 0)
212 pkt->
pri = atoi(pri);
214 if(pkt->
pri > 127) pkt->
pri = 127;
215 if(pkt->
pri < -128) pkt->
pri = -128;
224 log_write(sm->
log, LOG_ERR,
"dropping iq without type");
369 for(i = 0; i < 40; i++) {
370 r = (int) (36.0 * rand() / RAND_MAX);
371 id[i] = (r >= 0 && r <= 9) ? (r + 48) : (r + 87);
383 if(pkt == NULL)
return;
387 if(pkt->
to == NULL) {
397 if(pkt->
rto == NULL) {
398 log_debug(
ZONE,
"invalid to address on packet, unable to route");
405 if(pkt->
rfrom != NULL)
409 if(pkt->
rfrom == NULL) {
410 log_debug(
ZONE,
"invalid from address on packet, unable to route");
462 if(pkt == NULL)
return;
470 if(pkt->
rto == NULL) {
471 log_debug(
ZONE,
"invalid to address on packet, unable to route");
478 if(pkt->
rfrom != NULL)
482 if(pkt->
rfrom == NULL) {
483 log_debug(
ZONE,
"invalid from address on packet, unable to route");
512 #ifdef ENABLE_SUPERSEDED 519 log_debug(
ZONE,
"added pkt XEP-0091 delay stamp %s", timestamp);
527 log_debug(
ZONE,
"added pkt XEP-0203 delay stamp %s", timestamp);
pkt_t pkt_error(pkt_t pkt, int err)
pkt_type_t type
packet type
jid_t jid
session jid (user@host/res)
struct nad_elem_st * elems
nad_t nad_new(void)
create a new nad
int nad_append_attr(nad_t nad, int ns, const char *name, const char *val)
attach new attr to the last elem
data structures and prototypes for the session manager
#define NAD_CDATA_L(N, E)
const char * id
component id
#define sx_nad_write(s, nad)
const char * jid_full(jid_t jid)
expand and return the full
jid_t rfrom
addressing of enclosing route
jid_t jid_new(const char *id, int len)
make a new jid
pkt_t pkt_tofrom(pkt_t pkt)
swap a packet's to and from attributes
int nad_find_attr(nad_t nad, unsigned int elem, int ns, const char *name, const char *val)
get a matching attr on this elem, both name and optional val
void nad_set_attr(nad_t nad, unsigned int elem, int ns, const char *name, const char *val, int vallen)
create, update, or zap any matching attr on this elem
void * xhash_getx(xht h, const char *key, int len)
void log_write(log_t log, int level, const char *msgfmt,...)
mod_ret_t mm_out_sess(mm_t mm, sess_t sess, pkt_t pkt)
packets to active session
int nad_add_namespace(nad_t nad, const char *uri, const char *prefix)
bring a new namespace into scope
pkt_t pkt_dup(pkt_t pkt, const char *to, const char *from)
duplicate pkt, replacing addresses
void pkt_id_new(pkt_t pkt)
create an id value for new iq packets
int nad_insert_elem(nad_t nad, unsigned int parent, int ns, const char *name, const char *cdata)
shove in a new child elem after the given one
int nad_append_elem(nad_t nad, int ns, const char *name, int depth)
create a new elem on the list
void nad_free(nad_t nad)
free that nad
nad_t nad_copy(nad_t nad)
copy a nad
int nad_find_namespace(nad_t nad, unsigned int elem, const char *uri, const char *prefix)
get a matching ns on this elem, both uri and optional prefix
pkt_t pkt_new(sm_t sm, nad_t nad)
jid_t from
packet addressing (not used for routing)
sx_t router
SX of router connection.
packet summary data wrapper
#define NAD_ENAME_L(N, E)
#define NAD_NURI_L(N, NS)
nad_t nad
nad of the entire packet
session manager global context
void jid_free(jid_t jid)
free a jid
advertisement (available)
void datetime_out(time_t t, datetime_t type, char *date, int datelen)
struct pkt_st * pkt_t
packet summary data wrapper
mod_ret_t mm_out_router(mm_t mm, pkt_t pkt)
packets to router
void pkt_id(pkt_t src, pkt_t dest)
convenience - copy the packet id from src to dest
void pkt_router(pkt_t pkt)
nad_t stanza_error(nad_t nad, int elem, int err)
error the packet
packet was unhandled, should be passed to the next module
packet was handled (and freed)
There is one instance of this struct per user who is logged in to this c2s instance.
int nad_find_elem(nad_t nad, unsigned int elem, int ns, const char *name, int depth)
locate the next elem at a given depth with an optional matching name
void pkt_delay(pkt_t pkt, time_t t, const char *from)
add an x:delay stamp
jid_t jid_dup(jid_t jid)
duplicate a jid
advertisement (unavailable)
xht xmlns
index of namespaces (for iq sub-namespace in pkt_t)
pkt_t pkt_create(sm_t sm, const char *elem, const char *type, const char *to, const char *from)
void sess_route(sess_t sess, pkt_t pkt)
send a packet to the client for this session
mod_ret_t
module return values
void pkt_sess(pkt_t pkt, sess_t sess)
session request failed (mask)
route_type_t rtype
type of enclosing route