"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/h235/h235caps.cxx" between
h323plus-1_27_0.tar.gz and h323plus-1_27_1.tar.gz

About: H.323 Plus offers libraries for voice (VoIP) and videoconferencing using H.323.

h235caps.cxx  (h323plus-1_27_0):h235caps.cxx  (h323plus-1_27_1)
skipping to change at line 661 skipping to change at line 661
{ {
return ChildCapability->GetIdentifier(); return ChildCapability->GetIdentifier();
} }
H323Codec * H323SecureCapability::CreateCodec(H323Codec::Direction direction) co nst H323Codec * H323SecureCapability::CreateCodec(H323Codec::Direction direction) co nst
{ {
return ChildCapability->CreateCodec(direction); return ChildCapability->CreateCodec(direction);
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// For extended
H323SecureExtendedCapability::H323SecureExtendedCapability(H323Capability * chil
dCapability, enum H235ChType Ch, H323Capabilities * capabilities, unsigned secNo
, PBoolean active)
: H323ExtendedVideoCapability(""),
ChildCapability(childCapability), chtype(Ch), m_active(active)
,
m_capabilities(capabilities), m_secNo(secNo), nrtpqos(NULL)
{
assignedCapabilityNumber = ChildCapability->GetCapabilityNumber();
}
H323SecureExtendedCapability::H323SecureExtendedCapability(RTP_QOS * _rtpqos,H32
3Capability * childCapability)
: H323ExtendedVideoCapability(""),
ChildCapability(childCapability), chtype(H235ChNew), m_active(
false),
m_capabilities(NULL), m_secNo(0), nrtpqos(_rtpqos)
{
}
H323SecureExtendedCapability::~H323SecureExtendedCapability()
{
delete ChildCapability;
}
void H323SecureExtendedCapability::AttachQoS(RTP_QOS * _rtpqos)
{
#ifdef P_QOS
delete nrtpqos;
nrtpqos = _rtpqos;
#endif
}
void H323SecureExtendedCapability::SetAssociatedCapability(unsigned _secNo)
{
m_secNo = _secNo;
}
H323Channel * H323SecureExtendedCapability::CreateChannel(H323Connection & conne
ction,
H323Channel::Directions dir,
unsigned sessionID,
const H245_H2250LogicalChannelParameters * para
m) const
{
// create a standard RTP channel if we don't have a DH token
H235Capabilities * caps = dynamic_cast<H235Capabilities*>(connection.GetLocalC
apabilitiesRef());
if (!caps || !caps->GetDiffieHellMan())
return connection.CreateRealTimeLogicalChannel(*ChildCapability, dir, sessio
nID, param, nrtpqos);
// Support for encrypted external RTP Channel
H323Channel * extRTPChannel = connection.CreateRealTimeLogicalChannel(*this, d
ir, sessionID, param, nrtpqos);
if (extRTPChannel)
return extRTPChannel;
RTP_Session * session = NULL; // Session
if (
#ifdef H323_H46026
connection.H46026IsMediaTunneled() ||
#endif
!param || !param->HasOptionalField(H245_H2250LogicalChannelParameters::e_me
diaControlChannel)) {
// Make a fake transport address from the connection so gets initialised wit
h
// the transport type (IP, IPX, multicast etc).
H245_TransportAddress addr;
connection.GetControlChannel().SetUpTransportPDU(addr, H323Transport::UseLoc
alTSAP);
session = connection.UseSession(sessionID, addr, dir, nrtpqos);
} else {
session = connection.UseSession(param->m_sessionID, param->m_mediaControlCha
nnel, dir, nrtpqos);
}
if (!session)
return NULL;
return new H323SecureRTPChannel(connection, *this, dir, *session);
}
unsigned H323SecureExtendedCapability::GetCapabilityNumber() const
{
return ChildCapability->GetCapabilityNumber();
};
void H323SecureExtendedCapability::SetCapabilityNumber(unsigned num)
{
assignedCapabilityNumber = num;
ChildCapability->SetCapabilityNumber(num);
}
void H323SecureExtendedCapability::SetCapabilityList(H323Capabilities * capabili
ties)
{
m_capabilities = capabilities;
}
void H323SecureExtendedCapability::SetEncryptionActive(PBoolean active)
{
m_active = active;
}
PBoolean H323SecureExtendedCapability::IsEncryptionActive() const
{
return m_active;
}
void H323SecureExtendedCapability::SetEncryptionAlgorithm(const PString & alg)
{
m_algorithm = alg;
}
const PString & H323SecureExtendedCapability::GetEncryptionAlgorithm() const
{
return m_algorithm;
}
const OpalMediaFormat & H323SecureExtendedCapability::GetMediaFormat() const
{
return ChildCapability->GetMediaFormat();
}
OpalMediaFormat & H323SecureExtendedCapability::GetWritableMediaFormat()
{
return ChildCapability->GetWritableMediaFormat();
}
H323Capability::MainTypes H323SecureExtendedCapability::GetMainType() const
{
return ChildCapability->GetMainType();
}
PObject * H323SecureExtendedCapability::Clone() const
{
PTRACE(3, "H235ExtRTP\tCloning Capability: " << GetFormatName());
H235ChType ch = H235ChNew;
switch (chtype) {
case H235ChNew:
ch = H235ChClone;
break;
case H235ChClone:
ch = H235Channel;
break;
case H235Channel:
ch = H235Channel;
break;
}
return new H323SecureExtendedCapability((H323Capability *)ChildCapability->Clo
ne(), ch, m_capabilities, m_secNo, m_active);
}
PBoolean H323SecureExtendedCapability::IsMatch(const PASN_Choice & subTypePDU) c
onst
{
if (PIsDescendant(&subTypePDU, H245_VideoCapability) &&
ChildCapability->GetMainType() == H323Capability::e_Video) {
const H245_VideoCapability & video = (const H245_VideoCapability &)sub
TypePDU;
return ChildCapability->IsMatch(video);
}
if (PIsDescendant(&subTypePDU, H245_H235Media_mediaType)) {
const H245_H235Media_mediaType & data =
(const H245_H235Media_mediaType &)subTypePDU;
return IsSubMatch(data);
}
return false;
}
PBoolean H323SecureExtendedCapability::IsSubMatch(const PASN_Choice & subTypePDU
) const
{
const H245_H235Media_mediaType & dataType = (const H245_H235Media_mediaType
&)subTypePDU;
if (dataType.GetTag() == H245_H235Media_mediaType::e_videoData &&
ChildCapability->GetMainType() == H323Capability::e_Video) {
const H245_VideoCapability & video = dataType;
return ChildCapability->IsMatch(video);
}
return false;
}
PObject::Comparison H323SecureExtendedCapability::Compare(const PObject & obj) c
onst
{
if (!PIsDescendant(&obj, H323SecureExtendedCapability))
return LessThan;
Comparison result = H323Capability::Compare(obj);
if (result != EqualTo)
return result;
const H323SecureExtendedCapability & other = (const H323SecureExtendedCapabili
ty &)obj;
return ChildCapability->Compare(*(other.GetChildCapability()));
}
unsigned H323SecureExtendedCapability::GetDefaultSessionID() const
{
return ChildCapability->GetDefaultSessionID();
}
////////////////////////////////////////////////////////////////////////
// PDU Sending
PBoolean H323SecureExtendedCapability::OnSendingPDU(H245_ModeElement & mode) con
st
{
switch (ChildCapability->GetMainType()) {
case H323Capability::e_Video:
#ifdef H323_VIDEO
return ((H323ExtendedVideoCapability *)ChildCapability)->OnSendingPD
U(mode);
#endif // H323_VIDEO
case H323Capability::e_Audio:
case H323Capability::e_Data:
default:
return false;
}
}
PBoolean H323SecureExtendedCapability::OnSendingPDU(H245_DataType & dataType) co
nst
{
// find the matching H235SecurityCapability to get the agreed algorithms
// if not found or no matching algorithm then assume no encryption.
H235SecurityCapability * secCap = NULL;
if (m_capabilities) {
secCap = (H235SecurityCapability *)m_capabilities->FindCapability(m_secN
o);
if (secCap && secCap->GetAlgorithmCount() > 0) {
(PRemoveConst(H323SecureExtendedCapability,this))->SetEncryptionActiv
e(true);
(PRemoveConst(H323SecureExtendedCapability,this))->SetEncryptionAlgor
ithm(secCap->GetAlgorithm());
}
}
if (!IsEncryptionActive()) {
switch (ChildCapability->GetMainType()) {
case H323Capability::e_Video:
#ifdef H323_VIDEO
dataType.SetTag(H245_DataType::e_videoData);
return ((H323CodecExtendedVideoCapability *)ChildCapability)->On
SendingPDU((H245_VideoCapability &)dataType, e_OLC);
#endif // H323_VIDEO
case H323Capability::e_Audio:
case H323Capability::e_Data:
default:
break;
}
return false;
}
dataType.SetTag(H245_DataType::e_h235Media);
H245_H235Media & h235Media = dataType;
// Load the algorithm
if (secCap)
secCap->OnSendingPDU(h235Media.m_encryptionAuthenticationAndIntegrity, e_O
LC);
H245_H235Media_mediaType & cType = h235Media.m_mediaType;
switch (ChildCapability->GetMainType()) {
case H323Capability::e_Video:
#ifdef H323_VIDEO
cType.SetTag(H245_H235Media_mediaType::e_videoData);
return ((H323CodecExtendedVideoCapability *)ChildCapability)->OnSend
ingPDU((H245_VideoCapability &)cType, e_OLC);
#endif // H323_VIDEO
case H323Capability::e_Audio:
case H323Capability::e_Data:
default:
break;
}
return false;
}
PBoolean H323SecureExtendedCapability::OnReceivedPDU(const H245_DataType & dataT
ype,PBoolean receiver)
{
if (dataType.GetTag() != H245_DataType::e_h235Media)
return ChildCapability->OnReceivedPDU(dataType, receiver);
const H245_H235Media & h235Media = dataType;
if (m_capabilities) {
H235SecurityCapability * secCap = (H235SecurityCapability *)m_capabiliti
es->FindCapability(m_secNo);
if (!secCap || !secCap->OnReceivedPDU(h235Media.m_encryptionAuthenticati
onAndIntegrity, e_OLC)) {
PTRACE(4,"H235\tFailed to locate security capability " << m_secNo);
return false;
}
if (secCap && secCap->GetAlgorithmCount() > 0) {
SetEncryptionAlgorithm(secCap->GetAlgorithm());
SetEncryptionActive(true);
}
}
const H245_H235Media_mediaType & mediaType = h235Media.m_mediaType;
switch (ChildCapability->GetMainType()) {
case H323Capability::e_Video:
#ifdef H323_VIDEO
if (mediaType.GetTag() == H245_H235Media_mediaType::e_videoData)
return ((H323CodecExtendedVideoCapability *)ChildCapability)->OnR
eceivedPDU((const H245_VideoCapability &)mediaType);
break;
#endif // H323_VIDEO
case H323Capability::e_Audio:
case H323Capability::e_Data:
default:
break;
}
return false;
}
//////////////////////////////////////////////////////////////////////////////
// Child Capability Intercept
PBoolean H323SecureExtendedCapability::OnSendingPDU(H245_Capability & pdu) const
{
switch (ChildCapability->GetMainType()) {
case H323Capability::e_Video:
#ifdef H323_VIDEO
return ((H323CodecExtendedVideoCapability *)ChildCapability)->OnSend
ingPDU(pdu);
#endif // H323_VIDEO
case H323Capability::e_Audio:
case H323Capability::e_Data:
case H323Capability::e_UserInput:
case H323Capability::e_ExtendVideo:
default:
return false;
}
}
PBoolean H323SecureExtendedCapability::OnReceivedPDU(const H245_Capability & pdu
)
{
switch (ChildCapability->GetMainType()) {
case H323Capability::e_Video:
#ifdef H323_VIDEO
return ((H323CodecExtendedVideoCapability *)ChildCapability)->OnRece
ivedPDU(pdu);
#endif // H323_VIDEO
case H323Capability::e_Audio:
case H323Capability::e_Data:
case H323Capability::e_UserInput:
case H323Capability::e_ExtendVideo:
default:
return false;
}
}
PString H323SecureExtendedCapability::GetFormatName() const
{
return ChildCapability->GetFormatName() + (m_active ? " #" : "");
}
unsigned H323SecureExtendedCapability::GetSubType() const
{
return ChildCapability->GetSubType();
}
PString H323SecureExtendedCapability::GetIdentifier() const
{
return ChildCapability->GetIdentifier();
}
H323Codec * H323SecureExtendedCapability::CreateCodec(H323Codec::Direction direc
tion) const
{
return ChildCapability->CreateCodec(direction);
}
const H323Capabilities & H323SecureExtendedCapability::GetCapabilities() const
{
H323ExtendedVideoCapability* extCap = dynamic_cast<H323ExtendedVideoCapabili
ty*>(ChildCapability);
if (extCap)
return extCap->GetCapabilities();
else
return extCapabilities;
}
/////////////////////////////////////////////////////////////////////////////
H323SecureDataCapability::H323SecureDataCapability(H323Capability & childCapabil ity, enum H235ChType Ch, H323Capabilities * capabilities, H323SecureDataCapability::H323SecureDataCapability(H323Capability & childCapabil ity, enum H235ChType Ch, H323Capabilities * capabilities,
unsigned secNo, PBoolean active ) unsigned secNo, PBoolean active )
: ChildCapability((H323Capability *)childCapability.Clone()), chtype(Ch), m_acti ve(active), m_capabilities(capabilities), : ChildCapability((H323Capability *)childCapability.Clone()), chtype(Ch), m_acti ve(active), m_capabilities(capabilities),
m_secNo(secNo), m_algorithm(PString()) m_secNo(secNo), m_algorithm(PString())
{ {
assignedCapabilityNumber = childCapability.GetCapabilityNumber(); assignedCapabilityNumber = childCapability.GetCapabilityNumber();
} }
H323SecureDataCapability::~H323SecureDataCapability() H323SecureDataCapability::~H323SecureDataCapability()
skipping to change at line 950 skipping to change at line 1310
return newCapabilityNumber; return newCapabilityNumber;
} }
void H235Capabilities::AddSecure(PINDEX descriptorNum, PINDEX simultaneous, H323 Capability * capability) void H235Capabilities::AddSecure(PINDEX descriptorNum, PINDEX simultaneous, H323 Capability * capability)
{ {
if (capability == NULL) if (capability == NULL)
return; return;
if (!PIsDescendant(capability,H323SecureCapability) && if (!PIsDescendant(capability,H323SecureCapability) &&
!PIsDescendant(capability,H323SecureExtendedCapability) &&
!PIsDescendant(capability,H323SecureDataCapability) && !PIsDescendant(capability,H323SecureDataCapability) &&
!PIsDescendant(capability,H235SecurityCapability)) !PIsDescendant(capability,H235SecurityCapability))
return; return;
// See if already added, confuses things if you add the same instance twice // See if already added, confuses things if you add the same instance twice
if (table.GetObjectsIndex(capability) != P_MAX_INDEX) if (table.GetObjectsIndex(capability) != P_MAX_INDEX)
return; return;
// Create the secure capability wrapper // Create the secure capability wrapper
unsigned capNumber = SetCapabilityNumber(table, capability->GetCapabilityNum ber()); unsigned capNumber = SetCapabilityNumber(table, capability->GetCapabilityNum ber());
skipping to change at line 979 skipping to change at line 1340
capability->SetCapabilityList(this); capability->SetCapabilityList(this);
capability->SetAssociatedCapability(secNumber); capability->SetAssociatedCapability(secNumber);
PTRACE(3, "H323\tAdded Secure Capability: " << *capability); PTRACE(3, "H323\tAdded Secure Capability: " << *capability);
} }
H323Capability * H235Capabilities::CopySecure(PINDEX descriptorNum, PINDEX simul taneous, const H323Capability & capability) H323Capability * H235Capabilities::CopySecure(PINDEX descriptorNum, PINDEX simul taneous, const H323Capability & capability)
{ {
if (!PIsDescendant(&capability,H323SecureCapability) && if (!PIsDescendant(&capability,H323SecureCapability) &&
!PIsDescendant(&capability,H323SecureExtendedCapability) &&
!PIsDescendant(&capability,H323SecureDataCapability) && !PIsDescendant(&capability,H323SecureDataCapability) &&
!PIsDescendant(&capability,H235SecurityCapability)) !PIsDescendant(&capability,H235SecurityCapability))
return NULL; return NULL;
if (PIsDescendant(&capability,H235SecurityCapability)) { if (PIsDescendant(&capability,H235SecurityCapability)) {
H235SecurityCapability * newCapability = (H235SecurityCapability *)capabili ty.Clone(); H235SecurityCapability * newCapability = (H235SecurityCapability *)capabili ty.Clone();
newCapability->SetCapabilityNumber(capability.GetCapabilityNumber()); newCapability->SetCapabilityNumber(capability.GetCapabilityNumber());
table.Append(newCapability); table.Append(newCapability);
SetCapability(descriptorNum, simultaneous, newCapability); SetCapability(descriptorNum, simultaneous, newCapability);
return newCapability; return newCapability;
skipping to change at line 1001 skipping to change at line 1363
newCapability->SetCapabilityNumber(capability.GetCapabilityNumber()); newCapability->SetCapabilityNumber(capability.GetCapabilityNumber());
newCapability->SetCapabilityList(this); newCapability->SetCapabilityList(this);
SetCapability(descriptorNum, simultaneous, newCapability); SetCapability(descriptorNum, simultaneous, newCapability);
PTRACE(3, "H323\tCopied Secure Capability: " << *newCapability); PTRACE(3, "H323\tCopied Secure Capability: " << *newCapability);
return newCapability; return newCapability;
} }
} }
void H235Capabilities::WrapCapability(PINDEX descriptorNum, PINDEX simultaneous, H323Capability & capability) void H235Capabilities::WrapCapability(PINDEX descriptorNum, PINDEX simultaneous, H323Capability & capability)
{ {
if (PIsDescendant(&capability,H323SecureCapability) || if (PIsDescendant(&capability,H323SecureCapability) ||
PIsDescendant(&capability,H323SecureExtendedCapability) ||
PIsDescendant(&capability,H323SecureDataCapability) || PIsDescendant(&capability,H323SecureDataCapability) ||
PIsDescendant(&capability,H235SecurityCapability)) { PIsDescendant(&capability,H235SecurityCapability)) {
CopySecure(descriptorNum, simultaneous, capability); CopySecure(descriptorNum, simultaneous, capability);
return; return;
} }
if (!IsH235Codec(capability.GetFormatName())) { if (!IsH235Codec(capability.GetFormatName())) {
SetCapability(descriptorNum, simultaneous, (H323Capability *)capability. Clone()); SetCapability(descriptorNum, simultaneous, (H323Capability *)capability. Clone());
return; return;
} }
switch (capability.GetDefaultSessionID()) { switch (capability.GetDefaultSessionID()) {
case OpalMediaFormat::DefaultAudioSessionID: case OpalMediaFormat::DefaultAudioSessionID:
case OpalMediaFormat::DefaultVideoSessionID: case OpalMediaFormat::DefaultVideoSessionID:
AddSecure(descriptorNum, simultaneous, new H323SecureCapability(capa bility, H235ChNew,this)); AddSecure(descriptorNum, simultaneous, new H323SecureCapability(capa bility, H235ChNew,this));
break; break;
case OpalMediaFormat::DefaultExtVideoSessionID:
AddSecure(descriptorNum, simultaneous, new H323SecureExtendedCapabil
ity((H323Capability *)capability.Clone(), H235ChNew,this));
break;
case OpalMediaFormat::DefaultDataSessionID: case OpalMediaFormat::DefaultDataSessionID:
AddSecure(descriptorNum, simultaneous, new H323SecureDataCapability( capability, H235ChNew,this)); AddSecure(descriptorNum, simultaneous, new H323SecureDataCapability( capability, H235ChNew,this));
break; break;
case OpalMediaFormat::NonRTPSessionID: case OpalMediaFormat::NonRTPSessionID:
//case OpalMediaFormat::DefaultDataSessionID: //case OpalMediaFormat::DefaultDataSessionID:
case OpalMediaFormat::DefaultExtVideoSessionID: //case OpalMediaFormat::DefaultExtVideoSessionID:
case OpalMediaFormat::DefaultFileSessionID: case OpalMediaFormat::DefaultFileSessionID:
default: default:
SetCapability(descriptorNum, simultaneous, (H323Capability *)capabil ity.Clone()); SetCapability(descriptorNum, simultaneous, (H323Capability *)capabil ity.Clone());
break; break;
} }
} }
static PBoolean MatchWildcard(const PCaselessString & str, const PStringArray & wildcard) static PBoolean MatchWildcard(const PCaselessString & str, const PStringArray & wildcard)
{ {
PINDEX last = 0; PINDEX last = 0;
skipping to change at line 1075 skipping to change at line 1440
mediaFormat = OpalMediaFormat(capName.Left(capName.GetLength()-4)); mediaFormat = OpalMediaFormat(capName.Left(capName.GetLength()-4));
if (mediaFormat.IsValid() && mediaFormat.GetDefaultSessionID() == sessio n) { if (mediaFormat.IsValid() && mediaFormat.GetDefaultSessionID() == sessio n) {
// add the capability // add the capability
H323Capability * capability = H323Capability::Create(capName); H323Capability * capability = H323Capability::Create(capName);
H323Capability * newCapability = NULL; H323Capability * newCapability = NULL;
PINDEX num=0; PINDEX num=0;
switch (session) { switch (session) {
case OpalMediaFormat::DefaultAudioSessionID: case OpalMediaFormat::DefaultAudioSessionID:
case OpalMediaFormat::DefaultVideoSessionID: case OpalMediaFormat::DefaultVideoSessionID:
newCapability = new H323SecureCapability(*capability, H235Ch New, this); newCapability = new H323SecureCapability(*capability, H235Ch New, this);
// TODO: assigning to num twice doesn't make sense
num = SetCapability(descriptorNum, simultaneous, newCapabili ty); num = SetCapability(descriptorNum, simultaneous, newCapabili ty);
num = SetCapability(descriptorNum, simultaneous, num = SetCapability(descriptorNum, simultaneous,
new H235SecurityCapability(this, newCapa bility->GetCapabilityNumber())); new H235SecurityCapability(this, newCapa bility->GetCapabilityNumber()));
break; break;
case OpalMediaFormat::DefaultDataSessionID: case OpalMediaFormat::DefaultDataSessionID:
newCapability = new H323SecureDataCapability(*capability, H2 35ChNew, this); newCapability = new H323SecureDataCapability(*capability, H2 35ChNew, this);
// TODO: assigning to num twice doesn't make sense
num = SetCapability(descriptorNum, simultaneous, newCapabili ty); num = SetCapability(descriptorNum, simultaneous, newCapabili ty);
num = SetCapability(descriptorNum, simultaneous, num = SetCapability(descriptorNum, simultaneous,
new H235SecurityCapability(this, newCapa bility->GetCapabilityNumber())); new H235SecurityCapability(this, newCapa bility->GetCapabilityNumber()));
break; break;
case OpalMediaFormat::DefaultExtVideoSessionID: case OpalMediaFormat::DefaultExtVideoSessionID:
newCapability = new H323SecureExtendedCapability((H323Capabi
lity *)capability->Clone(), H235ChNew, this);
// TODO: assigning to num twice doesn't make sense
num = SetCapability(descriptorNum, simultaneous, newCapabili
ty);
num = SetCapability(descriptorNum, simultaneous,
new H235SecurityCapability(this, newCapa
bility->GetCapabilityNumber()));
break;
case OpalMediaFormat::DefaultFileSessionID: case OpalMediaFormat::DefaultFileSessionID:
default: default:
num = SetCapability(descriptorNum, simultaneous, capability) ; num = SetCapability(descriptorNum, simultaneous, capability) ;
break; break;
} }
if (descriptorNum == P_MAX_INDEX) { if (descriptorNum == P_MAX_INDEX) {
reply = num; reply = num;
descriptorNum = num; descriptorNum = num;
simultaneous = P_MAX_INDEX; simultaneous = P_MAX_INDEX;
 End of changes. 10 change blocks. 
2 lines changed or deleted 419 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)