[Contents] [Prev] [Next] [Index] [Report an Error]


Practical Examples

You can use the macros in this section for configuring your system or as examples of useful macros you can build yourself.

Configuring Frame Relay

You can organize your macros in many different ways to suit your needs. The first sample macro in this section, ds1mac.mac, shows a typical method of organization. It consists of a number of related macros for configuring interfaces on CT1 and CE1 modules, as described in Table 7-4.

Some of the macros provide a single configuration function, like configuring the controller. These are invoked by other macros that are executable from the command line. A high-level macro invokes several of the executables, acting much like a script to provide greater functionality.

Table 7-4 Contents of ds1mac.mac
Macro Name
Description
Help
Lists the executable macros in ds1mac.mac
controllerDs1
Executable macro that configures Cx1 ports; calls macro cntrDs1
ds1Encap
Executable macro that configures Frame Relay encapsulation on Cx1 serial interfaces; calls macro cx1Encap
ds1FrCir
Executable macro that configures Frame Relay circuits on Cx1 subinterfaces; calls macro cx1FRCir
configCx1
Executable macro that configures Cx1 serial Frame Relay interfaces; calls macros cntrDs1, cx1Encap, and cx1FrCir
cntrDs1
Configures the Cx1 controller; called by other macros
cx1Encap
Configures Frame Relay encapsulation on serial interfaces; called by other macros
cx1FrCir
Configures Frame Relay circuits on the subinterfaces; called by other macros

Table 7-5 lists the complete set of macros contained in ds1mac.mac. You can run the Help macro to list the other executable macros contained in ds1mac.mac. To configure Frame Relay on your system with ds1mac.mac, you can do one of the following:

In either case, to run the macros you must provide the required values described in the macros.

Table 7-5 ds1mac.mac 
<# Help #>
! This file contains the following executable macros:
!  controllerDs1
!  ds1Encap
!  ds1FrCir
!  configCx1
<# endtmpl #>
<# controllerDs1 #>
<# if env.argc = 0 #>
! This macro configures your Cx1 controller.
! This macro will configure e1 ports as unframed.
! This macro should be called with 4 arguments.
! The argument list should be as follows:
! type; number of numPorts; slot; port; clock; framing; 
lineCoding
<# return #>
<# endif #>
<# type := env.argv(1) #>
<# ifCount := env.argv(2) #>
<# slot := env.argv(3) #>
<# port := env.argv(4)#>
<# clock := env.argv(5) #>
<# framing := env.argv(6) #>
<# coding := env.argv(7) #>

<# if clock = 'internal' #>
<# clock := 'internal mod' #>
<# endif #>

