Просмотр исходного кода

Closes #90 renames IApp_* functions + minor improvements

Signed-off-by: Martin Melik Merkumians <melik-merkumians@acin.tuwien.ac.at>
Martin Melik Merkumians 8 лет назад
Родитель
Сommit
2a65e624f5

+ 1 - 1
source/src/cip/cipassembly.h

@@ -34,7 +34,7 @@ void ShutdownAssemblies(void);
 /** @brief notify an Assembly object that data has been received for it.
  *
  *  The data will be copied into the assembly objects attribute 3 and
- *  the application will be informed with the IApp_after_assembly_data_received function.
+ *  the application will be informed with the AfterAssemblyDataReceived function.
  *
  *  @param instance the assembly object instance for which the data was received
  *  @param data pointer to the data received

+ 2 - 2
source/src/cip/cipconnectionmanager.c

@@ -1568,11 +1568,11 @@ void CloseConnection(ConnectionObject *RESTRICT connection_object) {
   connection_object->state = kConnectionStateNonExistent;
   if ( 0x03 != (connection_object->transport_type_class_trigger & 0x03) ) {
     /* only close the UDP connection for not class 3 connections */
-    IApp_CloseSocket_udp(
+    CloseUdpSocket(
       connection_object->socket[kUdpCommuncationDirectionConsuming]);
     connection_object->socket[kUdpCommuncationDirectionConsuming] =
       kEipInvalidSocket;
-    IApp_CloseSocket_udp(
+    CloseUdpSocket(
       connection_object->socket[kUdpCommuncationDirectionProducing]);
     connection_object->socket[kUdpCommuncationDirectionProducing] =
       kEipInvalidSocket;

+ 2 - 2
source/src/cip/cipioconnection.c

@@ -973,13 +973,13 @@ EipStatus OpenCommunicationChannels(ConnectionObject *connection_object) {
 
 void CloseCommunicationChannelsAndRemoveFromActiveConnectionsList(
   ConnectionObject *connection_object) {
-  IApp_CloseSocket_udp(
+  CloseUdpSocket(
     connection_object->socket[kUdpCommuncationDirectionConsuming]);
 
   connection_object->socket[kUdpCommuncationDirectionConsuming] =
     kEipInvalidSocket;
 
-  IApp_CloseSocket_udp(
+  CloseUdpSocket(
     connection_object->socket[kUdpCommuncationDirectionProducing]);
 
   connection_object->socket[kUdpCommuncationDirectionProducing] =

+ 1 - 1
source/src/enet_encap/cpf.c

@@ -138,7 +138,7 @@ int NotifyConnectedCommonPacketFormat(EncapsulationData *received_data,
  */
 EipStatus CreateCommonPacketFormatStructure(
   const EipUint8 *data,
-  int data_length,
+  size_t data_length,
   CipCommonPacketFormatData *common_packet_format_data) {
 
   common_packet_format_data->address_info_item[0].type_id = 0;

+ 1 - 1
source/src/enet_encap/cpf.h

@@ -107,7 +107,7 @@ int NotifyConnectedCommonPacketFormat(EncapsulationData *received_data,
  */
 EipStatus CreateCommonPacketFormatStructure(
   const EipUint8 *data,
-  int data_length,
+  size_t data_length,
   CipCommonPacketFormatData *common_packet_format_data);
 
 /** @ingroup ENCAP

+ 3 - 3
source/src/enet_encap/encap.c

@@ -518,7 +518,7 @@ EipStatus HandleReceivedUnregisterSessionCommand(
            OPENER_NUMBER_OF_SUPPORTED_SESSIONS) ) {
     size_t i = receive_data->session_handle - 1;
     if (kEipInvalidSocket != g_registered_sessions[i]) {
-      IApp_CloseSocket_tcp(g_registered_sessions[i]);
+      CloseTcpSocket(g_registered_sessions[i]);
       g_registered_sessions[i] = kEipInvalidSocket;
       return kEipStatusOk;
     }
@@ -675,7 +675,7 @@ void CloseSession(int socket) {
   OPENER_TRACE_INFO("encap.c: Close session\n");
   for (size_t i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
     if (g_registered_sessions[i] == socket) {
-      IApp_CloseSocket_tcp(socket);
+      CloseTcpSocket(socket);
       g_registered_sessions[i] = kEipInvalidSocket;
       break;
     }
@@ -698,7 +698,7 @@ void EncapsulationShutDown(void) {
   OPENER_TRACE_INFO("encap.c: Encapsulation shutdown\n");
   for (size_t i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
     if (kEipInvalidSocket != g_registered_sessions[i]) {
-      IApp_CloseSocket_tcp(g_registered_sessions[i]);
+      CloseTcpSocket(g_registered_sessions[i]);
       g_registered_sessions[i] = kEipInvalidSocket;
     }
   }

+ 1 - 1
source/src/opener_api.h

@@ -297,7 +297,7 @@ int DecodeData(const EipUint8 cip_type,
  * In order to support a configuration assembly object it has to be created with
  * this function.
  * The notification on received configuration data is handled with the
- * IApp_after_receive function.
+ * AfterAssemblyDataReceived.
  */
 CipInstance *CreateAssemblyObject(const EipUint32 instance_number,
                                   EipByte *const data,

+ 11 - 16
source/src/ports/generic_networkhandler.c

@@ -238,11 +238,11 @@ EipStatus NetworkHandlerInitialize(void) {
   return kEipStatusOk;
 }
 
-void IApp_CloseSocket_udp(int socket_handle) {
+void CloseUdpSocket(int socket_handle) {
   CloseSocket(socket_handle);
 }
 
-void IApp_CloseSocket_tcp(int socket_handle) {
+void CloseTcpSocket(int socket_handle) {
   RemoveSocketTimerFromList(socket_handle);
   CloseSocket(socket_handle);
 }
@@ -359,7 +359,7 @@ EipStatus NetworkHandlerProcessOnce(void) {
         /* if it is still checked it is a TCP receive */
         if ( kEipStatusError == HandleDataOnTcpSocket(socket) ) /* if error */
         {
-          IApp_CloseSocket_tcp(socket);
+          CloseTcpSocket(socket);
           RemoveSession(socket); /* clean up session and close the socket */
         }
       }
@@ -396,14 +396,11 @@ EipStatus NetworkHandlerFinish(void) {
 
 void CheckAndHandleUdpGlobalBroadcastSocket(void) {
 
-  struct sockaddr_in from_address;
-  socklen_t from_address_length;
-
   /* see if this is an unsolicited inbound UDP message */
   if ( true ==
        CheckSocketSet(g_network_status.udp_global_broadcast_listener) ) {
-
-    from_address_length = sizeof(from_address);
+	  struct sockaddr_in from_address = {0};
+	  socklen_t from_address_length = sizeof(from_address);
 
     OPENER_TRACE_STATE(
       "networkhandler: unsolicited UDP message on EIP global broadcast socket\n");
@@ -456,13 +453,12 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
 
 void CheckAndHandleUdpUnicastSocket(void) {
 
-  struct sockaddr_in from_address;
-  socklen_t from_address_length;
 
   /* see if this is an unsolicited inbound UDP message */
   if ( true == CheckSocketSet(g_network_status.udp_unicast_listener) ) {
 
-    from_address_length = sizeof(from_address);
+  struct sockaddr_in from_address = {0};
+	  socklen_t from_address_length = sizeof(from_address);
 
     OPENER_TRACE_STATE(
       "networkhandler: unsolicited UDP message on EIP unicast socket\n");
@@ -823,8 +819,6 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
 }
 
 void CheckAndHandleConsumingUdpSockets(void) {
-  struct sockaddr_in from_address;
-  socklen_t from_address_length;
 
   ConnectionObject *connection_object_iterator = g_active_connection_list;
   ConnectionObject *current_connection_object = NULL;
@@ -842,7 +836,8 @@ void CheckAndHandleConsumingUdpSockets(void) {
               == CheckSocketSet(
                 current_connection_object->socket[
                   kUdpCommuncationDirectionConsuming]) ) ) {
-      from_address_length = sizeof(from_address);
+    	  struct sockaddr_in from_address = {0};
+    	socklen_t from_address_length = sizeof(from_address);
       int received_size = recvfrom(
         current_connection_object->socket[kUdpCommuncationDirectionConsuming],
         g_ethernet_communication_buffer, PC_OPENER_ETHERNET_BUFFER_SIZE, 0,
@@ -921,8 +916,8 @@ void CheckEncapsulationInactivity(int socket_handle) {
         socket_timer);
 
       if ( diff_milliseconds >=
-           (1000UL * (MilliSeconds)g_encapsulation_inactivity_timeout) ) {
-        IApp_CloseSocket_tcp(socket_handle);
+    		  (MilliSeconds) (1000UL * g_encapsulation_inactivity_timeout) ) {
+        CloseTcpSocket(socket_handle);
         RemoveSession(socket_handle);
       }
     }

+ 2 - 2
source/src/ports/generic_networkhandler.h

@@ -66,9 +66,9 @@ NetworkStatus g_network_status; /**< Global variable holding the current network
  */
 EipStatus NetworkHandlerInitialize(void);
 
-void IApp_CloseSocket_udp(int socket_handle);
+void CloseUdpSocket(int socket_handle);
 
-void IApp_CloseSocket_tcp(int socket_handle);
+void CloseTcpSocket(int socket_handle);
 
 
 /** @brief Initializes the network handler, shall be implemented by a port-specific networkhandler