src/node/internet-node.cc
changeset 521 e540282f8462
parent 520 92160600f7f2
child 522 d5039448597a
equal deleted inserted replaced
520:92160600f7f2 521:e540282f8462
    30 #include "udp.h"
    30 #include "udp.h"
    31 #include "ipv4.h"
    31 #include "ipv4.h"
    32 #include "arp.h"
    32 #include "arp.h"
    33 #include "net-device.h"
    33 #include "net-device.h"
    34 #include "i-udp-impl.h"
    34 #include "i-udp-impl.h"
       
    35 #include "i-arp-private.h"
    35 
    36 
    36 namespace ns3 {
    37 namespace ns3 {
    37 
    38 
    38 
    39 
    39 InternetNode::InternetNode()
    40 InternetNode::InternetNode()
    40 {
    41 {
    41   Ipv4 *ipv4 = new Ipv4 (this);
    42   Ipv4 *ipv4 = new Ipv4 (this);
    42   Arp *arp = new Arp (this);
    43   Arp *arp = new Arp (this);
    43   Udp *udp = new Udp (this);
    44   Udp *udp = new Udp (this);
    44 
    45 
    45 
       
    46   // Instantiate the capabilities
       
    47   ApplicationList *applicationList = new ApplicationList(this);
    46   ApplicationList *applicationList = new ApplicationList(this);
    48   L3Demux *l3Demux = new L3Demux(this);
    47   L3Demux *l3Demux = new L3Demux(this);
    49   Ipv4L4Demux *ipv4L4Demux = new Ipv4L4Demux(this);
    48   Ipv4L4Demux *ipv4L4Demux = new Ipv4L4Demux(this);
    50 
    49 
    51   l3Demux->Insert (ipv4);
    50   l3Demux->Insert (ipv4);
    52   l3Demux->Insert (arp);
    51   l3Demux->Insert (arp);
    53   ipv4L4Demux->Insert (udp);
    52   ipv4L4Demux->Insert (udp);
    54 
    53 
    55   IUdpImpl *udpImpl = new IUdpImpl (udp);
    54   IUdpImpl *udpImpl = new IUdpImpl (udp);
       
    55   IArpPrivate *arpPrivate = new IArpPrivate (arp);
    56 
    56 
       
    57   NsUnknown::AddInterface (arpPrivate);
    57   NsUnknown::AddInterface (udpImpl);
    58   NsUnknown::AddInterface (udpImpl);
    58   NsUnknown::AddInterface (applicationList);
    59   NsUnknown::AddInterface (applicationList);
    59   NsUnknown::AddInterface (l3Demux);
    60   NsUnknown::AddInterface (l3Demux);
    60   NsUnknown::AddInterface (ipv4L4Demux);
    61   NsUnknown::AddInterface (ipv4L4Demux);
    61 
    62 
    65   ipv4L4Demux->Unref ();
    66   ipv4L4Demux->Unref ();
    66   ipv4->Unref ();
    67   ipv4->Unref ();
    67   arp->Unref ();
    68   arp->Unref ();
    68   udp->Unref ();
    69   udp->Unref ();
    69   udpImpl->Unref ();
    70   udpImpl->Unref ();
       
    71   arpPrivate->Unref ();
    70 }
    72 }
    71 
    73 
    72 InternetNode::~InternetNode ()
    74 InternetNode::~InternetNode ()
    73 {}
    75 {}
    74 
    76 
    86   resolver->Add ("ipv4",
    88   resolver->Add ("ipv4",
    87                  MakeCallback (&Ipv4::CreateTraceResolver, ipv4),
    89                  MakeCallback (&Ipv4::CreateTraceResolver, ipv4),
    88                  InternetNode::IPV4);
    90                  InternetNode::IPV4);
    89   ipv4->Unref ();
    91   ipv4->Unref ();
    90 
    92 
    91   Arp *arp = GetArp ();
       
    92   resolver->Add ("arp",
       
    93                  MakeCallback (&Arp::CreateTraceResolver, arp),
       
    94                  InternetNode::ARP);
       
    95   arp->Unref ();
       
    96 
    93 
    97   return resolver;
    94   return resolver;
    98 }
    95 }
    99 
    96 
   100 void 
    97 void 
   109   L3Demux *l3Demux = QueryInterface<L3Demux> (L3Demux::iid);
   106   L3Demux *l3Demux = QueryInterface<L3Demux> (L3Demux::iid);
   110   Ipv4 *ipv4 = static_cast<Ipv4*> (l3Demux->PeekProtocol (Ipv4::PROT_NUMBER));
   107   Ipv4 *ipv4 = static_cast<Ipv4*> (l3Demux->PeekProtocol (Ipv4::PROT_NUMBER));
   111   l3Demux->Unref ();
   108   l3Demux->Unref ();
   112   ipv4->Ref ();
   109   ipv4->Ref ();
   113   return ipv4;
   110   return ipv4;
   114 }
       
   115 
       
   116 Arp *
       
   117 InternetNode::GetArp (void) const
       
   118 {
       
   119   L3Demux *l3Demux = QueryInterface<L3Demux> (L3Demux::iid);
       
   120   Arp *arp = static_cast<Arp*> (l3Demux->PeekProtocol (Arp::PROT_NUMBER));
       
   121   l3Demux->Unref ();
       
   122   arp->Ref ();
       
   123   return arp;
       
   124 }
   111 }
   125 
   112 
   126 void 
   113 void 
   127 InternetNode::DoAddDevice (NetDevice *device) const
   114 InternetNode::DoAddDevice (NetDevice *device) const
   128 {
   115 {