Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN int nta_check_accept ( nta_incoming_t irq,
sip_t const *  sip,
sip_accept_t const *  acceptable,
sip_accept_t const **  return_acceptable,
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Check that UAC accepts one of listed MIME content-types.

The list of acceptable content-types are compared with the acceptable content-types. If match is found, it is returned in return_acceptable. If no match is found, a 406 is returned. If irq is non-NULL, the 406 response message is sent to the client, too.

Parameters:
irq incoming transaction object (may be NULL).
sip contents of the SIP message
acceptable list of acceptable content types
return_acceptable optional return-value parameter for matched content-type
tag,value,... optional list of tagged arguments used when responding to the transaction
Returns:
406 if no content-type is acceptable by client, 0 if successful.

Definition at line 288 of file nta_check.c.

References sip_accept_s::ac_next, sip_accept_s::ac_q, sip_accept_s::ac_type, sip_cseq_s::cs_method, sip_request_s::rq_method, SIP_406_NOT_ACCEPTABLE, sip_s::sip_accept, sip_s::sip_cseq, sip_method_invite, sip_method_options, sip_method_prack, sip_method_update, sip_s::sip_request, SIPTAG_ACCEPT, ta_end, ta_start, and ta_tags.

{
  ta_list ta;
  sip_accept_t const *ac, *ab;
  sip_method_t method;

  if (!acceptable)
    return 0;

  if (sip->sip_request)
    method = sip->sip_request->rq_method;
  else /* if (sip->sip_cseq) */
    method = sip->sip_cseq->cs_method;

  /* Missing Accept header implies support for SDP in INVITE and OPTIONS
   * (and PRACK and UPDATE?)
   */
  if (!sip->sip_accept && (method == sip_method_invite ||
                     method == sip_method_options ||
                     method == sip_method_prack ||
                     method == sip_method_update)) {
    for (ab = acceptable; ab; ab = ab->ac_next)
      if (strcasecmp(application_sdp, ab->ac_type) == 0) {
      if (return_acceptable) *return_acceptable = ab;
      return 0;
      }
  }

  for (ac = sip->sip_accept; ac; ac = ac->ac_next) {
    if (sip_q_value(ac->ac_q) == 0 || !ac->ac_type)
      continue;

    for (ab = acceptable; ab; ab = ab->ac_next)
      if (strcasecmp(ac->ac_type, ab->ac_type) == 0) {
      if (return_acceptable) *return_acceptable = ab;
      return 0;
      }
  }

  if (irq) {
    ta_start(ta, tag, value);
    nta_incoming_treply(irq,
                  SIP_406_NOT_ACCEPTABLE,
                  SIPTAG_ACCEPT(acceptable),
                  ta_tags(ta));
    ta_end(ta);
  }

  return 406;
}


Generated by  Doxygen 1.6.0   Back to index