diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-10-20 21:12:14 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-10-20 21:12:14 +0200 | 
| commit | dfa41a405f0c80549f6dd5c0c111e3b62ce83b07 (patch) | |
| tree | 6faaf52a51bf99351fec25ff5ae967511726c825 /protocols/jabber/iq.c | |
| parent | f920d9eb003541245e0fc32a381447cbba8fbea5 (diff) | |
Now all IQ packets get an ID and cached packets get a "special" ID. This
makes it easier to find out if an event handler has to be called for a
reply packet.
Diffstat (limited to 'protocols/jabber/iq.c')
| -rw-r--r-- | protocols/jabber/iq.c | 34 | 
1 files changed, 26 insertions, 8 deletions
| diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 8864e3fd..446a25bb 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -44,11 +44,12 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  	{  		struct jabber_cache_entry *entry; -		if( ( s = xt_find_attr( node, "id" ) ) == NULL ) +		if( ( s = xt_find_attr( node, "id" ) ) == NULL || +		    strncmp( s, JABBER_CACHED_ID, strlen( JABBER_CACHED_ID ) ) != 0 )  		{ -			/* Silently ignore it, without an ID we don't know -			   how to handle the packet, but it doesn't have -			   to be a serious problem. */ +			/* Silently ignore it, without an ID (or an non-cache +			   ID) we don't know how to handle the packet and we +			   probably don't have to. */  			return XT_HANDLED;  		} @@ -64,7 +65,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  		if( !( c = xt_find_node( node->children, "query" ) ) ||  		    !( s = xt_find_attr( c, "xmlns" ) ) )  		{ -			serv_got_crap( gc, "WARNING: Received incomplete IQ-get packet" ); +			serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );  			return XT_HANDLED;  		} @@ -124,9 +125,26 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  	}  	else if( strcmp( type, "set" ) == 0 )  	{ -		xt_free_node( reply ); -		reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" ); -		pack = 0; +		if( !( c = xt_find_node( node->children, "query" ) ) || +		    !( s = xt_find_attr( c, "xmlns" ) ) ) +		{ +			serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type ); +			return XT_HANDLED; +		} +		 +		if( strcmp( s, "jabber:iq:roster" ) == 0 ) +		{ +			/* This is a roster push packet, probably. Here we +			   should check if the packet is legitimate by +			   checking if it really comes from the user's JID +			   and, if so, process it. */ +		} +		else +		{ +			xt_free_node( reply ); +			reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" ); +			pack = 0; +		}  	}  	/* If we recognized the xmlns and managed to generate a reply, | 
