EthernetManager Class
EthernetManager manages the IP interfaces to the ethernet. More...
Header: | #include <OSAPI/Network/EthernetManager.h> |
Inherits: | CDPComponent |
Public Functions
virtual | ~EthernetManager(void) |
virtual void | CreateNetworkInterfaceList(XMLElementEx *networkInterface) |
virtual int | GetCDPtcpMaxTransferUnitBody() |
virtual int | GetLinkStatus(const IpAddress &ipAdr) |
const IpAddress | GetNetworkInterface(std::string strName, bool *found = NULL) |
const IpAddress | GetNetworkInterface(unsigned int nIndex, bool *found = NULL) |
int | GetNetworkInterfaceIndex(const IpAddress &ipAdr) |
const IpAddress | GetNetworkInterfaceMac(unsigned char *mac, bool *found = NULL) |
unsigned int | GetNumberofNetworkInterfaces() |
virtual void | SetCDPtcpMaxTransferUnitBody(int newCDPtcpMaxTransferUnitBody) |
virtual void | SetInvalidInterfaceIndex(unsigned int invalidInterfaceIndex) |
Reimplemented Public Functions
virtual void | Activate() override |
virtual void | Configure(const char *componentXML) override |
virtual void | Create(const char *fullName) override |
virtual void | CreateModel() override |
virtual void | Destroy() override |
virtual void | Suspend() override |
- 90 public functions inherited from CDPComponent
- 37 public functions inherited from CDPObject
- 46 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Static Public Members
EthernetManager * | GetInstance() |
- 2 static public members inherited from CDPComponent
- 6 static public members inherited from CDPObject
- 1 static public member inherited from CDPBaseObject
Protected Functions
EthernetManager(void) | |
int | DisableEthernetInterface(unsigned int applicationNetworkInterfaceNo, bool disable) |
void | InitRoutingTable() |
Reimplemented Protected Functions
virtual void | ProcessNull() override |
- 12 protected functions inherited from CDPComponent
- 13 protected functions inherited from CDPObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Additional Inherited Members
- 31 protected variables inherited from CDPComponent
- 7 protected variables inherited from CDPObject
- 9 protected variables inherited from CDPBaseObject
- 1 static protected member inherited from CDPObject
Detailed Description
EthernetManager manages the IP interfaces to the ethernet.
The EthernetManager is handling features like ethernet traffic monitoring (statistics signals), ip interface monitoring (link-status), etc.
Initializing of ethernet interfaces
The list of ethernet interfaces (s_networkInterfaceList) is established, and the interfaces are added to the routing table.
Access methods for ehternet interfaces
Some access methods for getting information about the ethernet interfaces are provided:
- IpAddress GetNetworkInterface(std::string strName, bool* found); - Returns ipaddress based on network interface name
- IpAddress GetNetworkInterface(unsigned int nIndex, bool* found); - Returns ipaddress based on index in s_networkInterfaceList
- IpAddress GetNetworkInterfaceMac(unsigned char* mac, bool* found); - Returns ipaddress based on mac address
- int GetNetworkInterfaceIndex(const IpAddress &ipAdr); - Returns ethernet interface number/index for specified IP address
- unsigned int GetNumberofNetworkInterfaces(); - Returns number of configured network interfaces
- int GetLinkStatus(const IpAddress& ipAdr); - Get Link status for the ethernet interface specified by IP address
Signals for statistics (ethernet traffic) and link
EthernetManager has signals for ethernet traffic, regarding UDP Unicast/ Broadcast Received/Sent, TCP Received/Sent and Total Received/Sent for the different configured ethernet interfaces. There are also link-status signals for the interfaces (alarms will be set if link is down).
Configuration possibilities, CDP Parameters
TCPmaxTransferUnitBody: Value of TCPmaxTransferUnitBody decides how TCP packets are sent (splitting into smaller packets or not).
A common/global value is stored in class EthernetManager, and there is a member in class TCPConnection deciding behaviour for every socket. This member-variable gets the value of the common/global value during startup, and can later be Set/Get.
The value of TCPmaxTransferUnitBody in Configuration decides the value of the common/global value:
- Not found or value 0: common/global value is set to a default value (4096). TCP packets larger than this limit, will be split.
- Negative value : common/global value is set to this negative value. There will be no splitting in smaller TCP packets.
- Positive value : common/global value is set to this positive value (will minimum become size CDP_TCP_MIN_TRANSFER_UNIT_BODY). TCP packets larger than this limit, will be split.
EthLinkSurveillanceInterv: Interval for how often to check link-status on the networkinterfaces specified in Application.xml.
StatisticsSignalsUpdateInterval: Interval whichs decides how often (but not faster than ts) the statistics signals are updated.
Member Function Documentation
[protected]
EthernetManager::EthernetManager(void)
Default constructor for EthernetManager.
[virtual]
EthernetManager::~EthernetManager(void)
Destructor for the EthernetManager.
[override virtual]
void EthernetManager::Activate()
Reimplemented from CDPBaseObject::Activate().
Activate the component
[override virtual]
void EthernetManager::Configure(const char *componentXML)
Reimplemented from CDPObject::Configure().
Configure from .xml description.
[override virtual]
void EthernetManager::Create(const char *fullName)
Reimplemented from CDPComponent::Create().
Creates a component instance.
[override virtual]
void EthernetManager::CreateModel()
Reimplemented from CDPBaseObject::CreateModel().
Creates the model for this component type
[virtual]
void EthernetManager::CreateNetworkInterfaceList(XMLElementEx *networkInterface)
Create the network interface list.
The network interface list is created from XML-configuration.
[override virtual]
void EthernetManager::Destroy()
Reimplemented from CDPBaseObject::Destroy().
Deletes allocated memory anbd calls CDPComponent::Destroy()
.
[protected]
int EthernetManager::DisableEthernetInterface(unsigned int applicationNetworkInterfaceNo, bool disable)
[virtual]
int EthernetManager::GetCDPtcpMaxTransferUnitBody()
Returns the value of the parameter TCPmaxTransferUnitBody:
Negative value | There will be no splitting in smaller TCP packets. |
Positive value | TCP packets larger than this limit, will be split into this size. |
0 | Should never be returned. |
[static]
EthernetManager *EthernetManager::GetInstance()
Get the single instance object pointer for the EthernetManager class.
Returns instance pointer to the single EthernetManager object.
[virtual]
int EthernetManager::GetLinkStatus(const IpAddress &ipAdr)
Get Link status for the ethernet interface specified by IP address
Returns Link status or Error code (negative number):
0 | no link established |
1 | link is established |
-1 | error or function not supported |
Parameter ipAdr | Which IP address to get Link Status for (the IP address must be one if the IP addresses specified in NetworkInterface-tag in Application.xml) |
const IpAddress EthernetManager::GetNetworkInterface(std::string strName, bool *found = NULL)
Returns ipaddress based on network interface name.
Returns the IpAddress object with corresponding name. If the Ethernet Interface is not found, an IpAddress object with only default values is returned.
Parameter strName (std::string) | The name of the requested network interface in current Application component. May contain the full path of the network interface for example "Application.ETH0". |
Parameter found (bool*) | Set to true (if returned IP corresponds to strName) or false (if strName was not found in s_networkInterfaceList). If found is NULL, it is not used by the function. |
const IpAddress EthernetManager::GetNetworkInterface(unsigned int nIndex, bool *found = NULL)
Returns ipaddress based on index in s_networkInterfaceList.
Returns a const IpAddress object for the requested Ethernet Interface. If the Ethernet Interface is not found, an IpAddress object set to default values is returned.
Parameter nIndex (unsigned int) | Index number of the requested network interface. |
Parameter found (bool*) | Set to true (if returned IP corresponds to nIndex) or false (if nIndex was not in range of s_networkInterfaceList-size). If found is NULL, it is not used by the function. |
int EthernetManager::GetNetworkInterfaceIndex(const IpAddress &ipAdr)
Returns ethernet interface number/index for specified IP address.
The first "NetworkInterface" in Application.xml gets value 0, the second gets value 1,.... Returns ethernet interfacenumber or -1 if not found.
Parameter ipAdr | Which IP address to get ethernet interface number for (must be specified in Application.xml) |
const IpAddress EthernetManager::GetNetworkInterfaceMac(unsigned char *mac, bool *found = NULL)
Returns ipaddress based on mac address. Returns the IpAddress object with corresponding mac. If the Ethernet Interface is not found, an IpAddress object with only default values is returned.
Param mac (unsigned char*) | The mac (8 unsigned bytes. Unused bytes should be set to 0) of the requested network interface. |
Param found (bool*) | Set to true (if returned IP corresponds to mac) or false (if mac was not found for the ip-addresses in s_networkInterfaceList). If found is NULL, it is not used by the function. |
unsigned int EthernetManager::GetNumberofNetworkInterfaces()
Returns number of configured network interfaces.
Returns number of network interfaces specified as "NetworkInterface" in Application.xml.
[protected]
void EthernetManager::InitRoutingTable()
Initialise the configured network interfaces to the routing table.
All network interfaces in the s_networkInterfaceList get assigned mac address for corresponding ethernet device.
The assignment of mac address follows these rules:
- The NetworkInterface configured 'on first line' in XML file, will connect to the first hardware networkinterface. Second to second, third to third, etc.
- Make sure to configure the NetworkInterface that do not have mac address specified first, since the line number indicates the hardware networkinterface to use.
- If a NetworkInterface is configured on a line-number bigger than number of hardware network interfaces, then the first networkinterface will be used.
- When mac address is specified, the hardware networkinterface with this mac address will be used.
- When mac address is specified, and no hardware networkinterface with this mac address is found, then the first network hardware networkinterface will be used.
- When specifying mac address in NetworkInterface, make sure to configure these NetworkInterfaces below those without mac address specifed, as the line number for these decides which hardware networkinterface will be used.
[override virtual protected]
void EthernetManager::ProcessNull()
Reimplemented from CDPComponent::ProcessNull().
State machine.
[virtual]
void EthernetManager::SetCDPtcpMaxTransferUnitBody(int newCDPtcpMaxTransferUnitBody)
Sets the value of the parameter TCPmaxTransferUnitBody:
Negative value | There will be no splitting in smaller TCP packets. |
Positive value | TCP packets larger than this limit will be split into this size. Will minimum become size CDP_TCP_MIN_TRANSFER_UNIT_BODY. |
0 | TCPmaxTransferUnitBody will be set to a default value (4096). |
[virtual]
void EthernetManager::SetInvalidInterfaceIndex(unsigned int invalidInterfaceIndex)
[override virtual]
void EthernetManager::Suspend()
Reimplemented from CDPBaseObject::Suspend().
Suspend the component
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.