encap_header.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_ENCAP_HEADER_H
27 #define ODVA_ETHERNETIP_ENCAP_HEADER_H
28 
29 #include <iostream>
34 
35 namespace eip {
36 
37 using serialization::Serializable;
38 using serialization::Reader;
39 using serialization::Writer;
40 
44 class EncapHeader : public Serializable
45 {
46 public:
53 
57  EncapHeader(EIP_UINT cmd = 0, EIP_UDINT handle = 0)
58  : command(cmd), length(0), session_handle(handle), status(0), options(0)
59  {
60  context[0] = 0;
61  context[1] = 0;
62  }
63 
68  virtual size_t getLength() const
69  {
70  return 24;
71  }
72 
79  virtual Writer& serialize(Writer& writer) const;
80 
89  virtual Reader& deserialize(Reader& reader, size_t length)
90  {
91  if (getLength() != length)
92  {
93  throw std::length_error("Invalid length given for encapsulation packet header");
94  }
95  deserialize(reader);
96  return reader;
97  }
98 
105  virtual Reader& deserialize(Reader& reader);
106 };
107 
108 } // namespace eip
109 
110 #endif // ODVA_ETHERNETIP_ENCAP_HEADER_H
uint32_t EIP_DWORD
Definition: eip_types.h:41
virtual Writer & serialize(Writer &writer) const
virtual size_t getLength() const
Definition: encap_header.h:68
EIP_UINT command
Definition: encap_header.h:47
EIP_DWORD context[2]
Definition: encap_header.h:51
EIP_UDINT session_handle
Definition: encap_header.h:49
Definition: connection.h:41
uint16_t EIP_UINT
Definition: eip_types.h:39
EIP_DWORD options
Definition: encap_header.h:52
uint32_t EIP_UDINT
Definition: eip_types.h:42
EIP_DWORD status
Definition: encap_header.h:50
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: encap_header.h:89
EncapHeader(EIP_UINT cmd=0, EIP_UDINT handle=0)
Definition: encap_header.h:57


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Mon Jun 10 2019 14:00:16