├── PLCTool ├── Icons │ ├── bomb.png │ ├── close.png │ ├── frames.png │ ├── pause.png │ ├── start.png │ ├── PLCTool.png │ ├── file-xml.png │ ├── history.png │ ├── messages.png │ ├── register.png │ ├── associate.png │ ├── configure.png │ ├── connect_no.png │ ├── fileimport.png │ ├── passwords.png │ └── Tarlogic │ │ ├── Tarlogic-0.png │ │ ├── Tarlogic-1.png │ │ ├── Tarlogic-2.png │ │ ├── Tarlogic-3.png │ │ ├── Tarlogic-4.png │ │ ├── Tarlogic-5.png │ │ ├── Tarlogic-6.png │ │ └── Tarlogic-7.png ├── Topology │ ├── octave-workspace │ ├── Switch.cpp │ ├── Switch.h │ ├── AdapterEventListener.cpp │ ├── Meter.h │ ├── Meter.cpp │ ├── Hub.h │ ├── Hub.cpp │ ├── Concentrator.h │ └── AdapterEventListener.h ├── gurux │ ├── include │ │ ├── OBiscodes.h │ │ ├── GXDLMSScheduleEntry.h │ │ ├── GXDLMSAssociationLogicalName.h │ │ ├── GXDLMSPrimeNbOfdmPlcMacFunctionalParameters.h │ │ ├── GXAttributeCollection.h │ │ ├── GXDLMSObjectFactory.h │ │ ├── GXDLMSSpecialDay.h │ │ ├── GXDLMSEmergencyProfile.h │ │ ├── GXDLMSValueEventCollection.h │ │ ├── GXDLMSIp4SetupIpOption.h │ │ ├── GXDLMSActionSet.h │ │ ├── GXDLMSSha1.h │ │ ├── GXDLMSModemInitialisation.h │ │ ├── GXXmlWriterSettings.h │ │ ├── GXDLMSConnectionEventArgs.h │ │ ├── GXDLMSSha256.h │ │ ├── GXDLMSActionItem.h │ │ ├── GXDLMSPushObject.h │ │ ├── GXDLMSMonitoredValue.h │ │ ├── GXDLMSCaptureObject.h │ │ ├── GXDLMSQualityOfService.h │ │ ├── GXDLMSObjectDefinition.h │ │ ├── GXAdjacentCell.h │ │ ├── IGXDLMSBase.h │ │ ├── GXDLMSScript.h │ │ ├── GXDLMSMd5.h │ │ ├── GXDLMSDayProfile.h │ │ ├── GXBitString.h │ │ ├── GXDLMSPppSetupIPCPOption.h │ │ ├── GXMacMulticastEntry.h │ │ ├── GXStandardObisCode.h │ │ ├── GXSNInfo.h │ │ ├── GXCommodity.h │ │ └── GXDLMSSeasonProfile.h │ └── src │ │ ├── GXStandardObisCodeCollection.cpp │ │ ├── GXAdjacentCell.cpp │ │ ├── GXDLMSActionSet.cpp │ │ ├── GXDLMSScript.cpp │ │ ├── GXSNInfo.cpp │ │ ├── GXXmlWriterSettings.cpp │ │ ├── GXChargeTable.cpp │ │ ├── GXDLMSActionItem.cpp │ │ ├── GXDLMSIp4SetupIpOption.cpp │ │ ├── GXUnitCharge.cpp │ │ ├── GXDLMSPppSetupIPCPOption.cpp │ │ ├── GXDLMSPppSetupLcpOption.cpp │ │ ├── GXTokenGatewayConfiguration.cpp │ │ ├── GXDLMSSpecialDay.cpp │ │ ├── GXDLMSCaptureObject.cpp │ │ ├── GXDLMSEmergencyProfile.cpp │ │ ├── GXDLMSModemInitialisation.cpp │ │ ├── GXDLMSLimits.cpp │ │ ├── GXCommodity.cpp │ │ ├── GXDLMSPushObject.cpp │ │ └── GXDLMSObjectDefinition.cpp ├── PLCTool.desktop ├── icons.qrc ├── main.cpp ├── Types │ ├── dlms │ │ ├── AuthenticationValue.cpp │ │ ├── Data.h │ │ ├── AuthenticationValue.h │ │ ├── ActionRequest.cpp │ │ ├── AcseApdu.h │ │ ├── XDlmsApdu.h │ │ ├── DlmsMessageType.h │ │ ├── DataInteger.h │ │ ├── MechanismName.h │ │ ├── ReleaseRequestReason.cpp │ │ ├── ReleaseRequestReason.h │ │ └── ActionRequest.h │ ├── ber │ │ ├── BerBitString.cpp │ │ ├── BerOctetString.cpp │ │ ├── BerGraphicString.cpp │ │ ├── BerContents.h │ │ ├── BerInteger.cpp │ │ └── BerBoolean.cpp │ └── general │ │ ├── Bytevector.cpp │ │ ├── Serializable.h │ │ └── Bytevector.h ├── Attacks │ ├── AttackController.cpp │ ├── AttackFactory.cpp │ ├── UIAttackController.cpp │ ├── Attack.cpp │ ├── AttackPluginLoader.h │ └── AttackFactory.h ├── App │ ├── DLMSTranslator.h │ └── GXDLMSTranslatorInterface.h ├── PRIME │ ├── libprime │ │ └── prime.h │ └── spip │ │ └── loop.c └── Ui │ ├── LoadingStatusDialog.h │ ├── ModemDialog.h │ ├── TranslatorUI.h │ ├── XMLHighlighter.h │ └── LoadingStatusDialog.cpp ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .clang-format └── README.md /PLCTool/Icons/bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/bomb.png -------------------------------------------------------------------------------- /PLCTool/Icons/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/close.png -------------------------------------------------------------------------------- /PLCTool/Icons/frames.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/frames.png -------------------------------------------------------------------------------- /PLCTool/Icons/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/pause.png -------------------------------------------------------------------------------- /PLCTool/Icons/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/start.png -------------------------------------------------------------------------------- /PLCTool/Icons/PLCTool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/PLCTool.png -------------------------------------------------------------------------------- /PLCTool/Icons/file-xml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/file-xml.png -------------------------------------------------------------------------------- /PLCTool/Icons/history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/history.png -------------------------------------------------------------------------------- /PLCTool/Icons/messages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/messages.png -------------------------------------------------------------------------------- /PLCTool/Icons/register.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/register.png -------------------------------------------------------------------------------- /PLCTool/Icons/associate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/associate.png -------------------------------------------------------------------------------- /PLCTool/Icons/configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/configure.png -------------------------------------------------------------------------------- /PLCTool/Icons/connect_no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/connect_no.png -------------------------------------------------------------------------------- /PLCTool/Icons/fileimport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/fileimport.png -------------------------------------------------------------------------------- /PLCTool/Icons/passwords.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/passwords.png -------------------------------------------------------------------------------- /PLCTool/Topology/octave-workspace: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Topology/octave-workspace -------------------------------------------------------------------------------- /PLCTool/gurux/include/OBiscodes.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/gurux/include/OBiscodes.h -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-0.png -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-1.png -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-2.png -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-3.png -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-4.png -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-5.png -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-6.png -------------------------------------------------------------------------------- /PLCTool/Icons/Tarlogic/Tarlogic-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/Icons/Tarlogic/Tarlogic-7.png -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSScheduleEntry.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/gurux/include/GXDLMSScheduleEntry.h -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXStandardObisCodeCollection.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/gurux/src/GXStandardObisCodeCollection.cpp -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSAssociationLogicalName.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/gurux/include/GXDLMSAssociationLogicalName.h -------------------------------------------------------------------------------- /PLCTool/PLCTool.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=PLCTool 4 | Comment=PLC Protocol Swiss Knife 5 | Exec=PLCTool 6 | Icon=PLCTool 7 | Categories=Utility 8 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSPrimeNbOfdmPlcMacFunctionalParameters.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TarlogicSecurity/PLCTool/HEAD/PLCTool/gurux/include/GXDLMSPrimeNbOfdmPlcMacFunctionalParameters.h -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | jobs: 6 | build: 7 | name: Build 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Install dependencies 11 | run: | 12 | sudo apt-get update 13 | sudo apt-get install qtbase5-dev qt5-qmake 14 | 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | 20 | - name: Configure 21 | run: | 22 | mkdir -p build && cd build 23 | qmake PREFIX=/usr .. 24 | 25 | - name: Build 26 | run: | 27 | cd build 28 | make 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.so.* 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | object_script.*.Release 15 | object_script.*.Debug 16 | *_plugin_import.cpp 17 | /.qmake.cache 18 | /.qmake.stash 19 | *.pro.user 20 | *.pro.user* 21 | *.qbs.user 22 | *.qbs.user* 23 | *.moc 24 | moc_*.cpp 25 | moc_*.h 26 | qrc_*.cpp 27 | ui_*.h 28 | *.qmlc 29 | *.jsc 30 | Makefile* 31 | *build-* 32 | *.qm 33 | *.prl 34 | 35 | # Qt unit tests 36 | target_wrapper.* 37 | 38 | # QtCreator 39 | *.autosave 40 | 41 | # QtCreator Qml 42 | *.qmlproject.user 43 | *.qmlproject.user.* 44 | 45 | # QtCreator CMake 46 | CMakeLists.txt.user* 47 | 48 | # QtCreator 4.8< compilation database 49 | compile_commands.json 50 | 51 | # QtCreator local machine specific files for imported projects 52 | *creator.user* 53 | *_qmlcache.qrc 54 | 55 | # License templates 56 | license-template 57 | 58 | # Build directories 59 | build 60 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: Google 3 | --- 4 | Language: Cpp 5 | IndentWidth: 2 6 | ContinuationIndentWidth: 4 7 | 8 | 9 | 10 | DerivePointerAlignment: false 11 | PointerAlignment: Right 12 | 13 | 14 | 15 | BreakBeforeBraces: Linux 16 | AlwaysBreakAfterReturnType: AllDefinitions 17 | AlwaysBreakBeforeMultilineStrings: true 18 | 19 | 20 | 21 | AlignAfterOpenBracket: AlwaysBreak 22 | BinPackArguments: false 23 | AllowAllArgumentsOnNextLine: false 24 | BinPackParameters: false 25 | AllowAllParametersOfDeclarationOnNextLine: false 26 | AllowShortIfStatementsOnASingleLine: Never 27 | AllowShortBlocksOnASingleLine: Never 28 | AllowShortCaseLabelsOnASingleLine: false 29 | AllowShortEnumsOnASingleLine: false 30 | AllowShortFunctionsOnASingleLine: None 31 | 32 | 33 | 34 | BreakStringLiterals: true 35 | SpaceAfterCStyleCast: true 36 | SpacesInContainerLiterals: false 37 | PenaltyReturnTypeOnItsOwnLine: 999 38 | 39 | 40 | 41 | FixNamespaceComments: true 42 | NamespaceIndentation: All 43 | SortUsingDeclarations: true 44 | CompactNamespaces: false 45 | --- 46 | -------------------------------------------------------------------------------- /PLCTool/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Icons/configure.png 4 | Icons/connect_no.png 5 | Icons/fileimport.png 6 | Icons/history.png 7 | Icons/close.png 8 | Icons/start.png 9 | Icons/pause.png 10 | Icons/associate.png 11 | Icons/register.png 12 | Icons/file-xml.png 13 | Icons/messages.png 14 | Icons/frames.png 15 | Icons/passwords.png 16 | Icons/Tarlogic/Tarlogic-0.png 17 | Icons/Tarlogic/Tarlogic-1.png 18 | Icons/Tarlogic/Tarlogic-2.png 19 | Icons/Tarlogic/Tarlogic-3.png 20 | Icons/Tarlogic/Tarlogic-4.png 21 | Icons/Tarlogic/Tarlogic-5.png 22 | Icons/Tarlogic/Tarlogic-6.png 23 | Icons/Tarlogic/Tarlogic-7.png 24 | Icons/bomb.png 25 | 26 | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PLCTool - A PRIME/DLMS graphical swiss-knife 2 | 3 | This repostory contains the source code of **PLCTool**, a Qt-based graphical tool used to analyze and debug PRIME / DLMS-based smart-meter networks, with special focus on the security of these deployments. 4 | 5 | Currently, **we support GNU/Linux and probably other Unix-based environments.** Windows support is on its way. 6 | 7 | This tool was presented in the talk **Hacking Smart Meters** of the RootedCON 2022, during which its use with the **ATPL360-EK** evaluation kit to send and receive data in PLC networks was demonstrated. 8 | 9 | Leave it running during a full 24-hour cycle and click on the Credential Logger button. If the PRIME you are in is not particularly secure, you may be able to see a few low-level-security DLMS passwords in the credential logger. 10 | 11 | 12 | ## Plugin support 13 | 14 | Plugin build and usage guide can be found here: [**PLCTool plugin support**](https://www.tarlogic.com/blog/plctool-plugin-support/) 15 | 16 | Sample plugins can be found here: [**PLCTool-Plugins**](https://github.com/TarlogicSecurity/PLCTool-Plugins) 17 | 18 | 19 | ## Build 20 | 21 | Build instructions and a usage guide here: [**PLCTool, the Swiss army knife of smart meters**](https://www.tarlogic.com/blog/plctool-swiss-army-knife-of-smart-meters/) 22 | 23 | 24 | Note that in order to build PLCTool, you will need: 25 | 26 | - A suitable C++ compiler (gcc 10.3 or higher) 27 | - Qt 5 development files, version 5.9.1 or higher 28 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXAttributeCollection.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXATTRIBUTECOLLECTION_H 36 | #define GXATTRIBUTECOLLECTION_H 37 | 38 | #include "GXDLMSAttribute.h" 39 | 40 | class CGXAttributeCollection : public std::vector 41 | { 42 | public: 43 | }; 44 | #endif //GXATTRIBUTECOLLECTION_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSObjectFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSOBJECTFACTORY_H 36 | #define GXDLMSOBJECTFACTORY_H 37 | 38 | #include "GXDLMSObject.h" 39 | 40 | class CGXDLMSObjectFactory 41 | { 42 | public: 43 | static CGXDLMSObject* CreateObject(DLMS_OBJECT_TYPE type); 44 | static CGXDLMSObject* CreateObject(DLMS_OBJECT_TYPE type, std::string ln); 45 | }; 46 | #endif //GXDLMSOBJECTFACTORY_H -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXAdjacentCell.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXAdjacentCell.h" 36 | 37 | unsigned long GXAdjacentCell::GetCellId() { 38 | return m_CellId; 39 | } 40 | 41 | void GXAdjacentCell::SetCellId(unsigned long value) { 42 | m_CellId = value; 43 | } 44 | 45 | unsigned char GXAdjacentCell::GetSignalQuality() { 46 | return m_SignalQuality; 47 | } 48 | 49 | void GXAdjacentCell::SetSignalQuality(unsigned char value) { 50 | m_SignalQuality = value; 51 | } -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSSpecialDay.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSSPECIALDAY_H 36 | #define GXDLMSSPECIALDAY_H 37 | 38 | #include "GXDate.h" 39 | 40 | class CGXDLMSSpecialDay 41 | { 42 | int m_Index; 43 | CGXDate m_Date; 44 | int m_DayId; 45 | 46 | public: 47 | int GetIndex(); 48 | void SetIndex(int value); 49 | 50 | CGXDate& GetDate(); 51 | void SetDate(CGXDate& value); 52 | void SetDate(CGXDateTime& value); 53 | 54 | int GetDayId(); 55 | void SetDayId(int value); 56 | 57 | std::string ToString(); 58 | }; 59 | #endif //GXDLMSSPECIALDAY_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSEmergencyProfile.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSEMERGENCYPROFILE_H 36 | #define GXDLMSEMERGENCYPROFILE_H 37 | 38 | class CGXDLMSEmergencyProfile 39 | { 40 | int m_ID; 41 | CGXDateTime m_ActivationTime; 42 | int m_Duration; 43 | public: 44 | 45 | int GetID(); 46 | void SetID(int value); 47 | 48 | CGXDateTime& GetActivationTime(); 49 | void SetActivationTime(CGXDateTime value); 50 | 51 | int GetDuration(); 52 | void SetDuration(int value); 53 | 54 | std::string ToString(); 55 | }; 56 | 57 | #endif //GXDLMSEMERGENCYPROFILE_H 58 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSValueEventCollection.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSVALUEEVENT_COLLECTION_H 36 | #define GXDLMSVALUEEVENT_COLLECTION_H 37 | 38 | #include "GXDLMSValueEventArg.h" 39 | 40 | 41 | class CGXDLMSValueEventCollection : public std::vector 42 | { 43 | public: 44 | /** 45 | * Destructor. 46 | */ 47 | ~CGXDLMSValueEventCollection() 48 | { 49 | for(std::vector::iterator it = begin(); it != end(); ++it) 50 | { 51 | delete *it; 52 | } 53 | clear(); 54 | } 55 | }; 56 | #endif //GXDLMSVALUEEVENT_COLLECTION_H 57 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSActionSet.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSActionSet.h" 36 | #include 37 | 38 | CGXDLMSActionSet::CGXDLMSActionSet() 39 | { 40 | } 41 | 42 | CGXDLMSActionItem& CGXDLMSActionSet::GetActionUp() 43 | { 44 | return m_ActionUp; 45 | } 46 | 47 | CGXDLMSActionItem& CGXDLMSActionSet::GetActionDown() 48 | { 49 | return m_ActionDown; 50 | } 51 | 52 | std::string CGXDLMSActionSet::ToString() 53 | { 54 | std::stringstream sb; 55 | sb << m_ActionUp.ToString().c_str(); 56 | sb << " "; 57 | sb << m_ActionDown.ToString().c_str(); 58 | return sb.str(); 59 | } -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSIp4SetupIpOption.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSIP4SETUPIPOPTION_H 36 | #define GXDLMSIP4SETUPIPOPTION_H 37 | 38 | #include "GXDLMSObject.h" 39 | 40 | class CGXDLMSIp4SetupIpOption 41 | { 42 | IP_OPTION_TYPE m_Type; 43 | short m_Length; 44 | CGXByteBuffer m_Data; 45 | public: 46 | IP_OPTION_TYPE GetType(); 47 | void SetType(IP_OPTION_TYPE value); 48 | 49 | short GetLength(); 50 | void SetLength(short value); 51 | CGXByteBuffer& GetData(); 52 | void SetData(CGXByteBuffer& value); 53 | 54 | std::string ToString(); 55 | }; 56 | #endif //GXDLMSIP4SETUPIPOPTION_H -------------------------------------------------------------------------------- /PLCTool/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "App/Application.h" 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | Application a(argc, argv); 35 | 36 | if (a.work()) 37 | return EXIT_SUCCESS; 38 | 39 | return EXIT_FAILURE; 40 | } 41 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSActionSet.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSACTIONSET_H 36 | #define GXDLMSACTIONSET_H 37 | 38 | #include "GXDLMSActionItem.h" 39 | 40 | class CGXDLMSActionSet 41 | { 42 | CGXDLMSActionItem m_ActionUp; 43 | CGXDLMSActionItem m_ActionDown; 44 | public: 45 | /** 46 | Constructor. 47 | */ 48 | CGXDLMSActionSet(); 49 | 50 | /** 51 | Destructor. 52 | */ 53 | ~CGXDLMSActionSet() 54 | { 55 | } 56 | 57 | CGXDLMSActionItem& GetActionUp(); 58 | 59 | CGXDLMSActionItem& GetActionDown(); 60 | 61 | std::string ToString(); 62 | }; 63 | 64 | #endif //GXDLMSACTIONSET_H -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSScript.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSScript.h" 36 | 37 | CGXDLMSScript::CGXDLMSScript() 38 | { 39 | } 40 | 41 | CGXDLMSScript::~CGXDLMSScript() 42 | { 43 | for (std::vector::iterator it = m_Actions.begin(); it != m_Actions.end(); ++it) 44 | { 45 | delete *it; 46 | } 47 | m_Actions.clear(); 48 | } 49 | 50 | int CGXDLMSScript::GetID() 51 | { 52 | return m_ID; 53 | } 54 | 55 | void CGXDLMSScript::SetID(int value) 56 | { 57 | m_ID = value; 58 | } 59 | 60 | std::vector& CGXDLMSScript::GetActions() 61 | { 62 | return m_Actions; 63 | } -------------------------------------------------------------------------------- /PLCTool/Topology/Switch.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include 31 | 32 | using namespace PLCTool; 33 | 34 | Switch::Switch() : Hub(nullptr, SWITCH, 0) 35 | { 36 | } 37 | 38 | Switch::Switch(SubNet *subnet, NodeId id) : Hub(subnet, SWITCH, id) 39 | { 40 | } 41 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/AuthenticationValue.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "AuthenticationValue.h" 31 | 32 | using namespace PLCTool; 33 | 34 | AuthenticationValue::AuthenticationValue() 35 | { 36 | this->identifier = BerIdentifier(BER_CONTEXT_SPECIFIC_CLASS, true, 0xc); 37 | } 38 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSSha1.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSSHA1_H 36 | #define GXDLMSSHA1_H 37 | 38 | #include "GXBytebuffer.h" 39 | 40 | //This class is used to handle SHA-1. 41 | class CGXDLMSSha1 42 | { 43 | private: 44 | static void Transform(unsigned long *block, unsigned int *digest, unsigned int *transforms); 45 | static void Update(CGXByteBuffer& data, unsigned int *digest, unsigned int *transforms); 46 | static int Final(CGXByteBuffer& data, unsigned int *digest, unsigned int *transforms, CGXByteBuffer& reply); 47 | 48 | public: 49 | static int Encrypt(CGXByteBuffer& data, CGXByteBuffer& crypted); 50 | }; 51 | #endif //GXDLMSSHA1_H -------------------------------------------------------------------------------- /PLCTool/Types/ber/BerBitString.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "BerBitString.h" 31 | 32 | using namespace PLCTool; 33 | 34 | BerBitString::BerBitString(bool constructed) 35 | { 36 | this->identifier = 37 | BerIdentifier(BER_UNIVERSAL_CLASS, constructed, BER_BIT_STRING); 38 | } 39 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSModemInitialisation.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSMODEMINITIALISATION_H 36 | #define GXDLMSMODEMINITIALISATION_H 37 | 38 | #include 39 | 40 | class CGXDLMSModemInitialisation 41 | { 42 | std::string m_Request; 43 | std::string m_Response; 44 | int m_Delay; 45 | 46 | public: 47 | CGXDLMSModemInitialisation(); 48 | std::string GetRequest(); 49 | void SetRequest(std::string value); 50 | std::string GetResponse(); 51 | void SetResponse(std::string value); 52 | int GetDelay(); 53 | void SetDelay(int value); 54 | 55 | std::string ToString(); 56 | }; 57 | #endif //GXDLMSMODEMINITIALISATION_H -------------------------------------------------------------------------------- /PLCTool/Types/ber/BerOctetString.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "BerOctetString.h" 31 | 32 | using namespace PLCTool; 33 | 34 | BerOctetString::BerOctetString(bool constructed) 35 | { 36 | this->identifier = 37 | BerIdentifier(BER_UNIVERSAL_CLASS, constructed, BER_OCTET_STRING); 38 | } 39 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXXmlWriterSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GX_XML_WRITER_SETTINGS 36 | #define GX_XML_WRITER_SETTINGS 37 | 38 | class CGXXmlWriterSettings 39 | { 40 | bool m_Values; 41 | bool m_SkipDefaults; 42 | public: 43 | //Constructor 44 | CGXXmlWriterSettings(); 45 | 46 | //Are attribute values also serialized. 47 | bool GetValues(); 48 | 49 | //Are attribute values also serialized. 50 | void SetValues(bool value); 51 | 52 | //Are default values serialized. 53 | bool GetSkipDefaults(); 54 | 55 | //Are default values serialized. 56 | void SetSkipDefaults(bool value); 57 | }; 58 | 59 | #endif //GX_XML_WRITER_SETTINGS -------------------------------------------------------------------------------- /PLCTool/Types/ber/BerGraphicString.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "BerGraphicString.h" 31 | 32 | using namespace PLCTool; 33 | 34 | BerGraphicString::BerGraphicString(bool constructed) 35 | { 36 | this->identifier = 37 | BerIdentifier(BER_UNIVERSAL_CLASS, constructed, BER_GRAPHIC_STRING); 38 | } 39 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSConnectionEventArgs.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSCONNECTIONEVENTARGS_H 36 | #define GXDLMSCONNECTIONEVENTARGS_H 37 | 38 | class CGXDLMSConnectionEventArgs 39 | { 40 | private: 41 | // Server ID that client try to use to make connection. 42 | int m_ServerAddress; 43 | public: 44 | /** 45 | * Constructor. 46 | */ 47 | CGXDLMSConnectionEventArgs() 48 | { 49 | m_ServerAddress = 0; 50 | } 51 | 52 | int GetServerAddress() 53 | { 54 | return m_ServerAddress; 55 | } 56 | void SetServerAddress(int value) 57 | { 58 | m_ServerAddress = value; 59 | } 60 | }; 61 | 62 | #endif //GXDLMSCONNECTIONEVENTARGS_H 63 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXSNInfo.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXSNInfo.h" 36 | 37 | CGXSNInfo::CGXSNInfo() 38 | { 39 | m_Action = false; 40 | m_Index = 0; 41 | m_Item = 0; 42 | } 43 | 44 | int CGXSNInfo::GetIndex() 45 | { 46 | return m_Index; 47 | } 48 | 49 | void CGXSNInfo::SetIndex(int value) 50 | { 51 | m_Index = value; 52 | } 53 | 54 | bool CGXSNInfo::IsAction() 55 | { 56 | return m_Action; 57 | } 58 | 59 | void CGXSNInfo::SetAction(bool value) 60 | { 61 | m_Action = value; 62 | } 63 | 64 | CGXDLMSObject* CGXSNInfo::GetItem() 65 | { 66 | return m_Item; 67 | } 68 | 69 | void CGXSNInfo::SetItem(CGXDLMSObject* value) 70 | { 71 | m_Item = value; 72 | } -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXXmlWriterSettings.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXXmlWriterSettings.h" 36 | 37 | CGXXmlWriterSettings::CGXXmlWriterSettings() 38 | { 39 | m_Values = true; 40 | m_SkipDefaults = true; 41 | } 42 | 43 | bool CGXXmlWriterSettings::GetValues() 44 | { 45 | return m_Values; 46 | } 47 | 48 | void CGXXmlWriterSettings::SetValues(bool value) 49 | { 50 | m_Values = value; 51 | } 52 | 53 | //Are default values serialized. 54 | bool CGXXmlWriterSettings::GetSkipDefaults() 55 | { 56 | return m_SkipDefaults; 57 | } 58 | 59 | //Are default values serialized. 60 | void CGXXmlWriterSettings::SetSkipDefaults(bool value) 61 | { 62 | m_SkipDefaults = value; 63 | } -------------------------------------------------------------------------------- /PLCTool/Topology/Switch.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef _TOPOLOGY_SWITCH_H 31 | #define _TOPOLOGY_SWITCH_H 32 | 33 | #include "Hub.h" 34 | 35 | namespace PLCTool { 36 | class Switch : public Hub { 37 | public: 38 | Switch(); 39 | Switch(SubNet *, NodeId id); 40 | }; 41 | } 42 | 43 | #endif // _TOPOLOGY_SWITCH_H 44 | 45 | -------------------------------------------------------------------------------- /PLCTool/Topology/AdapterEventListener.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include 31 | 32 | using namespace PLCTool; 33 | 34 | void 35 | AdapterEventListener::setAdapter(Adapter *adapter) 36 | { 37 | this->adapter = adapter; 38 | } 39 | 40 | AdapterEventListener::~AdapterEventListener(void) 41 | { 42 | } 43 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSSha256.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSSHA256_H 36 | #define GXDLMSSHA256_H 37 | 38 | #include "GXBytebuffer.h" 39 | 40 | //This class is used to handle SHA-256. 41 | class CGXDLMSSha256 42 | { 43 | private: 44 | static void Transform(unsigned int *h, const unsigned char *message, unsigned int block_nb); 45 | static int Final(unsigned int *h, unsigned char *block, unsigned char *digest, unsigned int len, unsigned int totalLen); 46 | static int Update(unsigned int *h, unsigned char *block, CGXByteBuffer& data, unsigned int *len, unsigned int *totalLen); 47 | public: 48 | static int Encrypt(CGXByteBuffer& data, CGXByteBuffer& crypted); 49 | }; 50 | #endif //GXDLMSSHA256_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSActionItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | #ifndef GXDLMSACTIONITEM_H 35 | #define GXDLMSACTIONITEM_H 36 | 37 | #include "enums.h" 38 | 39 | class CGXDLMSActionItem 40 | { 41 | friend class CGXDLMSActionSet; 42 | std::string m_LogicalName; 43 | int m_ScriptSelector; 44 | public: 45 | //Constructor. 46 | CGXDLMSActionItem(); 47 | 48 | //Destructor. 49 | ~CGXDLMSActionItem() 50 | { 51 | m_LogicalName.clear(); 52 | } 53 | std::string& GetLogicalName(); 54 | 55 | void SetLogicalName(std::string& value); 56 | 57 | int GetScriptSelector(); 58 | 59 | void SetScriptSelector(int value); 60 | 61 | std::string ToString(); 62 | }; 63 | #endif //GXDLMSACTIONITEM_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSPushObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSPUSHOBJECT_H 36 | #define GXDLMSPUSHOBJECT_H 37 | 38 | #include "enums.h" 39 | 40 | class CGXDLMSPushObject 41 | { 42 | private: 43 | DLMS_OBJECT_TYPE m_Type; 44 | std::string m_LogicalName; 45 | int m_AttributeIndex; 46 | int m_DataIndex; 47 | 48 | public: 49 | DLMS_OBJECT_TYPE GetType(); 50 | void SetType(DLMS_OBJECT_TYPE value); 51 | 52 | std::string GetLogicalName(); 53 | void SetLogicalName(std::string value); 54 | 55 | int GetAttributeIndex(); 56 | void SetAttributeIndex(int value); 57 | 58 | int GetDataIndex(); 59 | void SetDataIndex(int value); 60 | 61 | std::string ToString(); 62 | }; 63 | #endif //GXDLMSPUSHOBJECT_H -------------------------------------------------------------------------------- /PLCTool/Types/dlms/Data.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef DATA_H 31 | #define DATA_H 32 | 33 | #include 34 | 35 | namespace PLCTool 36 | { 37 | class Data : public Serializable 38 | { 39 | public: 40 | virtual ~Data(){}; 41 | 42 | virtual Data *clone() const = 0; 43 | }; 44 | } // namespace PLCTool 45 | 46 | #endif // DATA_H 47 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXChargeTable.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXChargeTable.h" 36 | #include "../include/GXHelpers.h" 37 | 38 | CGXChargeTable::CGXChargeTable() 39 | { 40 | m_ChargePerUnit = 0; 41 | } 42 | 43 | std::string& CGXChargeTable::GetIndex() 44 | { 45 | return m_Index; 46 | } 47 | 48 | void CGXChargeTable::SetIndex(std::string& value) 49 | { 50 | m_Index = value; 51 | } 52 | 53 | short CGXChargeTable::GetChargePerUnit() 54 | { 55 | return m_ChargePerUnit; 56 | } 57 | 58 | void CGXChargeTable::SetChargePerUnit(short value) 59 | { 60 | m_ChargePerUnit = value; 61 | } 62 | 63 | std::string CGXChargeTable::ToString() 64 | { 65 | std::string str = m_Index + " " + GXHelpers::IntToString(m_ChargePerUnit); 66 | return str; 67 | } -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSMonitoredValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSMONITOREDVALUE_H 36 | #define GXDLMSMONITOREDVALUE_H 37 | 38 | #include "GXDLMSObject.h" 39 | 40 | class CGXDLMSMonitoredValue 41 | { 42 | DLMS_OBJECT_TYPE m_ObjectType; 43 | std::string m_LogicalName; 44 | int m_AttributeIndex; 45 | public: 46 | 47 | CGXDLMSMonitoredValue(); 48 | void Update(CGXDLMSObject* pObj, int attributeIndex); 49 | 50 | DLMS_OBJECT_TYPE GetObjectType(); 51 | void SetObjectType(DLMS_OBJECT_TYPE value); 52 | 53 | std::string GetLogicalName(); 54 | void SetLogicalName(std::string value); 55 | 56 | int GetAttributeIndex(); 57 | void SetAttributeIndex(int value); 58 | 59 | std::string ToString(); 60 | }; 61 | 62 | #endif //GXDLMSMONITOREDVALUE_H -------------------------------------------------------------------------------- /PLCTool/Types/general/Bytevector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "Bytevector.h" 31 | 32 | using namespace PLCTool; 33 | 34 | std::vector 35 | Bytevector::getBytes() 36 | { 37 | return this->bytes; 38 | } 39 | 40 | void 41 | Bytevector::setBytes(std::vector bytes) 42 | { 43 | this->bytes = bytes; 44 | } 45 | 46 | size_t 47 | Bytevector::getSize() 48 | { 49 | return this->bytes.size(); 50 | } 51 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/AuthenticationValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef AUTHENTICATIONVALUE_H 31 | #define AUTHENTICATIONVALUE_H 32 | 33 | #include 34 | 35 | #include 36 | 37 | namespace PLCTool 38 | { 39 | class AuthenticationValue : public BerData 40 | { 41 | public: 42 | AuthenticationValue(); 43 | }; 44 | } // namespace PLCTool 45 | 46 | #endif // AUTHENTICATIONVALUE_H 47 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSCaptureObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSCAPTUREOBJECT_H 36 | #define GXDLMSCAPTUREOBJECT_H 37 | 38 | class CGXDLMSCaptureObject 39 | { 40 | private: 41 | int m_AttributeIndex; 42 | int m_DataIndex; 43 | 44 | public: 45 | /* 46 | * Constructor. 47 | */ 48 | CGXDLMSCaptureObject(); 49 | /* 50 | * Constructor. 51 | */ 52 | CGXDLMSCaptureObject(int attributeIndex, int dataIndex); 53 | 54 | /** 55 | Index of DLMS object in the profile generic table 56 | */ 57 | int GetAttributeIndex(); 58 | void SetAttributeIndex(int value); 59 | 60 | /** 61 | Data index of DLMS object in the profile generic table. 62 | */ 63 | int GetDataIndex(); 64 | void SetDataIndex(int value); 65 | }; 66 | #endif //GXDLMSCAPTUREOBJECT_H -------------------------------------------------------------------------------- /PLCTool/Attacks/AttackController.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "AttackController.h" 31 | 32 | using namespace PLCTool; 33 | 34 | AttackController::AttackController(QString name, QObject *parent) 35 | : QObject(parent), name(name) 36 | { 37 | 38 | } 39 | 40 | QString 41 | AttackController::getName(void) const 42 | { 43 | return name; 44 | } 45 | 46 | void 47 | AttackController::setName(QString name) 48 | { 49 | this->name = name; 50 | } 51 | -------------------------------------------------------------------------------- /PLCTool/Topology/Meter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef _TOPOLOGY_METER_H 31 | #define _TOPOLOGY_METER_H 32 | 33 | #include 34 | #include 35 | #include "Switch.h" 36 | 37 | namespace PLCTool { 38 | class Meter : public Switch { 39 | 40 | public: 41 | Meter(); 42 | Meter(SubNet *owner, NodeId id); 43 | 44 | void promote(void); 45 | void demote(void); 46 | }; 47 | } 48 | 49 | #endif // _TOPOLOGY_METER_H 50 | 51 | -------------------------------------------------------------------------------- /PLCTool/Attacks/AttackFactory.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "AttackFactory.h" 31 | 32 | #include 33 | #include 34 | 35 | using namespace PLCTool; 36 | 37 | AttackFactory::AttackFactory(QString const attackName, QObject *parent) 38 | : QObject(parent), attackName(attackName) 39 | { 40 | } 41 | 42 | QString 43 | AttackFactory::getAttackName(void) const 44 | { 45 | return attackName; 46 | } 47 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSQualityOfService.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | #ifndef GXDLMSQUALITYOFSERVICE_H 35 | #define GXDLMSQUALITYOFSERVICE_H 36 | 37 | #include "enums.h" 38 | 39 | class CGXDLMSQualityOfService 40 | { 41 | private: 42 | int m_Precedence; 43 | int m_Delay; 44 | int m_Reliability; 45 | int m_PeakThroughput; 46 | int m_MeanThroughput; 47 | 48 | public: 49 | int GetPrecedence(); 50 | void SetPrecedence(int value); 51 | 52 | int GetDelay(); 53 | void SetDelay(int value); 54 | 55 | int GetReliability(); 56 | void SetReliability(int value); 57 | 58 | int GetPeakThroughput(); 59 | void SetPeakThroughput(int value); 60 | 61 | int GetMeanThroughput(); 62 | void SetMeanThroughput(int value); 63 | 64 | std::string ToString(); 65 | }; 66 | #endif //GXDLMSQUALITYOFSERVICE_H -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSActionItem.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSActionItem.h" 36 | 37 | //Constructor. 38 | CGXDLMSActionItem::CGXDLMSActionItem() 39 | { 40 | m_ScriptSelector = 0; 41 | } 42 | 43 | std::string& CGXDLMSActionItem::GetLogicalName() 44 | { 45 | return m_LogicalName; 46 | } 47 | void CGXDLMSActionItem::SetLogicalName(std::string& value) 48 | { 49 | m_LogicalName = value; 50 | } 51 | 52 | int CGXDLMSActionItem::GetScriptSelector() 53 | { 54 | return m_ScriptSelector; 55 | } 56 | void CGXDLMSActionItem::SetScriptSelector(int value) 57 | { 58 | m_ScriptSelector = value; 59 | } 60 | 61 | std::string CGXDLMSActionItem::ToString() 62 | { 63 | std::stringstream sb; 64 | sb << m_LogicalName.c_str(); 65 | sb << " "; 66 | sb << m_ScriptSelector; 67 | return sb.str(); 68 | } -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSObjectDefinition.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSOBJECTDEFINITION_H 36 | #define GXDLMSOBJECTDEFINITION_H 37 | 38 | #include 39 | #include "enums.h" 40 | 41 | class CGXDLMSObjectDefinition 42 | { 43 | private: 44 | DLMS_OBJECT_TYPE m_ObjectType; 45 | std::string m_LogicalName; 46 | 47 | public: 48 | DLMS_OBJECT_TYPE GetObjectType(); 49 | void SetObjectType(DLMS_OBJECT_TYPE value); 50 | 51 | std::string GetLogicalName(); 52 | void SetLogicalName(std::string value); 53 | 54 | /* 55 | * Constructor 56 | */ 57 | CGXDLMSObjectDefinition(); 58 | 59 | /* 60 | * Constructor 61 | */ 62 | CGXDLMSObjectDefinition(DLMS_OBJECT_TYPE classId, std::string logicalName); 63 | 64 | std::string ToString(); 65 | }; 66 | #endif //GXDLMSOBJECTDEFINITION_H -------------------------------------------------------------------------------- /PLCTool/Topology/Meter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include 31 | 32 | using namespace PLCTool; 33 | 34 | Meter::Meter() : Switch(nullptr, 0) 35 | { 36 | this->demote(); 37 | } 38 | 39 | Meter::Meter(SubNet *subnet, NodeId id) : Switch(subnet, id) 40 | { 41 | this->demote(); 42 | } 43 | 44 | void 45 | Meter::promote(void) 46 | { 47 | this->eType = SWITCH; 48 | } 49 | 50 | void 51 | Meter::demote(void) 52 | { 53 | this->eType = METER; 54 | } 55 | -------------------------------------------------------------------------------- /PLCTool/Attacks/UIAttackController.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "UIAttackController.h" 31 | 32 | #include 33 | 34 | using namespace PLCTool; 35 | 36 | UIAttackController::UIAttackController( 37 | QString name, 38 | QString windowTitle, 39 | QObject *parent) 40 | : AttackController(name, parent), windowTitle(windowTitle) 41 | { 42 | } 43 | 44 | QString 45 | UIAttackController::getWindowTitle(void) 46 | { 47 | return this->windowTitle; 48 | } 49 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSIp4SetupIpOption.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSIp4SetupIpOption.h" 36 | #include 37 | 38 | IP_OPTION_TYPE CGXDLMSIp4SetupIpOption::GetType() 39 | { 40 | return m_Type; 41 | } 42 | void CGXDLMSIp4SetupIpOption::SetType(IP_OPTION_TYPE value) 43 | { 44 | m_Type = value; 45 | } 46 | 47 | short CGXDLMSIp4SetupIpOption::GetLength() 48 | { 49 | return m_Length; 50 | } 51 | void CGXDLMSIp4SetupIpOption::SetLength(short value) 52 | { 53 | m_Length = value; 54 | } 55 | 56 | CGXByteBuffer& CGXDLMSIp4SetupIpOption::GetData() 57 | { 58 | return m_Data; 59 | } 60 | 61 | void CGXDLMSIp4SetupIpOption::SetData(CGXByteBuffer& value) 62 | { 63 | m_Data = value; 64 | } 65 | 66 | std::string CGXDLMSIp4SetupIpOption::ToString() 67 | { 68 | std::stringstream sb; 69 | sb << m_Type; 70 | return sb.str(); 71 | } 72 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXAdjacentCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXADJACENTCELL_H 36 | #define GXADJACENTCELL_H 37 | 38 | #include 39 | 40 | class GXAdjacentCell 41 | { 42 | private: 43 | /** 44 | * Four byte cell ID. 45 | */ 46 | unsigned long m_CellId; 47 | 48 | /** 49 | * Signal quality. 50 | */ 51 | unsigned char m_SignalQuality; 52 | public: 53 | /** 54 | * @return Four byte cell ID. 55 | */ 56 | unsigned long GetCellId(); 57 | 58 | /** 59 | * @param value 60 | * Four byte cell ID. 61 | */ 62 | void SetCellId(unsigned long value); 63 | 64 | /** 65 | * @return Signal quality. 66 | */ 67 | unsigned char GetSignalQuality(); 68 | 69 | /** 70 | * @param value 71 | * Signal quality. 72 | */ 73 | void SetSignalQuality(unsigned char value); 74 | }; 75 | #endif //GXADJACENTCELL_H -------------------------------------------------------------------------------- /PLCTool/Topology/Hub.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef _TOPOLOGY_HUB_H 31 | #define _TOPOLOGY_HUB_H 32 | 33 | #include 34 | #include 35 | #include "SubNet.h" 36 | #include "Node.h" 37 | 38 | namespace PLCTool { 39 | class SubNet; 40 | 41 | class Hub: public Node { 42 | SubNet *hubSubNet = nullptr; 43 | 44 | public: 45 | Hub(); 46 | Hub(SubNet *parent, NodeType, NodeId id); 47 | ~Hub(); 48 | 49 | SubNet &subNet(void); 50 | }; 51 | } 52 | 53 | #endif // _TOPOLOGY_HUB_H 54 | 55 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/ActionRequest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "ActionRequest.h" 31 | 32 | #include 33 | 34 | using namespace PLCTool; 35 | 36 | std::vector 37 | ActionRequest::getBytes() 38 | { 39 | std::vector bytes; 40 | bytes.push_back(0xc3); 41 | 42 | return bytes; 43 | } 44 | 45 | void 46 | ActionRequest::setBytes(std::vector bytes) 47 | { 48 | assert(false); 49 | /* TODO */ 50 | } 51 | 52 | size_t 53 | ActionRequest::getSize() 54 | { 55 | return 1; 56 | } 57 | -------------------------------------------------------------------------------- /PLCTool/App/DLMSTranslator.h: -------------------------------------------------------------------------------- 1 | // 2 | // 1. Redistributions of source code must retain the above copyright notice, 3 | // this list of conditions and the following disclaimer. 4 | // 2. Redistributions in binary form must reproduce the above copyright notice, 5 | // this list of conditions and the following disclaimer in the documentation 6 | // and/or other materials provided with the distribution. 7 | // 3. Neither the name of copyright holders nor the names of its contributors 8 | // may be used to endorse or promote products derived from this software 9 | // without specific prior written permission. 10 | // 11 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 12 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 13 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 14 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 15 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 16 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 17 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 18 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 19 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 20 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 21 | // POSSIBILITY OF SUCH DAMAGE. 22 | // 23 | 24 | #ifndef DLMSTRANSLATOR_H 25 | #define DLMSTRANSLATOR_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | class DLMSTranslator 32 | { 33 | public: 34 | virtual ~DLMSTranslator(void){}; 35 | 36 | // Convert bytes to xml. 37 | // value: Bytes to convert. 38 | // Returns Converted xml. 39 | virtual int PduToXml(std::vector &value, std::string &output) = 0; 40 | 41 | // Convert xml to bytes. 42 | // xml: xml string to convert. 43 | // Returns Converted bytes. 44 | virtual int XmlToPdu(std::string &xml, std::vector &output) = 0; 45 | 46 | // Are comments added. 47 | virtual void SetComments(bool value) = 0; 48 | }; 49 | 50 | #endif // DLMSTRANSLATOR_H 51 | -------------------------------------------------------------------------------- /PLCTool/Topology/Hub.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include 31 | 32 | using namespace PLCTool; 33 | 34 | Hub::Hub() : Node() 35 | { 36 | this->hubSubNet = nullptr; 37 | } 38 | 39 | Hub::Hub(SubNet *parent, NodeType type, NodeId id) : Node(parent, type, id) 40 | { 41 | this->hubSubNet = new SubNet(this); 42 | } 43 | 44 | SubNet & 45 | Hub::subNet(void) 46 | { 47 | return *this->hubSubNet; 48 | } 49 | 50 | Hub::~Hub() 51 | { 52 | if (this->hubSubNet != nullptr) 53 | delete this->hubSubNet; 54 | } 55 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/IGXDLMSBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | #ifndef IGXDLMSBASE_H 35 | #define IGXDLMSBASE_H 36 | 37 | #include "GXDLMSVariant.h" 38 | #include "GXDLMSValueEventArg.h" 39 | 40 | class CGXDLMSSettings; 41 | 42 | struct IGXDLMSBase 43 | { 44 | public: 45 | // Returns amount of attributes. 46 | virtual int GetAttributeCount() = 0; 47 | 48 | // Returns amount of methods. 49 | virtual int GetMethodCount() = 0; 50 | 51 | // Returns value of given attribute. 52 | virtual int GetValue(CGXDLMSSettings& settings, CGXDLMSValueEventArg& e) = 0; 53 | 54 | // Set value of given attribute. 55 | virtual int SetValue(CGXDLMSSettings& settings, CGXDLMSValueEventArg& e) = 0; 56 | 57 | // Invokes method. 58 | virtual int Invoke(CGXDLMSSettings& settings, CGXDLMSValueEventArg& e) = 0; 59 | 60 | // virtual DLMS_DATA_TYPE GetUIDataType(int index) = 0; 61 | }; 62 | #endif //IGXDLMSBASE_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSScript.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSSCRIPT_H 36 | #define GXDLMSSCRIPT_H 37 | 38 | #include "GXDLMSScriptAction.h" 39 | 40 | class CGXDLMSScript 41 | { 42 | /** 43 | * Script identifier. 44 | */ 45 | int m_ID; 46 | 47 | /** 48 | * Script actions. 49 | */ 50 | std::vector m_Actions; 51 | 52 | public: 53 | /** 54 | * Constructor. 55 | */ 56 | CGXDLMSScript(); 57 | 58 | /** 59 | * Destructor. 60 | */ 61 | ~CGXDLMSScript(); 62 | 63 | /** 64 | * @return Script identifier. 65 | */ 66 | int GetID(); 67 | 68 | /** 69 | * @param value 70 | * Script identifier. 71 | */ 72 | void SetID(int value); 73 | 74 | /** 75 | * @return Script actions. 76 | */ 77 | std::vector& GetActions(); 78 | }; 79 | #endif //GXDLMSSCRIPT_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSMd5.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSMD5_H 36 | #define GXDLMSMD5_H 37 | 38 | #include "GXBytebuffer.h" 39 | 40 | class CGXDLMSMD5 41 | { 42 | private: 43 | // Constants . 44 | #define S11 7 45 | #define S12 12 46 | #define S13 17 47 | #define S14 22 48 | #define S21 5 49 | #define S22 9 50 | #define S23 14 51 | #define S24 20 52 | #define S31 4 53 | #define S32 11 54 | #define S33 16 55 | #define S34 23 56 | #define S41 6 57 | #define S42 10 58 | #define S43 15 59 | #define S44 21 60 | static void Encode(unsigned char * output, unsigned int *input, unsigned int len); 61 | static void Transform(unsigned char* block, unsigned int *state); 62 | static int Update(unsigned char* data, unsigned int len, unsigned char* buffer, unsigned int* count, unsigned int* state); 63 | 64 | public: 65 | static int Encrypt(CGXByteBuffer& data, CGXByteBuffer& crypted); 66 | }; 67 | #endif //GXDLMSMD5_H -------------------------------------------------------------------------------- /PLCTool/PRIME/libprime/prime.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef _PRIME_PRIME_H 31 | #define _PRIME_PRIME_H 32 | 33 | #include "layer.h" 34 | #include "state.h" 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif /* __cplusplus */ 39 | 40 | uint32_t prime13_crc32b(const uint8_t *sna, const uint8_t *message, size_t len); 41 | uint8_t prime13_crc8b(const uint8_t *sna, const uint8_t *message, size_t len); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif /* __cplusplus */ 46 | 47 | #endif /* _PRIME_PRIME_H */ 48 | 49 | -------------------------------------------------------------------------------- /PLCTool/PRIME/spip/loop.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "spip.h" 31 | 32 | BOOL 33 | spip_iface_loop( 34 | spip_iface_t *iface, 35 | BOOL (*on_pdu) (spip_iface_t *iface, struct spip_pdu *pdu, void *userdata), 36 | void *userdata) 37 | { 38 | struct spip_pdu *pdu = NULL; 39 | BOOL ok; 40 | 41 | while (spip_iface_read(iface, &pdu)) { 42 | ok = (on_pdu)(iface, pdu, userdata); 43 | spip_iface_dispose(iface, pdu); 44 | if (!ok) 45 | return TRUE; 46 | } 47 | 48 | return FALSE; 49 | } 50 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXUnitCharge.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXUnitCharge.h" 36 | 37 | CGXUnitCharge::CGXUnitCharge() 38 | { 39 | } 40 | 41 | CGXChargePerUnitScaling& CGXUnitCharge::GetChargePerUnitScaling() { 42 | return m_ChargePerUnitScaling; 43 | } 44 | 45 | CGXCommodity& CGXUnitCharge::GetCommodity() { 46 | return m_Commodity; 47 | } 48 | 49 | std::vector CGXUnitCharge::GetChargeTables() 50 | { 51 | return m_ChargeTables; 52 | } 53 | 54 | std::string CGXUnitCharge::ToString() 55 | { 56 | std::string str = m_ChargePerUnitScaling.ToString(); 57 | str.append(", "); 58 | str.append(m_Commodity.ToString()); 59 | str.append(", {"); 60 | for (std::vector::iterator it = m_ChargeTables.begin(); it != m_ChargeTables.end(); ++it) 61 | { 62 | str.append(it->ToString()); 63 | str.append(", "); 64 | } 65 | str.append("}"); 66 | return str; 67 | } -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSPppSetupIPCPOption.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSPppSetupIPCPOption.h" 36 | #include 37 | 38 | PPP_SETUP_IPCP_OPTION_TYPE CGXDLMSPppSetupIPCPOption::GetType() 39 | { 40 | return m_Type; 41 | } 42 | void CGXDLMSPppSetupIPCPOption::SetType(PPP_SETUP_IPCP_OPTION_TYPE value) 43 | { 44 | m_Type = value; 45 | } 46 | 47 | int CGXDLMSPppSetupIPCPOption::GetLength() 48 | { 49 | return m_Length; 50 | } 51 | void CGXDLMSPppSetupIPCPOption::SetLength(int value) 52 | { 53 | m_Length = value; 54 | } 55 | 56 | CGXDLMSVariant& CGXDLMSPppSetupIPCPOption::GetData() 57 | { 58 | return m_Data; 59 | } 60 | void CGXDLMSPppSetupIPCPOption::SetData(CGXDLMSVariant& value) 61 | { 62 | m_Data = value; 63 | } 64 | 65 | std::string CGXDLMSPppSetupIPCPOption::ToString() 66 | { 67 | std::stringstream sb; 68 | sb << m_Type; 69 | sb << " "; 70 | sb << m_Length; 71 | return sb.str(); 72 | } -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSPppSetupLcpOption.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSPppSetupLcpOption.h" 36 | #include 37 | 38 | PPP_SETUP_LCP_OPTION_TYPE CGXDLMSPppSetupLcpOption::GetType() 39 | { 40 | return m_Type; 41 | } 42 | void CGXDLMSPppSetupLcpOption::SetType(PPP_SETUP_LCP_OPTION_TYPE value) 43 | { 44 | m_Type = value; 45 | } 46 | 47 | int CGXDLMSPppSetupLcpOption::GetLength() 48 | { 49 | return m_Length; 50 | } 51 | 52 | void CGXDLMSPppSetupLcpOption::SetLength(int value) 53 | { 54 | m_Length = value; 55 | } 56 | 57 | CGXDLMSVariant& CGXDLMSPppSetupLcpOption::GetData() 58 | { 59 | return m_Data; 60 | } 61 | 62 | void CGXDLMSPppSetupLcpOption::SetData(CGXDLMSVariant& value) 63 | { 64 | m_Data = value; 65 | } 66 | 67 | std::string CGXDLMSPppSetupLcpOption::ToString() 68 | { 69 | std::stringstream sb; 70 | sb << m_Type; 71 | sb << " "; 72 | sb << m_Length; 73 | return sb.str(); 74 | } -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXTokenGatewayConfiguration.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXTokenGatewayConfiguration.h" 36 | #include "../include/GXHelpers.h" 37 | 38 | CGXTokenGatewayConfiguration::CGXTokenGatewayConfiguration() 39 | { 40 | }; 41 | 42 | std::string& CGXTokenGatewayConfiguration::GetCreditReference() { 43 | return m_CreditReference; 44 | } 45 | 46 | void CGXTokenGatewayConfiguration::SetCreditReference(std::string& value) { 47 | m_CreditReference = value; 48 | } 49 | 50 | unsigned char CGXTokenGatewayConfiguration::GetTokenProportion() { 51 | return m_TokenProportion; 52 | } 53 | 54 | void CGXTokenGatewayConfiguration::SetTokenProportion(unsigned char value) { 55 | m_TokenProportion = value; 56 | } 57 | 58 | std::string CGXTokenGatewayConfiguration::ToString() 59 | { 60 | std::string str = m_CreditReference; 61 | str.append(", "); 62 | str.append(GXHelpers::IntToString(m_TokenProportion)); 63 | return str; 64 | } -------------------------------------------------------------------------------- /PLCTool/Types/dlms/AcseApdu.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef ACSEAPDU_H 31 | #define ACSEAPDU_H 32 | 33 | #include "DlmsMessageType.h" 34 | 35 | namespace PLCTool 36 | { 37 | /** 38 | * @brief The AcseApdu class 39 | * Base class for ACSE APDU DLMS messages. 40 | * 41 | * More info on DLMS messages can be found on the DLMS Green Book: 42 | * https://www.dlms.com/files/Green-Book-Ed-83-Excerpt.pdf 43 | */ 44 | class AcseApdu : DlmsMessageType 45 | { 46 | public: 47 | virtual ~AcseApdu(){}; 48 | }; 49 | } // namespace PLCTool 50 | 51 | #endif // ACSEAPDU_H 52 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/XDlmsApdu.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef XDLMSAPDU_H 31 | #define XDLMSAPDU_H 32 | 33 | #include "DlmsMessageType.h" 34 | 35 | namespace PLCTool 36 | { 37 | /** 38 | * @brief The XDlmsApdu class 39 | * Base class for xDLMS messages. 40 | * 41 | * More info on DLMS messages can be found on the DLMS Green Book: 42 | * https://www.dlms.com/files/Green-Book-Ed-83-Excerpt.pdf 43 | */ 44 | class XDlmsApdu : public DlmsMessageType 45 | { 46 | public: 47 | virtual ~XDlmsApdu(){}; 48 | }; 49 | } // namespace PLCTool 50 | 51 | #endif // XDLMSAPDU_H 52 | -------------------------------------------------------------------------------- /PLCTool/Ui/LoadingStatusDialog.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef LOADINGSTATUSDIALOG_H 31 | #define LOADINGSTATUSDIALOG_H 32 | 33 | #include 34 | 35 | namespace Ui { 36 | class LoadingStatusDialog; 37 | } 38 | 39 | class LoadingStatusDialog : public QDialog 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | explicit LoadingStatusDialog(QWidget *parent = 0); 45 | ~LoadingStatusDialog(); 46 | 47 | void setStatus(QString); 48 | void setLimits(unsigned int curr, unsigned int max); 49 | 50 | private: 51 | Ui::LoadingStatusDialog *ui; 52 | }; 53 | 54 | #endif // LOADINGSTATUSDIALOG_H 55 | -------------------------------------------------------------------------------- /PLCTool/Ui/ModemDialog.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef MODEMDIALOG_H 31 | #define MODEMDIALOG_H 32 | 33 | #include 34 | 35 | namespace Ui { 36 | class ModemDialog; 37 | } 38 | 39 | class ModemDialog : public QDialog 40 | { 41 | Q_OBJECT 42 | 43 | void connectAll(void); 44 | 45 | public: 46 | explicit ModemDialog(QWidget *parent = 0); 47 | ~ModemDialog(); 48 | 49 | QString path(void) const; 50 | int baud(void) const; 51 | 52 | public slots: 53 | void onBrowse(void); 54 | 55 | private: 56 | Ui::ModemDialog *ui; 57 | }; 58 | 59 | #endif // MODEMDIALOG_H 60 | -------------------------------------------------------------------------------- /PLCTool/Ui/TranslatorUI.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef TRANSLATOR_H 31 | #define TRANSLATOR_H 32 | 33 | #include 34 | 35 | namespace Ui { 36 | class Translator; 37 | } 38 | 39 | class XMLHighlighter; 40 | 41 | class TranslatorUI : public QWidget 42 | { 43 | Q_OBJECT 44 | 45 | XMLHighlighter *highlighter = nullptr; 46 | void connectAll(void); 47 | 48 | public: 49 | explicit TranslatorUI(QWidget *parent = 0); 50 | ~TranslatorUI(); 51 | 52 | public slots: 53 | void onPduToXml(void); 54 | 55 | private: 56 | Ui::Translator *ui; 57 | }; 58 | 59 | #endif // TRANSLATOR_H 60 | -------------------------------------------------------------------------------- /PLCTool/Attacks/Attack.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "Attack.h" 31 | 32 | #include 33 | #include 34 | 35 | using namespace PLCTool; 36 | 37 | Attack::Attack(QString const attackName, PrimeAdapter *adapter, QObject *parent) 38 | : QObject(parent), attackName(attackName), adapter(adapter) 39 | { 40 | } 41 | 42 | void 43 | Attack::onStart() 44 | { 45 | emit attackStarted(); 46 | } 47 | 48 | void 49 | Attack::onCancel() 50 | { 51 | emit attackCancelled(); 52 | } 53 | 54 | void 55 | Attack::onEnd() 56 | { 57 | emit attackEnded(); 58 | } 59 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSSpecialDay.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSSpecialDay.h" 36 | #include 37 | 38 | int CGXDLMSSpecialDay::GetIndex() 39 | { 40 | return m_Index; 41 | } 42 | void CGXDLMSSpecialDay::SetIndex(int value) 43 | { 44 | m_Index = value; 45 | } 46 | 47 | CGXDate& CGXDLMSSpecialDay::GetDate() 48 | { 49 | return m_Date; 50 | } 51 | 52 | void CGXDLMSSpecialDay::SetDate(CGXDate& value) 53 | { 54 | m_Date = value; 55 | } 56 | 57 | void CGXDLMSSpecialDay::SetDate(CGXDateTime& value) 58 | { 59 | m_Date = value; 60 | } 61 | 62 | int CGXDLMSSpecialDay::GetDayId() 63 | { 64 | return m_DayId; 65 | } 66 | void CGXDLMSSpecialDay::SetDayId(int value) 67 | { 68 | m_DayId = value; 69 | } 70 | 71 | std::string CGXDLMSSpecialDay::ToString() 72 | { 73 | std::stringstream sb; 74 | sb << m_Index; 75 | sb << " "; 76 | sb << m_Date.ToString().c_str(); 77 | sb << " "; 78 | sb << m_DayId; 79 | return sb.str(); 80 | } -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSDayProfile.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSDAYPROFILE_H 36 | #define GXDLMSDAYPROFILE_H 37 | 38 | #include 39 | #include "GXDLMSDayProfileAction.h" 40 | 41 | class CGXDLMSDayProfile 42 | { 43 | short m_DayId; 44 | std::vector m_DaySchedules; 45 | public: 46 | /** 47 | Constructor. 48 | */ 49 | CGXDLMSDayProfile(); 50 | 51 | /** 52 | Constructor. 53 | */ 54 | CGXDLMSDayProfile(short dayId, std::vector& schedules); 55 | 56 | //Destructor. 57 | ~CGXDLMSDayProfile(); 58 | 59 | 60 | /** 61 | User defined identifier, identifying the currentday_profile. 62 | */ 63 | short GetDayId(); 64 | void SetDayId(short value); 65 | 66 | std::vector& GetDaySchedules(); 67 | void SetDaySchedules(std::vector& value); 68 | std::string ToString(); 69 | }; 70 | 71 | #endif //GXDLMSDAYPROFILE_H 72 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSCaptureObject.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSVariant.h" 36 | #include "../include/GXDLMSClient.h" 37 | #include "../include/GXDLMSCaptureObject.h" 38 | 39 | // Constructor. 40 | CGXDLMSCaptureObject::CGXDLMSCaptureObject() 41 | { 42 | 43 | } 44 | 45 | // Constructor. 46 | CGXDLMSCaptureObject::CGXDLMSCaptureObject(int attributeIndex, int dataIndex) 47 | { 48 | m_AttributeIndex = attributeIndex; 49 | m_DataIndex = dataIndex; 50 | } 51 | 52 | // Index of DLMS object in the profile generic table 53 | int CGXDLMSCaptureObject::GetAttributeIndex() 54 | { 55 | return m_AttributeIndex; 56 | } 57 | void CGXDLMSCaptureObject::SetAttributeIndex(int value) 58 | { 59 | m_AttributeIndex = value; 60 | } 61 | 62 | // Data index of DLMS object in the profile generic table. 63 | int CGXDLMSCaptureObject::GetDataIndex() 64 | { 65 | return m_DataIndex; 66 | } 67 | void CGXDLMSCaptureObject::SetDataIndex(int value) 68 | { 69 | m_DataIndex = value; 70 | } -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXBitString.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXBIT_STRING_H 36 | #define GXBIT_STRING_H 37 | 38 | #include 39 | /** 40 | * Date object. Time part is ignored. 41 | */ 42 | class CGXBitString 43 | { 44 | private: 45 | std::string m_Value; 46 | //Convert bit string to Integer. 47 | int ToInteger(int& value, unsigned char maxSize); 48 | public: 49 | //Constructor. 50 | CGXBitString(); 51 | 52 | //Constructor. 53 | CGXBitString(std::string value); 54 | 55 | //Convert bit string to string. 56 | std::string& ToString(); 57 | 58 | //Convert bit string to Integer. 59 | int ToInteger(int& value); 60 | 61 | //Convert bit string to byte. 62 | int ToByte(unsigned char& value); 63 | 64 | // Convert integer value to BitString. 65 | // value : Value to convert. 66 | // count: Amount of bits. 67 | // returns: Bitstring. 68 | static std::string ToBitString(unsigned int value, unsigned int count); 69 | }; 70 | #endif //GXBIT_STRING_H -------------------------------------------------------------------------------- /PLCTool/Types/ber/BerContents.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef BERCONTENTS_H 31 | #define BERCONTENTS_H 32 | 33 | #include 34 | 35 | namespace PLCTool 36 | { 37 | /** 38 | * @brief The BerContents class 39 | * Deprecated class. Its use is not recommended. 40 | */ 41 | class BerContents 42 | { 43 | public: 44 | static std::vector sanitizeBERContentsBytes( 45 | std::vector bytes, 46 | uint64_t length); 47 | static std::vector sanitizeBERIndefiniteContentsBytes( 48 | std::vector bytes); 49 | }; 50 | } // namespace PLCTool 51 | 52 | #endif // BERCONTENTS_H 53 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/DlmsMessageType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef DLMSMESSAGETYPE_H 31 | #define DLMSMESSAGETYPE_H 32 | 33 | #include 34 | 35 | #include 36 | 37 | namespace PLCTool 38 | { 39 | /** 40 | * @brief The DlmsMessageType class 41 | * General class to group every DLMS message type. The derived classes are 42 | * specified in ASN.1 notation. 43 | * 44 | * More info on ASN.1 notation can be found here: 45 | * https://luca.ntop.org/Teaching/Appunti/asn1.html 46 | */ 47 | class DlmsMessageType 48 | { 49 | public: 50 | virtual ~DlmsMessageType(){}; 51 | }; 52 | } // namespace PLCTool 53 | 54 | #endif // DLMSMESSAGETYPE_H 55 | -------------------------------------------------------------------------------- /PLCTool/Types/general/Serializable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef SERIALIZABLE_H 31 | #define SERIALIZABLE_H 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | namespace PLCTool 39 | { 40 | /** 41 | * @brief The Serializable class 42 | * Interface to implement a type that can be accessed as a byte string. 43 | */ 44 | class Serializable 45 | { 46 | public: 47 | virtual ~Serializable(){}; 48 | 49 | virtual std::vector getBytes() = 0; 50 | virtual void setBytes(std::vector bytes) = 0; 51 | virtual size_t getSize() = 0; 52 | }; 53 | } // namespace PLCTool 54 | 55 | #endif // SERIALIZABLE_H 56 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSEmergencyProfile.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSVariant.h" 36 | #include "../include/GXDLMSClient.h" 37 | #include "../include/GXDLMSEmergencyProfile.h" 38 | #include 39 | 40 | int CGXDLMSEmergencyProfile::GetID() 41 | { 42 | return m_ID; 43 | } 44 | void CGXDLMSEmergencyProfile::SetID(int value) 45 | { 46 | m_ID = value; 47 | } 48 | CGXDateTime& CGXDLMSEmergencyProfile::GetActivationTime() 49 | { 50 | return m_ActivationTime; 51 | } 52 | void CGXDLMSEmergencyProfile::SetActivationTime(CGXDateTime value) 53 | { 54 | m_ActivationTime = value; 55 | } 56 | int CGXDLMSEmergencyProfile::GetDuration() 57 | { 58 | return m_Duration; 59 | } 60 | void CGXDLMSEmergencyProfile::SetDuration(int value) 61 | { 62 | m_Duration = value; 63 | } 64 | 65 | std::string CGXDLMSEmergencyProfile::ToString() 66 | { 67 | std::stringstream sb; 68 | sb << m_ID; 69 | sb << " "; 70 | sb << m_ActivationTime.ToString().c_str(); 71 | sb << " "; 72 | sb << m_Duration; 73 | return sb.str(); 74 | } -------------------------------------------------------------------------------- /PLCTool/Ui/XMLHighlighter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef XMLHIGHLIGHTER_H 31 | #define XMLHIGHLIGHTER_H 32 | 33 | #include 34 | 35 | class XMLHighlighter : public QSyntaxHighlighter 36 | { 37 | struct HighlightingRule 38 | { 39 | QRegExp pattern; 40 | QTextCharFormat format; 41 | }; 42 | 43 | QVector highlightingRules; 44 | 45 | QTextCharFormat valueFormat; 46 | QRegExp valueStartExpression; 47 | QRegExp valueEndExpression; 48 | 49 | void highlightBlock(const QString & text); 50 | 51 | public: 52 | XMLHighlighter(QTextDocument *parent); 53 | virtual ~XMLHighlighter(); 54 | 55 | }; 56 | 57 | #endif // XMLHIGHLIGHTER_H 58 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/DataInteger.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef DATAINTEGER_H 31 | #define DATAINTEGER_H 32 | 33 | #include "Data.h" 34 | 35 | namespace PLCTool 36 | { 37 | class DataInteger : public Data 38 | { 39 | int8_t value; 40 | 41 | public: 42 | DataInteger() : DataInteger(0){}; 43 | DataInteger(int8_t value) : value(value){}; 44 | 45 | int8_t getValue() const; 46 | void setValue(int8_t value); 47 | 48 | std::vector getBytes() override; 49 | void setBytes(std::vector bytes) override; 50 | size_t getSize() override; 51 | 52 | Data *clone() const override; 53 | }; 54 | } // namespace PLCTool 55 | 56 | #endif // DATAINTEGER_H 57 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSPppSetupIPCPOption.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSPPPSETUPIPCPOPTION_H 36 | #define GXDLMSPPPSETUPIPCPOPTION_H 37 | 38 | #include "IGXDLMSBase.h" 39 | #include "GXDLMSObject.h" 40 | #include "GXHelpers.h" 41 | 42 | enum PPP_SETUP_IPCP_OPTION_TYPE 43 | { 44 | PPP_SETUP_IPCP_OPTION_TYPE_IPCOMPRESSIONPROTOCOL = 2, 45 | PPP_SETUP_IPCP_OPTION_TYPE_PREFLOCALIP = 3, 46 | PPP_SETUP_IPCP_OPTION_TYPE_PREFPEERIP = 20, 47 | PPP_SETUP_IPCP_OPTION_TYPE_GAO = 21, 48 | PPP_SETUP_IPCP_OPTION_TYPE_USIP = 22 49 | }; 50 | 51 | class CGXDLMSPppSetupIPCPOption 52 | { 53 | friend class CGXDLMSPppSetup; 54 | PPP_SETUP_IPCP_OPTION_TYPE m_Type; 55 | int m_Length; 56 | CGXDLMSVariant m_Data; 57 | public: 58 | 59 | PPP_SETUP_IPCP_OPTION_TYPE GetType(); 60 | void SetType(PPP_SETUP_IPCP_OPTION_TYPE value); 61 | 62 | int GetLength(); 63 | void SetLength(int value); 64 | 65 | CGXDLMSVariant& GetData(); 66 | void SetData(CGXDLMSVariant& value); 67 | 68 | std::string ToString(); 69 | }; 70 | #endif //GXDLMSPPPSETUPIPCPOPTION_H 71 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSModemInitialisation.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSModemInitialisation.h" 36 | #include 37 | 38 | CGXDLMSModemInitialisation::CGXDLMSModemInitialisation() 39 | { 40 | m_Delay = 0; 41 | } 42 | 43 | std::string CGXDLMSModemInitialisation::GetRequest() 44 | { 45 | return m_Request; 46 | } 47 | void CGXDLMSModemInitialisation::SetRequest(std::string value) 48 | { 49 | m_Request = value; 50 | } 51 | 52 | std::string CGXDLMSModemInitialisation::GetResponse() 53 | { 54 | return m_Response; 55 | } 56 | void CGXDLMSModemInitialisation::SetResponse(std::string value) 57 | { 58 | m_Response = value; 59 | } 60 | 61 | int CGXDLMSModemInitialisation::GetDelay() 62 | { 63 | return m_Delay; 64 | } 65 | 66 | void CGXDLMSModemInitialisation::SetDelay(int value) 67 | { 68 | m_Delay = value; 69 | } 70 | 71 | std::string CGXDLMSModemInitialisation::ToString() 72 | { 73 | std::stringstream sb; 74 | sb << m_Request.c_str(); 75 | sb << " "; 76 | sb << m_Response.c_str(); 77 | sb << " "; 78 | sb << m_Delay; 79 | return sb.str(); 80 | } -------------------------------------------------------------------------------- /PLCTool/Topology/Concentrator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef _TOPOLOGY_CONCENTRATOR_H 31 | #define _TOPOLOGY_CONCENTRATOR_H 32 | 33 | #include "Hub.h" 34 | #include 35 | #include 36 | 37 | namespace PLCTool { 38 | class Switch; 39 | class Meter; 40 | class Concentrator : public Hub { 41 | 42 | std::list dummyHubList; 43 | std::map switchTable; 44 | 45 | Hub *allocateDummyHub(SubNetId); 46 | bool deleteDummyHub(Hub *); 47 | 48 | public: 49 | Concentrator(); 50 | Concentrator(SubNet *, NodeId id); 51 | ~Concentrator(); 52 | 53 | SubNet *getSubNetFor(SubNetId sid); 54 | void promote(Meter *, SubNetId); 55 | Hub *assertSwitch(SubNetId); 56 | }; 57 | } 58 | 59 | #endif // _TOPOLOGY_CONCENTRATOR_H 60 | 61 | -------------------------------------------------------------------------------- /PLCTool/Types/general/Bytevector.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef BYTEVECTOR_H 31 | #define BYTEVECTOR_H 32 | 33 | #include "Serializable.h" 34 | 35 | namespace PLCTool 36 | { 37 | /** 38 | * @brief The Bytevector class 39 | * Base class for types that are represented internally as a byte vector. 40 | */ 41 | class Bytevector : public Serializable 42 | { 43 | protected: 44 | std::vector bytes; 45 | 46 | public: 47 | Bytevector(){}; 48 | Bytevector(std::vector bytes) : bytes(bytes){}; 49 | virtual ~Bytevector(){}; 50 | 51 | std::vector getBytes() override; 52 | void setBytes(std::vector bytes) override; 53 | size_t getSize() override; 54 | }; 55 | } // namespace PLCTool 56 | 57 | #endif // BYTEVECTOR_H 58 | -------------------------------------------------------------------------------- /PLCTool/App/GXDLMSTranslatorInterface.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef GXDLMSTRANSLATORINTERFACE_H 31 | #define GXDLMSTRANSLATORINTERFACE_H 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class GXDLMSTranslatorInterface : public DLMSTranslator 38 | { 39 | CGXDLMSTranslator *p_impl = nullptr; 40 | 41 | public: 42 | GXDLMSTranslatorInterface(DLMS_TRANSLATOR_OUTPUT_TYPE output_type); 43 | ~GXDLMSTranslatorInterface(void); 44 | 45 | int PduToXml(std::vector &value, std::string &output) override; 46 | int XmlToPdu(std::string &xml, std::vector &output) override; 47 | void SetComments(bool value) override; 48 | }; 49 | 50 | #endif // GXDLMSTRANSLATORINTERFACE_H 51 | -------------------------------------------------------------------------------- /PLCTool/Ui/LoadingStatusDialog.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "PLCTool/Ui/LoadingStatusDialog.h" 31 | 32 | #include "ui_LoadingStatusDialog.h" 33 | 34 | LoadingStatusDialog::LoadingStatusDialog(QWidget *parent) 35 | : QDialog(parent), ui(new Ui::LoadingStatusDialog) 36 | { 37 | ui->setupUi(this); 38 | this->ui->progressBar->setTextVisible(true); 39 | } 40 | 41 | LoadingStatusDialog::~LoadingStatusDialog() 42 | { 43 | delete ui; 44 | } 45 | 46 | void 47 | LoadingStatusDialog::setStatus(QString text) 48 | { 49 | this->ui->statusLabel->setText(text); 50 | } 51 | 52 | void 53 | LoadingStatusDialog::setLimits(unsigned int curr, unsigned int max) 54 | { 55 | this->ui->progressBar->setMaximum(static_cast(max)); 56 | this->ui->progressBar->setValue(static_cast(curr)); 57 | } 58 | -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSLimits.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSLimits.h" 36 | 37 | CGXDLMSLimits::CGXDLMSLimits() 38 | { 39 | m_MaxInfoTX = DEFAULT_MAX_INFO_TX; 40 | m_MaxInfoRX = DEFAULT_MAX_INFO_RX; 41 | m_WindowSizeTX = DEFAULT_WINDOWS_SIZE_TX; 42 | m_WindowSizeRX = DEFAULT_WINDOWS_SIZE_RX; 43 | } 44 | 45 | unsigned short CGXDLMSLimits::GetMaxInfoTX() 46 | { 47 | return m_MaxInfoTX; 48 | } 49 | 50 | void CGXDLMSLimits::SetMaxInfoTX(unsigned short value) 51 | { 52 | m_MaxInfoTX = value; 53 | } 54 | 55 | unsigned short CGXDLMSLimits::GetMaxInfoRX() 56 | { 57 | return m_MaxInfoRX; 58 | } 59 | 60 | void CGXDLMSLimits::SetMaxInfoRX(unsigned short value) 61 | { 62 | m_MaxInfoRX = value; 63 | } 64 | 65 | unsigned char CGXDLMSLimits::GetWindowSizeTX() 66 | { 67 | return m_WindowSizeRX; 68 | } 69 | 70 | void CGXDLMSLimits::SetWindowSizeTX(unsigned char value) 71 | { 72 | m_WindowSizeRX = value; 73 | } 74 | 75 | unsigned char CGXDLMSLimits::GetWindowSizeRX() 76 | { 77 | return m_WindowSizeTX; 78 | } 79 | 80 | void CGXDLMSLimits::SetWindowSizeRX(unsigned char value) 81 | { 82 | m_WindowSizeTX = value; 83 | } 84 | -------------------------------------------------------------------------------- /PLCTool/Types/ber/BerInteger.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "BerInteger.h" 31 | 32 | using namespace PLCTool; 33 | 34 | BerInteger::BerInteger(int64_t value) 35 | { 36 | this->identifier = BerIdentifier(BER_UNIVERSAL_CLASS, false, BER_INTEGER); 37 | this->value = Integer(value); 38 | this->length = BerLength(this->value.getSize()); 39 | } 40 | 41 | int64_t 42 | BerInteger::getValue() const 43 | { 44 | return this->value.getValue(); 45 | } 46 | 47 | void 48 | BerInteger::setValue(int64_t value) 49 | { 50 | this->value.setValue(value); 51 | updateLength(); 52 | } 53 | 54 | std::vector 55 | BerInteger::getContents() 56 | { 57 | return getContentsLocal(); 58 | } 59 | 60 | std::vector 61 | BerInteger::getContentsLocal() 62 | { 63 | return this->value.getBytes(); 64 | } 65 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/MechanismName.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef MECHANISMNAME_H 31 | #define MECHANISMNAME_H 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | namespace PLCTool 39 | { 40 | class MechanismName : public BerData 41 | { 42 | DLMS_AUTHENTICATION value; 43 | 44 | public: 45 | MechanismName() : MechanismName(DLMS_AUTHENTICATION_LOW){}; 46 | MechanismName(DLMS_AUTHENTICATION value); 47 | 48 | DLMS_AUTHENTICATION getValue() const; 49 | void setValue(DLMS_AUTHENTICATION value); 50 | 51 | std::vector getContents() override; 52 | 53 | private: 54 | std::vector getContentsLocal(); 55 | }; 56 | } // namespace PLCTool 57 | 58 | #endif // MECHANISMNAME_H 59 | -------------------------------------------------------------------------------- /PLCTool/Attacks/AttackPluginLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef ATTACKPLUGINLOADER_H 31 | #define ATTACKPLUGINLOADER_H 32 | 33 | #include 34 | #include 35 | 36 | namespace PLCTool 37 | { 38 | class AttackPluginLoader : public QObject 39 | { 40 | Q_OBJECT 41 | 42 | QList attackPluginPath; 43 | 44 | public: 45 | AttackPluginLoader(QObject *parent = nullptr); 46 | 47 | bool loadPlugin(const QString &path); 48 | unsigned loadPluginDir(const QString &directoryPath); 49 | 50 | void addPluginSearchPath(const QString &path); 51 | void addPluginSearchPath(const std::vector &path); 52 | void addPluginSearchPathFromEnvironment(void); 53 | 54 | unsigned scanForPlugins(); 55 | }; 56 | } // namespace PLCTool 57 | #endif // ATTACKPLUGINLOADER_H 58 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/ReleaseRequestReason.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "ReleaseRequestReason.h" 31 | 32 | #include 33 | 34 | using namespace PLCTool; 35 | 36 | ReleaseRequestReason::ReleaseRequestReason(DLMS_RELEASE_REQUEST_REASON reason) 37 | { 38 | this->identifier = BerIdentifier(BER_CONTEXT_SPECIFIC_CLASS, false, 0x00); 39 | this->reason = reason; 40 | } 41 | 42 | DLMS_RELEASE_REQUEST_REASON 43 | ReleaseRequestReason::getReason() const 44 | { 45 | return reason; 46 | } 47 | 48 | void 49 | ReleaseRequestReason::setReason(DLMS_RELEASE_REQUEST_REASON newReason) 50 | { 51 | reason = newReason; 52 | } 53 | 54 | std::vector 55 | ReleaseRequestReason::getContents() 56 | { 57 | uint8_t value = this->reason; 58 | 59 | return BerInteger(value).getBytes(); 60 | } 61 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/ReleaseRequestReason.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef RELEASEREQUESTREASON_H 31 | #define RELEASEREQUESTREASON_H 32 | 33 | #include 34 | #include 35 | 36 | namespace PLCTool 37 | { 38 | class ReleaseRequestReason : public BerData 39 | { 40 | DLMS_RELEASE_REQUEST_REASON reason; 41 | 42 | public: 43 | ReleaseRequestReason() 44 | : ReleaseRequestReason(DLMS_RELEASE_REQUEST_REASON_NORMAL){}; 45 | ReleaseRequestReason(DLMS_RELEASE_REQUEST_REASON reason); 46 | 47 | std::vector getContents() override; 48 | 49 | DLMS_RELEASE_REQUEST_REASON getReason() const; 50 | void setReason(DLMS_RELEASE_REQUEST_REASON newReason); 51 | }; 52 | } // namespace PLCTool 53 | 54 | #endif // RELEASEREQUESTREASON_H 55 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXMacMulticastEntry.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXMACMULTICASTENTRY_H 36 | #define GXMACMULTICASTENTRY_H 37 | 38 | class CGXMacMulticastEntry 39 | { 40 | /* 41 | * LCID of multicast group 42 | */ 43 | char m_Id; 44 | /* 45 | * Number of child nodes. 46 | */ 47 | short m_Members; 48 | public: 49 | /* 50 | * Returns LCID of multicast group 51 | */ 52 | char GetId() 53 | { 54 | return m_Id; 55 | } 56 | 57 | /* 58 | * value: LCID of multicast group 59 | */ 60 | void SetId(char value) 61 | { 62 | m_Id = value; 63 | } 64 | 65 | /* 66 | * Returns Number of child nodes. 67 | */ 68 | short GetMembers() 69 | { 70 | return m_Members; 71 | } 72 | 73 | /* 74 | * value: Number of child nodes. 75 | */ 76 | void SetMembers(short value) 77 | { 78 | m_Members = value; 79 | } 80 | 81 | std::string ToString() 82 | { 83 | std::stringstream sb; 84 | sb << m_Id; 85 | sb << ' '; 86 | sb << m_Members; 87 | return sb.str(); 88 | } 89 | 90 | }; 91 | #endif //GXMACMULTICASTENTRY_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXStandardObisCode.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | #ifndef GXSTANDARDOBISCODE_H 35 | #define GXSTANDARDOBISCODE_H 36 | 37 | #include 38 | #include 39 | 40 | class CGXStandardObisCode 41 | { 42 | std::vector< std::string > m_OBIS; 43 | std::string m_DataType; 44 | std::string m_Interfaces; 45 | std::string m_Description; 46 | public: 47 | // Constructor. 48 | CGXStandardObisCode() 49 | { 50 | } 51 | 52 | // Constructor. 53 | CGXStandardObisCode(std::vector< std::string > obis, std::string& desc, 54 | std::string& interfaces, std::string& dataType); 55 | // OBIS code. 56 | std::vector< std::string >& GetOBIS(); 57 | 58 | void SetOBIS(std::vector< std::string >& value); 59 | 60 | // OBIS code description. 61 | std::string& GetDescription(); 62 | 63 | void SetDescription(std::string value); 64 | 65 | // Interfaces that are using this m_OBIS code. 66 | std::string& GetInterfaces(); 67 | void SetInterfaces(std::string value); 68 | 69 | // Standard data types. 70 | std::string& GetDataType(); 71 | void SetDataType(std::string value); 72 | }; 73 | #endif //GXSTANDARDOBISCODE_H -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXSNInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXSNINFO_H 36 | #define GXSNINFO_H 37 | 38 | class CGXDLMSObject; 39 | 40 | class CGXSNInfo 41 | { 42 | private: 43 | /** 44 | * Is attribute index or action index 45 | */ 46 | bool m_Action; 47 | 48 | /** 49 | * Attribute index. 50 | */ 51 | int m_Index; 52 | 53 | /** 54 | * COSEM object. 55 | */ 56 | CGXDLMSObject* m_Item; 57 | 58 | public: 59 | /** 60 | * Constructor. 61 | */ 62 | CGXSNInfo(); 63 | /** 64 | * @return The index 65 | */ 66 | int GetIndex(); 67 | 68 | /** 69 | * @param value 70 | * The index to set 71 | */ 72 | void SetIndex(int value); 73 | 74 | /** 75 | * @return Is action. 76 | */ 77 | bool IsAction(); 78 | 79 | /** 80 | * @param value 81 | * Is action. 82 | */ 83 | void SetAction(bool value); 84 | 85 | /** 86 | * @return The item 87 | */ 88 | CGXDLMSObject* GetItem(); 89 | 90 | /** 91 | * @param value 92 | * The item to set 93 | */ 94 | void SetItem(CGXDLMSObject* value); 95 | }; 96 | #endif //GXSNINFO_H -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXCommodity.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXCommodity.h" 36 | #include "../include/GXHelpers.h" 37 | 38 | CGXCommodity::CGXCommodity() 39 | { 40 | m_Type = DLMS_OBJECT_TYPE_NONE; 41 | memset(m_LogicalName, 0, 6); 42 | m_Index = 0; 43 | } 44 | 45 | DLMS_OBJECT_TYPE CGXCommodity::GetType() 46 | { 47 | return m_Type; 48 | } 49 | 50 | void CGXCommodity::SetType(DLMS_OBJECT_TYPE value) 51 | { 52 | m_Type = value; 53 | } 54 | 55 | unsigned char* CGXCommodity::GetLogicalName() 56 | { 57 | return m_LogicalName; 58 | } 59 | 60 | void CGXCommodity::SetLogicalName(unsigned char* value) 61 | { 62 | memcpy(m_LogicalName, value, 6); 63 | } 64 | 65 | unsigned char CGXCommodity::GetIndex() 66 | { 67 | return m_Index; 68 | } 69 | 70 | void CGXCommodity::SetIndex(unsigned char value) 71 | { 72 | m_Index = value; 73 | } 74 | 75 | std::string CGXCommodity::ToString() 76 | { 77 | std::string ln; 78 | std::string str = GXHelpers::IntToString(m_Type); 79 | str.append(" "); 80 | GXHelpers::GetLogicalName(m_LogicalName, ln); 81 | str.append(ln); 82 | str.append(" "); 83 | str = GXHelpers::IntToString(m_Index); 84 | return str; 85 | } -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSPushObject.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSPushObject.h" 36 | #include 37 | 38 | DLMS_OBJECT_TYPE CGXDLMSPushObject::GetType() 39 | { 40 | return m_Type; 41 | } 42 | void CGXDLMSPushObject::SetType(DLMS_OBJECT_TYPE value) 43 | { 44 | m_Type = value; 45 | } 46 | 47 | std::string CGXDLMSPushObject::GetLogicalName() 48 | { 49 | return m_LogicalName; 50 | } 51 | void CGXDLMSPushObject::SetLogicalName(std::string value) 52 | { 53 | m_LogicalName = value; 54 | } 55 | 56 | 57 | int CGXDLMSPushObject::GetAttributeIndex() 58 | { 59 | return m_AttributeIndex; 60 | } 61 | void CGXDLMSPushObject::SetAttributeIndex(int value) 62 | { 63 | m_AttributeIndex = value; 64 | } 65 | 66 | int CGXDLMSPushObject::GetDataIndex() 67 | { 68 | return m_DataIndex; 69 | } 70 | void CGXDLMSPushObject::SetDataIndex(int value) 71 | { 72 | m_DataIndex = value; 73 | } 74 | 75 | std::string CGXDLMSPushObject::ToString() 76 | { 77 | std::stringstream sb; 78 | sb << m_Type; 79 | sb << " "; 80 | sb << m_LogicalName.c_str(); 81 | sb << " "; 82 | sb << m_AttributeIndex; 83 | sb << " "; 84 | sb << m_DataIndex; 85 | return sb.str(); 86 | } -------------------------------------------------------------------------------- /PLCTool/Topology/AdapterEventListener.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef _TOPOLOGY_ADAPTEREVENTLISTENER_H 31 | #define _TOPOLOGY_ADAPTEREVENTLISTENER_H 32 | 33 | #include 34 | #include "SubNet.h" 35 | #include "Hub.h" 36 | 37 | namespace PLCTool { 38 | class Adapter; 39 | 40 | class AdapterEventListener { 41 | Adapter *adapter; 42 | 43 | public: 44 | virtual ~AdapterEventListener(); 45 | 46 | void setAdapter(Adapter *); 47 | virtual void onNodeUp(Node *) = 0; 48 | virtual void onNodeUpdated(Node *) = 0; 49 | virtual void onNodeDown(Node *) = 0; 50 | virtual void onHubAnnounce(Hub *) = 0; 51 | virtual void onLinkFrame(std::vector const &) = 0; 52 | virtual void onNodeFrame(Node *, Node *, std::vector const &) = 0; 53 | }; 54 | } 55 | 56 | #endif // _TOPOLOGY_ADAPTEREVENTLISTENER_H 57 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXCommodity.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef CGXCOMMODITY_H 36 | #define CGXCOMMODITY_H 37 | 38 | #include "enums.h" 39 | 40 | /** 41 | Online help: 42 | http://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSCharge 43 | */ 44 | class CGXCommodity 45 | { 46 | DLMS_OBJECT_TYPE m_Type; 47 | unsigned char m_LogicalName[6]; 48 | unsigned char m_Index; 49 | public: 50 | // Constructor. 51 | CGXCommodity(); 52 | 53 | /** 54 | * @return Object type. 55 | */ 56 | DLMS_OBJECT_TYPE GetType(); 57 | 58 | /** 59 | * @param value 60 | * Object type. 61 | */ 62 | void SetType(DLMS_OBJECT_TYPE value); 63 | 64 | /** 65 | * @return Attribute index. 66 | */ 67 | unsigned char* GetLogicalName(); 68 | 69 | /** 70 | * @param value 71 | * Attribute index. 72 | */ 73 | void SetLogicalName(unsigned char* value); 74 | 75 | /** 76 | * @return Attribute index. 77 | */ 78 | unsigned char GetIndex(); 79 | 80 | /** 81 | * @param value 82 | * Attribute index. 83 | */ 84 | void SetIndex(unsigned char value); 85 | 86 | std::string ToString(); 87 | }; 88 | #endif //CGXCOMMODITY_H -------------------------------------------------------------------------------- /PLCTool/gurux/src/GXDLMSObjectDefinition.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #include "../include/GXDLMSObjectDefinition.h" 36 | #include 37 | #include "../include/GXDLMSConverter.h" 38 | 39 | CGXDLMSObjectDefinition::CGXDLMSObjectDefinition() 40 | { 41 | m_ObjectType = DLMS_OBJECT_TYPE_NONE; 42 | } 43 | 44 | /* 45 | * Constructor 46 | */ 47 | CGXDLMSObjectDefinition::CGXDLMSObjectDefinition(DLMS_OBJECT_TYPE classId, std::string logicalName) 48 | { 49 | m_ObjectType = classId; 50 | m_LogicalName = logicalName; 51 | } 52 | 53 | std::string CGXDLMSObjectDefinition::ToString() 54 | { 55 | std::stringstream sb; 56 | sb << CGXDLMSConverter::ToString(m_ObjectType); 57 | sb << " "; 58 | sb << m_LogicalName.c_str(); 59 | return sb.str(); 60 | } 61 | 62 | DLMS_OBJECT_TYPE CGXDLMSObjectDefinition::GetObjectType() 63 | { 64 | return m_ObjectType; 65 | } 66 | 67 | void CGXDLMSObjectDefinition::SetObjectType(DLMS_OBJECT_TYPE value) 68 | { 69 | m_ObjectType = value; 70 | } 71 | 72 | std::string CGXDLMSObjectDefinition::GetLogicalName() 73 | { 74 | return m_LogicalName; 75 | } 76 | void CGXDLMSObjectDefinition::SetLogicalName(std::string value) 77 | { 78 | m_LogicalName = value; 79 | } 80 | -------------------------------------------------------------------------------- /PLCTool/Types/ber/BerBoolean.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "BerBoolean.h" 31 | 32 | using namespace PLCTool; 33 | 34 | BerBoolean::BerBoolean(bool value) 35 | { 36 | this->identifier = BerIdentifier(BER_UNIVERSAL_CLASS, false, BER_BOOLEAN); 37 | this->value = value; 38 | this->length = BerLength(1); 39 | } 40 | 41 | bool 42 | BerBoolean::getValue() const 43 | { 44 | return this->value; 45 | } 46 | 47 | void 48 | BerBoolean::setValue(bool value) 49 | { 50 | this->value = value; 51 | } 52 | 53 | std::vector 54 | BerBoolean::getContents() 55 | { 56 | return getContentsLocal(); 57 | } 58 | 59 | std::vector 60 | BerBoolean::getContentsLocal() 61 | { 62 | std::vector bytes; 63 | 64 | if (this->value) 65 | bytes.push_back(0xff); 66 | else 67 | bytes.push_back(0x00); 68 | 69 | return bytes; 70 | } 71 | -------------------------------------------------------------------------------- /PLCTool/Types/dlms/ActionRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef ACTIONREQUEST_H 31 | #define ACTIONREQUEST_H 32 | 33 | #include 34 | 35 | #include "XDlmsApdu.h" 36 | 37 | namespace PLCTool 38 | { 39 | /** 40 | * @brief The ActionRequest class 41 | * Base class for action request DLMS messages. 42 | * 43 | * More info on DLMS messages can be found on the DLMS Green Book: 44 | * https://www.dlms.com/files/Green-Book-Ed-83-Excerpt.pdf 45 | */ 46 | class ActionRequest : public XDlmsApdu, public Serializable 47 | { 48 | public: 49 | virtual ~ActionRequest(){}; 50 | 51 | std::vector getBytes() override; 52 | void setBytes(std::vector bytes) override; 53 | size_t getSize() override; 54 | }; 55 | } // namespace PLCTool 56 | 57 | #endif // ACTIONREQUEST_H 58 | -------------------------------------------------------------------------------- /PLCTool/Attacks/AttackFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, Tarlogic Security SL 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 3. Neither the name of copyright holders nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software 15 | // without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE 21 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | // POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #ifndef _ATTACKS_ATTACKFACTORY_H 31 | #define _ATTACKS_ATTACKFACTORY_H 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | namespace PLCTool 39 | { 40 | class AttackFactory : public QObject 41 | { 42 | Q_OBJECT 43 | 44 | protected: 45 | QString const attackName; 46 | 47 | public: 48 | AttackFactory(QString const attackName, QObject *parent = nullptr); 49 | virtual ~AttackFactory(){}; 50 | 51 | virtual QString getAttackName(void) const; 52 | 53 | virtual Attack *getAttack(StringParams const ¶ms, PrimeAdapter *adapter) 54 | const = 0; 55 | virtual QList getAttackParamList(void) const = 0; 56 | }; 57 | } // namespace PLCTool 58 | 59 | #endif // _PRIME_ATTACKFACTORY_H 60 | -------------------------------------------------------------------------------- /PLCTool/gurux/include/GXDLMSSeasonProfile.h: -------------------------------------------------------------------------------- 1 | // 2 | // -------------------------------------------------------------------------- 3 | // Gurux Ltd 4 | // 5 | // 6 | // 7 | // Filename: $HeadURL$ 8 | // 9 | // Version: $Revision$, 10 | // $Date$ 11 | // $Author$ 12 | // 13 | // Copyright (c) Gurux Ltd 14 | // 15 | //--------------------------------------------------------------------------- 16 | // 17 | // DESCRIPTION 18 | // 19 | // This file is a part of Gurux Device Framework. 20 | // 21 | // Gurux Device Framework is Open Source software; you can redistribute it 22 | // and/or modify it under the terms of the GNU General Public License 23 | // as published by the Free Software Foundation; version 2 of the License. 24 | // Gurux Device Framework is distributed in the hope that it will be useful, 25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | // See the GNU General Public License for more details. 28 | // 29 | // More information of Gurux products: http://www.gurux.org 30 | // 31 | // This code is licensed under the GNU General Public License v2. 32 | // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt 33 | //--------------------------------------------------------------------------- 34 | 35 | #ifndef GXDLMSSEASONPROFILE_H 36 | #define GXDLMSSEASONPROFILE_H 37 | 38 | #include "GXDateTime.h" 39 | #include "GXBytebuffer.h" 40 | 41 | class CGXDLMSSeasonProfile 42 | { 43 | CGXByteBuffer m_Name; 44 | CGXDateTime m_Start; 45 | CGXByteBuffer m_WeekName; 46 | public: 47 | /** 48 | Constructor. 49 | */ 50 | CGXDLMSSeasonProfile(); 51 | 52 | /** 53 | Constructor. 54 | */ 55 | CGXDLMSSeasonProfile(std::string name, CGXDateTime& start, std::string weekName); 56 | 57 | /** 58 | Constructor. 59 | */ 60 | CGXDLMSSeasonProfile(CGXByteBuffer& name, CGXDateTime& start, CGXByteBuffer weekName); 61 | 62 | /** 63 | Name of season profile. 64 | */ 65 | CGXByteBuffer& GetName(); 66 | void SetName(CGXByteBuffer& value); 67 | 68 | /** 69 | Season Profile start time. 70 | */ 71 | CGXDateTime& GetStart(); 72 | void SetStart(CGXDateTime value); 73 | 74 | /** 75 | Week name of season profile. 76 | */ 77 | CGXByteBuffer& GetWeekName(); 78 | void SetWeekName(CGXByteBuffer& value); 79 | 80 | std::string ToString(); 81 | }; 82 | 83 | #endif //GXDLMSSEASONPROFILE_H 84 | --------------------------------------------------------------------------------