forward_open_request.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_FORWARD_OPEN_REQUEST_H
27 #define ODVA_ETHERNETIP_FORWARD_OPEN_REQUEST_H
28 
29 #include <string>
30 #include <boost/shared_ptr.hpp>
31 
36 #include "odva_ethernetip/path.h"
37 
38 using boost::shared_ptr;
39 
40 namespace eip {
41 
42 using serialization::Serializable;
43 using serialization::Reader;
44 using serialization::Writer;
45 
46 typedef enum
47 {
53 
54 typedef enum
55 {
60 } CONN_TYPE_T;
61 
66 class ForwardOpenRequest : public Serializable
67 {
68 public:
69 
83 
92  static EIP_DWORD calcConnectionParams(EIP_UINT size, bool variable, EIP_BYTE priority,
93  EIP_BYTE type, bool shared)
94  {
95  return (size & 0x7FFF) | (variable ? 0x2000000 : 0) | (priority & 0x03) << 26
96  | (type & 0x03) << 29 | (shared ? 0x80000000 : 0);
97  }
98 
102  EIP_DWORD setOriginToTargetParams(EIP_UINT size, bool variable, EIP_BYTE priority,
103  EIP_BYTE type, bool shared)
104  {
105  o_to_t_conn_params = calcConnectionParams(size, variable, priority, type, shared);
106  return 0;
107  }
108 
112  EIP_DWORD setTargetToOriginParams(EIP_UINT size, bool variable, EIP_BYTE priority,
113  EIP_BYTE type, bool shared)
114  {
115  t_to_o_conn_params = calcConnectionParams(size, variable, priority, type, shared);
116  return 0;
117  }
118 
124  {
125  return path_;
126  }
127 
132  virtual size_t getLength() const
133  {
134  return sizeof(timeout_tick_size)
135  + sizeof(timeout_ticks)
136  + sizeof(o_to_t_connection_id)
137  + sizeof(t_to_o_connection_id)
138  + sizeof(connection_sn)
139  + sizeof(originator_vendor_id)
140  + sizeof(originator_sn)
141  + sizeof(timeout_multiplyer)
142  + sizeof(o_to_t_rpi)
143  + sizeof(o_to_t_conn_params)
144  + sizeof(t_to_o_rpi)
145  + sizeof(t_to_o_conn_params)
146  + sizeof(conn_type)
147  + 3 // reserved bytes
148  + path_.getLength();
149  }
150 
157  virtual Writer& serialize(Writer& writer) const
158  {
159  EIP_BYTE reserved = 0;
160  writer.write(timeout_tick_size);
161  writer.write(timeout_ticks);
162  writer.write(o_to_t_connection_id);
163  writer.write(t_to_o_connection_id);
164  writer.write(connection_sn);
165  writer.write(originator_vendor_id);
166  writer.write(originator_sn);
167  writer.write(timeout_multiplyer);
168  writer.write(reserved);
169  writer.write(reserved);
170  writer.write(reserved);
171  writer.write(o_to_t_rpi);
172  writer.write(o_to_t_conn_params);
173  writer.write(t_to_o_rpi);
174  writer.write(t_to_o_conn_params);
175  writer.write(conn_type);
176  path_.serialize(writer);
177  return writer;
178  }
179 
183  virtual Reader& deserialize(Reader& reader, size_t length)
184  {
185  throw std::logic_error("Not implemented");
186  }
187 
191  virtual Reader& deserialize(Reader& reader)
192  {
193  throw std::logic_error("Not implemented");
194  }
195 
196 private:
198 };
199 
200 } // namespace eip
201 
202 #endif // ODVA_ETHERNETIP_FORWARD_OPEN_REQUEST_H
virtual Reader & deserialize(Reader &reader, size_t length)
uint32_t EIP_DWORD
Definition: eip_types.h:41
virtual Writer & serialize(Writer &writer) const
uint8_t EIP_USINT
Definition: eip_types.h:36
static EIP_DWORD calcConnectionParams(EIP_UINT size, bool variable, EIP_BYTE priority, EIP_BYTE type, bool shared)
EIP_DWORD setTargetToOriginParams(EIP_UINT size, bool variable, EIP_BYTE priority, EIP_BYTE type, bool shared)
virtual Writer & serialize(Writer &writer) const
Definition: path.h:137
virtual Reader & deserialize(Reader &reader)
EIP_DWORD setOriginToTargetParams(EIP_UINT size, bool variable, EIP_BYTE priority, EIP_BYTE type, bool shared)
uint8_t EIP_BYTE
Definition: eip_types.h:35
Definition: path.h:50
Definition: connection.h:41
uint16_t EIP_UINT
Definition: eip_types.h:39
virtual size_t getLength() const
Definition: path.cpp:79
uint32_t EIP_UDINT
Definition: eip_types.h:42
virtual size_t getLength() const


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