Commit e71fc0bf authored by jselbie's avatar jselbie

client code change - Filtering test comes befor Behavior test and separate modes on command line

parent 4c9272ed
...@@ -235,9 +235,17 @@ HRESULT CreateConfigFromCommandLine(ClientCmdLineArgs& args, StunClientLogicConf ...@@ -235,9 +235,17 @@ HRESULT CreateConfigFromCommandLine(ClientCmdLineArgs& args, StunClientLogicConf
config.fBehaviorTest = true; config.fBehaviorTest = true;
config.fFilteringTest = (fTCP == false); // impossible to to a filtering test in TCP config.fFilteringTest = (fTCP == false); // impossible to to a filtering test in TCP
} }
else if (args.strMode == "behavior")
{
config.fBehaviorTest = true;
}
else if (args.strMode == "filtering")
{
config.fFilteringTest = true;
}
else else
{ {
Logging::LogMsg(LL_ALWAYS, "Mode option must be 'full' or 'basic'"); Logging::LogMsg(LL_ALWAYS, "Mode option must be 'full', 'basic', 'behavior', or 'filtering'");
} }
} }
......
...@@ -6,7 +6,7 @@ include ../common.inc ...@@ -6,7 +6,7 @@ include ../common.inc
sh makecodefile.sh $^ $@ $(*)_text sh makecodefile.sh $^ $@ $(*)_text
%.txt: %.md %.txt: %.md
pandoc --no-wrap -s -w plain -o $@ $^ cat $^ | sed s/\*\*//g | pandoc --no-wrap -s -w plain -o $@
%.1: %.md %.1: %.md
pandoc -s -w man -o $@ $^ pandoc -s -w man -o $@ $^
......
.\" Automatically generated by Pandoc 1.16.0.2
.\"
.TH "STUNCLIENT" "1" "" "January 22, 2012" "User Manual" .TH "STUNCLIENT" "1" "" "January 22, 2012" "User Manual"
.hy
.SH NAME .SH NAME
.PP .PP
stunclient \- command line app for the STUN protocol stunclient \- command line app for the STUN protocol
...@@ -47,12 +50,23 @@ The default is 3478 for UDP and TCP. ...@@ -47,12 +50,23 @@ The default is 3478 for UDP and TCP.
.PP .PP
\f[B]\-\-mode\f[] MODE \f[B]\-\-mode\f[] MODE
.PP .PP
Where MODE is either "basic" or "full". Where MODE is either "basic", "behavior", or "filtering".
.PP
"basic" mode is the default and indicates that the client should perform "basic" mode is the default and indicates that the client should perform
a STUN binding test only. a STUN binding test only.
"full" mode indicates that the client should attempt to diagnose NAT .PP
behavior and filtering methodologies if the server supports this mode. "behavior" mode indicates that the client should attempt to diagnose NAT
behavior and port mapping methodologies if the server supports this
mode.
.PP
"filtering" mode indicates that the client should attempt to diagnose
NAT filtering methodologies if the server supports this mode.
The NAT filtering test is only supported for UDP. The NAT filtering test is only supported for UDP.
.PP
"full" mode is a deprecated mode.
It performs both a filtering and a behavior test together.
Users are encouraged to run these tests separately and to avoid using
the same local port.
.PP .PP
* * * * * * * * * *
.PP .PP
...@@ -111,9 +125,15 @@ Performs a simple binding test request with the server listening at ...@@ -111,9 +125,15 @@ Performs a simple binding test request with the server listening at
.RS .RS
.RE .RE
.TP .TP
.B stunclient \-\-mode full \-\-localport 9999 12.34.56.78 .B stunclient \-\-mode filtering \-\-localport 9999 12.34.56.78
Performs a full set of UDP NAT behavior tests from local port 9999 to Performs the NAT filtering tests from local port 9999 to the server
the server listening at IP Address 12.34.56.78 (port 3478) listening at IP Address 12.34.56.78 (port 3478)
.RS
.RE
.TP
.B stunclient \-\-mode behavior 12.34.56.78
Performs the NAT behavior and port mapping tests from a random local
port to the server listening at IP Address 12.34.56.78 (port 3478)
.RS .RS
.RE .RE
.TP .TP
......
...@@ -43,10 +43,19 @@ _____ ...@@ -43,10 +43,19 @@ _____
**--mode** MODE **--mode** MODE
Where MODE is either "basic" or "full". "basic" mode is the default and indicates that the Where MODE is either "basic", "behavior", or "filtering".
client should perform a STUN binding test only. "full" mode indicates that the client should
attempt to diagnose NAT behavior and filtering methodologies if the server supports this mode. "basic" mode is the default and indicates that the
The NAT filtering test is only supported for UDP. client should perform a STUN binding test only.
"behavior" mode indicates that the client should
attempt to diagnose NAT behavior and port mapping methodologies if the server supports this mode.
"filtering" mode indicates that the client should
attempt to diagnose NAT filtering methodologies if the server supports this mode. The NAT filtering test is only supported for UDP.
"full" mode is a deprecated mode. It performs both a filtering and a behavior test together. Users
are encouraged to run these tests separately and to avoid using the same local port.
____ ____
...@@ -96,8 +105,12 @@ Prints this help page ...@@ -96,8 +105,12 @@ Prints this help page
stunclient stunserver.org 3478 stunclient stunserver.org 3478
: Performs a simple binding test request with the server listening at "stunserver.org" : Performs a simple binding test request with the server listening at "stunserver.org"
stunclient --mode full --localport 9999 12.34.56.78 stunclient --mode filtering --localport 9999 12.34.56.78
: Performs a full set of UDP NAT behavior tests from local port 9999 to the server listening at IP : Performs the NAT filtering tests from local port 9999 to the server listening at IP
Address 12.34.56.78 (port 3478)
stunclient --mode behavior 12.34.56.78
: Performs the NAT behavior and port mapping tests from a random local port to the server listening at IP
Address 12.34.56.78 (port 3478) Address 12.34.56.78 (port 3478)
stunclient --protocol tcp stun.selbie.com stunclient --protocol tcp stun.selbie.com
......
This diff is collapsed.
.\" Automatically generated by Pandoc 1.16.0.2
.\"
.TH "STUNSERVER" "1" "" "January 22, 2012" "User Manual" .TH "STUNSERVER" "1" "" "January 22, 2012" "User Manual"
.hy
.SH NAME .SH NAME
.PP .PP
stunserver \- STUN protocol service (RFCs: 3489, 5389, 5789, 5780) stunserver \- STUN protocol service (RFCs: 3489, 5389, 5789, 5780)
...@@ -212,8 +215,7 @@ With no options, starts a basic STUN binding service on UDP port 3478. ...@@ -212,8 +215,7 @@ With no options, starts a basic STUN binding service on UDP port 3478.
.RS .RS
.RE .RE
.TP .TP
.B stunserver \-\-mode full \-\-primaryinterface 128.34.56.78 .B stunserver \-\-mode full \-\-primaryinterface 128.34.56.78 \-\-altinterface 128.34.56.79
\-\-altinterface 128.34.56.79
Above example starts a dual\-host STUN service on the the interfaces Above example starts a dual\-host STUN service on the the interfaces
identified by the IP address "128.34.56.78" and "128.34.56.79". identified by the IP address "128.34.56.78" and "128.34.56.79".
There are four UDP socket listeners There are four UDP socket listeners
...@@ -227,8 +229,7 @@ IP, Alternate Port) 128.34.56.79:3478 (Primary IP, Primary Port) ...@@ -227,8 +229,7 @@ IP, Alternate Port) 128.34.56.79:3478 (Primary IP, Primary Port)
An error occurs if the addresses specified do not exist on the local An error occurs if the addresses specified do not exist on the local
host running the service. host running the service.
.TP .TP
.B stunserver \-\-mode full \-\-primaryinterface eth0 \-\-altinterface .B stunserver \-\-mode full \-\-primaryinterface eth0 \-\-altinterface eth1
eth1
Same as above, except the interfaces are specified by their names as Same as above, except the interfaces are specified by their names as
enumerated by the system. enumerated by the system.
The "ifconfig" or "ipconfig" command will enumerate available interface The "ifconfig" or "ipconfig" command will enumerate available interface
......
This diff is collapsed.
...@@ -108,16 +108,6 @@ HRESULT CStunClientLogic::Initialize(StunClientLogicConfig& config) ...@@ -108,16 +108,6 @@ HRESULT CStunClientLogic::Initialize(StunClientLogicConfig& config)
_testlist.push_back(&_test1); _testlist.push_back(&_test1);
if (_config.fBehaviorTest)
{
_testBehavior2.Init(&_config, &_results);
_testlist.push_back(&_testBehavior2);
_testBehavior3.Init(&_config, &_results);
_testBehavior3.RunAsTest3(true);
_testlist.push_back(&_testBehavior3);
}
if (_config.fFilteringTest) if (_config.fFilteringTest)
{ {
_testFiltering2.Init(&_config, &_results); _testFiltering2.Init(&_config, &_results);
...@@ -127,6 +117,16 @@ HRESULT CStunClientLogic::Initialize(StunClientLogicConfig& config) ...@@ -127,6 +117,16 @@ HRESULT CStunClientLogic::Initialize(StunClientLogicConfig& config)
_testFiltering3.RunAsTest3(true); _testFiltering3.RunAsTest3(true);
_testlist.push_back(&_testFiltering3); _testlist.push_back(&_testFiltering3);
} }
if (_config.fBehaviorTest)
{
_testBehavior2.Init(&_config, &_results);
_testlist.push_back(&_testBehavior2);
_testBehavior3.Init(&_config, &_results);
_testBehavior3.RunAsTest3(true);
_testlist.push_back(&_testBehavior3);
}
_fPreCheckRunOnTest = false; _fPreCheckRunOnTest = false;
......
...@@ -74,13 +74,23 @@ HRESULT CStunClientTestBase::BasicReaderValidation(CRefCountedBuffer& spMsg, CSt ...@@ -74,13 +74,23 @@ HRESULT CStunClientTestBase::BasicReaderValidation(CRefCountedBuffer& spMsg, CSt
int cmp = 0; int cmp = 0;
readerstate = reader.AddBytes(spMsg->GetData(), spMsg->GetSize()); readerstate = reader.AddBytes(spMsg->GetData(), spMsg->GetSize());
ChkIf(readerstate != CStunMessageReader::BodyValidated, E_FAIL);
hr = (readerstate == CStunMessageReader::BodyValidated) ? S_OK : E_FAIL;
reader.GetTransactionId(&transid); if (FAILED(hr))
{
cmp = memcmp(transid.id, _transid.id, sizeof(_transid)); Logging::LogMsg(LL_DEBUG, "BasicReaderValidation - body parsing failed");
}
else
{
reader.GetTransactionId(&transid);
cmp = memcmp(transid.id, _transid.id, sizeof(_transid));
hr = (cmp == 0) ? S_OK : E_FAIL;
if (FAILED(hr))
{
Logging::LogMsg(LL_DEBUG, "BasicReaderValidation - transaction id comparison failed");
}
}
ChkIf(cmp!=0, E_FAIL);
Cleanup: Cleanup:
return hr; return hr;
...@@ -144,7 +154,6 @@ HRESULT CBasicBindingTest::ProcessResponse(CRefCountedBuffer& spMsg, CSocketAddr ...@@ -144,7 +154,6 @@ HRESULT CBasicBindingTest::ProcessResponse(CRefCountedBuffer& spMsg, CSocketAddr
CSocketAddress addrOther; CSocketAddress addrOther;
bool fHasOtherAddress = false; bool fHasOtherAddress = false;
// todo - figure out a way to make buffering TCP fragments work
Chk(BasicReaderValidation(spMsg, reader)); Chk(BasicReaderValidation(spMsg, reader));
hr = reader.GetXorMappedAddress(&addrMapped); hr = reader.GetXorMappedAddress(&addrMapped);
...@@ -252,10 +261,12 @@ HRESULT CBehaviorTest::GetMessage(CRefCountedBuffer& spMsg, CSocketAddress* pAdd ...@@ -252,10 +261,12 @@ HRESULT CBehaviorTest::GetMessage(CRefCountedBuffer& spMsg, CSocketAddress* pAdd
if (_fIsTest3 == false) if (_fIsTest3 == false)
{ {
Logging::LogMsg(LL_DEBUG, "Preparing message for behavior test #2 (destination=AP)");
*pAddrDest = _pResults->addrAP; *pAddrDest = _pResults->addrAP;
} }
else else
{ {
Logging::LogMsg(LL_DEBUG, "Preparing message for behavior test #2 (destination=AA)");
*pAddrDest = _pResults->addrAA; *pAddrDest = _pResults->addrAA;
} }
...@@ -369,12 +380,14 @@ HRESULT CFilteringTest::GetMessage(CRefCountedBuffer& spMsg, CSocketAddress* pAd ...@@ -369,12 +380,14 @@ HRESULT CFilteringTest::GetMessage(CRefCountedBuffer& spMsg, CSocketAddress* pAd
if (_fIsTest3 == false) if (_fIsTest3 == false)
{ {
Logging::LogMsg(LL_DEBUG, "Preparing message for filtering test #2 (ChangeRequest=AA)");
change.fChangeIP = true; change.fChangeIP = true;
change.fChangePort = true; change.fChangePort = true;
builder.AddChangeRequest(change); builder.AddChangeRequest(change);
} }
else else
{ {
Logging::LogMsg(LL_DEBUG, "Preparing message for filtering test #3 (ChangeRequest=PA)");
change.fChangeIP = false; change.fChangeIP = false;
change.fChangePort = true; change.fChangePort = true;
builder.AddChangeRequest(change); builder.AddChangeRequest(change);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment