[Xorp-hackers] Duplicated code in RIP

Marko Zec zec@icir.org
Wed, 9 Nov 2005 19:13:28 +0100


On Wednesday 09 November 2005 18:06, Mark Doll wrote:
> I wonder why some member functions of class XrlPortIO<A> (i.e.
> request_socket_server, see file ~/rip/xlr_port_io.cc) are not
> generally defined using template parameter 'A' but are instead
> defined two times as specializations for 'IPv4' and 'IPv6', although
> the specializations only differ in constants and types, differences
> that are otherwise handled with class RIP_AF_CONSTANTS<A> throughout
> RIP.

Another difference is that RIP sends / receives packets on IPv4 sockets, 
while RIPng uses IPv6 sockets.  Different socket types -> different XRL 
interfaces that need to be used, thus the need for specialization 
(socket4 vs socket6) in certain member functions.

Marko

> Wouldn't it be less error prone for future
> modifications/extensions/code reuse and easier to read/understand the
> code for newbies like me if there's no duplicated code within XORP?