Просмотр исходного кода

Adds comments to encap.c/.h, updates data types to Cip* data types

capxilinx 10 лет назад
Родитель
Сommit
0285f6fcee
2 измененных файлов с 19 добавлено и 16 удалено
  1. 9 9
      source/src/enet_encap/encap.c
  2. 10 7
      source/src/enet_encap/encap.h

+ 9 - 9
source/src/enet_encap/encap.c

@@ -44,14 +44,14 @@ const int kSenderContextSize = 8; /**< size of sender context in encapsulation h
 
 /** @brief definition of known encapsulation commands */
 typedef enum {
-  kEncapsulationCommandNoOperation = 0x0000,
-  kEncapsulationCommandListServices = 0x0004,
-  kEncapsulationCommandListIdentity = 0x0063,
-  kEncapsulationCommandListInterfaces = 0x0064,
-  kEncapsulationCommandRegisterSession = 0x0065,
-  kEncapsulationCommandUnregisterSession = 0x0066,
-  kEncapsulationCommandSendRequestReplyData = 0x006F,
-  kEncapsulationCommandSendUnitData = 0x0070
+  kEncapsulationCommandNoOperation = 0x0000, /**< only allowed for TCP */
+  kEncapsulationCommandListServices = 0x0004, /**< allowed for both UDP and TCP */
+  kEncapsulationCommandListIdentity = 0x0063, /**< allowed for both UDP and TCP */
+  kEncapsulationCommandListInterfaces = 0x0064, /**< optional, allowed for both UDP and TCP */
+  kEncapsulationCommandRegisterSession = 0x0065, /**< only allowed for TCP */
+  kEncapsulationCommandUnregisterSession = 0x0066, /**< only allowed for TCP */
+  kEncapsulationCommandSendRequestReplyData = 0x006F, /**< only allowed for TCP */
+  kEncapsulationCommandSendUnitData = 0x0070 /**< only allowed for TCP */
 } EncapsulationCommand;
 
 /** @brief definition of capability flags */
@@ -357,7 +357,7 @@ void HandleReceivedListIdentityCommandUdp(int socket,
 int EncapsulateListIdentyResponseMessage(const EipByte *const communication_buffer) {
   EipUint8 *communication_buffer_runner = communication_buffer;
 
-  AddIntToMessage(1, &communication_buffer_runner); /* one item */
+  AddIntToMessage(1, &communication_buffer_runner); /* Item count: one item */
   AddIntToMessage(kCipItemIdListIdentityResponse, &communication_buffer_runner);
 
   EipByte *id_length_buffer = communication_buffer_runner;

+ 10 - 7
source/src/enet_encap/encap.h

@@ -22,7 +22,9 @@
 
 static const int kOpenerEthernetPort = 0xAF12;
 
-/* definition of status codes in encapsulation protocol */
+/** @brief definition of status codes in encapsulation protocol
+ * All other codes are either legacy codes, or reserved for future use
+ *  */
 typedef enum {
   kEncapsulationProtocolSuccess = 0x0000,
   kEncapsulationProtocolInvalidCommand = 0x0001,
@@ -31,15 +33,16 @@ typedef enum {
   kEncapsulationProtocolInvalidSessionHandle = 0x0064,
   kEncapsulationProtocolInvalidLength = 0x0065,
   kEncapsulationProtocolUnsupportedProtocol = 0x0069
-} EncapsulationProtocolStatus;
+} EncapsulationProtocolErrorCode;
 
 /*** structs ***/
 typedef struct encapsulation_data {
-  EipUint16 command_code;
-  EipUint16 data_length;
-  EipUint32 session_handle;
-  EipUint32 status;
-  EipUint32 options;
+  CipUint command_code;
+  CipUint data_length;
+  CipUdint session_handle;
+  CipUdint status;
+  CipOctet sender_context[8]; /**< length of 8, according to the specification */
+  CipUdint options;
   EipUint8 *communication_buffer_start; /**< Pointer to the communication buffer used for this message */
   EipUint8 *current_communication_buffer_position; /**< The current position in the communication buffer during the decoding process */
 } EncapsulationData;