|
@@ -21,7 +21,6 @@
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
|
|
|
|
-#include "defs.h"
|
|
|
|
|
|
|
|
#ifdef EXTRA_DEBUG
|
|
#ifdef EXTRA_DEBUG
|
|
#include <assert.h>
|
|
#include <assert.h>
|
|
@@ -60,9 +59,7 @@
|
|
*/
|
|
*/
|
|
char *build_local(struct cell *Trans,unsigned int branch,
|
|
char *build_local(struct cell *Trans,unsigned int branch,
|
|
unsigned int *len, char *method, int method_len, str *to
|
|
unsigned int *len, char *method, int method_len, str *to
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
, struct cancel_reason* reason
|
|
, struct cancel_reason* reason
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
)
|
|
)
|
|
{
|
|
{
|
|
char *cancel_buf, *p, *via;
|
|
char *cancel_buf, *p, *via;
|
|
@@ -73,10 +70,8 @@ char *build_local(struct cell *Trans,unsigned int branch,
|
|
str branch_str;
|
|
str branch_str;
|
|
str via_id;
|
|
str via_id;
|
|
struct hostport hp;
|
|
struct hostport hp;
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
int reason_len, code_len;
|
|
int reason_len, code_len;
|
|
struct hdr_field *reas1, *reas_last;
|
|
struct hdr_field *reas1, *reas_last;
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
|
|
|
|
/* init */
|
|
/* init */
|
|
via_id.s=0;
|
|
via_id.s=0;
|
|
@@ -139,7 +134,6 @@ char *build_local(struct cell *Trans,unsigned int branch,
|
|
}
|
|
}
|
|
/* Content Length, EoM */
|
|
/* Content Length, EoM */
|
|
*len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
|
|
*len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
reason_len = 0;
|
|
reason_len = 0;
|
|
reas1 = 0;
|
|
reas1 = 0;
|
|
reas_last = 0;
|
|
reas_last = 0;
|
|
@@ -172,7 +166,6 @@ char *build_local(struct cell *Trans,unsigned int branch,
|
|
LM_BUG("unhandled reason cause %d\n", reason->cause);
|
|
LM_BUG("unhandled reason cause %d\n", reason->cause);
|
|
}
|
|
}
|
|
*len+= reason_len;
|
|
*len+= reason_len;
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
*len+= CRLF_LEN; /* end of msg. */
|
|
*len+= CRLF_LEN; /* end of msg. */
|
|
|
|
|
|
cancel_buf=shm_malloc( *len+1 );
|
|
cancel_buf=shm_malloc( *len+1 );
|
|
@@ -215,7 +208,6 @@ char *build_local(struct cell *Trans,unsigned int branch,
|
|
}
|
|
}
|
|
/* Content Length */
|
|
/* Content Length */
|
|
append_str(p, CONTENT_LENGTH "0" CRLF, CONTENT_LENGTH_LEN + 1 + CRLF_LEN);
|
|
append_str(p, CONTENT_LENGTH "0" CRLF, CONTENT_LENGTH_LEN + 1 + CRLF_LEN);
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
/* add reason if needed */
|
|
/* add reason if needed */
|
|
if (reason_len) {
|
|
if (reason_len) {
|
|
if (likely(reason->cause > 0)) {
|
|
if (likely(reason->cause > 0)) {
|
|
@@ -243,7 +235,6 @@ char *build_local(struct cell *Trans,unsigned int branch,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
append_str(p, CRLF, CRLF_LEN); /* msg. end */
|
|
append_str(p, CRLF, CRLF_LEN); /* msg. end */
|
|
*p=0;
|
|
*p=0;
|
|
|
|
|
|
@@ -263,9 +254,7 @@ error:
|
|
*/
|
|
*/
|
|
char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
unsigned int *len, char *method, int method_len, str *to
|
|
unsigned int *len, char *method, int method_len, str *to
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
, struct cancel_reason *reason
|
|
, struct cancel_reason *reason
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
)
|
|
)
|
|
{
|
|
{
|
|
char *invite_buf, *invite_buf_end;
|
|
char *invite_buf, *invite_buf_end;
|
|
@@ -275,10 +264,8 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
enum _hdr_types_t hf_type;
|
|
enum _hdr_types_t hf_type;
|
|
int first_via, to_len;
|
|
int first_via, to_len;
|
|
int cancel_buf_len;
|
|
int cancel_buf_len;
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
int reason_len, code_len;
|
|
int reason_len, code_len;
|
|
struct hdr_field *reas1, *reas_last, *hdr;
|
|
struct hdr_field *reas1, *reas_last, *hdr;
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
int hadded = 0;
|
|
int hadded = 0;
|
|
sr_cfgenv_t *cenv = NULL;
|
|
sr_cfgenv_t *cenv = NULL;
|
|
|
|
|
|
@@ -295,7 +282,6 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
reason_len = 0;
|
|
reason_len = 0;
|
|
reas1 = 0;
|
|
reas1 = 0;
|
|
reas_last = 0;
|
|
reas_last = 0;
|
|
@@ -327,7 +313,6 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
} else if (unlikely(reason->cause < CANCEL_REAS_MIN))
|
|
} else if (unlikely(reason->cause < CANCEL_REAS_MIN))
|
|
LM_BUG("unhandled reason cause %d\n", reason->cause);
|
|
LM_BUG("unhandled reason cause %d\n", reason->cause);
|
|
}
|
|
}
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
|
|
|
|
invite_buf_end = invite_buf + invite_len;
|
|
invite_buf_end = invite_buf + invite_len;
|
|
s = invite_buf;
|
|
s = invite_buf;
|
|
@@ -337,11 +322,8 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
I just extend it with the length of new To HF to be sure.
|
|
I just extend it with the length of new To HF to be sure.
|
|
Ugly, but we avoid lots of checks and memory allocations this way */
|
|
Ugly, but we avoid lots of checks and memory allocations this way */
|
|
to_len = to ? to->len : 0;
|
|
to_len = to ? to->len : 0;
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
cancel_buf_len = invite_len + to_len + reason_len;
|
|
cancel_buf_len = invite_len + to_len + reason_len;
|
|
-#else
|
|
|
|
- cancel_buf_len = invite_len + to_len;
|
|
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
|
|
+
|
|
cancel_buf = shm_malloc(sizeof(char)*cancel_buf_len);
|
|
cancel_buf = shm_malloc(sizeof(char)*cancel_buf_len);
|
|
if (!cancel_buf)
|
|
if (!cancel_buf)
|
|
{
|
|
{
|
|
@@ -437,7 +419,6 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
|
|
|
|
case HDR_EOH_T:
|
|
case HDR_EOH_T:
|
|
/* end of SIP message found */
|
|
/* end of SIP message found */
|
|
-#ifdef CANCEL_REASON_SUPPORT
|
|
|
|
/* add reason if needed */
|
|
/* add reason if needed */
|
|
if (reason_len) {
|
|
if (reason_len) {
|
|
/* if reason_len !=0, no need for any reason enabled
|
|
/* if reason_len !=0, no need for any reason enabled
|
|
@@ -470,7 +451,6 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#endif /* CANCEL_REASON_SUPPORT */
|
|
|
|
/* final (end-of-headers) CRLF */
|
|
/* final (end-of-headers) CRLF */
|
|
append_str(d, CRLF, CRLF_LEN);
|
|
append_str(d, CRLF, CRLF_LEN);
|
|
*len = d - cancel_buf;
|
|
*len = d - cancel_buf;
|