[Re-devel] notify does not need to have body

Juha Heinanen jh at tutpro.com
Sat Sep 20 13:22:57 CEST 2014


baresip currently replies with 415 Unsupported Media Type when it
receives NOTIFY without body.  however, according to rfc3265

   If the resource
   has no meaningful state at the time that the SUBSCRIBE message is
   processed, this NOTIFY message MAY contain an empty or neutral body.

the patch below to modules/presence/subscriber.c allows notify without
body and sets presence status to UNKNOWN.

-- juha

*** /usr/src/orig/baresip/modules/presence/subscriber.c	Fri Sep 19 18:57:48 2014
--- subscriber.c	Sat Sep 20 14:21:42 2014
***************
*** 78,94 ****
  {
  	enum presence_status status = PRESENCE_CLOSED;
  	struct presence *pres = arg;
! 	const struct sip_hdr *hdr;
  	struct pl pl;
  
  	pres->failc = 0;
  
! 	hdr = sip_msg_hdr(msg, SIP_HDR_CONTENT_TYPE);
! 	if (!hdr || 0 != pl_strcasecmp(&hdr->val, "application/pidf+xml")) {
  
! 		if (hdr)
  			warning("presence: unsupported content-type: '%r'\n",
! 				&hdr->val);
  
  		sip_treplyf(NULL, NULL, sip, msg, false,
  			    415, "Unsupported Media Type",
--- 78,106 ----
  {
  	enum presence_status status = PRESENCE_CLOSED;
  	struct presence *pres = arg;
! 	const struct sip_hdr *type_hdr, *length_hdr;
  	struct pl pl;
  
  	pres->failc = 0;
  
! 	type_hdr = sip_msg_hdr(msg, SIP_HDR_CONTENT_TYPE);
  
! 	if (!type_hdr) {
! 
! 		length_hdr = sip_msg_hdr(msg, SIP_HDR_CONTENT_LENGTH);
! 		if (0 == pl_strcmp(&length_hdr->val, "0")) {
! 
! 			status = PRESENCE_UNKNOWN;
! 			goto done;
! 		}
! 	}
! 
! 	if (!type_hdr ||
! 	    0 != pl_strcasecmp(&type_hdr->val, "application/pidf+xml")) {
! 
! 		if (type_hdr)
  			warning("presence: unsupported content-type: '%r'\n",
! 				&type_hdr->val);
  
  		sip_treplyf(NULL, NULL, sip, msg, false,
  			    415, "Unsupported Media Type",
***************
*** 124,129 ****
--- 136,142 ----
  		status = PRESENCE_BUSY;
  	}
  
+ done:
  	(void)sip_treply(NULL, sip, msg, 200, "OK");
  
  	contact_set_presence(pres->contact, status);

_______________________________________________
Re-devel mailing list
Re-devel at lists.creytiv.com
http://lists.creytiv.com/mailman/listinfo/re-devel



More information about the Re-devel mailing list