... | ... |
@@ -33,7 +33,7 @@ |
33 | 33 |
#include "data_lump_rpl.h" |
34 | 34 |
|
35 | 35 |
|
36 |
-struct lump_rpl* build_lump_rpl( char* text, int len ) |
|
36 |
+struct lump_rpl* build_lump_rpl( char* text, int len , int type) |
|
37 | 37 |
{ |
38 | 38 |
struct lump_rpl *lump = 0; |
39 | 39 |
|
... | ... |
@@ -53,6 +53,7 @@ struct lump_rpl* build_lump_rpl( char* text, int len ) |
53 | 53 |
|
54 | 54 |
memcpy(lump->text.s,text,len); |
55 | 55 |
lump->text.len = len; |
56 |
+ lump->type = type; |
|
56 | 57 |
lump->next = 0; |
57 | 58 |
|
58 | 59 |
return lump; |
... | ... |
@@ -64,7 +65,7 @@ error: |
64 | 65 |
|
65 | 66 |
|
66 | 67 |
|
67 |
-void add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
68 |
+int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
68 | 69 |
{ |
69 | 70 |
struct lump_rpl *foo; |
70 | 71 |
|
... | ... |
@@ -72,9 +73,18 @@ void add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
72 | 73 |
{ |
73 | 74 |
msg->reply_lump = lump; |
74 | 75 |
}else{ |
75 |
- for(foo=msg->reply_lump;foo->next;foo=foo->next); |
|
76 |
+ if (lump->type!=LUMP_RPL_BODY) |
|
77 |
+ for(foo=msg->reply_lump;foo->next;foo=foo->next); |
|
78 |
+ else |
|
79 |
+ for(foo=msg->reply_lump;foo->next;foo=foo->next) |
|
80 |
+ if (lump->type==LUMP_RPL_BODY) { |
|
81 |
+ LOG(L_ERR,"ERROR:add_lump_rpl: LUMP_RPL_BODY " |
|
82 |
+ "already added!\n"); |
|
83 |
+ return -1; |
|
84 |
+ } |
|
76 | 85 |
foo->next = lump; |
77 | 86 |
} |
87 |
+ return 0; |
|
78 | 88 |
} |
79 | 89 |
|
80 | 90 |
|
... | ... |
@@ -86,4 +96,25 @@ void free_lump_rpl(struct lump_rpl* lump) |
86 | 96 |
} |
87 | 97 |
|
88 | 98 |
|
99 |
+void unlink_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
100 |
+{ |
|
101 |
+ struct lump_rpl *foo,*prev; |
|
102 |
+ |
|
103 |
+ /* look for the lump to be unlink */ |
|
104 |
+ foo = msg->reply_lump; |
|
105 |
+ prev = 0; |
|
106 |
+ while( foo && foo!=lump ) { |
|
107 |
+ prev = foo; |
|
108 |
+ foo = foo->next; |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ /* if the lump was found into the list -> unlink it */ |
|
112 |
+ if (foo) { |
|
113 |
+ if (prev) |
|
114 |
+ prev->next = foo->next; |
|
115 |
+ else |
|
116 |
+ msg->reply_lump = foo->next; |
|
117 |
+ } |
|
118 |
+} |
|
119 |
+ |
|
89 | 120 |
|
... | ... |
@@ -33,16 +33,22 @@ |
33 | 33 |
#include "parser/msg_parser.h" |
34 | 34 |
|
35 | 35 |
|
36 |
+#define LUMP_RPL_HDR 1 |
|
37 |
+#define LUMP_RPL_BODY 2 |
|
38 |
+ |
|
36 | 39 |
struct lump_rpl |
37 | 40 |
{ |
38 | 41 |
str text; |
42 |
+ int type; |
|
39 | 43 |
struct lump_rpl* next; |
40 | 44 |
}; |
41 | 45 |
|
42 |
-struct lump_rpl* build_lump_rpl( char* , int ); |
|
46 |
+struct lump_rpl* build_lump_rpl( char* , int , int ); |
|
43 | 47 |
|
44 |
-void add_lump_rpl(struct sip_msg * , struct lump_rpl* ); |
|
48 |
+int add_lump_rpl(struct sip_msg * , struct lump_rpl* ); |
|
45 | 49 |
|
46 | 50 |
void free_lump_rpl(struct lump_rpl* ); |
47 | 51 |
|
52 |
+void unlink_lump_rpl(struct sip_msg *, struct lump_rpl* ); |
|
53 |
+ |
|
48 | 54 |
#endif |
... | ... |
@@ -1505,57 +1505,28 @@ error: |
1505 | 1505 |
|
1506 | 1506 |
|
1507 | 1507 |
|
1508 |
- |
|
1509 |
- |
|
1510 |
-char * build_res_buf_from_sip_req( unsigned int code, char *text, |
|
1511 |
- char *new_tag, unsigned int new_tag_len, |
|
1512 |
- struct sip_msg* msg, unsigned int *returned_len, |
|
1513 |
- struct bookmark *bmark) |
|
1514 |
-{ |
|
1515 |
- return build_res_buf_with_body_from_sip_req(code,text,new_tag,new_tag_len, |
|
1516 |
- 0,0, /* no body */ |
|
1517 |
- 0,0, /* no content type */ |
|
1518 |
- msg,returned_len, bmark); |
|
1519 |
-} |
|
1520 |
- |
|
1521 |
-char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
|
1522 |
- char *new_tag, unsigned int new_tag_len , |
|
1523 |
- char *body, unsigned int body_len, |
|
1524 |
- char *content_type, unsigned int content_type_len, |
|
1525 |
- struct sip_msg* msg, unsigned int *returned_len, |
|
1526 |
- struct bookmark *bmark) |
|
1508 |
+char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag, |
|
1509 |
+ struct sip_msg* msg, unsigned int *returned_len, struct bookmark *bmark) |
|
1527 | 1510 |
{ |
1528 | 1511 |
char *buf, *p; |
1529 | 1512 |
unsigned int len,foo; |
1530 | 1513 |
struct hdr_field *hdr; |
1531 | 1514 |
struct lump_rpl *lump; |
1515 |
+ struct lump_rpl *body; |
|
1532 | 1516 |
int i; |
1533 | 1517 |
char backup; |
1534 |
- char *received_buf; |
|
1535 |
- char *rport_buf; |
|
1536 |
- unsigned int received_len; |
|
1537 |
- unsigned int rport_len; |
|
1538 |
- unsigned int delete_len; |
|
1539 |
- char *warning; |
|
1540 |
- unsigned int warning_len; |
|
1541 |
- unsigned int text_len; |
|
1542 |
- int content_len_len; |
|
1543 |
- char *content_len; |
|
1544 |
- char content_len_buf[MAX_CONTENT_LEN_BUF]; |
|
1518 |
+ str received = {0,0}; |
|
1519 |
+ str rport = {0,0}; |
|
1520 |
+ str warning = {0,0}; |
|
1521 |
+ str content_len = {0,0}; |
|
1522 |
+ unsigned int text_len; |
|
1545 | 1523 |
char *after_body; |
1546 | 1524 |
str to_tag; |
1547 | 1525 |
char *totags; |
1548 | 1526 |
int rcvd; |
1549 | 1527 |
|
1550 |
- received_buf=0; |
|
1551 |
- received_len=0; |
|
1552 |
- rport_buf=0; |
|
1553 |
- rport_len=0; |
|
1554 |
- delete_len=0; |
|
1528 |
+ body = 0; |
|
1555 | 1529 |
buf=0; |
1556 |
- /* make -Wall happy */ |
|
1557 |
- warning=0; |
|
1558 |
- content_len=0; |
|
1559 | 1530 |
|
1560 | 1531 |
text_len=strlen(text); |
1561 | 1532 |
|
... | ... |
@@ -1569,6 +1540,9 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1569 | 1540 |
goto error00; |
1570 | 1541 |
} |
1571 | 1542 |
|
1543 |
+ /*computes the lenght of the new response buffer*/ |
|
1544 |
+ len = 0; |
|
1545 |
+ |
|
1572 | 1546 |
/* check if received needs to be added */ |
1573 | 1547 |
backup = msg->via1->host.s[msg->via1->host.len]; |
1574 | 1548 |
msg->via1->host.s[msg->via1->host.len] = 0; |
... | ... |
@@ -1577,7 +1551,7 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1577 | 1551 |
msg->via1->port, received_dns); |
1578 | 1552 |
msg->via1->host.s[msg->via1->host.len] = backup; |
1579 | 1553 |
if (rcvd) { |
1580 |
- if ((received_buf=received_builder(msg,&received_len))==0) { |
|
1554 |
+ if ((received.s=received_builder(msg,&received.len))==0) { |
|
1581 | 1555 |
LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: " |
1582 | 1556 |
"alas, received_builder failed\n"); |
1583 | 1557 |
goto error00; |
... | ... |
@@ -1586,78 +1560,70 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1586 | 1560 |
/* check if rport needs to be updated */ |
1587 | 1561 |
if ( (msg->msg_flags&FL_FORCE_RPORT)|| |
1588 | 1562 |
(msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){ |
1589 |
- if ((rport_buf=rport_builder(msg, &rport_len))==0){ |
|
1563 |
+ if ((rport.s=rport_builder(msg, &rport.len))==0){ |
|
1590 | 1564 |
LOG(L_ERR, "ERROR: build_res_buf_from_sip_req:" |
1591 | 1565 |
" rport_builder failed\n"); |
1592 | 1566 |
goto error01; /* free everything */ |
1593 | 1567 |
} |
1594 | 1568 |
if (msg->via1->rport) |
1595 |
- delete_len=msg->via1->rport->size+1; /* include ';' */ |
|
1569 |
+ len -= msg->via1->rport->size+1; /* include ';' */ |
|
1596 | 1570 |
} |
1597 | 1571 |
|
1598 |
- /*computes the lenght of the new response buffer*/ |
|
1599 |
- len = 0; |
|
1600 | 1572 |
/* first line */ |
1601 | 1573 |
len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ + |
1602 | 1574 |
text_len + CRLF_LEN/*new line*/; |
1603 | 1575 |
/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/ |
1604 | 1576 |
for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) { |
1605 |
- if (hdr->type==HDR_TO) { |
|
1606 |
- if (new_tag) |
|
1607 |
- { |
|
1608 |
- to_tag=get_to(msg)->tag_value; |
|
1609 |
- if (to_tag.s ) |
|
1610 |
- len+=new_tag_len-to_tag.len; |
|
1611 |
- else |
|
1612 |
- len+=new_tag_len+TOTAG_TOKEN_LEN/*";tag="*/; |
|
1613 |
- } |
|
1614 |
- else { |
|
1615 |
- len+=hdr->len; |
|
1616 |
- continue; |
|
1617 |
- } |
|
1618 |
- } else if (hdr->type==HDR_VIA) { |
|
1577 |
+ switch (hdr->type) { |
|
1578 |
+ case HDR_TO: |
|
1579 |
+ if (new_tag && new_tag->len) { |
|
1580 |
+ to_tag=get_to(msg)->tag_value; |
|
1581 |
+ if (to_tag.len ) |
|
1582 |
+ len+=new_tag->len-to_tag.len; |
|
1583 |
+ else |
|
1584 |
+ len+=new_tag->len+TOTAG_TOKEN_LEN/*";tag="*/; |
|
1585 |
+ } else { |
|
1586 |
+ len += hdr->len; |
|
1587 |
+ } |
|
1588 |
+ break; |
|
1589 |
+ case HDR_VIA: |
|
1619 | 1590 |
/* we always add CRLF to via*/ |
1620 | 1591 |
len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN; |
1621 |
- if (hdr==msg->h_via1) len += received_len+rport_len; |
|
1622 |
- continue; |
|
1623 |
- } else if (hdr->type==HDR_RECORDROUTE) { |
|
1592 |
+ if (hdr==msg->h_via1) len += received.len+rport.len; |
|
1593 |
+ break; |
|
1594 |
+ case HDR_RECORDROUTE: |
|
1624 | 1595 |
/* RR only for 1xx and 2xx replies */ |
1625 |
- if (code<180 || code>=300) continue; |
|
1626 |
- } else if (!(hdr->type==HDR_FROM |
|
1627 |
- || hdr->type==HDR_CALLID |
|
1628 |
- || hdr->type==HDR_CSEQ)) { |
|
1629 |
- continue; |
|
1596 |
+ if (code<180 || code>=300) |
|
1597 |
+ break; |
|
1598 |
+ case HDR_FROM: |
|
1599 |
+ case HDR_CALLID: |
|
1600 |
+ case HDR_CSEQ: |
|
1601 |
+ /* we keep the original termination for these headers*/ |
|
1602 |
+ len += hdr->len; |
|
1630 | 1603 |
} |
1631 |
- len += hdr->len; /* we keep the original termination for these |
|
1632 |
- headers*/ |
|
1633 | 1604 |
} |
1634 |
- len-=delete_len; |
|
1635 |
- /*lumps length*/ |
|
1636 |
- for(lump=msg->reply_lump;lump;lump=lump->next) |
|
1605 |
+ /* lumps length */ |
|
1606 |
+ for(lump=msg->reply_lump;lump;lump=lump->next) { |
|
1637 | 1607 |
len += lump->text.len; |
1638 |
- if (server_signature) { |
|
1639 |
- /*server header*/ |
|
1640 |
- len += SERVER_HDR_LEN + CRLF_LEN; |
|
1641 |
- } |
|
1642 |
- |
|
1643 |
- if (body_len) { |
|
1644 |
- content_len=int2str(body_len, &content_len_len); |
|
1645 |
- memcpy(content_len_buf,content_len,content_len_len+1); |
|
1646 |
- content_len = content_len_buf; |
|
1647 |
- len += CONTENT_LENGTH_LEN + content_len_len + CRLF_LEN; |
|
1648 |
- len += body_len; |
|
1649 |
- } else { |
|
1650 |
- len +=CONTENT_LENGTH_LEN+1 + CRLF_LEN; |
|
1651 |
- } |
|
1652 |
- if(content_type_len) { |
|
1653 |
- len += content_type_len + CRLF_LEN; |
|
1608 |
+ if (lump->type==LUMP_RPL_BODY && lump->text.s && lump->text.len) |
|
1609 |
+ body = lump; |
|
1654 | 1610 |
} |
1655 |
- |
|
1611 |
+ /* server header */ |
|
1612 |
+ if (server_signature) |
|
1613 |
+ len += SERVER_HDR_LEN + CRLF_LEN; |
|
1614 |
+ /* warning hdr */ |
|
1656 | 1615 |
if (sip_warning) { |
1657 |
- warning = warning_builder(msg,&warning_len); |
|
1658 |
- if (warning) len += warning_len + CRLF_LEN; |
|
1616 |
+ warning.s = warning_builder(msg,&warning.len); |
|
1617 |
+ if (warning.s) len += warning.len + CRLF_LEN; |
|
1659 | 1618 |
else LOG(L_WARN, "WARNING: warning skipped -- too big\n"); |
1660 | 1619 |
} |
1620 |
+ /* content length hdr */ |
|
1621 |
+ len += CONTENT_LENGTH_LEN + 1/*0*/ + CRLF_LEN; |
|
1622 |
+ /* body */ |
|
1623 |
+ if (body) { |
|
1624 |
+ content_len.s = int2str(body->text.len, &content_len.len); |
|
1625 |
+ len += content_len.len - 1 + body->text.len; |
|
1626 |
+ } |
|
1661 | 1627 |
/* end of message */ |
1662 | 1628 |
len += CRLF_LEN; /*new line*/ |
1663 | 1629 |
|
... | ... |
@@ -1691,13 +1657,13 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1691 | 1657 |
{ |
1692 | 1658 |
case HDR_VIA: |
1693 | 1659 |
if (hdr==msg->h_via1){ |
1694 |
- if (rport_buf){ |
|
1660 |
+ if (rport.s){ |
|
1695 | 1661 |
if (msg->via1->rport){ /* delete the old one */ |
1696 | 1662 |
/* copy until rport */ |
1697 | 1663 |
append_str_trans( p, hdr->name.s , |
1698 | 1664 |
msg->via1->rport->start-hdr->name.s-1,msg); |
1699 | 1665 |
/* copy new rport */ |
1700 |
- append_str(p, rport_buf, rport_len); |
|
1666 |
+ append_str(p, rport.s, rport.len); |
|
1701 | 1667 |
/* copy the rest of the via */ |
1702 | 1668 |
append_str_trans(p, msg->via1->rport->start+ |
1703 | 1669 |
msg->via1->rport->size, |
... | ... |
@@ -1708,15 +1674,15 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1708 | 1674 |
/* normal whole via copy */ |
1709 | 1675 |
append_str_trans( p, hdr->name.s , |
1710 | 1676 |
(hdr->body.s+hdr->body.len)-hdr->name.s, msg); |
1711 |
- append_str(p, rport_buf, rport_len); |
|
1677 |
+ append_str(p, rport.s, rport.len); |
|
1712 | 1678 |
} |
1713 | 1679 |
}else{ |
1714 | 1680 |
/* normal whole via copy */ |
1715 | 1681 |
append_str_trans( p, hdr->name.s , |
1716 | 1682 |
(hdr->body.s+hdr->body.len)-hdr->name.s, msg); |
1717 | 1683 |
} |
1718 |
- if (received_buf) |
|
1719 |
- append_str( p, received_buf, received_len); |
|
1684 |
+ if (received.s) |
|
1685 |
+ append_str( p, received.s, received.len); |
|
1720 | 1686 |
}else{ |
1721 | 1687 |
/* normal whole via copy */ |
1722 | 1688 |
append_str_trans( p, hdr->name.s, |
... | ... |
@@ -1730,14 +1696,14 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1730 | 1696 |
append_str(p, hdr->name.s, hdr->len); |
1731 | 1697 |
break; |
1732 | 1698 |
case HDR_TO: |
1733 |
- if (new_tag){ |
|
1699 |
+ if (new_tag && new_tag->len){ |
|
1734 | 1700 |
if (to_tag.s ) { /* replacement */ |
1735 | 1701 |
/* before to-tag */ |
1736 | 1702 |
append_str( p, hdr->name.s, to_tag.s-hdr->name.s); |
1737 | 1703 |
/* to tag replacement */ |
1738 | 1704 |
bmark->to_tag_val.s=p; |
1739 |
- bmark->to_tag_val.len=new_tag_len; |
|
1740 |
- append_str( p, new_tag,new_tag_len); |
|
1705 |
+ bmark->to_tag_val.len=new_tag->len; |
|
1706 |
+ append_str( p, new_tag->s,new_tag->len); |
|
1741 | 1707 |
/* the rest after to-tag */ |
1742 | 1708 |
append_str( p, to_tag.s+to_tag.len, |
1743 | 1709 |
hdr->name.s+hdr->len-(to_tag.s+to_tag.len)); |
... | ... |
@@ -1746,8 +1712,8 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1746 | 1712 |
append_str( p, hdr->name.s, after_body-hdr->name.s); |
1747 | 1713 |
append_str(p, TOTAG_TOKEN, TOTAG_TOKEN_LEN); |
1748 | 1714 |
bmark->to_tag_val.s=p; |
1749 |
- bmark->to_tag_val.len=new_tag_len; |
|
1750 |
- append_str( p, new_tag,new_tag_len); |
|
1715 |
+ bmark->to_tag_val.len=new_tag->len; |
|
1716 |
+ append_str( p, new_tag->s,new_tag->len); |
|
1751 | 1717 |
append_str( p, after_body, |
1752 | 1718 |
hdr->name.s+hdr->len-after_body); |
1753 | 1719 |
} |
... | ... |
@@ -1764,72 +1730,68 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text , |
1764 | 1730 |
case HDR_CSEQ: |
1765 | 1731 |
append_str(p, hdr->name.s, hdr->len); |
1766 | 1732 |
} /* for switch */ |
1767 |
- /*lumps*/ |
|
1733 |
+ /* lumps */ |
|
1768 | 1734 |
for(lump=msg->reply_lump;lump;lump=lump->next) |
1769 |
- { |
|
1770 |
- memcpy(p,lump->text.s,lump->text.len); |
|
1771 |
- p += lump->text.len; |
|
1772 |
- } |
|
1735 |
+ if (lump->type==LUMP_RPL_HDR){ |
|
1736 |
+ memcpy(p,lump->text.s,lump->text.len); |
|
1737 |
+ p += lump->text.len; |
|
1738 |
+ } |
|
1739 |
+ /* server header */ |
|
1773 | 1740 |
if (server_signature) { |
1774 |
- /*server header*/ |
|
1775 | 1741 |
memcpy( p, SERVER_HDR , SERVER_HDR_LEN ); |
1776 | 1742 |
p+=SERVER_HDR_LEN; |
1777 | 1743 |
memcpy( p, CRLF, CRLF_LEN ); |
1778 | 1744 |
p+=CRLF_LEN; |
1779 | 1745 |
} |
1780 |
- |
|
1781 |
- if (body_len) { |
|
1782 |
- memcpy(p, CONTENT_LENGTH, CONTENT_LENGTH_LEN ); |
|
1783 |
- p+=CONTENT_LENGTH_LEN; |
|
1784 |
- memcpy( p, content_len, content_len_len ); |
|
1785 |
- p+=content_len_len; |
|
1786 |
- memcpy( p, CRLF, CRLF_LEN ); |
|
1787 |
- p+=CRLF_LEN; |
|
1746 |
+ /* content_length hdr */ |
|
1747 |
+ memcpy(p, CONTENT_LENGTH, CONTENT_LENGTH_LEN ); |
|
1748 |
+ p+=CONTENT_LENGTH_LEN; |
|
1749 |
+ if (content_len.len) { |
|
1750 |
+ memcpy( p, content_len.s, content_len.len ); |
|
1751 |
+ p+=content_len.len; |
|
1788 | 1752 |
} else { |
1789 |
- /* content length header*/ |
|
1790 |
- memcpy( p, CONTENT_LENGTH "0" CRLF, CONTENT_LENGTH_LEN+1+CRLF_LEN ); |
|
1791 |
- p+=CONTENT_LENGTH_LEN+1+CRLF_LEN; |
|
1753 |
+ *(p++) = '0'; |
|
1792 | 1754 |
} |
1793 |
- if(content_type_len){ |
|
1794 |
- memcpy( p, content_type, content_type_len ); |
|
1795 |
- p+=content_type_len; |
|
1796 |
- memcpy( p, CRLF, CRLF_LEN ); |
|
1797 |
- p+=CRLF_LEN; |
|
1798 |
- } |
|
1799 |
- if (sip_warning && warning) { |
|
1800 |
- memcpy( p, warning, warning_len); |
|
1801 |
- p+=warning_len; |
|
1755 |
+ memcpy( p, CRLF, CRLF_LEN ); |
|
1756 |
+ p+=CRLF_LEN; |
|
1757 |
+ /* warning header */ |
|
1758 |
+ if (warning.s) { |
|
1759 |
+ memcpy( p, warning.s, warning.len); |
|
1760 |
+ p+=warning.len; |
|
1802 | 1761 |
memcpy( p, CRLF, CRLF_LEN); |
1803 | 1762 |
p+=CRLF_LEN; |
1804 | 1763 |
} |
1805 | 1764 |
/*end of message*/ |
1806 | 1765 |
memcpy( p, CRLF, CRLF_LEN ); |
1807 | 1766 |
p+=CRLF_LEN; |
1808 |
- if(body_len){ |
|
1809 |
- memcpy ( p, body, body_len ); |
|
1810 |
- p+=body_len; |
|
1767 |
+ /* body */ |
|
1768 |
+ if (body) { |
|
1769 |
+ memcpy ( p, body->text.s, body->text.len ); |
|
1770 |
+ p+=body->text.len; |
|
1811 | 1771 |
} |
1772 |
+ |
|
1812 | 1773 |
*(p) = 0; |
1813 | 1774 |
*returned_len = len; |
1814 | 1775 |
/* in req2reply, received_buf is not introduced to lumps and |
1815 | 1776 |
needs to be deleted here |
1816 | 1777 |
*/ |
1817 |
- if (received_buf) pkg_free(received_buf); |
|
1818 |
- if (rport_buf) pkg_free(rport_buf); |
|
1778 |
+ if (received.s) pkg_free(received.s); |
|
1779 |
+ if (rport.s) pkg_free(rport.s); |
|
1819 | 1780 |
return buf; |
1820 | 1781 |
|
1821 | 1782 |
error01: |
1822 |
- if (received_buf) pkg_free(received_buf); |
|
1823 |
- if (rport_buf) pkg_free(rport_buf); |
|
1783 |
+ if (received.s) pkg_free(received.s); |
|
1784 |
+ if (rport.s) pkg_free(rport.s); |
|
1824 | 1785 |
error00: |
1825 | 1786 |
*returned_len=0; |
1826 | 1787 |
return 0; |
1827 | 1788 |
} |
1828 | 1789 |
|
1790 |
+ |
|
1791 |
+ |
|
1829 | 1792 |
/* return number of chars printed or 0 if space exceeded; |
1830 | 1793 |
assumes buffer sace of at least MAX_BRANCH_PARAM_LEN |
1831 | 1794 |
*/ |
1832 |
- |
|
1833 | 1795 |
int branch_builder( unsigned int hash_index, |
1834 | 1796 |
/* only either parameter useful */ |
1835 | 1797 |
unsigned int label, char * char_v, |
... | ... |
@@ -45,7 +45,7 @@ |
45 | 45 |
#define WARNING_PHRASE " \"Noisy feedback tells: " |
46 | 46 |
#define WARNING_PHRASE_LEN (sizeof(WARNING_PHRASE)-1) |
47 | 47 |
|
48 |
-#define MAX_CONTENT_LEN_BUF INT2STR_MAX_LEN /* see ut.h/int2str() */ |
|
48 |
+//#define MAX_CONTENT_LEN_BUF INT2STR_MAX_LEN /* see ut.h/int2str() */ |
|
49 | 49 |
|
50 | 50 |
#include "parser/msg_parser.h" |
51 | 51 |
#include "ip_addr.h" |
... | ... |
@@ -62,13 +62,14 @@ char * build_req_buf_from_sip_req ( struct sip_msg* msg, |
62 | 62 |
char * build_res_buf_from_sip_res( struct sip_msg* msg, |
63 | 63 |
unsigned int *returned_len); |
64 | 64 |
|
65 |
-char * build_res_buf_from_sip_req( unsigned int code , |
|
65 |
+ |
|
66 |
+char * build_res_buf_from_sip_req( unsigned int code , |
|
66 | 67 |
char *text , |
67 |
- char *new_tag , |
|
68 |
- unsigned int new_tag_len , |
|
68 |
+ str *new_tag , |
|
69 | 69 |
struct sip_msg* msg, |
70 | 70 |
unsigned int *returned_len, |
71 | 71 |
struct bookmark *bmark); |
72 |
+/* |
|
72 | 73 |
char * build_res_buf_with_body_from_sip_req( unsigned int code , |
73 | 74 |
char *text , |
74 | 75 |
char *new_tag , |
... | ... |
@@ -80,7 +81,7 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code , |
80 | 81 |
struct sip_msg* msg, |
81 | 82 |
unsigned int *returned_len, |
82 | 83 |
struct bookmark *bmark); |
83 |
- |
|
84 |
+*/ |
|
84 | 85 |
char* via_builder( unsigned int *len, |
85 | 86 |
struct socket_info* send_sock, |
86 | 87 |
str *branch, str* extra_params, int proto ); |