add: p_msg = T->inbound_request; r_msg = rpl;  if ( parse_headers(rpl,HDR_TO)==-1 || !rpl->to ) { LOG(L_ERR, "ERROR: t_build_and_send_ACK: cannot generate a HBH ACK if key HFs in INVITE missing\n"); goto error; }  len = 0;  len += 4+p_msg->first_line.u.request.uri.len+1+p_msg->first_line.u.request.version.len+CRLF_LEN;  len+= MY_VIA_LEN + names_len[0] + 1+ port_no_str_len + MY_BRANCH_LEN + 3*sizeof(unsigned int)  + CRLF_LEN;  for ( hdr=p_msg->headers ; hdr ; hdr=hdr->next ) if ( hdr->type==HDR_FROM || hdr->type==HDR_CALLID || hdr->type==HDR_CSEQ ) len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) ; else if ( hdr->type==HDR_TO ) len += ((r_msg->to->body.s+r_msg->to->body.len ) - r_msg->to->name.s ) ;   len -= 3;  len += CRLF_LEN;
context: int t_build_and_send_ACK( struct cell *Trans, unsigned int branch){    struct sip_msg* p_msg = T->inbound_request;    struct via_body *via;    struct hdr_field *hdr;    char *ack_buf=NULL, *p;    unsigned int len;    int n;   /* enough place for first line and Via ? */   if ( 4 + p_msg->first_line.u.request.uri.len + 1 + p_msg->first_line.u.request.version.len +	CRLF_LEN + MY_VIA_LEN + names_len[0] + 1 + port_no_str_len + MY_BRANCH_LEN  < MAX_ACK_LEN ) {		LOG( L_ERR, "ERROR: t_build_and_send_ACK: no place for FL/Via\n");		goto error;   }   ack_buf = (char *)malloc( MAX_ACK_LEN );   p = ack_buf;   /* first line */   memcpy( p , "ACK " , 4);   p += 4;   memcpy( p , p_msg->first_line.u.request.uri.s , p_msg->first_line.u.request.uri.len );   p += p_msg->first_line.u.request.uri.len;   *(p++) = ' ';   memcpy( p , p_msg->first_line.u.request.version.s , p_msg->first_line.u.request.version.len );   p += p_msg->first_line.u.request.version.len;   memcpy( p, CRLF, CRLF_LEN );   p+=CRLF_LEN;   /* insert our via */   memcpy( p , MY_VIA , MY_VIA_LEN );   p += MY_VIA_LEN;   memcpy( p , names[0] , names_len[0] );   p += names_len[0];   *(p++) = ':';   memcpy( p , port_no_str , port_no_str_len );   p += port_no_str_len;   memcpy( p, MY_BRANCH, MY_BRANCH_LEN );   p+=MY_BRANCH_LEN;   n=snprintf( p, ack_buf + MAX_ACK_LEN - p,                 ".%x.%x.%x%s",                 Trans->hash_index, Trans->label, branch, CRLF );   if (n==-1) {	LOG(L_ERR, "ERROR: t_build_and_send_ACK: not enough memory for branch\n");	goto error;   }   p+=n;   if (!check_transaction_quadruple( p_msg )) {	LOG(L_ERR, "ERROR: t_build_and_send_ACK: cannot generate a HBH ACK if key HFs in INVITE missing\n");	goto error;   }   /* To */   if (copy_hf( &p, p_msg->to , ack_buf + MAX_ACK_LEN )==-1) {	LOG(L_ERR, "ERROR: t_build_and_send_ACK: no place for To\n");	goto error;   }   /* From */   if (copy_hf( &p, p_msg->from, ack_buf + MAX_ACK_LEN )==-1) {	LOG(L_ERR, "ERROR: t_build_and_send_ACK: no place for From\n");	goto error;   }   /* CallId */   if (copy_hf( &p, p_msg->callid, ack_buf + MAX_ACK_LEN )==-1) {	LOG(L_ERR, "ERROR: t_build_and_send_ACK: no place for callid\n");	goto error;   }   /* CSeq, EoH */   n=snprintf( p, ack_buf + MAX_ACK_LEN - p,                 "Cseq: %*s ACK%s%s", get_cseq(p_msg)->number.len,		get_cseq(p_msg)->number.s, CRLF, CRLF );   if (n==-1) {	LOG(L_ERR, "ERROR: t_build_and_send_ACK: no enough memory for Cseq\n");	goto error;   }   p+=n;   /* sends the ACK message to the same destination as the INVITE */   udp_send( ack_buf, p-ack_buf, (struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );   /* free mem*/   if (ack_buf) free( ack_buf );   return 0;error:   	if (ack_buf) free( ack_buf );	return -1;}