src/devices/csma/csma-ipv4-topology.cc
changeset 1432 3aef7d7a71c2
parent 1430 25fa26a6533e
child 1433 a6fb891b59fd
equal deleted inserted replaced
1431:3760d52ef5d1 1432:3aef7d7a71c2
    89                                                   false, true);
    89                                                   false, true);
    90   nd1->AddQueue(q);
    90   nd1->AddQueue(q);
    91   nd1->Attach (ch);
    91   nd1->Attach (ch);
    92 }
    92 }
    93 
    93 
    94 void
    94 uint32_t
    95 CsmaIpv4Topology::AddIpv4Address(Ptr<Node> n1,
    95 CsmaIpv4Topology::AddIpv4Address(
    96                                  int ndNum,
    96   Ptr<Node>             node,
    97                                  const Ipv4Address& addr1,
    97   uint32_t              netDeviceNumber,
    98                                  const Ipv4Mask& netmask1)
    98   const Ipv4Address     address,
       
    99   const Ipv4Mask        mask)
    99 {
   100 {
   100   // Duplex link is assumed to be subnetted as a /30
   101   Ptr<NetDevice> nd = node->GetDevice(netDeviceNumber);
   101   // May run this unnumbered in the future?
       
   102   Ipv4Mask netmask(netmask1);
       
   103 
   102 
   104   Ptr<NetDevice> nd1 = n1->GetDevice(ndNum);
   103   Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
       
   104   uint32_t ifIndex = ipv4->AddInterface (nd);
   105 
   105 
   106   Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> (Ipv4::iid);
   106   ipv4->SetAddress (ifIndex, address);
   107   uint32_t index1 = ip1->AddInterface (nd1);
   107   ipv4->SetNetworkMask (ifIndex, mask);
   108 
   108   ipv4->SetUp (ifIndex);
   109   ip1->SetAddress (index1, addr1);
   109   return ifIndex;
   110   ip1->SetNetworkMask (index1, netmask);
       
   111   ip1->SetUp (index1);
       
   112 }
   110 }
   113 
   111 
   114 void
   112 void
   115 CsmaIpv4Topology::AddIpv4Routes (
   113 CsmaIpv4Topology::AddIpv4Routes (
   116   Ptr<NetDevice> nd1, Ptr<NetDevice> nd2)
   114   Ptr<NetDevice> nd1, Ptr<NetDevice> nd2)