diff --git a/bindings/python/ns3modulegen.py b/bindings/python/ns3modulegen.py index 148f464a8..6bbe41af7 100755 --- a/bindings/python/ns3modulegen.py +++ b/bindings/python/ns3modulegen.py @@ -95,6 +95,7 @@ def main(): ns3modulegen_core_customizations.CommandLine_customizations(root_module) ns3modulegen_core_customizations.TypeId_customizations(root_module) ns3modulegen_core_customizations.add_std_ofstream(root_module) + ns3modulegen_core_customizations.add_ipv4_address_tp_hash(root_module) for local_module in LOCAL_MODULES: diff --git a/bindings/python/ns3modulegen_core_customizations.py b/bindings/python/ns3modulegen_core_customizations.py index d82aa1e63..807dbabb0 100644 --- a/bindings/python/ns3modulegen_core_customizations.py +++ b/bindings/python/ns3modulegen_core_customizations.py @@ -572,3 +572,14 @@ def add_std_ofstream(module): Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")]) ofstream.add_method('close', None, []) +def add_ipv4_address_tp_hash(module): + module.body.writeln(''' +long +_ns3_Ipv4Address_tp_hash (PyObject *obj) +{ + PyNs3Ipv4Address *addr = reinterpret_cast (obj); + return static_cast (ns3::Ipv4AddressHash () (*addr->obj)); +} +''') + module.header.writeln('long _ns3_Ipv4Address_tp_hash (PyObject *obj);') + module['Ipv4Address'].pytype.slots['tp_hash'] = "_ns3_Ipv4Address_tp_hash"