On Mon, 2008-11-24 at 05:04 -0800, Norman wrote:
> Hi Gustavo,
> Many thanks for your suggestion.
> Are you sure that this object/functions are meant to use directly?
> From what I see there is not header file in "./build/debug/ns3/" for
> Ipv4LoopbackInterface.
> [ this is not a problem since I can use the one from "./src/internet-
> stack",
> but what bothers me is the fact that AddIpv4Interface() method is
> private for object "Ipv4L3Protocol" and I'm not sure how to use it
> properly before starting to modifying "ns".
> Snip from: "src/internet-stack/ipv4-l3-protocol.cc":
> void
> Ipv4L3Protocol::SetupLoopback (void)
> {
> NS_LOG_FUNCTION_NOARGS ();
> Ptr<Ipv4LoopbackInterface> interface =
> CreateObject<Ipv4LoopbackInterface> ();
> interface->SetNode (m_node);
> interface->SetAddress (Ipv4Address::GetLoopback ());
> interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
> uint32_t index = AddIpv4Interface (interface);
> AddHostRouteTo (Ipv4Address::GetLoopback (), index);
> interface->SetUp ();
> }
> And below what I'm trying to do:
> void makerid2(char *ipaddr, Ptr<Node> n) {
> Ptr<Ipv4LoopbackInterface> interface =
> CreateObject<Ipv4LoopbackInterface> ();
> Ptr<Ipv4StaticRouting> srt = CreateObject<Ipv4StaticRouting> ();
> Ipv4Address ip(ipaddr);
> interface->SetNode (n);
> interface->SetAddress (ip);
> interface->SetNetworkMask (0xffffffff);
> uint32_t index = AddIpv4Interface (interface);
> srt->AddHostRouteTo (ip, index);
> interface->SetUp ();
> }
> That's the error I get once trying to run it:
> [469/513] cxx: scratch/myfirst.cc -> build/debug/scratch/myfirst_4.o
> ../scratch/myfirst.cc: In function 'void makerid2(char*,
> ns3::Ptr<ns3::Node>)':
> ../scratch/myfirst.cc:236: error: 'AddIpv4Interface' was not declared
> in this scope
> Build failed
> -> task failed (err #129): [bld:///wrk/ns3/ns-3.2/scratch/
> myfirst_4.o]
> This is because AddIpv4Interface is a private method,
> any idea how to solve it nicely without any modification to ns?
There is no other way than to patch the src/internet-stack directory.