TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
BGTrafficHandle.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 "BGTrafficHandle.h"
17 #include "Ieee802Ctrl_m.h"
18 
19 #define ETHERAPP_BUFFER_SAP 0xe0
20 
21 namespace TTEthernetModel {
22 
23 Define_Module(BGTrafficHandle);
24 
26 {
27  Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
28  etherctrl->setDsap(ETHERAPP_BUFFER_SAP);
29  cMessage *msg = new cMessage("register_DSAP", IEEE802CTRL_REGISTER_DSAP);
30  msg->setControlInfo(etherctrl);
31 
32  send(msg, "lowerLayerOut");
33 }
34 
35 void BGTrafficHandle::handleMessage(cMessage *msg)
36 {
37  if(msg->arrivedOn("lowerLayerIn")){
38  send(msg, "out");
39  }
40  else if(msg->arrivedOn("in")){
41  Ieee802Ctrl *etherctrl = new Ieee802Ctrl();
42  etherctrl->setSsap(ETHERAPP_BUFFER_SAP);
43  etherctrl->setDsap(ETHERAPP_BUFFER_SAP);
44  msg->setControlInfo(etherctrl);
45  send(msg, "lowerLayerOut");
46  }
47 }
48 
49 } //namespace