structs.h
Go to the documentation of this file.
00001 /*
00002  * structs.h
00003  *
00004  *  Created on: 13.08.2013
00005  *      Author: Günther Cwioro
00006  */
00007 
00008 #ifndef STRUCTS_H_
00009 #define STRUCTS_H_
00010 
00011 #include "functions.h"
00012 
00013 
00014 bool compareMac(const unsigned char mac1[6], const unsigned char mac2[6]);
00015 bool compareMac(char* mac1[6], char* mac2[6]);
00016 
00017 struct routing_entry {
00018     std::string hostname_destination;
00019     std::string hostname_source;
00020     std::list<mac> mac_path_l;
00021     uint32_t id;
00022     unsigned long ts;
00023     unsigned char next_hop[6];
00024     unsigned char previous_hop[6]; // previous
00025     uint16_t hobs;
00026     uint16_t current_hop;
00027     uint8_t root_distance; //multicast
00028     bool cr_entry;
00029 
00030     routing_entry() {
00031         ts = getMillisecondsTime();
00032     }
00033 
00034     routing_entry(string hname_src, uint32_t id) {
00035         hostname_source = hname_src;
00036         this->id = id;
00037         ts = getMillisecondsTime();
00038     }
00039 
00040     bool samePath(routing_entry r) {
00041         if (mac_path_l.size() != r.mac_path_l.size())
00042             return false;
00043 
00044         std::list<mac>::iterator i_other = r.mac_path_l.begin();
00045         std::list<mac>::iterator i_this = mac_path_l.begin();
00046         while (i_this == mac_path_l.end() || i_other == r.mac_path_l.end()) {
00047 
00048             if (compareMac((*i_this).mac_adr, (*i_other).mac_adr) == false)
00049                 return false;
00050 
00051             i_this++;
00052             i_other++;
00053 
00054         }
00055 
00056         return true;
00057     }
00058 
00059    bool operator ==(const routing_entry& st) {
00060         if (hostname_source.compare(st.hostname_source) == 0 && id == st.id) {
00061             ts = getMillisecondsTime();
00062             return true;
00063         }
00064 
00065         return false;
00066     }
00067 };
00068 
00069 struct route_request {
00070     std::string hostname_source;
00071     std::string hostname_destination;
00072     uint32_t id;
00073     uint8_t response_sent;
00074     uint8_t retransmitted;
00075     uint32_t hop_limit;
00076     uint16_t counter; // defines how much requests have been received with the same id
00077     unsigned char receiver_mac[6]; // only needed for mc
00078     uint8_t is_mc;
00079     //uint8_t is_join_req;
00080 
00081     long int ts;
00082 
00083     route_request() {
00084         counter = 0;
00085         ts = getMillisecondsTime();
00086    
00087         retransmitted = 0;
00088         response_sent = 0;
00089     }
00090 
00091     bool operator ==(const route_request& st) {
00092         if (hostname_source.compare(st.hostname_source) == 0 && id == st.id)// && compareMac((const char*)st.receiver_mac,(const char*) this->receiver_mac))
00093             return true;
00094 
00095         return false;
00096     }
00097 
00098 };
00099 
00100 struct stc_ack {
00101     std::string network_string;
00102     uint32_t frame_id;
00103     uint8_t retransmitted;
00104     unsigned char mac[6];
00105 
00106     //ecl::StopWatch timer;
00107 
00108 
00109     // Assignment operator.
00110 
00111     bool operator ==(const stc_ack& st) {
00112 
00113         return (frame_id == st.frame_id && compareMac(st.mac, mac));
00114 
00115     }
00116 
00117 };
00118 
00119 #include "RoutedFrame.cpp"
00120 #include "RoutedFrame.h"
00121 #include "defines.h"
00122 
00123 struct stc_RoutedFrame {
00124     RoutedFrame frame;
00125     uint8_t retransmitted;
00126     bool frame_is_ack;
00127     string hostname_destination;
00128     unsigned char mac[6];
00129 
00130     unsigned long time_stamp;
00131 
00132     bool operator ==(const stc_RoutedFrame& st) {
00133         return (frame.header_.frame_id == st.frame.header_.frame_id && hostname_destination.compare(st.hostname_destination) == 0);
00134     }
00135 
00136 
00137 
00138 
00139 };
00140 
00141 struct hostname_mac {
00142     std::string hostname;
00143     unsigned char mac[6];
00144     //uint8_t no_hello_got;
00145     bool reachable;
00146     unsigned long ts;
00147 
00148     hostname_mac() {
00149         ts = getMillisecondsTime();
00150     }
00151 
00152     hostname_mac(unsigned char* m) {
00153         memcpy(mac, m, 6);
00154         ts = getMillisecondsTime();
00155     }
00156 
00157     void stamp() {
00158         ts = getMillisecondsTime();
00159     }
00160 
00161     bool operator ==(const hostname_mac& st) {
00162         for (int i = 0; i < 6; i++)
00163             if (st.mac[i] != mac[i])
00164                 return false;
00165 
00166         return true;
00167     }
00168 };
00169 
00170 struct stc_packet {
00171     string src;
00172     string mc_group;
00173     uint32_t id;
00174 
00175     unsigned long ts;
00176 
00177     stc_packet(string source, string mc_g, uint32_t p_id) {
00178         src = source;
00179         id = p_id;
00180         //size = p_size;
00181         mc_group = mc_g;
00182         ts = getMillisecondsTime();
00183     }
00184 
00185     bool operator ==(const stc_packet& p) {
00186         return p.src.compare(src) == 0 && p.id == id && mc_group.compare(p.mc_group) == 0;
00187 
00188 
00189     }
00190 
00191 };
00192 
00193 struct ack_cr_info {
00194     unsigned char frame_src_mac[6];
00195     unsigned char frame_dst_mac[6];
00196     uint32_t id;
00197     uint32_t seq;
00198     unsigned long ts;
00199     std::string source_host;
00200     std::string mc_group;
00201     bool retransmitted;
00202     std::string network_string;
00203     uint8_t frame_type;
00204 
00205     ack_cr_info() {
00206         ts = getMillisecondsTime();
00207         seq = 0;
00208         mc_group = "";
00209         retransmitted = false;
00210     }
00211 
00212     bool operator ==(const ack_cr_info& p) {
00213 
00214         return compareMac(frame_src_mac, p.frame_src_mac) && compareMac(frame_dst_mac, p.frame_dst_mac) && id == p.id && seq == p.seq && mc_group.compare(p.mc_group) == 0 && source_host.compare(p.source_host) == 0 && frame_type == p.frame_type;
00215     }
00216 };
00217 
00218 
00219 /*
00220 struct neighbor
00221 {
00222         hostname_mac host_mac;
00223         nav_msgs::Odometry position;
00224 
00225         bool operator ==(const neighbor& st)
00226         {
00227                   return host_mac.operator ==(st.host_mac);
00228         }
00229 };
00230  */
00231 
00232 
00233 
00234 
00235 struct mc_tree {
00236     std::string group_name;
00237     routing_entry route_uplink;
00238     std::list<mac> mc_downlinks;
00239     bool member;
00240     bool active;
00241     bool connected;
00242     bool root; //true if current robot is root of the tree
00243     uint8_t root_distance;
00244 
00245     bool operator ==(const mc_tree& st) {
00246         if (group_name.compare(st.group_name) == 0)
00247             return true;
00248 
00249         return false;
00250     }
00251 
00252 };
00253 
00254 struct bcasts {
00255     uint32_t id;
00256     std::string src;
00257 
00258     bcasts(uint32_t id_, std::string src_) {
00259         id = id_;
00260         src = src_;
00261     }
00262 
00263     bool operator ==(const bcasts& st) {
00264         return (src.compare(st.src) == 0 && id == st.id);
00265 
00266     }
00267 
00268 
00269 };
00270 
00271 
00272 #endif /* STRUCTS_H_ */


adhoc_communication
Author(s): Guenter Cwioro , Torsten Andre
autogenerated on Thu Aug 27 2015 11:56:40