<# tmpl.cntrDs1(type, ifCount, slot, port, clock, framing, 
coding) #>
<# endtmpl #>
<# ds1Encap #>
<# if env.argc = 0 #>
! This macro configures Frame Relay encapsulation on Cx1 
serial
! interfaces. 
! This macro must be called with 4 arguments.
! If the protocol is Frame Relay (fr), then specify the 
type (DTE
! or DCE) and the lmi type.
! The argument list should be as follows:
! number of numPorts; slot; port; proto; frType; frLmi
<# return #>
<# endif #>
<# ifCount := env.argv(1) #>
<# slot := env.argv(2) #>
<# port := env.argv(3) #>
<# proto := env.argv(4) #>
<# if proto = 'fr' #>
<# proto := 'frame-relay ietf' #>
<# endif #>
<# tmpl.cx1Encap(ifCount, slot, port, proto) #>
<# endtmpl #>
<# ds1FrCir #>
<# if env.argc = 0 #>
! This macro configures Frame Relay circuits on Cx1
! subinterfaces. 
! This macro must be called with 4 arguments.
! The argument list should be as follows:
! number of numPorts; slot; port; numCirs; dlci
<# return #>
<# endif #>
<# ifCount := env.argv(1) #>
<# slot := env.argv(2) #>
<# port := env.argv(3) #>
<# numCirs := env.argv(4) #>
<# dlci := env.argv(5) #>
<# tmpl.cx1FrCir(ifCount, slot, port, numCirs, dlci) #>
<# endtmpl #>
<# configCx1 #>
<# if env.argc = 0 #>
! This macro configures Cx1 serial Frame Relay interfaces.
! This macro must be called with 4 arguments.
! The argument list should be as follows:
! type; number of numPorts; slot; port; clock; framing; 
coding; proto; frType; frLmi; numCirs; dlci
<# return #>
<# endif #>
<# type := env.argv(1) #>
<# ifCount := env.argv(2) #>
<# slot := env.argv(3) #>
<# port := env.argv(4) #>
<# clock := env.argv(5) #>
<# framing := env.argv(6) #>
<# coding := env.argv(7) #>
<# proto := env.argv(8) #>
<# tmpl.cntrDs1(type, ifCount, slot, port, clock, framing, 
coding) #>
<# if proto = 'fr' #>
<# frType := env.argv(9) #>
<# frLmi := env.argv(10) #>
<# numCirs := env.argv(11) #>
<# dlci := env.argv(12) #>
<# tmpl.cx1Encap(ifCount, slot, port, proto, frType, frLmi) 
#>
<# tmpl.cx1FrCir(ifCount, slot, port, numCirs, dlci) #>
<# else #>
<# tmpl.cx1Encap(ifCount, slot, port, proto, type, type) #>
<# endif #>
<# endtmpl #>
<# cntrDs1 #>
<# //This macro is called by other macros to configure DS1 
ports #>
<# //Parameters in order are interface Type; numPorts; 
slot; port; clock; framing; lineCoding #>
!
! Configure Cx1 Controller
!
<# type := param[1] #>
<# ifCount := env.atoi(param[2]) #>
<# slot := param[3] #>
<# port := env.atoi(param[4]) #>
<# clock := param[5] #>
<# framing := param[6] #>
<# coding := param[7] #>
<# while ifCount-- > 0 #>
controller <# type;' '; slot;'/';port;'\n' #>
<# if framing = 'unframed' #>
unframed
<# else #>
framing <# framing;'\n' #>
linecoding <# coding;'\n' #>
<# endif #>
clock source <# clock;'\n' #>
no shutdown

<# port++ #>
<# endwhile #>
<# endtmpl #>
<# cx1Encap #>
<# //This macro is called by other macros to configure 
Frame Relay encapsulation on serial interfaces. #>
<# //Parameters in order are interface Type; numPorts; 
slot; port; clock; framing; lineCoding #>
!
! Configure Encapsulation
!
<# ifCount := env.atoi(param[1]) #>
<# slot := param[2] #>
<# port := env.atoi(param[3]) #>
<# proto := param[4] #>
<# if proto = 'fr' #>
<# proto := 'frame-relay ietf' #>
<# endif #>
<# while ifCount-- > 0 #>
interface serial <# slot;'/';port;':1';'\n' #>
encapsulation <# proto;'\n' #>
<# if proto = 'frame-relay ietf' #>
frame-relay intf-type <# param[5];'\n'#>
frame-relay lmi-type <# param[6];'\n'#>
<# endif #>

<# port++ #>
<# endwhile #>
<# endtmpl #>
<# cx1FrCir #>
<# //This macro is called by other macros to configure 
Frame Relay circuits on subinterfaces. #>
<# //Parameters in order are interface numPorts; slot; 
port; numCirs; dlci #>
!
! Configure Frame Relay Circuits 
!
<# ifCount := env.atoi(param[1]) #>
<# slot := param[2] #>
<# port := env.atoi(param[3]) #>
<# numCirs := env.atoi(param[4]) #>
<# startDlci := env.atoi(param[5]) #>
<# id := env.atoi('1') #>
<# while ifCount-- > 0 #>
<# cirs := numCirs #>
<# id := env.atoi('1') #>
<# dlci := startDlci #>
<# while cirs-- > 0 #>
interface serial <# slot;'/';port;':1.';id;'\n' #>
frame-relay interface-dlci <# dlci #> ietf

<# id++; dlci++ #>
<# endwhile #>
<# port++ #>
<# endwhile #>
<# endtmpl #>

Configuring ATM Interfaces

The sample macro in Table 7-6 configures ATM interfaces based on the inputs you provide when prompted by the macro.

Table 7-6 Sample macro to configure ATM interfaces 
<# atmIf #>
<# slotPort:=env.getline("slot/port?") #>
<# while (vcType != 1 && vcType != 2);
    vcTypeStr :=env.getline("VC type (1 = AAL5MUX IP, 2 = AAL5SNAP)?");
    vcType := env.atoi(vcTypeStr);
    endwhile #>
