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

SOFIAPUBFUN int nta_check_method ( nta_incoming_t irq,
sip_t const *  sip,
sip_allow_t const *  allow,
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Check that we allow the request method.

The request-method is compared with the list of supported methods in allow. If match is found, 0 is is returned. Otherwise, if the request-method is well-known, 405 is returned. If the request-method is unknown, 501 is returned. If irq is non-NULL, the 405 or 501 response message is sent to the client, too.

Parameters:
irq incoming transaction object (may be NULL).
sip contents of the SIP message
allow list of allowed methods
tag,value,... optional list of tagged arguments used when responding to the transaction
Returns:
0 if successful, 405 is request-method is not allowed, 501 if request-method is unknown.

Definition at line 149 of file nta_check.c.

References name, sip_request_s::rq_method, sip_request_s::rq_method_name, SIP_405_METHOD_NOT_ALLOWED, SIP_501_NOT_IMPLEMENTED, sip_method_unknown, sip_s::sip_request, SIPTAG_ALLOW, ta_end, ta_start, and ta_tags.

{
  /* Check extensions */
  sip_method_t method = sip->sip_request->rq_method;
  char const *name = sip->sip_request->rq_method_name;

  if (sip_is_allowed(allow, method, name))
    return 0;

  if (irq) {
    ta_list ta;
    ta_start(ta, tag, value);

    if (method != sip_method_unknown)
      /* Well-known method */
      nta_incoming_treply(irq,
                    SIP_405_METHOD_NOT_ALLOWED,
                    SIPTAG_ALLOW(allow),
                    ta_tags(ta));
    else
      /* Completeley unknown method */
      nta_incoming_treply(irq,
                    SIP_501_NOT_IMPLEMENTED,
                    SIPTAG_ALLOW(allow),
                    ta_tags(ta));
    ta_end(ta);
  }

  return method != sip_method_unknown ? 405 : 501;
}


Generated by  Doxygen 1.6.0   Back to index