src/helper/ipv4-address-helper.cc
changeset 2983 e3a416fe9dd5
parent 2888 872dc8466352
child 3179 1763f7ac8e80
equal deleted inserted replaced
2982:a7e3e54c7e94 2983:e3a416fe9dd5
    29 
    29 
    30 namespace ns3 {
    30 namespace ns3 {
    31 
    31 
    32 Ipv4AddressHelper::Ipv4AddressHelper () 
    32 Ipv4AddressHelper::Ipv4AddressHelper () 
    33 {
    33 {
    34   NS_LOG_FUNCTION;
    34   NS_LOG_FUNCTION_NOARGS ();
    35 
    35 
    36 //
    36 //
    37 // Set the default values to an illegal state.  Do this so the client is 
    37 // Set the default values to an illegal state.  Do this so the client is 
    38 // forced to think at least briefly about what addresses get used and what
    38 // forced to think at least briefly about what addresses get used and what
    39 // is going on here.
    39 // is going on here.
    50 Ipv4AddressHelper::SetBase (
    50 Ipv4AddressHelper::SetBase (
    51   const Ipv4Address network, 
    51   const Ipv4Address network, 
    52   const Ipv4Mask mask,
    52   const Ipv4Mask mask,
    53   const Ipv4Address address)
    53   const Ipv4Address address)
    54 {
    54 {
    55   NS_LOG_FUNCTION;
    55   NS_LOG_FUNCTION_NOARGS ();
    56 
    56 
    57   m_network = network.GetHostOrder ();
    57   m_network = network.GetHostOrder ();
    58   m_mask = mask.GetHostOrder ();
    58   m_mask = mask.GetHostOrder ();
    59   m_base = m_address = address.GetHostOrder ();
    59   m_base = m_address = address.GetHostOrder ();
    60 
    60 
   112 }
   112 }
   113 
   113 
   114   Ipv4Address
   114   Ipv4Address
   115 Ipv4AddressHelper::NewNetwork (void)
   115 Ipv4AddressHelper::NewNetwork (void)
   116 {
   116 {
   117   NS_LOG_FUNCTION;
   117   NS_LOG_FUNCTION_NOARGS ();
   118   ++m_network;
   118   ++m_network;
   119   m_address = m_base;
   119   m_address = m_base;
   120   return Ipv4Address (m_network << m_shift);
   120   return Ipv4Address (m_network << m_shift);
   121 }
   121 }
   122 
   122 
   123 Ipv4InterfaceContainer
   123 Ipv4InterfaceContainer
   124 Ipv4AddressHelper::Assign (const NetDeviceContainer &c)
   124 Ipv4AddressHelper::Assign (const NetDeviceContainer &c)
   125 {
   125 {
   126   NS_LOG_FUNCTION;
   126   NS_LOG_FUNCTION_NOARGS ();
   127   Ipv4InterfaceContainer retval;
   127   Ipv4InterfaceContainer retval;
   128   for (uint32_t i = 0; i < c.GetN (); ++i) {
   128   for (uint32_t i = 0; i < c.GetN (); ++i) {
   129     Ptr<NetDevice> device = c.Get (i);
   129     Ptr<NetDevice> device = c.Get (i);
   130 
   130 
   131     Ptr<Node> node = device->GetNode ();
   131     Ptr<Node> node = device->GetNode ();
   154 const uint32_t N_BITS = 32;
   154 const uint32_t N_BITS = 32;
   155 
   155 
   156   uint32_t
   156   uint32_t
   157 Ipv4AddressHelper::NumAddressBits (uint32_t maskbits) const
   157 Ipv4AddressHelper::NumAddressBits (uint32_t maskbits) const
   158 {
   158 {
   159   NS_LOG_FUNCTION;
   159   NS_LOG_FUNCTION_NOARGS ();
   160   for (uint32_t i = 0; i < N_BITS; ++i)
   160   for (uint32_t i = 0; i < N_BITS; ++i)
   161     {
   161     {
   162       if (maskbits & 1)
   162       if (maskbits & 1)
   163         {
   163         {
   164           NS_LOG_LOGIC ("NumAddressBits -> " << i);
   164           NS_LOG_LOGIC ("NumAddressBits -> " << i);