Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Uint128 + manetrouting: removed conversion operators of Uint128

added 'explicit' for Uint128 constructor by char string
uses explicit conversions in manetrouting code
  • Loading branch information...
commit ab947029505caac4fba688a0530415314a90ff1e 1 parent de0a537
@ZoltanBojthe ZoltanBojthe authored
View
2  src/networklayer/manetrouting/aodv/aodv-uu/aodv_neighbor.cc
@@ -175,7 +175,7 @@ void NS_CLASS neighbor_link_break(rt_table_t * rt)
{
/* Decide whether new precursors make this a non unicast RERR */
rerr_add_udest(rerr, rt_u->dest_addr, rt_u->dest_seqno);
- if (rerr_unicast_dest.s_addr)
+ if (rerr_unicast_dest.s_addr != 0)
{
for (unsigned int i = 0; i< rt_u->precursors.size(); i++)
{
View
2  src/networklayer/manetrouting/aodv/aodv-uu/aodv_rerr.cc
@@ -188,7 +188,7 @@ void NS_CLASS rerr_process(RERR * rerr, int rerrlen,struct in_addr ip_src,
ip_to_str(rt->dest_addr), rt->dest_seqno);
#ifdef AODV_USE_STL_RT
- if (rerr_unicast_dest.s_addr)
+ if (rerr_unicast_dest.s_addr != 0)
{
for (unsigned int i = 0; i< rt->precursors.size(); i++)
{
View
2  src/networklayer/manetrouting/aodv/aodv-uu/aodv_rreq.cc
@@ -253,7 +253,7 @@ void NS_CLASS rreq_process(RREQ * rreq, int rreqlen, struct in_addr ip_src,
/* Ignore RREQ's that originated from this node. Either we do this
or we buffer our own sent RREQ's as we do with others we
receive. */
- ifaddr = DEV_IFINDEX(ifindex).ipaddr.s_addr;
+ ifaddr = DEV_IFINDEX(ifindex).ipaddr.s_addr.toUint();
#ifndef OMNETPP
if (rreq_orig.s_addr == DEV_IFINDEX(ifindex).ipaddr.s_addr)
return;
View
2  src/networklayer/manetrouting/aodv/aodv_uu_omnet.cc
@@ -867,7 +867,7 @@ void NS_CLASS processPacket(IPv4Datagram * p,unsigned int ifindex)
/* If this is a TCP packet and we don't have a route, we should
set the gratuituos flag in the RREQ. */
- bool isMcast = ie->ipv4Data()->isMemberOfMulticastGroup(IPv4Address(dest_addr.s_addr));
+ bool isMcast = ie->ipv4Data()->isMemberOfMulticastGroup(IPv4Address(dest_addr.s_addr.toUint()));
/* If the packet is not interesting we just let it go through... */
if (dest_addr.s_addr == AODV_BROADCAST ||isMcast)
View
20 src/networklayer/manetrouting/base/ManetRoutingBase.cc
@@ -791,7 +791,7 @@ void ManetRoutingBase::omnet_chg_rte(const Uint128 &dst, const Uint128 &gtwy, co
opp_error("Manet routing protocol is not register");
/* Add route to kernel routing table ... */
- IPv4Address desAddress((uint32_t)dst);
+ IPv4Address desAddress(dst.toUint());
if (!createInternalStore && routesVector)
{
delete routesVector;
@@ -868,8 +868,8 @@ void ManetRoutingBase::omnet_chg_rte(const Uint128 &dst, const Uint128 &gtwy, co
if (del_entry)
return;
- IPv4Address netmask((uint32_t)netm);
- IPv4Address gateway((uint32_t)gtwy);
+ IPv4Address netmask(netm.toUint());
+ IPv4Address gateway(gtwy.toUint());
// The default mask is for manet routing is IPv4Address::ALLONES_ADDRESS
if (netm==0)
@@ -961,7 +961,7 @@ void ManetRoutingBase::omnet_chg_rte(const Uint128 &dst, const Uint128 &gtwy, co
opp_error("Manet routing protocol is not register");
/* Add route to kernel routing table ... */
- IPv4Address desAddress((uint32_t)dst);
+ IPv4Address desAddress(dst.toUint());
if (!createInternalStore && routesVector)
{
delete routesVector;
@@ -1023,8 +1023,8 @@ void ManetRoutingBase::omnet_chg_rte(const Uint128 &dst, const Uint128 &gtwy, co
if (del_entry)
return;
- IPv4Address netmask((uint32_t)netm);
- IPv4Address gateway((uint32_t)gtwy);
+ IPv4Address netmask(netm.toUint());
+ IPv4Address gateway(gtwy.toUint());
if (netm==0)
netmask = IPv4Address::ALLONES_ADDRESS;
@@ -1117,7 +1117,7 @@ Uint128 ManetRoutingBase::omnet_exist_rte(Uint128 dst)
opp_error("Manet routing protocol is not register");
/* Add route to kernel routing table ... */
- IPv4Address desAddress((uint32_t)dst);
+ IPv4Address desAddress(dst.toUint());
const IPv4Route *e = NULL;
if (mac_layer_)
return (Uint128) 0;
@@ -1508,7 +1508,7 @@ bool ManetRoutingBase::setRoute(const Uint128 & destination, const Uint128 &next
opp_error("Manet routing protocol is not register");
/* Add route to kernel routing table ... */
- IPv4Address desAddress((uint32_t)destination);
+ IPv4Address desAddress(destination.toUint());
bool del_entry = (nextHop == (Uint128)0);
if (!createInternalStore && routesVector)
@@ -1582,8 +1582,8 @@ bool ManetRoutingBase::setRoute(const Uint128 & destination, const Uint128 &next
if (del_entry)
return true;
- IPv4Address netmask((uint32_t)mask);
- IPv4Address gateway((uint32_t)nextHop);
+ IPv4Address netmask(mask.toUint());
+ IPv4Address gateway(nextHop.toUint());
if (mask==(Uint128)0)
netmask = IPv4Address::ALLONES_ADDRESS;
InterfaceEntry *ie = getInterfaceEntry(ifaceIndex);
View
4 src/networklayer/manetrouting/batman/BatmanData.cc
@@ -1392,7 +1392,7 @@ int Batman::add_del_interface_rules(int8_t rule_action)
if ((batman_if = is_batman_if(ifr))==NULL)
continue;
- add_del_rule(netaddr, netmask, BATMAN_RT_TABLE_TUNNEL, (rule_action == RULE_DEL ? 0 : BATMAN_RT_PRIO_TUNNEL + if_count), 0, RULE_TYPE_SRC, rule_action);
+ add_del_rule(netaddr, mask, BATMAN_RT_TABLE_TUNNEL, (rule_action == RULE_DEL ? 0 : BATMAN_RT_PRIO_TUNNEL + if_count), 0, RULE_TYPE_SRC, rule_action);
if (ifr->isLoopback())
add_del_rule(0, 0, BATMAN_RT_TABLE_TUNNEL, BATMAN_RT_PRIO_TUNNEL, ifr, RULE_TYPE_IIF, rule_action);
@@ -1402,7 +1402,7 @@ int Batman::add_del_interface_rules(int8_t rule_action)
return 1;
}
-void Batman::add_del_rule(uint32_t network, uint8_t netmask, int8_t rt_table, uint32_t prio, InterfaceEntry *iif, int8_t rule_type, int8_t rule_action)
+void Batman::add_del_rule(const Uint128& network, uint8_t netmask, int8_t rt_table, uint32_t prio, InterfaceEntry *iif, int8_t rule_type, int8_t rule_action)
{
return;
}
View
2  src/networklayer/manetrouting/batman/batman.h
@@ -117,7 +117,7 @@ class Batman : public ManetRoutingBase
uint8_t ring_buffer_avg(std::vector<uint8_t> &tq_recv);
// Routing table modification
void add_del_route(const Uint128 &, uint8_t netmask, const Uint128 &, int32_t, InterfaceEntry *dev, uint8_t rt_table, int8_t route_type, int8_t route_action);
- void add_del_rule(uint32_t network, uint8_t netmask, int8_t rt_table, uint32_t prio, InterfaceEntry *dev, int8_t rule_type, int8_t rule_action);
+ void add_del_rule(const Uint128& network, uint8_t netmask, int8_t rt_table, uint32_t prio, InterfaceEntry *dev, int8_t rule_type, int8_t rule_action);
int add_del_interface_rules(int8_t rule_action);
//
// Default routes methods
View
2  src/networklayer/manetrouting/dymo/dymo_msg_struct.cc
@@ -349,7 +349,7 @@ std::string DYMO_element::detailedInfo() const
}
else if (rerr_type)
{
- IPv4Address naddr((uint32_t) notify_addr);
+ IPv4Address naddr(notify_addr.toUint());
out << " Notify address " << naddr << "\n"; // Khmm
for (int i = 0; i < rerr_type->numBlocks(); i++)
{
View
2  src/networklayer/manetrouting/dymo/dymo_um_omnet.cc
@@ -713,7 +713,7 @@ void DYMOUM::processPacket(IPv4Datagram * p, unsigned int ifindex )
}
InterfaceEntry * ie = getInterfaceEntry(ifindex);
- bool isMcast = ie->ipv4Data()->isMemberOfMulticastGroup(IPv4Address(dest_addr.s_addr));
+ bool isMcast = ie->ipv4Data()->isMemberOfMulticastGroup(IPv4Address(dest_addr.s_addr.toUint()));
/* If the packet is not interesting we just let it go through... */
if (dest_addr.s_addr == DYMO_BROADCAST || isMcast)
View
6 src/networklayer/manetrouting/dymo/dymoum/dymo_uerr.cc
@@ -51,9 +51,15 @@ UERR *NS_CLASS uerr_create(struct in_addr target_addr,
uerr->i = 0;
uerr->res = 0;
+#ifndef OMNETPP
uerr->target_addr = (u_int32_t) target_addr.s_addr;
uerr->uerr_node_addr = (u_int32_t) uerr_node_addr.s_addr;
uerr->uelem_target_addr = (u_int32_t) uelem_target_addr.s_addr;
+#else
+ uerr->target_addr = target_addr.s_addr.toUint();
+ uerr->uerr_node_addr = uerr_node_addr.s_addr.toUint();
+ uerr->uelem_target_addr = uelem_target_addr.s_addr.toUint();
+#endif
uerr->uelem_type = uelem_type;
return uerr;
View
2  src/networklayer/manetrouting/olsr/OLSR.cc
@@ -2725,7 +2725,7 @@ OLSR::emf_to_seconds(uint8_t olsr_format)
int
OLSR::node_id(const nsaddr_t &addr)
{
- return addr;
+ return addr.toUint();
/*
// Preventing a bad use for this function
if ((uint32_t)addr == IP_BROADCAST)
View
15 src/util/uint128.h
@@ -101,7 +101,7 @@ class Uint128
Uint128(const double& a);
Uint128(const long double& a);
- Uint128(const char *sz) {set(sz);}
+ explicit Uint128(const char *sz) {set(sz);}
// TODO: Consider creation of operator= to eliminate
// the need of intermediate objects during assignments.
@@ -170,19 +170,6 @@ class Uint128
double toDouble() const;
long double toLongDouble() const;
- operator double() const {return toDouble(); }
- operator int() const {return toUint();}
- operator uint32_t() const { return toUint();}
- operator uint64_t() const {return toUint64();}
- operator int64_t() const {return toUint64();}
-
- operator bool()
- {
- if (lo==0 && hi == 0)
- return false;
- return true;
- }
-
// Arithmetic methods
Uint128 div(const Uint128&, Uint128&) const;
Please sign in to comment.
Something went wrong with that request. Please try again.