OpENer - Open Source EtherNet/IP(TM) I/O Target Stack
2.1
|
#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"
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 |
EipBool8 CheckSocketSet | ( | int | socket | ) |
check if the given socket is set in the read set
socket | The socket to check |
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().
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().
void CloseUdpSocket | ( | int | socket_handle | ) |
Definition at line 257 of file generic_networkhandler.c.
References CloseSocket().
Referenced by CloseCommunicationChannelsAndRemoveFromActiveConnectionsList(), and CloseConnection().
int GetMaxSocket | ( | int | socket1, |
int | socket2, | ||
int | socket3, | ||
int | socket4 | ||
) |
Returns the socket with the highest id.
socket1 | First socket |
socket2 | Second socket |
socket3 | Third socket |
socket4 | Fourth socket |
Definition at line 1008 of file generic_networkhandler.c.
Referenced by NetworkHandlerInitialize().
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().
EipStatus NetworkHandlerInitialize | ( | void | ) |
The platform independent part of network handler initialization routine.
Initializes the network handler, shall be implemented by a port-specific networkhandler.
The platform independent part of network handler initialization routine.
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().
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().
MilliSeconds g_actual_time |
Definition at line 46 of file generic_networkhandler.h.
Referenced by CheckEncapsulationInactivity(), HandleDataOnTcpSocket(), HandleReceivedRegisterSessionCommand(), and NetworkHandlerProcessOnce().
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().
NetworkStatus g_network_status |
Global variable holding the current network status
Definition at line 58 of file generic_networkhandler.h.
Referenced by CheckAndHandleTcpListenerSocket(), CheckAndHandleUdpGlobalBroadcastSocket(), CheckAndHandleUdpUnicastSocket(), NetworkHandlerFinish(), NetworkHandlerInitialize(), and NetworkHandlerProcessOnce().
struct timeval g_time_value |
Definition at line 45 of file generic_networkhandler.h.
Referenced by NetworkHandlerProcessOnce().
SocketTimer g_timestamps[OPENER_NUMBER_OF_SUPPORTED_SESSIONS] |
Definition at line 30 of file generic_networkhandler.h.
Referenced by CheckAndHandleTcpListenerSocket(), CheckEncapsulationInactivity(), HandleDataOnTcpSocket(), HandleReceivedRegisterSessionCommand(), NetworkHandlerInitialize(), and RemoveSocketTimerFromList().
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 master_socket |
Definition at line 34 of file generic_networkhandler.h.
Referenced by CheckAndHandleTcpListenerSocket(), CheckSocketSet(), CloseSocket(), CreateUdpSocket(), NetworkHandlerInitialize(), and NetworkHandlerProcessOnce().
fd_set read_socket |
Definition at line 35 of file generic_networkhandler.h.
Referenced by CheckSocketSet(), NetworkHandlerInitialize(), and NetworkHandlerProcessOnce().