[Xorp-hackers] Migrating Routing Process to XORP

Pavlin Radoslavov pavlin@icir.org
Thu, 04 Nov 2004 13:09:06 -0800


> I am trying to migrate a routing process to XORP but I am having some 
> problems on understanding somethings. I have already mapped in the 
> routing process code everywhere it uses sockets to send/receive control 
> packets and the first thing I want to do is to migrate this 
> functionality to XORP. But I confess that I am a bit lost. At first I 
> though that I should use the XrlSocketServer class for this, but looking 
> at the RIP example code I found no reference to this class. So, what how 
> should I do it?

Currently, you can use the XrlSocketServer for TCP and UDP sockets
only. To send and receive packets, set socket options, etc, you have
to use the xrl/interfaces/socket{4,6}.xif and
xrl/interfaces/socket{4,6}_user.xif XRL interfaces to use the FEA
For example, one of the XRLs inside socket4.xif is "udp_open_and_bind"
to create a bound UDP socket. Hence, if you search the rip directory
for "udp_open_and_bind" you will find how it is used.
Similarly, the "recv_event" XRL in file socket4_user.xif is used to
receive a packet on a socket, so you can search for that string as
well to find-out how to receive packets via XRLs.

> Maybe it could be easier to understand from an example. The original 
> code is based on a "select", i.e., it creates a socket server for 
> listening the interface and an infinite loop keeps monitoring the 
> arrival of packets (through a select) so that they can be processed. How 
> can I convert this kind of construction to go through XORP?

You would have to use the XORP EventLoop class, and then the sending
and receiving of XRLs you need to send/receive your data packets and
everything else is handled automatically. You can have a look in
function static_routes_main() inside file
static_routes/xorp_static_routes.cc for a very simple example how to
do that.