[Xorp-users] Xorp and PPP

Atanu Ghosh atanu@ICSI.Berkeley.EDU
Thu, 21 Apr 2005 16:21:29 -0700


    >> Is there any possibility to make xorp recognize dynamically PPP
    >> logical interfaces?  I'm trying to configure it in order to treat
    >> multicast flows on PPP sessions...

    Pavlin> A basic question: are all interface names visible by
    Pavlin> "ifconfig -a" before you start XORP (i.e., just the names
    Pavlin> even though they may not have IP addresses yet)?  If yes,
    Pavlin> then maybe you will be able to use XORP with such
    Pavlin> interfaces, but be aware that we haven't tried XORP with PPP
    Pavlin> interfaces so you may run into some problems.

    Pavlin> If no, then you cannot use XORP as-is, because within the
    Pavlin> XORP configuration you must tell XORP about all interfaces
    Pavlin> it is suppose to use. Off the top of my head, one possible
    Pavlin> solution is to write a script that is invoked and generates
    Pavlin> a new XORP configuration whenever you have a new PPP
    Pavlin> interface or an existing one is deleted.  Other folks may
    Pavlin> have better solutions.

I use the python expect script below to toggle one of a routers
peerings. The script starts a xorpsh and send it commands. A similar
idea could be used to configure a PPP interface when it appears.

     Atanu.

----------------------------------------
#!/usr/bin/env python
#

import pexpect

def configuration(xorpsh, command, debug=0):
    """
    Run a configuration mode command
    """

    xorpsh.sendline(command)
    xorpsh.expect('[edit]')
    xorpsh.expect('XORP>')
    if 1 == debug:
        print xorpsh.before
        print xorpsh.after


def toggle(xorpsh, router, debug=0):
    """
    Toggle the peering to router
    """

    configuration(xorpsh, 'configure', debug)
    configuration(xorpsh,
                  'set protocols bgp peer ' + router + ' disable true', debug)
    configuration(xorpsh, 'commit', debug)
    if 1 == debug:
        configuration(xorpsh, 'show protocols bgp peer ' + router,
                      debug)
    configuration(xorpsh,
                  'set protocols bgp peer ' + router + ' disable false', debug)
    configuration(xorpsh, 'commit', debug)
    if 1 == debug:
        configuration(xorpsh, 'show protocols bgp peer '+ router,
                      debug)


xorpsh = pexpect.spawn('xorpsh')
xorpsh.expect('Xorp>')
toggle(xorpsh, "router3-loop0", 1)
----------------------------------------