Configuring Local DAHDI FXS/FXO Channels

The local FXS and FXO channels that are defined by DAHDI can be configured to implement local extensions and CO lines. To configure these extensions and CO lines, the user must make sure that the context "from-pstn" and "from-internal" are in the dial plan.

These two contexts can be configured in two separate files that are stored in the "local" subdirectory and that are included in the extensions.conf file. Here is an example of our local extensions file, that uses the "stdexten" routine, that is defined in extensions.conf, to define a number of local extensions, among other things.

/etc/asterisk/local/dahdi-extensions.conf:

     ; local/dahdi-extensions.conf - Local DAHDI extensions.
     ;
     ; This module is included at the appropriate spot in the dialplan (defined
     ; by extensions.conf).  It defines the local extensions that are implemented
     ; by DAHDI line cards, such as the Digium or OpenVox cards.
     ;
     ; The DAHDI utility dahdi_genconf automatically assigns DAHDI channels to all
     ; of the local lines implemented on DAHDI cards.  It assigns each channel to
     ; either the "from-internal" context, which we can use herein, or the
     ; "from-pstn" context.
     ;
     ;
     ; Local extensions defined as DAHDI devices.  The "from-internal" context
     ; contains all of the FXS lines supported by DAHDI.
     ;
     [from-internal]
     ; Don't break the dialtone, until after the user dials the first digit of
     ; the outbound code.  Note that the ignorepat must appear in this context,
     ; nowhere else.
     ignorepat => ${OUTBOUNDCODE:0:1}
     ; Include the definition of a standard extension from extensions.conf.
     include => stdexten
     ; Define the operator's extension as zero.  It rings whatever phone you
     ; wish it to ring (using ring cadence 2).  The extension is whatever
     ; mailbox you wish to use.
     exten => 0,1,Gosub(602,stdexten(dahdi/1r1))
     ; Define the local extensions.
     exten => 600,1,Gosub(${EXTEN},stdexten(dahdi/1))
     exten => 601,1,Gosub(${EXTEN},stdexten(dahdi/2))
     exten => 602,1,Gosub(${EXTEN},stdexten(dahdi/3))
     exten => 603,1,Gosub(${EXTEN},stdexten(dahdi/4))
     exten => 604,1,Gosub(${EXTEN},stdexten(dahdi/5))
     ; Allow a user to dial one of the local extensions, prefixed with an
     ; asterisk, to go directly to the extension's voicemail box.  This
     ; allows the user to transfer an incoming call to a voicemail box, say
     ; when the caller asks to speak to someone whom the user knows to be
     ; away.
     ;
     ; Note that, if the SPECIALCODE is set to "", the extensions could
     ; interfere with the special function codes that begin with the same
     ; digit as our extensions.  Fortunately, we use two-digit special function
     ; codes and three digit extensions, and asterisk knows how to sort it all
     ; out.
     exten => _${EXTPATTERN},1,VoiceMail(${EXTEN:1})
     ; Include the parking lot.  This will define extensions 700-7nn (depending
     ; on the settings in features.conf).
     include => parkedcalls
     ; We optionally enable the virtual extensions from inside lines, if the
     ; virtual inside switch is on.
     exten => _${VIRTPATTERN},1,Gotoif($[${EXISTS(${VIRTINSIDE})}]?\
                                       virtual-extensions,${EXTEN},1:)
     exten => _${VIRTPATTERN},n,Playback(sorry2)
     exten => _${VIRTPATTERN},n,Hangup()
     ; Define the same extension that gets us into voicemail from outside, just
     ; in case someone dials it from inside.
     exten => ${EXTVMAIL},1,VoicemailMain()
     exten => ${EXTVMAIL},n,Hangup()
     ; Define an extension used to record IVR prompts.
     exten => ${EXTRECORDIVR},1,Macro(recordivr)
     ; Include the special feature codes.
     include => feature-codes
     ; Include the dial plans for outside lines.
     include => outside-local
     include => outside-longdistance

And, here is an example of our local CO lines file, that uses the "ivrmenutree" macro, that is defined in the local ivr-menutree.conf file, to define the rules for answering the local CO lines and routing the answered calls.

/etc/asterisk/local/dahdi-colines.conf:

     ; local/dahdi-colines.conf - Local DAHDI CO lines.
     ;
     ; This module is included at the appropriate spot in the dialplan (defined
     ; by extensions.conf).  It defines the local CO lines that are implemented
     ; by DAHDI line cards, such as the Digium or OpenVox cards.
     ;
     ; The DAHDI utility dahdi_genconf automatically assigns DAHDI channels to all
     ; of the local lines implemented on DAHDI cards.  It assigns each channel to
     ; either the "from-internal" or "from-pstn" context, which we can use herein.
     ;
     ;
     ; Local CO lines defined as DAHDI devices.  The "from-pstn" context contains
     ; all of the FXO lines supported by DAHDI.
     ;
     [from-pstn]
     ; Based on the time of day, we either jump to the day ring or night ring
     ; context.  This lets the user ring some phones, during the day, before the
     ; IVR attendant gets involved.  Note that the times used herein need not
     ; match the times that the IVR attendant checks for to implement its menus.
     exten => s,1,GotoIfTime(08:00-21:00,*,*,*?dahdidayring,s,1)
     ; Fall through to the night ring.
     exten => s,n,Goto(dahdinightring,s,1)