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 61.
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 61: Contents of ds1mac.mac
The following examples list 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 router 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.
<# 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 #>