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

SOFIAPUBFUN int nta_incoming_complete_response ( nta_incoming_t irq,
msg_t msg,
int  status,
char const *  phrase,
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Complete a response message.

Parameters:
irq server transaction object
msg response message to be completed
status status code (in range 100 - 699)
phrase status phrase (may be NULL)
tag,value,... taged argument list
Generate status structure based on status and phrase. Add essential headers to the response message: , , , , , and optionally .

Definition at line 5763 of file nta.c.

References sip_addr_s::a_tag, msg_home, sip_record_route, sip_s::sip_status, sip_status_create(), sip_s::sip_to, sip_status_s::st_status, su_seterrno(), ta_end, ta_start, and ta_tags.

{
  su_home_t *home = msg_home(msg);
  sip_t *sip = sip_object(msg);
  int retval;
  ta_list ta;

  if (irq == NULL || sip == NULL)
    return su_seterrno(EFAULT), -1;

  if (status != 0 && (status < 100 || status > 699))
    return su_seterrno(EINVAL), -1;

  if (status != 0 && !sip->sip_status)
    sip->sip_status = sip_status_create(home, status, phrase, NULL);

  ta_start(ta, tag, value);
  retval = sip_add_tl(msg, sip, ta_tags(ta));
  ta_end(ta);

  if (retval < 0)
    return -1;

  if (irq->irq_default)
    return sip_complete_message(msg);

  if (status > 100 && !irq->irq_tag) {
    if (sip->sip_to)
      nta_incoming_tag(irq, sip->sip_to->a_tag);
    else
      nta_incoming_tag(irq, NULL);
  }

  if (nta_incoming_response_headers(irq, msg, sip) < 0)
    return -1;

  if (sip->sip_status && sip->sip_status->st_status > 100 &&
      irq->irq_tag && sip->sip_to && !sip->sip_to->a_tag)
    if (sip_to_tag(home, sip->sip_to, irq->irq_tag) < 0)
      return -1;

  if (status < 300 && !sip->sip_record_route && irq->irq_record_route)
    if (sip_add_dup(msg, sip, (sip_header_t *)irq->irq_record_route) < 0)
      return -1;

  return sip_complete_message(msg);
}


Generated by  Doxygen 1.6.0   Back to index