From JulienRefer, 6 Years ago, written in Plain Text.
- go back
Embed
Viewing differences between and NoBodyRefer
  1. The REFER I get:
  2.    REFER sip:44555202@172.16.16.141:9781;transport=udp SIP/2.0
  3.    Via: SIP/2.0/UDP 172.16.16.130:5060;branch=z9hG4bK-524287-1---cca7663c48d77f3a;rport
  4.    Via: SIP/2.0/UDP 192.168.63.72:5061;branch=z9hG4bK-2b6d69c5
  5.    Max-Forwards: 69
  6.    Contact: <sip:44111200@192.168.63.72:5061>
  7.    To: <sip:44555202@172.16.16.130>;tag=a1r2KaQ5Q3vUm
  8.    From: <sip:44111200@172.16.16.130>;tag=33099d38e40eb484o1
  9.    Call-ID: b0184248-ae01d2b4@192.168.63.72
  10.    CSeq: 103 REFER
  11.    User-Agent: Cisco/SPA504G-7.6.0
  12.    Refer-To: <sip:44555204@172.16.16.130?Replaces=e1d8e9ed-f4fa54d8%40192.168.63.72%3Bfrom-tag%3D7fbc6ee9cfb6340co1%3Bto-tag%3DBajUN578mcKeg>
  13.    Referred-By: <sip:44111200@172.16.16.130>
  14.    Content-Length: 0
  15.  
  16. The part of RFC 3515 saying a body is not mandatory:
  17. 2.3 Message Body Inclusion
  18.  
  19.    A REFER method MAY contain a body.  This specification assigns no
  20.    meaning to such a body.  A receiving agent may choose to process the
  21.    body according to its Content-Type.
  22.  
  23.  
  24.  
  25. Original code not firing the event if the REFER does not have a body+content-type:
  26.         if (sip->sip_content_type &&
  27.                 sip->sip_content_type->c_type && sip->sip_payload && sip->sip_payload->pl_data && !strcasecmp(sip->sip_event->o_type, "refer")) {
  28.                 if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_NOTIFY_REFER) == SWITCH_STATUS_SUCCESS) {
  29.                         switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "content-type", sip->sip_content_type->c_type);
  30.                         switch_event_add_body(s_event, "%s", sip->sip_payload->pl_data);
  31.                 }
  32.         }
  33.  
  34.  
  35. What I think the code should be like to cope with a REFER without a body (not tested yet):
  36.   if (!strcasecmp(sip->sip_event->o_type, "refer")) {
  37.     if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_NOTIFY_REFER) == SWITCH_STATUS_SUCCESS) {
  38.       if (sip->sip_content_type && sip->sip_content_type->c_type && sip->sip_payload && sip->sip_payload->pl_data) {
  39.         switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "content-type", sip->sip_content_type->c_type);
  40.         switch_event_add_body(s_event, "%s", sip->sip_payload->pl_data);
  41.       }
  42.     }
  43.   }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.