TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CTBuffer.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
15 
16 #include "Buffer.h"
17 #include "CTBuffer.h"
18 #include "TTE4INETDefs.h"
19 #include "CTFrame.h"
20 
21 #include "HelperFunctions.h"
22 
23 using namespace TTEthernetModel;
24 
26 
28 }
29 
30  void CTBuffer::putFrame(EtherFrame* frame){
31  int priority = par("priority").longValue();
32  if(frame && priority>=0){
33  frame->setSchedulingPriority(priority);
34  }
35  enqueue(frame);
36 }
37 
38 void CTBuffer::handleMessage(cMessage *msg)
39 {
40  if (msg->arrivedOn("in"))
41  {
42  CTFrame *ctframe = dynamic_cast<CTFrame *>(msg);
43  //Try to correct destination mac
44  if(ctframe != NULL){
45  if(ctframe->getDest().isUnspecified()){
46  ctframe->setCtID(ctId);
47  ctframe->setCtMarker(ctMarker & ctMask);
48  }
49  else if(ctframe->getCtMarker()==0){
50  ctframe->setCtMarker(ctMarker & ctMask);
51  }
52  }
54  }
55 }
56 
57 void CTBuffer::handleParameterChange(const char* parname){
58  ctMask = (uint32_t)par("ct_mask").longValue();
59  ctMarker = (uint32_t)par("ct_marker").longValue();
60  ctId = (uint16_t)par("ct_id").longValue();
61 
63 }