"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/h323neg.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.

h323neg.cxx  (h323plus-1_27_0):h323neg.cxx  (h323plus-1_27_1)
skipping to change at line 65 skipping to change at line 65
void H245Negotiator::HandleTimeout(PTimer &, H323_INT) void H245Negotiator::HandleTimeout(PTimer &, H323_INT)
{ {
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
H245NegMasterSlaveDetermination::H245NegMasterSlaveDetermination(H323EndPoint & end, H245NegMasterSlaveDetermination::H245NegMasterSlaveDetermination(H323EndPoint & end,
H323Connection & conn) H323Connection & conn)
: H245Negotiator(end, conn), state(e_Idle), determinationNumber(PRandom::Numbe r()%16777216), : H245Negotiator(end, conn), state(e_Idle), determinationNumber(PRandom::Numbe r()%16777216),
retryCount(1), status(e_Indeterminate) retryCount(1), tryToBecomSlave(false), status(e_Indeterminate)
{ {
} }
PBoolean H245NegMasterSlaveDetermination::Start(PBoolean renegotiate) PBoolean H245NegMasterSlaveDetermination::Start(PBoolean renegotiate)
{ {
PWaitAndSignal wait(mutex); PWaitAndSignal wait(mutex);
if (state != e_Idle) { if (state != e_Idle) {
PTRACE(3, "H245\tMasterSlaveDetermination already in progress"); PTRACE(3, "H245\tMasterSlaveDetermination already in progress");
skipping to change at line 91 skipping to change at line 91
retryCount = 1; retryCount = 1;
return Restart(); return Restart();
} }
PBoolean H245NegMasterSlaveDetermination::Restart() PBoolean H245NegMasterSlaveDetermination::Restart()
{ {
PTRACE(3, "H245\tSending MasterSlaveDetermination"); PTRACE(3, "H245\tSending MasterSlaveDetermination");
// Begin the Master/Slave determination procedure // Begin the Master/Slave determination procedure
determinationNumber = PRandom::Number()%16777216; determinationNumber = PRandom::Number() % 16777216;
replyTimer = endpoint.GetMasterSlaveDeterminationTimeout(); replyTimer = endpoint.GetMasterSlaveDeterminationTimeout();
state = e_Outgoing; state = e_Outgoing;
if (tryToBecomSlave) {
PTRACE(3, "H245\tCheating MasterSlaveDetermination - waiting");
return true;
}
H323ControlPDU pdu; H323ControlPDU pdu;
pdu.BuildMasterSlaveDetermination(endpoint.GetTerminalType(), determinationNum ber); pdu.BuildMasterSlaveDetermination(endpoint.GetTerminalType(), determinationNum ber);
return connection.WriteControlPDU(pdu); return connection.WriteControlPDU(pdu);
} }
void H245NegMasterSlaveDetermination::Stop() void H245NegMasterSlaveDetermination::Stop()
{ {
PWaitAndSignal wait(mutex); PWaitAndSignal wait(mutex);
PTRACE(3, "H245\tStopping MasterSlaveDetermination: state=" << state); PTRACE(3, "H245\tStopping MasterSlaveDetermination: state=" << state);
skipping to change at line 136 skipping to change at line 141
replyTimer = endpoint.GetMasterSlaveDeterminationTimeout(); replyTimer = endpoint.GetMasterSlaveDeterminationTimeout();
// Determine the master and slave // Determine the master and slave
MasterSlaveStatus newStatus; MasterSlaveStatus newStatus;
if (pdu.m_terminalType < (unsigned)endpoint.GetTerminalType()) if (pdu.m_terminalType < (unsigned)endpoint.GetTerminalType())
newStatus = e_DeterminedMaster; newStatus = e_DeterminedMaster;
else if (pdu.m_terminalType > (unsigned)endpoint.GetTerminalType()) else if (pdu.m_terminalType > (unsigned)endpoint.GetTerminalType())
newStatus = e_DeterminedSlave; newStatus = e_DeterminedSlave;
else { else {
DWORD moduloDiff = (pdu.m_statusDeterminationNumber - determinationNumber)&0 xffffff; DWORD moduloDiff = (pdu.m_statusDeterminationNumber - determinationNumber) & 0xffffff;
if (moduloDiff == 0 || moduloDiff == 0x800000) if (moduloDiff == 0 || moduloDiff == 0x800000)
newStatus = e_Indeterminate; newStatus = e_Indeterminate;
else if (moduloDiff < 0x800000) else if (moduloDiff < 0x800000)
newStatus = e_DeterminedMaster; newStatus = e_DeterminedMaster;
else else
newStatus = e_DeterminedSlave; newStatus = e_DeterminedSlave;
} }
if (tryToBecomSlave) {
if (newStatus != e_DeterminedSlave) {
// find a fitting determinationNumber number
if (pdu.m_statusDeterminationNumber < 0x800000) {
determinationNumber = 0x800000;
} else {
determinationNumber = 0;
}
PTRACE(3, "H245\tCheating MasterSlaveDetermination - changing determinatio
n number to " << determinationNumber);
}
// send MasterSlaveDetermination message now
PTRACE(3, "H245\tCheating MasterSlaveDetermination - sending");
H323ControlPDU pdu;
pdu.BuildMasterSlaveDetermination(endpoint.GetTerminalType(), determinationN
umber);
connection.WriteControlPDU(pdu);
// voila - we are slave
newStatus = e_DeterminedSlave;
}
H323ControlPDU reply; H323ControlPDU reply;
if (newStatus != e_Indeterminate) { if (newStatus != e_Indeterminate) {
PTRACE(2, "H245\tMasterSlaveDetermination: local is " PTRACE(2, "H245\tMasterSlaveDetermination: local is "
<< (newStatus == e_DeterminedMaster ? "master" : "slave")); << (newStatus == e_DeterminedMaster ? "master" : "slave"));
reply.BuildMasterSlaveDeterminationAck(newStatus == e_DeterminedMaster); reply.BuildMasterSlaveDeterminationAck(newStatus == e_DeterminedMaster);
state = e_Incoming; state = e_Incoming;
status = newStatus; status = newStatus;
} }
else if (state == e_Outgoing) { else if (state == e_Outgoing) {
 End of changes. 5 change blocks. 
3 lines changed or deleted 30 lines changed or added

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