00001 00026 #include "odva_ethernetip/identity_item_data.h" 00027 00028 namespace eip { 00029 00030 size_t IdentityItemData::getLength() const 00031 { 00032 // TODO: verify that this is correct 00033 return sizeof(encap_protocol_version) 00034 + sizeof(sockaddr) 00035 + sizeof(vendor_id) 00036 + sizeof(device_type) 00037 + sizeof(product_code) 00038 + sizeof(revision) 00039 + sizeof(status) 00040 + sizeof(serial_number) 00041 + sizeof(EIP_USINT) 00042 + product_name.length() 00043 + sizeof(state); 00044 } 00045 00046 Writer& IdentityItemData::serialize(Writer& writer) const 00047 { 00048 writer.write(encap_protocol_version); 00049 writer.write(sockaddr); 00050 writer.write(vendor_id); 00051 writer.write(device_type); 00052 writer.write(product_code); 00053 writer.write(revision); 00054 writer.write(status); 00055 writer.write(serial_number); 00056 00057 EIP_USINT name_length = product_name.size(); 00058 writer.write(name_length); 00059 writer.writeBytes(product_name.c_str(), name_length); 00060 writer.write(state); 00061 return writer; 00062 } 00063 00064 Reader& IdentityItemData::deserialize(Reader& reader) 00065 { 00066 reader.read(encap_protocol_version); 00067 reader.read(sockaddr); 00068 reader.read(vendor_id); 00069 reader.read(device_type); 00070 reader.read(product_code); 00071 reader.read(revision); 00072 reader.read(status); 00073 reader.read(serial_number); 00074 00075 EIP_USINT name_length; 00076 reader.read(name_length); 00077 product_name.resize(name_length); 00078 reader.readBytes(&product_name[0], name_length); 00079 reader.read(state); 00080 return reader; 00081 } 00082 00083 } // namespace eip