|
|
@@ -274,7 +274,7 @@ void SkipEncapsulationHeader(ENIPMessage *const outgoing_message) {
|
|
|
outgoing_message->current_message_position += ENCAPSULATION_HEADER_LENGTH;
|
|
|
}
|
|
|
|
|
|
-void GenerateEncapsulationHeader(const EncapsulationData *const receive_data, const size_t command_specific_data_length, const size_t session_handle,
|
|
|
+void GenerateEncapsulationHeader(const EncapsulationData *const receive_data, const size_t command_specific_data_length, const CipSessionHandle session_handle,
|
|
|
const EncapsulationProtocolErrorCode encapsulation_protocol_status, ENIPMessage *const outgoing_message) {
|
|
|
AddIntToMessage(receive_data->command_code, outgoing_message);
|
|
|
AddIntToMessage(command_specific_data_length, outgoing_message);
|
|
|
@@ -416,7 +416,7 @@ void DetermineDelayTime(const EipByte *buffer_start, DelayedEncapsulationMessage
|
|
|
delayed_message_buffer->time_out = rand() % maximum_delay_time;
|
|
|
}
|
|
|
|
|
|
-void EncapsulateRegisterSessionCommandResponseMessage(const EncapsulationData *const receive_data, const size_t session_handle,
|
|
|
+void EncapsulateRegisterSessionCommandResponseMessage(const EncapsulationData *const receive_data, const CipSessionHandle session_handle,
|
|
|
const EncapsulationProtocolErrorCode encapsulation_protocol_status, ENIPMessage *const outgoing_message) {
|
|
|
|
|
|
/* Encapsulation header */
|
|
|
@@ -434,7 +434,7 @@ void EncapsulateRegisterSessionCommandResponseMessage(const EncapsulationData *c
|
|
|
*/
|
|
|
void HandleReceivedRegisterSessionCommand(int socket, const EncapsulationData *const receive_data, ENIPMessage *const outgoing_message) {
|
|
|
int session_index = 0;
|
|
|
- size_t session_handle = 0;
|
|
|
+ CipSessionHandle session_handle = 0;
|
|
|
EncapsulationProtocolErrorCode encapsulation_protocol_status = kEncapsulationProtocolSuccess;
|
|
|
|
|
|
EipUint16 protocol_version = GetUintFromMessage((const EipUint8** const ) &receive_data->current_communication_buffer_position);
|
|
|
@@ -443,7 +443,7 @@ void HandleReceivedRegisterSessionCommand(int socket, const EncapsulationData *c
|
|
|
/* check if requested protocol version is supported and the register session option flag is zero*/
|
|
|
if((0 < protocol_version) && (protocol_version <= kSupportedProtocolVersion) && (0 == option_flag)) { /*Option field should be zero*/
|
|
|
/* check if the socket has already a session open */
|
|
|
- for(size_t i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
+ for(unsigned int i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
if(g_registered_sessions[i] == socket) {
|
|
|
/* the socket has already registered a session this is not allowed*/
|
|
|
OPENER_TRACE_INFO(
|
|
|
@@ -467,7 +467,7 @@ void HandleReceivedRegisterSessionCommand(int socket, const EncapsulationData *c
|
|
|
SocketTimerSetSocket(socket_timer, socket);
|
|
|
SocketTimerSetLastUpdate(socket_timer, g_actual_time);
|
|
|
g_registered_sessions[session_index] = socket; /* store associated socket */
|
|
|
- session_handle = session_index + 1;
|
|
|
+ session_handle = (CipSessionHandle)(session_index + 1);
|
|
|
encapsulation_protocol_status = kEncapsulationProtocolSuccess;
|
|
|
}
|
|
|
}
|
|
|
@@ -490,7 +490,7 @@ EipStatus HandleReceivedUnregisterSessionCommand(const EncapsulationData *const
|
|
|
OPENER_TRACE_INFO("encap.c: Unregister Session Command\n");
|
|
|
if((0 < receive_data->session_handle) && (receive_data->session_handle <=
|
|
|
OPENER_NUMBER_OF_SUPPORTED_SESSIONS)) {
|
|
|
- size_t i = receive_data->session_handle - 1;
|
|
|
+ CipSessionHandle i = receive_data->session_handle - 1;
|
|
|
if(kEipInvalidSocket != g_registered_sessions[i]) {
|
|
|
CloseTcpSocket(g_registered_sessions[i]);
|
|
|
g_registered_sessions[i] = kEipInvalidSocket;
|
|
|
@@ -643,7 +643,7 @@ SessionStatus CheckRegisteredSessions(const EncapsulationData *const receive_dat
|
|
|
|
|
|
void CloseSessionBySessionHandle(const CipConnectionObject *const connection_object) {
|
|
|
OPENER_TRACE_INFO("encap.c: Close session by handle\n");
|
|
|
- size_t session_handle = connection_object->associated_encapsulation_session;
|
|
|
+ CipSessionHandle session_handle = connection_object->associated_encapsulation_session;
|
|
|
CloseTcpSocket(g_registered_sessions[session_handle - 1]);
|
|
|
g_registered_sessions[session_handle - 1] = kEipInvalidSocket;
|
|
|
OPENER_TRACE_INFO("encap.c: Close session by handle done\n");
|
|
|
@@ -651,7 +651,7 @@ void CloseSessionBySessionHandle(const CipConnectionObject *const connection_obj
|
|
|
|
|
|
void CloseSession(int socket) {
|
|
|
OPENER_TRACE_INFO("encap.c: Close session\n");
|
|
|
- for(size_t i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
+ for(unsigned int i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
if(g_registered_sessions[i] == socket) {
|
|
|
CloseTcpSocket(socket);
|
|
|
g_registered_sessions[i] = kEipInvalidSocket;
|
|
|
@@ -663,7 +663,7 @@ void CloseSession(int socket) {
|
|
|
|
|
|
void RemoveSession(const int socket) {
|
|
|
OPENER_TRACE_INFO("encap.c: Removing session\n");
|
|
|
- for(size_t i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
+ for(unsigned int i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
if(g_registered_sessions[i] == socket) {
|
|
|
g_registered_sessions[i] = kEipInvalidSocket;
|
|
|
CloseClass3ConnectionBasedOnSession(i + 1);
|
|
|
@@ -717,8 +717,8 @@ void CloseEncapsulationSessionBySockAddr(const CipConnectionObject *const connec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-size_t GetSessionFromSocket(const int socket_handle) {
|
|
|
- for(size_t i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
+CipSessionHandle GetSessionFromSocket(const int socket_handle) {
|
|
|
+ for(CipSessionHandle i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
|
|
|
if(socket_handle == g_registered_sessions[i]) {
|
|
|
return i;
|
|
|
}
|
|
|
@@ -726,7 +726,7 @@ size_t GetSessionFromSocket(const int socket_handle) {
|
|
|
return OPENER_NUMBER_OF_SUPPORTED_SESSIONS;
|
|
|
}
|
|
|
|
|
|
-void CloseClass3ConnectionBasedOnSession(size_t encapsulation_session_handle) {
|
|
|
+void CloseClass3ConnectionBasedOnSession(CipSessionHandle encapsulation_session_handle) {
|
|
|
DoublyLinkedListNode *node = connection_list.first;
|
|
|
while(NULL != node) {
|
|
|
CipConnectionObject *connection_object = node->data;
|