> i would appreciate inside info on this one. why is answer.conn.addrType
> set in AmSession::getSdpAnswer, when its value is later overridden and
> how can i prevent the overwriting from happening?
answer.conn.addrType didn't have any effect because a fixed string
"IPv4" was used in AmSdp::print.
below is patch that allows a single signaling interface to be used for
both IPv4 or IPv6 rtp media streams when terminating calls to sems.
let me know if a better solution is in the works. if not, i'll commit
the patch in a few days.
-- juha
diff --git a/core/AmSdp.cpp b/core/AmSdp.cpp
index 55e1ed1..6bc7e6a 100644
--- a/core/AmSdp.cpp
+++ b/core/AmSdp.cpp
@@ -237,7 +237,7 @@ void AmSdp::print(string& body) const
{
string out_buf = "v="+int2str(version)+"\r\n"
"o="+origin.user+" "+int2str(origin.sessId)+" "+
- int2str(origin.sessV)+" IN IP4 ";
+ int2str(origin.sessV)+" IN " + addr_t_2_str(conn.addrType) + " ";
if (!origin.conn.address.empty())
out_buf += origin.conn.address+"\r\n";
else if (!conn.address.empty())
@@ -250,7 +250,8 @@ void AmSdp::print(string& body) const
out_buf +=
"s="+sessionName+"\r\n";
if (!conn.address.empty())
- out_buf += "c=IN IP4 "+conn.address+"\r\n";
+ out_buf += "c=IN " + addr_t_2_str(conn.addrType) + " " +
+ conn.address + "\r\n";
out_buf += "t=0 0\r\n";
@@ -300,7 +301,8 @@ void AmSdp::print(string& body) const
}
if (!media_it->conn.address.empty())
- out_buf += "\r\nc=IN IP4 "+media_it->conn.address;
+ out_buf += "\r\nc=IN " + addr_t_2_str(media_it->conn.addrType) +
+ " " + media_it->conn.address;
out_buf += "\r\n" + options;
diff --git a/core/AmSession.cpp b/core/AmSession.cpp
index 91f1dc7..503fc5f 100644
--- a/core/AmSession.cpp
+++ b/core/AmSession.cpp
@@ -982,8 +982,8 @@ bool AmSession::getSdpAnswer(const AmSdp& offer, AmSdp&
answer)
//answer.origin.sessV = 1;
answer.sessionName = "sems";
answer.conn.network = NT_IN;
- answer.conn.addrType = AT_V4;
- answer.conn.address = advertisedIP();
+ answer.conn.addrType = offer.conn.addrType;
+ answer.conn.address = advertisedIP(offer.conn.addrType);
answer.media.clear();
bool audio_1st_stream = true;
@@ -1233,7 +1233,7 @@ void AmSession::onFailure()
// Utility for basic NAT handling: allow the config file to specify the IP
// address to use in SDP bodies
-string AmSession::advertisedIP()
+string AmSession::advertisedIP(int addrType)
{
if(rtp_interface < 0){
// TODO: get default media interface for signaling IF instead
@@ -1248,10 +1248,16 @@ string AmSession::advertisedIP()
assert(rtp_interface >= 0);
assert((unsigned int)rtp_interface < AmConfig::RTP_Ifs.size());
- string set_ip = AmConfig::RTP_Ifs[rtp_interface].PublicIP;
- if (set_ip.empty())
- return AmConfig::RTP_Ifs[rtp_interface].LocalIP; // "media_ip" parameter.
-
+ string set_ip = "";
+ for (size_t i = rtp_interface; i < AmConfig::RTP_Ifs.size(); i++) {
+ set_ip = AmConfig::RTP_Ifs[i].PublicIP;
+ if (set_ip.empty())
+ set_ip = AmConfig::RTP_Ifs[i].LocalIP; // "media_ip" parameter.
+ if ((addrType == AT_NONE) ||
+ ((addrType == AT_V4) && (set_ip.find(".") != std::string::npos)) ||
+ ((addrType == AT_V6) && (set_ip.find(":") != std::string::npos)))
+ return set_ip;
+ }
return set_ip;
}
diff --git a/core/AmSession.h b/core/AmSession.h
index daa227b..ec2a2dc 100644
--- a/core/AmSession.h
+++ b/core/AmSession.h
@@ -584,7 +584,7 @@ public:
virtual void onBeforeDestroy() { }
// The IP address to put as c= in SDP bodies
- string advertisedIP();
+ string advertisedIP(int addrType = AT_NONE);
/** format session id for debugging */
string sid4dbg();
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev