forward_open_success.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
27 #define ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
28 
29 #include <string>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/make_shared.hpp>
32 
38 
39 using boost::shared_ptr;
40 using boost::make_shared;
41 
42 namespace eip {
43 
44 using serialization::Serializable;
45 using serialization::SerializableBuffer;
46 using serialization::Reader;
47 using serialization::Writer;
48 
53 class ForwardOpenSuccess : public Serializable
54 {
55 public:
56 
64 
69  shared_ptr<Serializable> getResponseData() const
70  {
71  return response_data_;
72  }
73 
78  virtual size_t getLength() const
79  {
80  size_t result = sizeof(o_to_t_connection_id)
81  + sizeof(t_to_o_connection_id)
82  + sizeof(connection_sn)
83  + sizeof(originator_vendor_id)
84  + sizeof(originator_sn)
85  + sizeof(o_to_t_api)
86  + sizeof(t_to_o_api)
87  + 2; // reserved byte and data length
88  if (response_data_)
89  {
90  result += response_data_->getLength();
91  }
92  return result;
93  }
94 
101  virtual Writer& serialize(Writer& writer) const
102  {
103  throw std::logic_error("Not implemented");
104  }
105 
109  virtual Reader& deserialize(Reader& reader, size_t length)
110  {
111  return deserialize(reader);
112  }
113 
117  virtual Reader& deserialize(Reader& reader)
118  {
119  EIP_USINT data_length;
120  reader.read(o_to_t_connection_id);
121  reader.read(t_to_o_connection_id);
122  reader.read(connection_sn);
123  reader.read(originator_vendor_id);
124  reader.read(originator_sn);
125  reader.read(o_to_t_api);
126  reader.read(t_to_o_api);
127  reader.read(data_length);
128  reader.skip(1);
129  if (data_length > 0)
130  {
131  shared_ptr<SerializableBuffer> sb = make_shared<SerializableBuffer> ();
132  sb->deserialize(reader, data_length*2);
133  response_data_ = sb;
134  }
135  else
136  {
137  response_data_ = shared_ptr<Serializable>();
138  }
139  return reader;
140  }
141 
142 private:
143  shared_ptr<Serializable> response_data_;
144 
145 };
146 
147 } // namespace eip
148 
149 #endif // ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
uint8_t EIP_USINT
Definition: eip_types.h:36
virtual Reader & deserialize(Reader &reader)
shared_ptr< Serializable > getResponseData() const
virtual Writer & serialize(Writer &writer) const
Definition: connection.h:41
uint16_t EIP_UINT
Definition: eip_types.h:39
uint32_t EIP_UDINT
Definition: eip_types.h:42
virtual size_t getLength() const
virtual Reader & deserialize(Reader &reader, size_t length)
shared_ptr< Serializable > response_data_


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