Changeset 3363


Ignore:
Timestamp:
Nov 10, 2010 12:13:46 PM (11 years ago)
Author:
bennylp
Message:

Fixed #1156: New option to ignore bad NOTIFY presence message body (thanks Johan Lantz for the suggestion)

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_config.h

    r3361 r3363  
    902902 
    903903/** 
     904 * Specify the status code value to respond to bad message body in NOTIFY 
     905 * request for presence. Scenarios that are considered bad include non- 
     906 * PIDF/XML and non-XPIDF/XML body, multipart message bodies without PIDF/XML 
     907 * nor XPIDF/XML part, and bad (parsing error) PIDF and X-PIDF bodies 
     908 * themselves. 
     909 * 
     910 * Default value is 488. Application may change this to 200 to ignore the 
     911 * unrecognised content (this is useful if the application wishes to handle 
     912 * the content itself). Only non-3xx final response code is allowed here. 
     913 * 
     914 * Default: 488 (Not Acceptable Here) 
     915 */ 
     916#ifndef PJSIP_PRES_BAD_CONTENT_RESPONSE 
     917#   define PJSIP_PRES_BAD_CONTENT_RESPONSE      488 
     918#endif 
     919 
     920 
     921/** 
    904922 * Add "timestamp" information in generated PIDF document for both server 
    905923 * subscription and presence publication. 
  • pjproject/trunk/pjsip/src/pjsip-simple/presence.c

    r3337 r3363  
    3636#define PRES_DEFAULT_EXPIRES        PJSIP_PRES_DEFAULT_EXPIRES 
    3737 
     38#if PJSIP_PRES_BAD_CONTENT_RESPONSE < 200 || \ 
     39    PJSIP_PRES_BAD_CONTENT_RESPONSE > 699 || \ 
     40    PJSIP_PRES_BAD_CONTENT_RESPONSE/100 == 3 
     41# error Invalid PJSIP_PRES_BAD_CONTENT_RESPONSE value 
     42#endif 
     43 
    3844/* 
    3945 * Presence module (mod-presence) 
     
    760766    if (status != PJ_SUCCESS) { 
    761767        /* Unsupported or bad Content-Type */ 
    762         pjsip_accept_hdr *accept_hdr; 
    763         pjsip_warning_hdr *warn_hdr; 
    764  
    765         *p_st_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 
    766  
    767         /* Add Accept header */ 
    768         accept_hdr = pjsip_accept_hdr_create(rdata->tp_info.pool); 
    769         accept_hdr->values[accept_hdr->count++] = STR_APP_PIDF_XML; 
    770         accept_hdr->values[accept_hdr->count++] = STR_APP_XPIDF_XML; 
    771         pj_list_push_back(res_hdr, accept_hdr); 
    772  
    773         /* Add Warning header */ 
    774         warn_hdr = pjsip_warning_hdr_create_from_status( 
    775                                     rdata->tp_info.pool, 
    776                                     pjsip_endpt_name(pres->dlg->endpt), 
    777                                     status); 
    778         pj_list_push_back(res_hdr, warn_hdr); 
    779  
    780         return status; 
     768        if (PJSIP_PRES_BAD_CONTENT_RESPONSE >= 300) { 
     769            pjsip_accept_hdr *accept_hdr; 
     770            pjsip_warning_hdr *warn_hdr; 
     771 
     772            *p_st_code = PJSIP_PRES_BAD_CONTENT_RESPONSE; 
     773 
     774            /* Add Accept header */ 
     775            accept_hdr = pjsip_accept_hdr_create(rdata->tp_info.pool); 
     776            accept_hdr->values[accept_hdr->count++] = STR_APP_PIDF_XML; 
     777            accept_hdr->values[accept_hdr->count++] = STR_APP_XPIDF_XML; 
     778            pj_list_push_back(res_hdr, accept_hdr); 
     779 
     780            /* Add Warning header */ 
     781            warn_hdr = pjsip_warning_hdr_create_from_status( 
     782                                        rdata->tp_info.pool, 
     783                                        pjsip_endpt_name(pres->dlg->endpt), 
     784                                        status); 
     785            pj_list_push_back(res_hdr, warn_hdr); 
     786 
     787            return status; 
     788        } else { 
     789            pj_assert(PJSIP_PRES_BAD_CONTENT_RESPONSE/100 == 2); 
     790            PJ_PERROR(4,(THIS_FILE, status, 
     791                         "Ignoring presence error due to " 
     792                         "PJSIP_PRES_BAD_CONTENT_RESPONSE setting [%d]", 
     793                         PJSIP_PRES_BAD_CONTENT_RESPONSE)); 
     794            *p_st_code = PJSIP_PRES_BAD_CONTENT_RESPONSE; 
     795            status = PJ_SUCCESS; 
     796        } 
    781797    } 
    782798 
Note: See TracChangeset for help on using the changeset viewer.