00001 /* 00002 * File: MultiHopBroadcastFrame.h 00003 * Author: cwioro 00004 * 00005 * Created on September 17, 2014, 12:00 PM 00006 */ 00007 00008 #ifndef MULTIHOPBROADCASTFRAME_H 00009 #define MULTIHOPBROADCASTFRAME_H 00010 00011 struct mh_bcast_header { 00012 uint8_t frame_type; 00013 uint32_t id; 00014 uint8_t payload_type; 00015 uint16_t current_hop; 00016 uint16_t hop_limit; 00017 uint32_t hostname_source_len; 00018 uint32_t topic_len; 00019 uint32_t payload_len; 00020 00021 } __attribute__((packed)); 00022 00023 class MultiHopBroadcastFrame : public EthernetFrame { 00024 public: 00025 MultiHopBroadcastFrame(std::string topic_to_publish, std::string data, string source_host, uint8_t payload_type_field, uint16_t hop_range); 00026 MultiHopBroadcastFrame(unsigned char* buffer); 00027 virtual ~MultiHopBroadcastFrame(); 00028 00029 std::string getFrameAsNetworkString(unsigned char* source); 00030 00031 bool rebroadcast; 00032 00033 using EthernetFrame::GetCrc32; 00034 00035 static uint32_t frame_count_stat; 00036 static uint32_t HEADER_FIXED_LEN; 00037 00038 struct mh_bcast_header header_; 00039 uint16_t buffer_str_len_; 00040 00041 std::string hostname_source_; 00042 std::string topic_; 00043 std::string payload_; 00044 private: 00045 00046 }; 00047 00048 uint32_t MultiHopBroadcastFrame::frame_count_stat = 0; 00049 uint32_t MultiHopBroadcastFrame::HEADER_FIXED_LEN = sizeof (eh_header) + sizeof (mh_bcast_header); 00050 00051 #endif /* MULTIHOPBROADCASTFRAME_H */ 00052