OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
generic_networkhandler.h File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "opener_api.h"
#include "typedefs.h"
#include "endianconv.h"
#include "cipconnectionmanager.h"
#include "networkhandler.h"
#include "appcontype.h"
#include "socket_timer.h"
Include dependency graph for generic_networkhandler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NetworkStatus
 Struct representing the current network status. More...
 

Functions

EipBool8 CheckSocketSet (int socket)
 check if the given socket is set in the read set More...
 
void CloseTcpSocket (int socket_handle)
 
void CloseUdpSocket (int socket_handle)
 
int GetMaxSocket (int socket1, int socket2, int socket3, int socket4)
 Returns the socket with the highest id. More...
 
EipStatus NetworkHandlerFinish (void)
 
EipStatus NetworkHandlerInitialize (void)
 The platform independent part of network handler initialization routine. More...
 
EipStatus NetworkHandlerProcessOnce (void)
 

Variables

MilliSeconds g_actual_time
 
int g_current_active_tcp_socket
 This variable holds the TCP socket the received to last explicit message. It is needed for opening point to point connection to determine the peer's address. More...
 
MilliSeconds g_last_time
 
NetworkStatus g_network_status
 
struct timeval g_time_value
 
SocketTimer g_timestamps [OPENER_NUMBER_OF_SUPPORTED_SESSIONS]
 
int highest_socket_handle
 
fd_set master_socket
 
fd_set read_socket
 

Function Documentation

EipBool8 CheckSocketSet ( int  socket)

check if the given socket is set in the read set

Parameters
socketThe socket to check
Returns
true if socket is set

Definition at line 278 of file generic_networkhandler.c.

References master_socket, OPENER_TRACE_INFO, and read_socket.

Referenced by CheckAndHandleConsumingUdpSockets(), CheckAndHandleTcpListenerSocket(), CheckAndHandleUdpGlobalBroadcastSocket(), CheckAndHandleUdpUnicastSocket(), and NetworkHandlerProcessOnce().

Here is the caller graph for this function:

void CloseTcpSocket ( int  socket_handle)

Definition at line 261 of file generic_networkhandler.c.

References CloseSocket(), and RemoveSocketTimerFromList().

Referenced by CheckEncapsulationInactivity(), CloseSession(), CloseSessionBySessionHandle(), EncapsulationShutDown(), HandleReceivedUnregisterSessionCommand(), and NetworkHandlerProcessOnce().

Here is the call graph for this function:

Here is the caller graph for this function:

void CloseUdpSocket ( int  socket_handle)

Definition at line 257 of file generic_networkhandler.c.

References CloseSocket().

Referenced by CloseCommunicationChannelsAndRemoveFromActiveConnectionsList(), and CloseConnection().

Here is the call graph for this function:

Here is the caller graph for this function:

int GetMaxSocket ( int  socket1,
int  socket2,
int  socket3,
int  socket4 
)

Returns the socket with the highest id.

Parameters
socket1First socket
socket2Second socket
socket3Third socket
socket4Fourth socket
Returns
Highest socket id from the provided sockets

Definition at line 1008 of file generic_networkhandler.c.

Referenced by NetworkHandlerInitialize().

Here is the caller graph for this function:

EipStatus NetworkHandlerFinish ( void  )

Definition at line 419 of file generic_networkhandler.c.

References CloseSocket(), g_network_status, kEipStatusOk, NetworkStatus::tcp_listener, NetworkStatus::udp_global_broadcast_listener, and NetworkStatus::udp_unicast_listener.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus NetworkHandlerInitialize ( void  )

The platform independent part of network handler initialization routine.

Initializes the network handler, shall be implemented by a port-specific networkhandler.

Returns
Returns the OpENer status after the initialization routine
EipStatus, if initialization failed EipError is returned

The platform independent part of network handler initialization routine.

Returns
EipStatus, if initialization failed EipError is returned

Definition at line 67 of file generic_networkhandler.c.

References NetworkStatus::elapsed_time, FreeErrorMessage(), g_last_time, g_network_status, g_timestamps, GetErrorMessage(), GetMaxSocket(), GetMilliSeconds(), GetSocketErrorNumber(), highest_socket_handle, kEipStatusError, kEipStatusOk, master_socket, MAX_NO_OF_TCP_SOCKETS, NetworkHandlerInitializePlatform(), OPENER_NUMBER_OF_SUPPORTED_SESSIONS, OPENER_TRACE_ERR, read_socket, SetSocketToNonBlocking(), cip_connection_object::socket, SocketTimerArrayInitialize(), NetworkStatus::tcp_listener, NetworkStatus::udp_global_broadcast_listener, and NetworkStatus::udp_unicast_listener.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus NetworkHandlerProcessOnce ( void  )

Definition at line 347 of file generic_networkhandler.c.

References CheckAndHandleConsumingUdpSockets(), CheckAndHandleTcpListenerSocket(), CheckAndHandleUdpGlobalBroadcastSocket(), CheckAndHandleUdpUnicastSocket(), CheckEncapsulationInactivity(), CheckSocketSet(), CloseTcpSocket(), NetworkStatus::elapsed_time, FreeErrorMessage(), g_actual_time, g_last_time, g_network_status, g_time_value, GetErrorMessage(), GetMilliSeconds(), GetSocketErrorNumber(), HandleDataOnTcpSocket(), highest_socket_handle, kEipStatusError, kEipStatusOk, ManageConnections(), master_socket, OPENER_TRACE_ERR, read_socket, and RemoveSession().

Referenced by executeEventLoop(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int g_current_active_tcp_socket

This variable holds the TCP socket the received to last explicit message. It is needed for opening point to point connection to determine the peer's address.

Definition at line 43 of file generic_networkhandler.h.

Referenced by CreateUdpSocket(), and HandleDataOnTcpSocket().

MilliSeconds g_last_time

Definition at line 47 of file generic_networkhandler.h.

Referenced by NetworkHandlerInitialize(), and NetworkHandlerProcessOnce().

struct timeval g_time_value

Definition at line 45 of file generic_networkhandler.h.

Referenced by NetworkHandlerProcessOnce().

int highest_socket_handle

temporary file descriptor for select()

Definition at line 37 of file generic_networkhandler.h.

Referenced by CheckAndHandleTcpListenerSocket(), CreateUdpSocket(), NetworkHandlerInitialize(), and NetworkHandlerProcessOnce().

fd_set read_socket