Skip to content

Commit 08112e9

Browse files
authored
Merge pull request signalwire#767 from signalwire/sofiacleanup
[mod_sofia] Cleanup usage of sofia-sip headers.
2 parents 8a5850f + b06036e commit 08112e9

File tree

10 files changed

+191
-120
lines changed

10 files changed

+191
-120
lines changed

libs/sofia-sip/.update

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Tue May 12 18:04:14 UTC 2020
1+
Fri Jul 31 17:46:57 CDT 2020

libs/sofia-sip/libsofia-sip-ua/nua/nua.c

+62-1
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,14 @@ void nua_destroy(nua_t *nua)
234234
#if HAVE_SMIME /* Start NRC Boston */
235235
sm_destroy(nua->sm);
236236
#endif /* End NRC Boston */
237-
su_home_unref(nua->nua_home);
237+
nua_unref(nua);
238238
}
239239
}
240240

241+
void nua_unref(nua_t *nua) {
242+
if (nua) su_home_unref(nua->nua_home);
243+
}
244+
241245
/** Fetch callback context from nua.
242246
*
243247
* @param nua Pointer to @nua stack object
@@ -1089,3 +1093,60 @@ nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id)
10891093
}
10901094
return NULL;
10911095
}
1096+
1097+
/** Get leg from dialog. */
1098+
const nta_leg_t *nua_get_dialog_state_leg(nua_handle_t *nh)
1099+
{
1100+
if (nh && nh->nh_ds)
1101+
return nh->nh_ds->ds_leg;
1102+
else
1103+
return NULL;
1104+
}
1105+
1106+
/** Get su_home_t from nua handle. */
1107+
su_home_t *nua_handle_get_home(nua_handle_t *nh)
1108+
{
1109+
if (nh && nh->nh_home)
1110+
return nh->nh_home;
1111+
else
1112+
return NULL;
1113+
}
1114+
1115+
/** Get su_home_t from nua. */
1116+
su_home_t *nua_get_home(nua_t *nua)
1117+
{
1118+
if (nua && nua->nua_home)
1119+
return nua->nua_home;
1120+
else
1121+
return NULL;
1122+
}
1123+
1124+
/** Get nta_agent_t from nua. */
1125+
nta_agent_t *nua_get_agent(nua_t *nua)
1126+
{
1127+
if (nua && nua->nua_nta)
1128+
return nua->nua_nta;
1129+
else
1130+
return NULL;
1131+
}
1132+
1133+
/** Set has invite of a nua handle */
1134+
void nua_handle_set_has_invite(nua_handle_t *nh, unsigned val)
1135+
{
1136+
if (nh)
1137+
nh->nh_has_invite = val;
1138+
}
1139+
1140+
/** Check if nua handle is destroyed */
1141+
unsigned nua_handle_is_destroyed(nua_handle_t *nh)
1142+
{
1143+
assert(nh);
1144+
return nh->nh_destroyed;
1145+
}
1146+
1147+
void nua_handle_dialog_usage_set_refresh_range(nua_handle_t *nh,
1148+
unsigned min, unsigned max) {
1149+
if (nh && nh->nh_ds && nh->nh_ds->ds_usage) {
1150+
nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, min, max);
1151+
}
1152+
}

libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h

+14
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
#include <sofia-sip/sip.h>
4848
#endif
4949

50+
#ifndef NTA_H
51+
#include <sofia-sip/nta.h>
52+
#endif
53+
5054
#ifndef NUA_TAG_H
5155
#include <sofia-sip/nua_tag.h>
5256
#endif
@@ -386,6 +390,16 @@ SOFIAPUBFUN nua_handle_t *nua_handle_by_replaces(nua_t *nua,
386390

387391
nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id);
388392

393+
SOFIAPUBFUN const nta_leg_t *nua_get_dialog_state_leg(nua_handle_t *nh);
394+
SOFIAPUBFUN su_home_t *nua_handle_get_home(nua_handle_t *nh);
395+
SOFIAPUBFUN void nua_unref(nua_t *nua);
396+
SOFIAPUBFUN su_home_t *nua_get_home(nua_t *nua);
397+
SOFIAPUBFUN nta_agent_t *nua_get_agent(nua_t *nua);
398+
SOFIAPUBFUN void nua_handle_set_has_invite(nua_handle_t *nh, unsigned val);
399+
SOFIAPUBFUN unsigned nua_handle_is_destroyed(nua_handle_t *nh);
400+
SOFIAPUBFUN void nua_handle_dialog_usage_set_refresh_range(nua_handle_t *nh,
401+
unsigned min, unsigned max);
402+
389403
SOFIA_END_DECLS
390404

391405
#endif

src/mod/endpoints/mod_sofia/mod_sofia.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2456,7 +2456,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
24562456
/* Set sip_to_tag to local tag for inbound channels. */
24572457
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
24582458
const char* to_tag = "";
2459-
to_tag = switch_str_nil(nta_leg_get_tag(tech_pvt->nh->nh_ds->ds_leg));
2459+
to_tag = switch_str_nil(nta_leg_get_tag(nua_get_dialog_state_leg(tech_pvt->nh)));
24602460
if(to_tag) {
24612461
switch_channel_set_variable(channel, "sip_to_tag", to_tag);
24622462
}
@@ -5251,7 +5251,7 @@ static int notify_csta_callback(void *pArg, int argc, char **argv, char **column
52515251

52525252
//nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
52535253
nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(full_to), SIPTAG_TO_STR(full_from), SIPTAG_CONTACT_STR(profile->url), TAG_END());
5254-
cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY);
5254+
cseq = sip_cseq_create(nua_handle_get_home(nh), callsequence, SIP_METHOD_NOTIFY);
52555255

52565256
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
52575257

src/mod/endpoints/mod_sofia/mod_sofia.h

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ typedef struct private_object private_object_t;
142142
#include <sofia-sip/msg_addr.h>
143143
#include <sofia-sip/tport_tag.h>
144144
#include <sofia-sip/sip_extra.h>
145-
#include "nua_stack.h"
146145
#include "sofia-sip/msg_parser.h"
147146
#include "sofia-sip/sip_parser.h"
148147
#include "sofia-sip/tport_tag.h"

src/mod/endpoints/mod_sofia/sip-dig.c

-3
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@
133133

134134

135135
#include "switch.h"
136-
#ifndef WIN32
137-
#include "../../config.h"
138-
#endif
139136

140137
#include "sofia-sip/su.h"
141138

0 commit comments

Comments
 (0)