Skip to content

Commit af7a257

Browse files
author
gasmibal
committed
Reverse To and From headers in the response
1 parent 38c87a0 commit af7a257

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/sip/esosip.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ es_status es_osip_init(OUT es_osip_t **_ctx, struct event_base *base)
119119
/* list of pending event */
120120
if (osip_list_init(&ctx->pendingEv) != OSIP_SUCCESS) {
121121
ESIP_TRACE(ESIP_LOG_ERROR, "List for pending event initialization failed");
122+
free(ctx->osip);
123+
free(ctx);
122124
return ES_ERROR_OUTOFRESOURCES;
123125
}
124126

125127
/* Set internal OSip Callback */
126128
if ((ret = _es_osip_set_internal_callbacks(ctx)) != ES_OK) {
129+
free(ctx->osip);
127130
free(ctx);
128131
return ret;
129132
}
@@ -159,9 +162,6 @@ es_status es_osip_parse_msg(IN es_osip_t *_ctx, const char *buf, unsigned int si
159162
return ES_ERROR_NETWORK_PROBLEM;
160163
}
161164

162-
/* TODO: Chekc message type and send it to responsable module */
163-
164-
/* Assume it's INVITE Look for existant OSip Transaction */
165165
if (osip_find_transaction_and_add_event(ctx->osip, evt) != OSIP_SUCCESS) {
166166
ESIP_TRACE(ESIP_LOG_INFO, "New transaction");
167167
osip_transaction_t *tr = NULL;
@@ -382,10 +382,10 @@ static es_status _es_tools_build_response(
382382
}
383383

384384
/* Set From header */
385-
osip_from_clone(req->from, &msg->from);
385+
osip_from_clone(req->to, &msg->from);
386386

387387
/* Set To header */
388-
osip_to_clone(req->to, &msg->to);
388+
osip_to_clone(req->from, &msg->to);
389389
random_tag = osip_build_random_number();
390390
snprintf(str_random, sizeof(str_random), "%d", random_tag);
391391
osip_to_set_tag(msg->to, osip_strdup(str_random));
@@ -445,6 +445,8 @@ static int _es_internal_send_msg_cb(
445445

446446
es_transport_send(ctx->transportCtx, addr, port, buf, buf_len);
447447

448+
free(buf);
449+
448450
return OSIP_SUCCESS;
449451
}
450452

@@ -496,6 +498,7 @@ static void _es_internal_message_cb(int type, osip_transaction_t *tr, osip_messa
496498
break;
497499
case OSIP_NIST_REGISTER_RECEIVED:
498500
{
501+
/* TODO: Send it to REGISTRAR module */
499502
ESIP_TRACE(ESIP_LOG_INFO,"OSIP_NIST_REGISTER_RECEIVED");
500503

501504
osip_message_set_status_code(response, SIP_OK);

0 commit comments

Comments
 (0)