McPosAckObj.cpp
Go to the documentation of this file.
00001 /* 
00002  * File:   McPosAckObj.cpp
00003  * Author: cwioro
00004  * 
00005  * Created on August 7, 2014, 8:43 AM
00006  */
00007 
00008 #include <list>
00009 
00010 #include "McPosAckObj.h"
00011 #include "McTree.h"
00012 #include "structs.h"
00013 #include "EthernetFrame.h"
00014 #include "functions.h"
00015 #include "header.h"
00016 
00017 McPosAckObj::McPosAckObj(RoutedFrame* frame, McTree* group)
00018 {
00019 
00020     group_name = std::string(group->group_name_);
00021 
00022     packet_id = frame->header_.packet_id;
00023     sequence_num = frame->header_.packet_sequence_num;
00024 
00025     //memcpy(incoming_mac,frame->eh_h_.eh_source,6);
00026 
00027 
00028 
00029     if (!compareMac(group->route_uplink_->next_hop, frame->eh_h_.eh_source) && !group->root)
00030     {
00031         unsigned char* mac_p = new unsigned char[6];
00032         memcpy(mac_p, group->route_uplink_->next_hop, 6);
00033         missing_acks_l.push_back(mac_p);
00034         //ROS_ERROR("ADD Uplink %s", getMacAsCStr(mac_p));
00035     }
00036 
00037     for (std::list<mac*>::iterator i = group->downlinks_l_.begin(); i != group->downlinks_l_.end(); i++)
00038     {
00039         mac* m = *i;
00040 
00041 
00042         if (!compareMac(frame->eh_h_.eh_source, m->mac_adr))
00043         {
00044             unsigned char* mac_p = new unsigned char[6];
00045             memcpy(mac_p, m->mac_adr, 6);
00046             missing_acks_l.push_back(mac_p);
00047             //ROS_ERROR("ADD Downlink %s", getMacAsCStr(mac_p));
00048         }
00049     }
00050 }
00051 
00052 McPosAckObj::McPosAckObj(const McPosAckObj& orig)
00053 {
00054 }
00055 
00056 McPosAckObj::~McPosAckObj()
00057 {
00058 }
00059 
00060 bool McPosAckObj::GotAck(McAckFrame* ack)
00061 {
00062     if (ack->mc_group_.compare(group_name) == 0 && ack->header_.packet_id == packet_id && ack->header_.frame_seq_num == sequence_num)
00063     {
00064         for (std::list<unsigned char*>::iterator i = missing_acks_l.begin(); i != missing_acks_l.end();)
00065         {
00066             if (compareMac(*i, ack->eh_h_.eh_source))
00067             {
00068                 delete (*i);
00069                 i = missing_acks_l.erase(i);
00070                 return missing_acks_l.empty();
00071             }
00072             else
00073                 i++;
00074         }
00075     }
00076     return false;
00077 }


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