Skip to content

Commit

Permalink
ipv6: reduce usage of INET_WITH_xMIPv6 macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoltanBojthe authored and levy committed Nov 19, 2024
1 parent ef9496c commit 547340b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
13 changes: 0 additions & 13 deletions src/inet/networklayer/icmpv6/Ipv6NeighbourDiscovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2100,43 +2100,33 @@ void Ipv6NeighbourDiscovery::sendUnsolicitedNa(NetworkInterface *ie)
// Section 7.2.6: Sending Unsolicited Neighbor Advertisements
#ifdef INET_WITH_xMIPv6
Enter_Method("sendUnsolicitedNa");
#endif /* INET_WITH_xMIPv6 */

#ifndef INET_WITH_xMIPv6
// In some cases a node may be able to determine that its link-layer
// address has changed (e.g., hot-swap of an interface card) and may
// wish to inform its neighbors of the new link-layer address quickly.
// In such cases a node MAY send up to MAX_NEIGHBOR_ADVERTISEMENT
// unsolicited Neighbor Advertisement messages to the all-nodes
// multicast address. These advertisements MUST be separated by at
// least RetransTimer seconds.
#else /* INET_WITH_xMIPv6 */
auto na = makeShared<Ipv6NeighbourAdvertisement>();
Ipv6Address myIPv6Addr = ie->getProtocolData<Ipv6InterfaceData>()->getPreferredAddress();
#endif /* INET_WITH_xMIPv6 */

// The Target Address field in the unsolicited advertisement is set to
// an IP address of the interface, and the Target Link-Layer Address
// option is filled with the new link-layer address.
#ifdef INET_WITH_xMIPv6
na->setTargetAddress(myIPv6Addr);
auto sla = new Ipv6NdTargetLinkLayerAddress();
sla->setLinkLayerAddress(ie->getMacAddress());
na->getOptionsForUpdate().appendOption(sla);
na->addChunkLength(IPv6ND_LINK_LAYER_ADDRESS_OPTION_LENGTH);
#endif /* INET_WITH_xMIPv6 */

// The Solicited flag MUST be set to zero, in order to avoid confusing
// the Neighbor Unreachability Detection algorithm.
#ifdef INET_WITH_xMIPv6
na->setSolicitedFlag(false);
#endif /* INET_WITH_xMIPv6 */

// If the node is a router, it MUST set the Router flag to one;
// otherwise it MUST set it to zero.
#ifdef INET_WITH_xMIPv6
na->setRouterFlag(rt6->isRouter());
#endif /* INET_WITH_xMIPv6 */

// The Override flag MAY be set to either zero or one. In either case,
// neighboring nodes will immediately change the state of their Neighbor
Expand All @@ -2145,9 +2135,7 @@ void Ipv6NeighbourDiscovery::sendUnsolicitedNa(NetworkInterface *ie)
// one, neighboring nodes will install the new link-layer address in
// their caches. Otherwise, they will ignore the new link-layer
// address, choosing instead to probe the cached address.
#ifdef INET_WITH_xMIPv6
na->setOverrideFlag(true);
#endif /* INET_WITH_xMIPv6 */

