summaryrefslogtreecommitdiff
path: root/maximus/ethernet
diff options
context:
space:
mode:
Diffstat (limited to 'maximus/ethernet')
-rw-r--r--maximus/ethernet/inc/EtherSciMsg.h40
-rw-r--r--maximus/ethernet/inc/EtherSciMsgTest.h22
-rw-r--r--maximus/ethernet/src/EtherSciMsg.cpp75
-rw-r--r--maximus/ethernet/src/EtherSciMsgTest.cpp167
-rw-r--r--maximus/ethernet/src/EthernetProcessor.cpp3
-rw-r--r--maximus/ethernet/src/EthernetProcessorTest.cpp10
6 files changed, 276 insertions, 41 deletions
diff --git a/maximus/ethernet/inc/EtherSciMsg.h b/maximus/ethernet/inc/EtherSciMsg.h
index d05078b8e4..da47dced79 100644
--- a/maximus/ethernet/inc/EtherSciMsg.h
+++ b/maximus/ethernet/inc/EtherSciMsg.h
@@ -63,6 +63,8 @@ protected:
// Get from specialized SCI msg header
//
Ethernet_Type mSpecializedSciMsgType;
+ Ethernet_Sniffer_Type mSnifferType;
+ Ethernet_Flags mFlags;
// Specialized SCI msg header
//
@@ -137,12 +139,6 @@ public:
// private attribute accessor methods
//
- /**
- * Gets a pointer to the Ethernet processor.
- * @return mpEthernet
- */
- IEthernet * getEthernet ( ) const;
-
// protected attribute accessor methods
//
@@ -178,6 +174,32 @@ public:
*/
bool setSpecializedSciMsgType ( const Ethernet_Type type );
+ /**
+ * Gets the Ether SCI message SNIFFER type.
+ * @return mSnifferType
+ */
+ const Ethernet_Sniffer_Type getSnifferType ( ) const;
+
+ /**
+ * Sets the Ether SCI message SNIFFER type.
+ * @return bool
+ * @param sniffer_type the new value of mSnifferType
+ */
+ bool setSnifferType ( const Ethernet_Sniffer_Type sniffer_type );
+
+ /**
+ * Gets the Ether SCI message flags.
+ * @return mFlags
+ */
+ const Ethernet_Flags getFlags ( ) const;
+
+ /**
+ * Sets the Ether SCI message flags.
+ * @return bool
+ * @param flags the new value of mFlags
+ */
+ bool setFlags ( const Ethernet_Flags flags );
+
private:
// private methods
@@ -188,6 +210,12 @@ private:
*/
void initAttributes ( );
+ /**
+ * Gets a pointer to the Ethernet processor.
+ * @return mpEthernet
+ */
+ IEthernet * getEthernet ( ) const;
+
protected:
// protected methods
diff --git a/maximus/ethernet/inc/EtherSciMsgTest.h b/maximus/ethernet/inc/EtherSciMsgTest.h
index 779854f0d6..174142701c 100644
--- a/maximus/ethernet/inc/EtherSciMsgTest.h
+++ b/maximus/ethernet/inc/EtherSciMsgTest.h
@@ -14,7 +14,18 @@ class EtherSciMsgTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE (EtherSciMsgTest);
+ CPPUNIT_TEST (createTest);
CPPUNIT_TEST (dispatchMsgTest);
+ CPPUNIT_TEST (identifySpecializedSciMsgHeaderTest);
+ CPPUNIT_TEST (checkCompatibilityTest);
+ CPPUNIT_TEST (checkValidityTest);
+ CPPUNIT_TEST (displaySpecializedSciMsgHeaderTest);
+ CPPUNIT_TEST (displaySpecializedSciMsgTypeTest);
+ CPPUNIT_TEST (returnSpecializedSciMsgHeaderTest);
+ CPPUNIT_TEST (setSpecializedSciMsgHeaderTest);
+ CPPUNIT_TEST (setSpecializedSciMsgTypeTest);
+ CPPUNIT_TEST (setSnifferTypeTest);
+ CPPUNIT_TEST (setFlagsTest);
CPPUNIT_TEST_SUITE_END ();
public:
@@ -24,7 +35,18 @@ public:
protected:
+ void createTest (void);
void dispatchMsgTest (void);
+ void identifySpecializedSciMsgHeaderTest (void);
+ void checkCompatibilityTest (void);
+ void checkValidityTest (void);
+ void displaySpecializedSciMsgHeaderTest (void);
+ void displaySpecializedSciMsgTypeTest(void);
+ void returnSpecializedSciMsgHeaderTest (void);
+ void setSpecializedSciMsgHeaderTest (void);
+ void setSpecializedSciMsgTypeTest (void);
+ void setSnifferTypeTest (void);
+ void setFlagsTest (void);
private:
diff --git a/maximus/ethernet/src/EtherSciMsg.cpp b/maximus/ethernet/src/EtherSciMsg.cpp
index 9db18e9a6c..107116c52a 100644
--- a/maximus/ethernet/src/EtherSciMsg.cpp
+++ b/maximus/ethernet/src/EtherSciMsg.cpp
@@ -34,6 +34,8 @@ The original location of this file is /home/buret/eclipse/maximus/phy/src/EtherS
#include "Error.h"
#include "Logger.h"
+#include "interface/sniffer/defs.h" // for 'SNIFFER_BEACON' and 'SNIFFER_MME'
+
#include <iomanip> // for 'setfill()' and 'setw()'
using namespace std;
@@ -44,6 +46,8 @@ using namespace std;
EtherSciMsg::EtherSciMsg ( IEthernet * p_ethernet ):
mSpecializedSciMsgType(ETHERNET_TYPE_NONE),
+mSnifferType(0),
+mFlags(ETHERNET_FLAG_NONE),
mpEthernet(NULL)
{
logFunction();
@@ -64,8 +68,9 @@ void EtherSciMsg::initAttributes ( )
mSpecializedSciMsgHeader.version = ETHERNET_VERSION;
mSpecializedSciMsgHeader.type = ETHERNET_TYPE_NONE;
- mSpecializedSciMsgHeader.flags = 0x00;
- mSpecializedSciMsgHeader.reserved = 0x00;
+ mSpecializedSciMsgHeader.sniffer_type = 0x00;
+ mSpecializedSciMsgHeader.flags = ETHERNET_FLAG_NONE;
+ mSpecializedSciMsgHeader.reserved = 0x00000000;
}
@@ -136,6 +141,8 @@ bool EtherSciMsg::identifySpecializedSciMsgHeader ( )
// Set specialized SCI msg attributes from specialized SCI msg header
//
setSpecializedSciMsgType (static_cast<Ethernet_Type>(getSpecializedSciMsgHeader().type));
+ setSnifferType (static_cast<Ethernet_Sniffer_Type>(getSpecializedSciMsgHeader().sniffer_type));
+ setFlags (static_cast<Ethernet_Flags>(getSpecializedSciMsgHeader().flags));
displaySpecializedSciMsgHeader();
bIdentifyHeader = true;
}
@@ -175,7 +182,10 @@ bool EtherSciMsg::checkValidity ( ) const
// Check header values ranges
//
- if ((ETHERNET_TYPE_NB > getSpecializedSciMsgHeader().type) && (ETHERNET_TYPE_NONE < getSpecializedSciMsgHeader().type))
+ if ((ETHERNET_TYPE_NB > getSpecializedSciMsgHeader().type)
+ && (ETHERNET_TYPE_NONE < getSpecializedSciMsgHeader().type)
+ && (SNIFFER_MME >= getSpecializedSciMsgHeader().sniffer_type)
+ && (ETHERNET_FLAG_MAX >= getSpecializedSciMsgHeader().flags))
{
bCheck = SciMsg::checkValidity();
}
@@ -191,8 +201,9 @@ void EtherSciMsg::displaySpecializedSciMsgHeader ( ) const
clog << logger(LOG_INFO) << "Ether SCI message header = " << endl;
clog << logger(LOG_INFO) << "\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().version) << endl;
displaySpecializedSciMsgType(LOG_INFO);
- clog << logger(LOG_INFO) << "\tflags = 0x" << setfill('0') << setw(4) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().flags) << endl;
- clog << logger(LOG_INFO) << "\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().reserved) << endl;
+ clog << logger(LOG_INFO) << "\tsniffer type = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().sniffer_type) << endl;
+ clog << logger(LOG_INFO) << "\tflags = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(getSpecializedSciMsgHeader().flags) << endl;
+ clog << logger(LOG_INFO) << "\treserved = 0x" << setfill('0') << setw(8) << uppercase << hex << getSpecializedSciMsgHeader().reserved << endl;
}
@@ -247,6 +258,10 @@ void EtherSciMsg::displaySpecializedSciMsgType ( int log_level ) const
//
+// protected attribute accessor methods
+//
+
+
void * EtherSciMsg::returnSpecializedSciMsgHeader ( ) const
{
return (void*)&mSpecializedSciMsgHeader;
@@ -300,6 +315,52 @@ bool EtherSciMsg::setSpecializedSciMsgType ( const Ethernet_Type type )
}
-// protected attribute accessor methods
-//
+const Ethernet_Sniffer_Type EtherSciMsg::getSnifferType ( ) const
+{
+ if (SNIFFER_MME < mSnifferType)
+ {
+ errno = EINVAL;
+ throw Error(__PRETTY_FUNCTION__, "Ether SCI message header sniffer type is out-of-range", errno);
+ }
+
+ return mSnifferType;
+}
+
+
+bool EtherSciMsg::setSnifferType ( const Ethernet_Sniffer_Type sniffer_type )
+{
+ if (SNIFFER_MME < sniffer_type)
+ {
+ errno = EINVAL;
+ throw Error(__PRETTY_FUNCTION__, "Sniffer type is out-of-range", errno);
+ }
+ mSnifferType = sniffer_type;
+
+ return true;
+}
+
+
+const Ethernet_Flags EtherSciMsg::getFlags ( ) const
+{
+ if (ETHERNET_FLAG_MAX < mFlags)
+ {
+ errno = EINVAL;
+ throw Error(__PRETTY_FUNCTION__, "Ether SCI message header flags are out-of-range", errno);
+ }
+
+ return mFlags;
+}
+
+
+bool EtherSciMsg::setFlags ( const Ethernet_Flags flags )
+{
+ if (ETHERNET_FLAG_MAX < flags)
+ {
+ errno = EINVAL;
+ throw Error(__PRETTY_FUNCTION__, "Ether SCI message header flags are out-of-range", errno);
+ }
+ mFlags = flags;
+
+ return true;
+}
diff --git a/maximus/ethernet/src/EtherSciMsgTest.cpp b/maximus/ethernet/src/EtherSciMsgTest.cpp
index dfb0e5267a..f1fc281178 100644
--- a/maximus/ethernet/src/EtherSciMsgTest.cpp
+++ b/maximus/ethernet/src/EtherSciMsgTest.cpp
@@ -20,6 +20,21 @@ void EtherSciMsgTest::setUp (void)
mpSci = new SciServer();
mpEthernet = new EthernetProcessor (mpSci);
mpEtherSciMsg = new EtherSciMsg (mpEthernet);
+ CPPUNIT_ASSERT_MESSAGE("EtherSciMsg pointer is NULL", NULL != mpEtherSciMsg);
+
+ unsigned long frameLength = 1500;
+ unsigned char frame[frameLength];
+ memset(frame, 'F', frameLength);
+ mpEtherSciMsg->setSpecializedSciMsgDataLength(frameLength);
+ mpEtherSciMsg->setSpecializedSciMsgData(frame);
+
+ Ethernet_Header header;
+ header.version = ETHERNET_VERSION;
+ header.type = ETHERNET_TYPE_SNIFFER;
+ header.sniffer_type = 0;
+ header.flags = ETHERNET_FLAG_ENCRYPTED;
+ header.reserved = 0x12345678;
+ mpEtherSciMsg->setSpecializedSciMsgHeader(header);
}
@@ -45,30 +60,140 @@ void EtherSciMsgTest::tearDown (void)
}
+void EtherSciMsgTest::createTest (void)
+{
+ logTest();
+
+ SciMsg * pSciMsg = NULL;
+ pSciMsg = mpEtherSciMsg->create();
+ CPPUNIT_ASSERT_MESSAGE("createTest failed", NULL != pSciMsg);
+
+ delete(pSciMsg);
+ pSciMsg = NULL;
+}
+
+
void EtherSciMsgTest::dispatchMsgTest (void)
{
logTest();
- if (NULL != mpEtherSciMsg)
- {
- unsigned long frameLength = 1500;
- unsigned char frame[frameLength];
- memset(frame, 'F', frameLength);
- mpEtherSciMsg->setSpecializedSciMsgDataLength(frameLength);
- mpEtherSciMsg->setSpecializedSciMsgData(frame);
-
- ISystem * pSystem = new SystemManager(mpSci);
- pSystem->createStation(pSystem->getDefaultStationExecutable());
- CPPUNIT_ASSERT_MESSAGE("dispatchMsg failed", mpEtherSciMsg->dispatchMsg());
- if (NULL != pSystem)
- {
- delete (pSystem);
- pSystem = NULL;
- }
- }
- else
- {
- CPPUNIT_FAIL ("EtherSciMsg pointer is NULL");
- }
+ ISystem * pSystem = new SystemManager(mpSci);
+ CPPUNIT_ASSERT_MESSAGE("ISystem pointer is NULL", NULL != pSystem);
+ pSystem->createStation(pSystem->getDefaultStationExecutable());
+ CPPUNIT_ASSERT_MESSAGE("dispatchMsg failed", mpEtherSciMsg->dispatchMsg());
+
+ delete (pSystem);
+ pSystem = NULL;
+}
+
+
+void EtherSciMsgTest::identifySpecializedSciMsgHeaderTest (void)
+{
+ logTest();
+
+ unsigned long frameLength = 1500;
+ unsigned char frame[frameLength];
+ memset(frame, 0x01, frameLength);
+ mpEtherSciMsg->setSciMsgDataLength(frameLength);
+ mpEtherSciMsg->setSciMsgData(frame);
+ CPPUNIT_ASSERT_MESSAGE("identifySpecializedSciMsgHeader failed",
+ mpEtherSciMsg->identifySpecializedSciMsgHeader());
+}
+
+
+void EtherSciMsgTest::checkCompatibilityTest (void)
+{
+ logTest();
+
+ Sci_Msg_Header header;
+ header.version = SCI_MSG_VERSION;
+ mpEtherSciMsg->setSciMsgHeader(header);
+ CPPUNIT_ASSERT_MESSAGE("checkCompatibility failed",
+ mpEtherSciMsg->checkCompatibility());
+}
+
+
+void EtherSciMsgTest::checkValidityTest (void)
+{
+ logTest();
+
+ Sci_Msg_Header header;
+ header.magic_id = mpEtherSciMsg->getDefinedSciMsgMagicId();
+ header.msg_id = 0x8000;
+ mpEtherSciMsg->setSciMsgHeader(header);
+ CPPUNIT_ASSERT_MESSAGE("checkValidity failed",
+ mpEtherSciMsg->checkValidity());
+}
+
+
+void EtherSciMsgTest::displaySpecializedSciMsgHeaderTest (void)
+{
+ logTest();
+
+ mpEtherSciMsg->displaySpecializedSciMsgHeader();
+}
+
+
+void EtherSciMsgTest::displaySpecializedSciMsgTypeTest (void)
+{
+ logTest();
+
+ mpEtherSciMsg->displaySpecializedSciMsgType(LOG_INFO);
+}
+
+
+void EtherSciMsgTest::returnSpecializedSciMsgHeaderTest (void)
+{
+ logTest();
+
+ void * vpHeader = NULL;
+ vpHeader = mpEtherSciMsg->returnSpecializedSciMsgHeader();
+ CPPUNIT_ASSERT_MESSAGE("void pointer is NULL", NULL != vpHeader);
+ Ethernet_Header * pHeader = (Ethernet_Header *)vpHeader;
+ CPPUNIT_ASSERT_MESSAGE("returnSpecializedSciMsgHeader failed",
+ (mpEtherSciMsg->getSpecializedSciMsgHeader().version == pHeader->version)
+ && (mpEtherSciMsg->getSpecializedSciMsgHeader().type == pHeader->type)
+ && (mpEtherSciMsg->getSpecializedSciMsgHeader().sniffer_type == pHeader->sniffer_type)
+ && (mpEtherSciMsg->getSpecializedSciMsgHeader().flags == pHeader->flags)
+ && (mpEtherSciMsg->getSpecializedSciMsgHeader().reserved == pHeader->reserved));
+}
+
+
+void EtherSciMsgTest::setSpecializedSciMsgHeaderTest (void)
+{
+ logTest();
+
+ CPPUNIT_ASSERT_MESSAGE("setSpecializedSciMsgHeader failed",
+ ETHERNET_TYPE_SNIFFER == mpEtherSciMsg->getSpecializedSciMsgHeader().type);
+}
+
+
+void EtherSciMsgTest::setSpecializedSciMsgTypeTest (void)
+{
+ logTest();
+
+ CPPUNIT_ASSERT_MESSAGE("setSpecializedSciMsgType failed",
+ mpEtherSciMsg->setSpecializedSciMsgType(ETHERNET_TYPE_DATA)
+ && (ETHERNET_TYPE_DATA == mpEtherSciMsg->getSpecializedSciMsgType()));
+}
+
+
+void EtherSciMsgTest::setSnifferTypeTest (void)
+{
+ logTest();
+
+ CPPUNIT_ASSERT_MESSAGE("setSnifferType failed",
+ mpEtherSciMsg->setSnifferType(1)
+ && (1 == mpEtherSciMsg->getSnifferType()));
+}
+
+
+void EtherSciMsgTest::setFlagsTest (void)
+{
+ logTest();
+
+ CPPUNIT_ASSERT_MESSAGE("setFlags failed",
+ mpEtherSciMsg->setFlags(ETHERNET_FLAG_MAX)
+ && (ETHERNET_FLAG_MAX == mpEtherSciMsg->getFlags()));
}
diff --git a/maximus/ethernet/src/EthernetProcessor.cpp b/maximus/ethernet/src/EthernetProcessor.cpp
index 90c1290f33..081a2bd9c0 100644
--- a/maximus/ethernet/src/EthernetProcessor.cpp
+++ b/maximus/ethernet/src/EthernetProcessor.cpp
@@ -183,7 +183,8 @@ bool EthernetProcessor::fillEther ( EtherSciMsg & ether_sci_msg ) const
struct Ethernet_Header ethernetHeader;
ethernetHeader.version = ether_sci_msg.getSpecializedSciMsgHeader().version;
ethernetHeader.type = ether_sci_msg.getSpecializedSciMsgType();
- ethernetHeader.flags = ether_sci_msg.getSpecializedSciMsgHeader().flags;
+ ethernetHeader.sniffer_type = ether_sci_msg.getSnifferType();
+ ethernetHeader.flags = ether_sci_msg.getFlags();
ethernetHeader.reserved = ether_sci_msg.getSpecializedSciMsgHeader().reserved;
// Set specialized SCI msg header
diff --git a/maximus/ethernet/src/EthernetProcessorTest.cpp b/maximus/ethernet/src/EthernetProcessorTest.cpp
index d54ac826c4..c6e986fddd 100644
--- a/maximus/ethernet/src/EthernetProcessorTest.cpp
+++ b/maximus/ethernet/src/EthernetProcessorTest.cpp
@@ -62,13 +62,10 @@ void EthernetProcessorTest::createEtherTest (void)
logTest();
EtherSciMsg * pEtherSciMsg = mpEthernetProcessor->createEther();
+ CPPUNIT_ASSERT_MESSAGE ( "createEther failed", NULL != pEtherSciMsg );
- CPPUNIT_ASSERT_MESSAGE ( "Ether SCI message not correctly created",
- (NULL != pEtherSciMsg)
- && (mpEthernetProcessor == pEtherSciMsg->getEthernet()) );
-
- delete (pEtherSciMsg);
- pEtherSciMsg = NULL;
+ delete (pEtherSciMsg);
+ pEtherSciMsg = NULL;
}
@@ -77,6 +74,7 @@ void EthernetProcessorTest::sendEtherTest (void)
logTest();
EtherSciMsg * pEtherSciMsg = mpEthernetProcessor->createEther();
+ CPPUNIT_ASSERT_MESSAGE ( "Ether SCI message pointer is NULL", NULL != pEtherSciMsg );
// create the destination station
Sci_Msg_Station_Id stationId = mpCoreEngine->getSystem()->createStation(mpCoreEngine->getSystem()->getDefaultStationExecutable());