Skip to content

Formatting and cleanup #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BaseObject.cpp
Original file line number Diff line number Diff line change
@@ -18,4 +18,4 @@ namespace eipScanner {
cip::CipUint BaseObject::getInstanceId() const {
return _instanceId;
}
}
}
9 changes: 3 additions & 6 deletions src/ConnectionManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by Aleksey Timin on 11/18/19.
//

#include <algorithm>
#include <cassert>
#include <cstdlib>
@@ -196,8 +197,7 @@ namespace eipScanner {
<< ". But the connection is removed from ConnectionManager anyway";
}

auto rc = _connectionMap.erase(ptr->_t2oNetworkConnectionId);
(void) rc;
[[maybe_unused]] auto rc = _connectionMap.erase(ptr->_t2oNetworkConnectionId);
assert(rc);
} else {
Logger(LogLevel::WARNING) << "Attempt to close an already closed connection";
@@ -207,8 +207,6 @@ namespace eipScanner {
void ConnectionManager::handleConnections(std::chrono::milliseconds timeout) {
std::vector<BaseSocket::SPtr > sockets;
std::transform(_socketMap.begin(), _socketMap.end(), std::back_inserter(sockets), [](auto entry) {
auto fd = entry.second->getSocketFd();
(void) fd;
return entry.second;
});

@@ -231,8 +229,7 @@ namespace eipScanner {
if (socket == _socketMap.end()) {
auto newSocket = std::make_shared<UDPBoundSocket>(endPoint);
_socketMap[endPoint] = newSocket;
newSocket->setBeginReceiveHandler([](sockets::BaseSocket& sock) {
(void) sock;
newSocket->setBeginReceiveHandler([](sockets::BaseSocket&) {
Logger(LogLevel::DEBUG) << "Received something";
});

3 changes: 2 additions & 1 deletion src/ConnectionManager.h
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#define EIPSCANNER_CONNECTIONMANAGER_H

#include <map>

#include "MessageRouter.h"
#include "IOConnection.h"
#include "cip/connectionManager/ConnectionParameters.h"
@@ -78,7 +79,7 @@ namespace eipScanner {
std::map<cip::CipUint, IOConnection::SPtr> _connectionMap;
std::map<sockets::EndPoint, std::shared_ptr<sockets::UDPBoundSocket>> _socketMap;

sockets::UDPBoundSocket::SPtr findOrCreateSocket(const sockets::EndPoint& endPoint);
sockets::UDPBoundSocket::SPtr findOrCreateSocket(const sockets::EndPoint& endPoint);
cip::CipUint _incarnationId;
};
}
7 changes: 4 additions & 3 deletions src/DiscoveryManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by Aleksey Timin on 12/17/19.
//

#include <system_error>

#include "eip/EncapsPacketFactory.h"
@@ -48,7 +49,7 @@ namespace eipScanner {
CommonPacket commonPacket;
commonPacket.expand(std::vector<uint8_t>(data.begin()+EncapsPacket::HEADER_SIZE, data.end()));

for (int i=0; i < commonPacket.getItems().size(); ++i) {
for (size_t i = 0; i < commonPacket.getItems().size(); ++i) {
Buffer buffer(commonPacket.getItems()[i].getData());
CipUint ignore;
sockets::EndPoint socketAddr("", 0);
@@ -65,7 +66,7 @@ namespace eipScanner {
>> revision >> status
>> serialNumber >> productName;

IdentityObject identityObject(i);
IdentityObject identityObject(static_cast<cip::CipUint>(i));
identityObject.setVendorId(vendorId);
identityObject.setDeviceType(deviceType);
identityObject.setProductCode(productCode);
@@ -87,7 +88,7 @@ namespace eipScanner {
}

sockets::BaseSocket::SPtr DiscoveryManager::makeSocket() const {
auto socket = std::make_shared<UDPSocket>(_broadCastAddress);
auto socket = std::make_shared<UDPSocket>(_broadCastAddress);
socket->setRecvTimeout(_receiveTimout);

int broadcast = 1;
4 changes: 3 additions & 1 deletion src/FileObject.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//
// Created by Aleksey Timin on 11/21/19.
//

#include <map>

#include "FileObject.h"
#include "fileObject/FileObjectState.h"
#include "utils/Buffer.h"
@@ -37,4 +39,4 @@ namespace eipScanner {
bool FileObject::handleTransfers(SessionInfoIf::SPtr si) {
return _state->transfer(si);
}
}
}
2 changes: 1 addition & 1 deletion src/FileObject.h
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ namespace eipScanner {
* @brief Gets the current state of the file
* @return
*/
std::unique_ptr<fileObject::FileObjectState>& getState();
std::unique_ptr<fileObject::FileObjectState>& getState();

/**
* @brief Initiates uploading the file from the EIP adapter
2 changes: 1 addition & 1 deletion src/IOConnection.cpp
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ namespace eipScanner {

_o2tTimer = 0;
_sendDataHandle(_outputData);
if (_o2tFixedSize && _outputData.size() != _o2tDataSize) {
if (_o2tFixedSize && _outputData.size() != _o2tDataSize) {
Logger(LogLevel::WARNING) << "Connection O2T_ID=" << _o2tNetworkConnectionId
<< " has fixed size " << _o2tDataSize << " bytes but " << _outputData.size()
<< " bytes are to send. Don't send this data.";
7 changes: 4 additions & 3 deletions src/IOConnection.h
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@

#include <memory>
#include <vector>

#include <functional>
#include "cip/Types.h"
#include "sockets/UDPSocket.h"
@@ -91,9 +92,9 @@ namespace eipScanner {
cip::CipUdint _serialNumber;

cip::CipUsint _transportTypeTrigger;
cip::CipBool _o2tRealTimeFormat;
cip::CipBool _t2oRealTimeFormat;
cip::CipUint _sequenceValueCount;
cip::CipBool _o2tRealTimeFormat;
cip::CipBool _t2oRealTimeFormat;
cip::CipUint _sequenceValueCount;
std::vector<uint8_t> _connectionPath;
cip::CipUint _originatorVendorId;
cip::CipUdint _originatorSerialNumber;
5 changes: 3 additions & 2 deletions src/MessageRouter.cpp
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
//

#include <cassert>

#include "eip/EncapsPacketFactory.h"
#include "utils/Buffer.h"
#include "MessageRouter.h"
@@ -22,9 +23,9 @@ namespace eipScanner {
using eip::EncapsPacket;
using eip::EncapsPacketFactory;

MessageRouter::MessageRouter(bool use_8_bit_path_segments)
MessageRouter::MessageRouter(bool use_8_bit_path_segments)
: _use_8_bit_path_segments(use_8_bit_path_segments)
{};
{}

MessageRouter::~MessageRouter() = default;

1 change: 1 addition & 0 deletions src/MessageRouter.h
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#define EIPSCANNER_MESSAGEROUTER_H

#include <memory>

#include "cip/EPath.h"
#include "cip/Services.h"
#include "cip/MessageRouterResponse.h"
2 changes: 2 additions & 0 deletions src/ParameterObject.h
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@

#include <cmath>
#include <stdexcept>

#include "MessageRouter.h"
#include "utils/Buffer.h"
#include "BaseObject.h"
@@ -382,4 +383,5 @@ class ParameterObject : public BaseObject {
};

}

#endif // EIPSCANNER_PARAMETEROBJECT_H
4 changes: 2 additions & 2 deletions src/SessionInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Created by Aleksey Timin on 11/16/19.
// Created by Aleksey Timin on 11/16/19.
//


@@ -76,4 +76,4 @@ namespace eipScanner {
return _socket.getRemoteEndPoint();
}

}
}
2 changes: 2 additions & 0 deletions src/SessionInfoIf.h
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#define EIPSCANNER_SESSIONINFOIF_H

#include <memory>

#include "eip/EncapsPacket.h"
#include "sockets/EndPoint.h"

@@ -39,4 +40,5 @@ namespace eipScanner {
virtual sockets::EndPoint getRemoteEndPoint() const = 0;
};
}

#endif //EIPSCANNER_SESSIONINFOIF_H
3 changes: 2 additions & 1 deletion src/cip/CipRevision.cpp
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
//

#include "CipRevision.h"

namespace eipScanner {
namespace cip {

@@ -33,4 +34,4 @@ namespace cip {
return _minorRevision;
}
}
}
}
1 change: 1 addition & 0 deletions src/cip/CipRevision.h
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#define EIPSCANNER_CIP_CIPREVISION_H

#include <string>

#include "Types.h"

namespace eipScanner {
3 changes: 2 additions & 1 deletion src/cip/CipString.cpp
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@
//

#include "CipString.h"

namespace eipScanner {
namespace cip {


}
}
}
1 change: 1 addition & 0 deletions src/cip/CipString.h
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
#include <iterator>
#include <string>
#include <vector>

#include "Types.h"

namespace eipScanner {
6 changes: 4 additions & 2 deletions src/cip/EPath.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
//
// Created by Aleksey Timin on 11/16/19.
//

#include <stdexcept>

#include "utils/Buffer.h"
#include "EPath.h"

namespace eipScanner {
namespace cip {
using utils::Buffer;

enum class EPathSegmentTypes : CipUsint {
enum class EPathSegmentTypes : CipUsint {
CLASS_8_BITS = 0x20,
CLASS_16_BITS = 0x21,
INSTANCE_8_BITS = 0x24,
@@ -132,7 +134,7 @@ namespace cip {
_attributeId = 0;
_size = 0;

for (int i = 0; i < data.size() && !buffer.empty(); ++i) {
for (size_t i = 0; i < data.size() && !buffer.empty(); ++i) {
EPathSegmentTypes segmentType;
CipUsint ignore = 0;
CipUsint byte;
5 changes: 3 additions & 2 deletions src/cip/EPath.h
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@
#ifndef EIPSCANNER_CIP_EPATH_H
#define EIPSCANNER_CIP_EPATH_H

#include <vector>
#include <string>
#include <cstdint>
#include <string>
#include <vector>

#include "Types.h"

@@ -38,4 +38,5 @@ namespace cip {
};
}
}

#endif // EIPSCANNER_CIP_EPATH_H
3 changes: 2 additions & 1 deletion src/cip/GeneralStatusCodes.h
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ namespace cip {
//! A connection related service failed along the connection path.
CONNECTION_FAILURE = 0x01,

//! Resources needed for the object to perform the requested service
//! Resources needed for the object to perform the requested service
//! were unavailable.
RESOURCE_UNAVAILABLE = 0x02,

@@ -168,4 +168,5 @@ namespace cip {

}
}

#endif //EIPSCANNER_CIP_GENERALSTATUSCODES_H
2 changes: 1 addition & 1 deletion src/cip/MessageRouterRequest.cpp
Original file line number Diff line number Diff line change
@@ -30,4 +30,4 @@ namespace cip {
return buffer.data();
}
}
}
}
1 change: 0 additions & 1 deletion src/cip/MessageRouterRequest.h
Original file line number Diff line number Diff line change
@@ -29,5 +29,4 @@ namespace cip {
}
}


#endif // EIPSCANNER_CIP_MESSAGEROUTERREQUEST_H
2 changes: 2 additions & 0 deletions src/cip/MessageRouterResponse.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//
// Created by Aleksey Timin on 11/16/19.
//

#include <stdexcept>

#include "MessageRouterResponse.h"
#include "utils/Buffer.h"
#include "utils/Logger.h"
1 change: 1 addition & 0 deletions src/cip/Types.h
Original file line number Diff line number Diff line change
@@ -67,4 +67,5 @@ namespace cip {
};
}
}

#endif //EIPSCANNER_CIP_TYPES_H
1 change: 1 addition & 0 deletions src/cip/connectionManager/ConnectionParameters.h
Original file line number Diff line number Diff line change
@@ -33,4 +33,5 @@ namespace connectionManager {
}
}
}

#endif //EIPSCANNER_CIP_CONNECTIONPARAMETERS_H
1 change: 1 addition & 0 deletions src/cip/connectionManager/ForwardCloseRequest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by Aleksey Timin on 11/19/19.
//

#include "ForwardCloseRequest.h"
#include "utils/Buffer.h"

2 changes: 2 additions & 0 deletions src/cip/connectionManager/ForwardCloseRequest.h
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#define EIPSCANNER_CIP_CONNECTIONMANAGER_FORWARDCLOSEREQUEST_H

#include <vector>

#include "ConnectionParameters.h"

namespace eipScanner {
@@ -31,4 +32,5 @@ namespace connectionManager {
}
}
}

#endif // EIPSCANNER_CIP_CONNECTIONMANAGER_FORWARDOPENREQUEST_H
6 changes: 3 additions & 3 deletions src/cip/connectionManager/ForwardOpenRequest.cpp
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@
// Created by Aleksey Timin on 11/18/19.
//

#include "ForwardOpenRequest.h"

#include <cassert>
#include <utility>
#include <assert.h>

#include "ForwardOpenRequest.h"
#include "utils/Buffer.h"

namespace eipScanner {
Loading