[Xorp-hackers] Events and sockets in XORP

Pavlin Radoslavov pavlin at ICSI.Berkeley.EDU
Mon Feb 2 11:48:08 PST 2009


> > First you need to open the TCP socket by using one of the tcp_open*
> > XRLs, which will give you the sockid. Then you can use sockid for
> > additional operations on the socket.
> >
> > You might also have a look at fea/test_xrl_sockets4_tcp.cc for usage
> > of some of the TCP-related XRLs.
> >
> > Pavlin
> >
> 
> 
> I was trying to do something like this:
> 
> int XrlBpsfNode::startup() {
>   const IPv4 localIP("146.169.3.2");
>   const uint32_t localPort(1337);
>   printf("%s\n", "Starting up XrlBpsfNode");
>   XrlSocket4V0p1Client cl(this);
>   if(!cl.send_tcp_open_and_bind("socket4/0.1/tcp_open_and_bind",
>                                 "bpsf/0.1", localIP, localPort,
>                                 callback(this, &XrlBpsfNode::bind_cb))) {
>     printf("%s\n", "Error opening and binding socket");
>     return(XORP_ERROR);
>   }
>   return cl.send_tcp_listen("socket4/0.1/tcp_listen", server_sockid, 100,
>                             callback(this, &XrlBpsfNode::listen_cb));
> }

In the above code you cannot call send_tcp_open_and_bind() and
send_tcp_listen() back-to-back. You must return to the eventloop
after you call the first XRL, because only when the bind_cb is
called you will get the sockid for the new socket.

In other words, only after bind_cb is called you can call the rest
of the XRL(s) that require sockid.

> but when I run make I keep getting errors like this:
> 
> g++ -g -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith
> -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -o
> xorp_bpsf xorp_bpsf.o  ./.libs/libbpsf.a
> ../xrl/targets/.libs/libbpsfbase.a ../libxipc/.libs/libxipc.a
> ../libcomm/.libs/libcomm.a ../libxorp/.libs/libxorp.a -lpcap -lcrypto
> -lrt
> ./.libs/libbpsf.a(xrl_bpsf_node.o): In function `XrlBpsfNode::startup()':
> /root/project/xorp1.6/xorp-1.6/bpsf/xrl_bpsf_node.cc:37: undefined
> reference to `XrlSocket4V0p1Client::send_tcp_open_and_bind(char
> const*, std::basic_string<char, std::char_traits<char>,
> std::allocator<char> > const&, IPv4 const&, unsigned int const&,
> ref_ptr<XorpCallback2<void, XrlError const&, std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const*> > const&)'
> /root/project/xorp1.6/xorp-1.6/bpsf/xrl_bpsf_node.cc:44: undefined
> reference to `XrlSocket4V0p1Client::send_tcp_listen(char const*,
> std::basic_string<char, std::char_traits<char>, std::allocator<char> >
> const&, unsigned int const&, ref_ptr<XorpCallback1<void, XrlError
> const&> > const&)'
> collect2: ld returned 1 exit status
> make: *** [xorp_bpsf] Error 1
> 
> 
> even though I have included "xrl/interfaces/socket4_xif.hh" where
> those functions are defined. I'm not sure if the target destination
> I'm passing ("bpsf/0.1") is correct. This is the process I wrote which
> implements socket4_user/0.1, but for some reason the compiler doesn't
> like it.

I think the issue is that you need to link your program with the
particular XRL interface library as well:

(top_builddir)/xrl/interfaces/libsocket4xif.la

For reference, see the test_xrl_sockets4_tcp entry in
fea/Makefile.am .

Pavlin



More information about the Xorp-hackers mailing list