ciptcpipinterface.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*******************************************************************************
  2. * Copyright (c) 2009, Rockwell Automation, Inc.
  3. * All rights reserved.
  4. *
  5. ******************************************************************************/
  6. #ifndef OPENER_CIPTCPIPINTERFACE_H_
  7. #define OPENER_CIPTCPIPINTERFACE_H_
  8. /** @file ciptcpipinterface.h
  9. * @brief Public interface of the TCP/IP Interface Object
  10. *
  11. */
  12. #include "typedefs.h"
  13. #include "ciptypes.h"
  14. /** @brief TCP/IP Interface class code */
  15. static const CipUint kCipTcpIpInterfaceClassCode = 0xF5U;
  16. /* Declare constants for status attribute (#1) */
  17. /** Indicates a pending configuration change in the TTL Value and/or Mcast Config attributes.*/
  18. static const CipDword kTcpipStatusMcastPend = 0x10U;
  19. /** Indicates a pending configuration change in the Interface Configuration attribute. */
  20. static const CipDword kTcpipStatusIfaceCfgPend = 0x20U;
  21. /** Indicates when an IP address conflict has been detected by ACD. */
  22. static const CipDword kTcpipStatusAcdStatus = 0x40U;
  23. /** Indicates when an IP address conflict has been detected by ACD or the defense failed. */
  24. static const CipDword kTcpipStatusAcdFault = 0x80U;
  25. /* Declare constants for config_control attribute (#3) */
  26. static const CipDword kTcpipCfgCtrlStaticIp = 0x00U; /**< IP configuration method is manual IP assignment */
  27. static const CipDword kTcpipCfgCtrlBootp = 0x01U; /**< IP configuration method is BOOTP */
  28. static const CipDword kTcpipCfgCtrlDhcp = 0x02U; /**< IP configuration method is DHCP */
  29. static const CipDword kTcpipCfgCtrlMethodMask = 0x0FU; /**< bit mask for the method field */
  30. static const CipDword kTcpipCfgCtrlDnsEnable = 0x10U; /**< enables DNS resolution on originator devices */
  31. /** @brief Multicast Configuration struct, called Mcast config
  32. *
  33. */
  34. typedef struct multicast_address_configuration {
  35. CipUsint alloc_control; /**< 0 for default multicast address generation algorithm; 1 for multicast addresses according to Num MCast and MCast Start Addr */
  36. CipUsint reserved_shall_be_zero; /**< shall be zero */
  37. CipUint number_of_allocated_multicast_addresses; /**< Number of IP multicast addresses allocated */
  38. CipUdint starting_multicast_address; /**< Starting multicast address from which Num Mcast addresses are allocated */
  39. } MulticastAddressConfiguration;
  40. /** @brief Declaration of the TCP/IP object's structure type
  41. */
  42. typedef struct {
  43. CipDword status; /**< attribute #1 TCP status */
  44. CipDword config_capability; /**< attribute #2 bitmap of capability flags */
  45. CipDword config_control; /**< attribute #3 bitmap: control the interface configuration method: static / BOOTP / DHCP */
  46. CipEpath physical_link_object; /**< attribute #4 references the Ethernet Link object for this interface */
  47. CipTcpIpInterfaceConfiguration interface_configuration;/**< attribute #5 IP, network mask, gateway, name server 1 & 2, domain name*/
  48. CipString hostname; /**< #6 host name*/
  49. CipUsint mcast_ttl_value; /**< #8 the time to live value to be used for multi-cast connections */
  50. /** #9 The multicast configuration for this device */
  51. MulticastAddressConfiguration mcast_config;
  52. CipBool select_acd; /**< attribute #10 - Is ACD enabled? */
  53. /** #13 Number of seconds of inactivity before TCP connection is closed */
  54. CipUint encapsulation_inactivity_timeout;
  55. } CipTcpIpObject;
  56. /* global public variables */
  57. extern CipTcpIpObject g_tcpip; /**< declaration of TCP/IP object instance 1 data */
  58. /* public functions */
  59. /** @brief Initializing the data structures of the TCP/IP interface object
  60. *
  61. * @return kEipStatusOk on success, otherwise kEipStatusError
  62. */
  63. EipStatus CipTcpIpInterfaceInit(void);
  64. /** @brief Clean up the allocated data of the TCP/IP interface object.
  65. *
  66. * Currently this is the host name string and the domain name string.
  67. *
  68. */
  69. void ShutdownTcpIpInterface(void);
  70. /** @brief Calculate Multicast address base from current IP setting
  71. *
  72. * @param tcpip pointer to TCP/IP object
  73. */
  74. void CipTcpIpCalculateMulticastIp(CipTcpIpObject *const tcpip);
  75. /** @brief Public Method to get Encapsulation Inactivity Timeout Value
  76. *
  77. *
  78. */
  79. EipUint16 GetEncapsulationInactivityTimeout(CipInstance *instance);
  80. #endif /* OPENER_CIPTCPIPINTERFACE_H_ */