encap_header.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_ENCAP_HEADER_H
00027 #define ODVA_ETHERNETIP_ENCAP_HEADER_H
00028 
00029 #include <iostream>
00030 #include "odva_ethernetip/eip_types.h"
00031 #include "odva_ethernetip/serialization/reader.h"
00032 #include "odva_ethernetip/serialization/writer.h"
00033 #include "odva_ethernetip/serialization/serializable.h"
00034 
00035 namespace eip {
00036 
00037 using serialization::Serializable;
00038 using serialization::Reader;
00039 using serialization::Writer;
00040 
00044 class EncapHeader : public Serializable
00045 {
00046 public:
00047   EIP_UINT  command;
00048   EIP_UINT  length;
00049   EIP_UDINT session_handle;
00050   EIP_DWORD status;
00051   EIP_DWORD context[2];
00052   EIP_DWORD options;
00053 
00057   EncapHeader(EIP_UINT cmd = 0, EIP_UDINT handle = 0)
00058     : command(cmd), length(0), session_handle(handle), status(0), options(0)
00059   {
00060     context[0] = 0;
00061     context[1] = 0;
00062   }
00063 
00068   virtual size_t getLength() const
00069   {
00070     return 24;
00071   }
00072 
00079   virtual Writer& serialize(Writer& writer) const;
00080 
00089   virtual Reader& deserialize(Reader& reader, size_t length)
00090   {
00091     if (getLength() != length)
00092     {
00093       throw std::length_error("Invalid length given for encapsulation packet header");
00094     }
00095     deserialize(reader);
00096     return reader;
00097   }
00098 
00105   virtual Reader& deserialize(Reader& reader);
00106 };
00107 
00108 } // namespace eip
00109 
00110 #endif  // ODVA_ETHERNETIP_ENCAP_HEADER_H


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Sat Jun 8 2019 20:21:23