<# if vcType = 1; vcTypeStr := "aal5mux ip"; else; vcTypeStr := "aal5snap"; endif 
#>
<# encapRouted:=1; encapBridged:=2; encapPPP:=3 #>
<# while (encapType < encapRouted || encapType > encapPPP );
    encapTypeStr  :=env.getline("encapsulation (1 = routed, 2 = bridged, 3 = 
ppp)?");
    encapType := env.atoi(encapTypeStr);
    endwhile #>
<# if encapType = encapPPP #>
    <# authNone:=1; authPap:=2; authChap:=3; authPapChap:=4; authChapPap:=5 #>
    <# while (authType < authNone || authType > authChapPap );
        authTypeStr  :=env.getline("authentication (1 = None, 2 = PAP, 3 = CHAP, 4 = 
PAP/CHAP; 5 = CHAP/PAP)?");
        authType    := env.atoi(authTypeStr);
        endwhile #>
    <# endif #>
<# vpStartStr := env.getline("Starting VP number?"); 
vpStart:=env.atoi(vpStartStr)#>
<# vpEndStr   := env.getline("Ending   VP number?"); vpEnd  
:=env.atoi(vpEndStr)#>
<# vcStartStr := env.getline("Starting VC number?"); 
vcStart:=env.atoi(vcStartStr)#>
<# vcEndStr   := env.getline("Ending   VC number?"); vcEnd  
:=env.atoi(vcEndStr)#>

<# loopbackStr := env.getline("Loopback interface number or <cr>?") #>
<# vp := vpStart; while vp <= vpEnd, ++vp #>
    <# vc := vcStart; while vc <= vcEnd, ++vc #>
        interface atm <#slotPort $ '.' $ ++i;'\n'#>
        atm pvc <# i; ' '; vp; ' '; vc; ' '; vcTypeStr;'\n'#>
        <# if encapType = encapPpp #>
            encap ppp
            <# if authType = authPap#>
                ppp authentication pap
            <# elseif authType = authPapChap#>
                ppp authentication pap chap
            <# elseif authType = authChapPap#>
                ppp authentication chap pap
            <# elseif authType = authChap#>
                ppp authentication chap
                <# endif #>
        <# elseif encapType = encapBridged #>
        encap bridged1483
                <# endif #>
        <# if loopbackStr != "" #>
            ip unnumbered loopback <# loopbackStr;"\n" #>
            <# endif #>
!
        <# endwhile #>
!
    <# endwhile #>
<# if encapType = encapPPP #>
    <# authNone:=1; authPap:=2; authChap:=3; authPapChap:=4; authChapPap:=5 #>
    <# while (authType < authNone || authType > authChapPap );
        authTypeStr  :=env.getline("authentication (1 = None, 2 = PAP, 3 = CHAP, 4 = 
PAP/CHAP; 5 = CHAP/PAP)?");
        authType    := env.atoi(authTypeStr);
        endwhile #>
    <# endif #>
<# vpStartStr := env.getline("Starting VP number?"); 
vpStart:=env.atoi(vpStartStr)#>
<# vpEndStr   := env.getline("Ending   VP number?"); vpEnd  
:=env.atoi(vpEndStr)#>
<# vcStartStr := env.getline("Starting VC number?"); 
vcStart:=env.atoi(vcStartStr)#>
<# vcEndStr   := env.getline("Ending   VC number?"); vcEnd  
:=env.atoi(vcEndStr)#>
<# loopbackStr := env.getline("Loopback interface number or <cr>?") #>
<# vp := vpStart; while vp <= vpEnd, ++vp #>
    <# vc := vcStart; while vc <= vcEnd, ++vc #>
        interface atm <#slotPort $ '.' $ ++i;'\n'#>
        atm pvc <# i; ' '; vp; ' '; vc; ' '; vcTypeStr;'\n'#>
        <# if encapType = encapPpp #>
            encap ppp
            <# if authType = authPap#>
                ppp authentication pap
            <# elseif authType = authPapChap#>
                ppp authentication pap chap
            <# elseif authType = authChapPap#>
                ppp authentication chap pap
            <# elseif authType = authChap#>
                ppp authentication chap
                <# endif #>
        <# elseif encapType = encapBridged #>
        encap bridged1483
                <# endif #>
        <# if loopbackStr != "" #>
            ip unnumbered loopback <# loopbackStr;"\n" #>
            <# endif #>
!
        <# endwhile #>
!
    <# endwhile #>
<# endtmpl #>


[Contents] [Prev] [Next] [Index] [Report an Error]