فهرست منبع

EIP Security object - new attributes #8 and #9 added

micsat 2 سال پیش
والد
کامیت
32195ca737
2فایلهای تغییر یافته به همراه35 افزوده شده و 5 حذف شده
  1. 28 5
      source/src/cip/cip_security/ethernetipsecurity.c
  2. 7 0
      source/src/cip/cip_security/ethernetipsecurity.h

+ 28 - 5
source/src/cip/cip_security/ethernetipsecurity.c

@@ -61,8 +61,16 @@
 /* ********************************************************************
  * defines
  */
-/** The implemented class revision is 5 */
-#define ETHERNET_IP_SECURITY_OBJECT_REVISION 5
+/** The implemented class revision is 7 */
+#define ETHERNET_IP_SECURITY_OBJECT_REVISION 7
+
+/**
+ * declaration of (static) Ethernet/IP Security object class data
+ */
+EIPSecurityObjectClassAttributes eip_security_class_attr = {
+  .number_of_psks_supported = 0,
+  .psk_usages_supported = 4  // Bit 2 set
+};
 
 /* ********************************************************************
  * global public variables
@@ -140,7 +148,7 @@ EIPSecurityObject g_eip_security = {
   .available_cipher_suites = NULL,                  /** Attribute #3 */
   //.allowed_cipher_suites = allowed_cipher_suites,                         /** Attribute #4 */
   .active_device_certificates = active_device_certificates,   /** Attribute #6 */
-  .pre_shared_keys.number_of_pre_shared_keys = 0,   /** Attribute #5 */
+  .pre_shared_keys.number_of_pre_shared_keys = 0,  //default = 0  /** Attribute #5 */ 
   .check_expiration = 0,                            /** Attribute #11 */
   .pull_model_enabled = true,    // default: true   /** Attribute #13 */
   .pull_model_status = 0x0000,                      /** Attribute #14 */
@@ -658,6 +666,20 @@ void EIPSecurityObjectInitializeClassSettings(CipClass *class) {
                    NULL,
                    (void *) &class->highest_attribute_number,
                    kGetableSingleAndAll ); /* max instance attribute number*/
+  InsertAttribute( (CipInstance *) class,
+                   8,
+                   kCipUint,
+                   EncodeCipUint,
+                   NULL,
+                   (void *) &eip_security_class_attr.number_of_psks_supported,
+                   kGetableSingle ); /* number of PSKs supported*/
+  InsertAttribute( (CipInstance *) class,
+                   9,
+                   kCipByte,
+                   EncodeCipByte,
+                   NULL,
+                   (void *) &eip_security_class_attr.psk_usages_supported,
+                   kGetableSingle ); /* PSK Usages supported by the device*/
 
   /* Add class services to the meta class */
   InsertService(meta_class,
@@ -680,8 +702,9 @@ EipStatus EIPSecurityInit(void) {
   CipInstance *eip_security_object_instance;
 
   eip_security_object_class = CreateCipClass(
-    kEIPSecurityObjectClassCode, 0,   /* # class attributes */
-    7,                                /* # highest class attribute number */
+    kEIPSecurityObjectClassCode, 
+    9,                                /* # class attributes */
+    9,                                /* # highest class attribute number */
     2,                                /* # class services */
     16,                               /* # instance attributes */
     16,                               /* # highest instance attribute number */

+ 7 - 0
source/src/cip/cip_security/ethernetipsecurity.h

@@ -138,6 +138,13 @@ typedef struct {
   CipUsint udp_only_policy;                              /** Attribute #16 */
 } EIPSecurityObject;
 
+/** @brief Ethernet/IP Security Object specific class attributes
+ *  @see Volume 8, Chapter 5-4.3 */
+typedef struct eip_security_class_attributes {
+  CipUint number_of_psks_supported;           /** Class Attribute #8 */
+  CipBool psk_usages_supported;               /** Class Attribute #9 */
+} EIPSecurityObjectClassAttributes;
+
 /* ********************************************************************
  * global public variables
  */