// A node that has multiple IP addresses assigned to an interface MAY
// multicast a separate Neighbor Advertisement for each address. In
Expand All @@ -2174,7 +2162,6 @@ void Ipv6NeighbourDiscovery::sendUnsolicitedNa(NetworkInterface *ie)
// Neighbor Unreachability Detection algorithm ensures that all nodes
// obtain a reachable link-layer address, though the delay may be
// slightly longer.
#ifdef INET_WITH_xMIPv6
auto packet = new Packet("NApacket");
Icmpv6::insertCrc(crcMode, na, packet);
packet->insertAtFront(na);
Expand Down
26 changes: 10 additions & 16 deletions src/inet/networklayer/ipv6/Ipv6InterfaceData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ std::string Ipv6InterfaceData::RouterMulticastData::detailedInfo()
Ipv6InterfaceData::Ipv6InterfaceData()
: InterfaceProtocolData(NetworkInterface::F_IPV6_DATA)
{
#ifdef INET_WITH_xMIPv6
// rt6 = IPv6RoutingTableAccess().get();
#endif /* INET_WITH_xMIPv6 */
/*******************Setting host/node/router Protocol Constants************/
routerConstants.maxInitialRtrAdvertInterval = IPv6_MAX_INITIAL_RTR_ADVERT_INTERVAL;
routerConstants.maxInitialRtrAdvertisements = IPv6_MAX_INITIAL_RTR_ADVERTISEMENTS;
Expand All @@ -85,15 +82,6 @@ Ipv6InterfaceData::Ipv6InterfaceData()
hostConstants.rtrSolicitationInterval = IPv6_RTR_SOLICITATION_INTERVAL;
hostConstants.maxRtrSolicitations = IPv6_MAX_RTR_SOLICITATIONS;

#ifdef INET_WITH_xMIPv6
hostConstants.initialBindAckTimeout = MIPv6_INITIAL_BINDACK_TIMEOUT; // MIPv6: added by Zarrar Yousaf @ CNI UniDo 17.06.07
hostConstants.maxBindAckTimeout = MIPv6_MAX_BINDACK_TIMEOUT; // MIPv6: added by Zarrar Yousaf @ CNI UniDo 17.06.07
hostConstants.initialBindAckTimeoutFirst = MIPv6_INITIAL_BINDACK_TIMEOUT_FIRST; // MIPv6: 12.9.07 - CB
hostConstants.maxRRBindingLifeTime = MIPv6_MAX_RR_BINDING_LIFETIME; // 14.9.07 - CB
hostConstants.maxHABindingLifeTime = MIPv6_MAX_HA_BINDING_LIFETIME; // 14.9.07 - CB
hostConstants.maxTokenLifeTime = MIPv6_MAX_TOKEN_LIFETIME; // 14.9.07 - CB
#endif /* INET_WITH_xMIPv6 */

nodeConstants.maxMulticastSolicit = IPv6_MAX_MULTICAST_SOLICIT;
nodeConstants.maxUnicastSolicit = IPv6_MAX_UNICAST_SOLICIT;
nodeConstants.maxAnycastDelayTime = IPv6_MAX_ANYCAST_DELAY_TIME;
Expand All @@ -120,16 +108,22 @@ Ipv6InterfaceData::Ipv6InterfaceData()
rtrVars.advManagedFlag = false;
rtrVars.advOtherConfigFlag = false;

#ifdef INET_WITH_xMIPv6
rtrVars.advHomeAgentFlag = false; // Zarrar Yousaf Feb-March 2007
#endif /* INET_WITH_xMIPv6 */

rtrVars.advLinkMTU = IPv6_MIN_MTU;
rtrVars.advReachableTime = IPv6_DEFAULT_ADV_REACHABLE_TIME;
rtrVars.advRetransTimer = IPv6_DEFAULT_ADV_RETRANS_TIMER;
rtrVars.advCurHopLimit = IPv6_DEFAULT_ADVCURHOPLIMIT;
rtrVars.advDefaultLifetime = 3 * rtrVars.maxRtrAdvInterval;

#ifdef INET_WITH_xMIPv6
rtrVars.advHomeAgentFlag = false; // Zarrar Yousaf Feb-March 2007
hostConstants.initialBindAckTimeout = MIPv6_INITIAL_BINDACK_TIMEOUT; // MIPv6: added by Zarrar Yousaf @ CNI UniDo 17.06.07
hostConstants.maxBindAckTimeout = MIPv6_MAX_BINDACK_TIMEOUT; // MIPv6: added by Zarrar Yousaf @ CNI UniDo 17.06.07
hostConstants.initialBindAckTimeoutFirst = MIPv6_INITIAL_BINDACK_TIMEOUT_FIRST; // MIPv6: 12.9.07 - CB
hostConstants.maxRRBindingLifeTime = MIPv6_MAX_RR_BINDING_LIFETIME; // 14.9.07 - CB
hostConstants.maxHABindingLifeTime = MIPv6_MAX_HA_BINDING_LIFETIME; // 14.9.07 - CB
hostConstants.maxTokenLifeTime = MIPv6_MAX_TOKEN_LIFETIME; // 14.9.07 - CB
#endif /* INET_WITH_xMIPv6 */

#if USE_MOBILITY
if (rtrVars.advDefaultLifetime < 1)
rtrVars.advDefaultLifetime = 1;
Expand Down

0 comments on commit 547340b

Please sign in to comment.