From 8fdc4215690791d65377973b84d02dc44917a7ff Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 24 Mar 2011 08:05:08 +0000 Subject: Added in first two templates for Polycom and Linksys ATA --- templates/linksysata-template.lua | 838 ++++++++++++++++++++++++++++++++++++++ templates/polycom-template.lua | 312 ++++++++++++++ 2 files changed, 1150 insertions(+) create mode 100644 templates/linksysata-template.lua create mode 100644 templates/polycom-template.lua (limited to 'templates') diff --git a/templates/linksysata-template.lua b/templates/linksysata-template.lua new file mode 100644 index 0000000..230c3fa --- /dev/null +++ b/templates/linksysata-template.lua @@ -0,0 +1,838 @@ +<% +-- Linksys ATA Configuration File Template +local values = ... +server=values.device.registrar +web_server=ENV['HTTP_HOST'] +moh=values.device.musiconhold +dialpattern=values.device.digitmap +%> + +<% local values = ... %> + + + + +Yes +80 +Yes + +<%= values.device.adminpassword %> + +<%= values.device.adminpassword %> + + + +Yes + + + + + + +<% io.write(values.reg1.extension) %> + + + + +DHCP,Manual +Sequential + +<% io.write(web_server) %> + + + + + + + + +Yes +Yes +2 +900 +900 + +60 + +Yes +Yes + +Event: check-sync + +No + + + + +http://<% io.write(web_server) %>/Linksys/$MA.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +$PN $MAC -- Requesting resync $SCHEME://$SERVIP:$PORT$PATH +$PN $MAC -- Successful resync $SCHEME://$SERVIP:$PORT$PATH +$PN $MAC -- Resync failed: $ERR + + + + +Yes +7200 + + + + + + +(!5.1.6)?http://<% io.write(web_server) %>/pap2t-5-1-6.bin + + + +$PN $MAC -- Requesting upgrade $SCHEME://$SERVIP:$PORT$PATH +$PN $MAC -- Successful upgrade $SCHEME://$SERVIP:$PORT$PATH -- $ERR +$PN $MAC -- Upgrade failed: $ERR + + + +70 +5 +2 +$MAU $VERSION +$MAU $VERSION + + +application/dtmf-relay +application/hook-flash +No +No + + + +2 +32 +5 +6 +31 +32 +32 +32 +240 +30 +1 +7200 +60 +60 + + + + + + + + + + + + + +10050 +16384 +0 +5 + + + +100 +101 +98 +97 +96 +99 + +NSE +telephone-event +PCMU +PCMA +G726-16 +G726-24 +G726-32 +G726-40 +G729 +G729ab +G723 + + + +Yes +Yes +Yes +Yes +Yes +No +No +No + + + +15 + + + + + + + + +Yes + +No +<% io.write(moh) %> +30 +No + + +5060 + +No + +$NOTIFY +0x68 +$PROXY +0xb8 + + + + + +high +Yes +Yes +No +Yes + + +0 +No + + + + +<% io.write(server) %> + +No + +Yes + +Yes +No + +60 +Yes +Yes +Yes +3600 + + + + +Michael Mason ATA1 USA WKL +<% io.write(values.reg1.extension) %> +<% io.write(values.reg1.password) %> +No + + + + + + +Yes +No +No +Yes +Yes +Yes +Yes +No +No +No +No +No +Yes +Yes +No +Yes +Yes +Yes +Yes +Yes +Yes +Yes +No +No +No +Yes + + + +G711u +No +No +medium +Yes +Yes +Yes +No +Yes +No +Yes +No +Yes +Yes +G711u +No +Yes +Auto +ReINVITE +None +Yes +No + + +(<% io.write(dialpattern) %>) + +No + + + +Forward +Forward +Forward + + +<% + if values.services and values.services.forwarding and values.reg1 then + local pg_t = values.reg1 + local fwddata = {} + + if pg_t.forwardallenable then + fwddata.all = pg_t.forwardall + else + fwddata.all = "" + end + if pg_t.forwardbusyenable then + fwddata.busy = pg_t.forwardbusy + else + fwddata.busy = "" + end + if pg_t.forwardnoanswerenable then + fwddata.noanswer = pg_t.forwardnoanswer + else + fwddata.noanswer = "" + end +%> +<%= fwddata.all %> +<%= fwddata.busy %> +<%= fwddata.noanswer %> +20 +<% + end +%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +No +No +No +Yes +Yes +Yes +No + +No + + + + + + + + + + + + + + +1 +1 +8 + + +0 +0 +0 +New VM Available +No + + + + +No + +No + +30 +No + + +5060 + +Yes + +$NOTIFY +0x68 +$PROXY +0xb8 + + + + + + + +high +No +No +No +No + + +0 +No + + + + + + +No + +Yes + +Yes +No + +60 +Yes +No +No +3600 +2147483647 + + + + + + +No + + + + + + +Yes +Yes +No +Yes +No +No +No +No +No +No +No +No +Yes +Yes +No +Yes +Yes +Yes +Yes +Yes +Yes +Yes +No +No +No +Yes + + + +G711u +No +Yes +medium +Yes +Yes +Yes +No +Yes +No +Yes +No +Yes +Yes +G711u +No +Yes +Auto +ReINVITE +None +Yes +Yes + + + +(<:1123>[2-9]xxxxxxS0|<411:18003733411>|*xx|[369]11S0|0|00|011[2-9]x.|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.) + +No + + + +Forward +Forward +Forward + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +No +No +No +Yes +Yes +Yes +No + + + + + + + + + + + + + + + + +1 +1 +8 + + +0 +0 +0 +New VM Available +No + + +1 +1 + +.020 + + +350@-19,440@-19;10(*/0/1+2) +350@-19,440@-19;10(*/0/1+2) +420@-16;10(*/0/1) +350@-19,440@-19;10(*/0/1+2) +480@-19,620@-19;10(.5/.5/1+2) +480@-19,620@-19;10(.25/.25/1+2) +480@-10,620@0;10(.125/.125/1+2) +440@-19,480@-19;*(2/4/1+2) +600@-16;1(.25/.25/1) +985@-16,1428@-16,1777@-16;20(.380/0/1,.380/0/2,.380/0/3,0/4/0) +914@-16,1371@-16,1777@-16;20(.274/0/1,.274/0/2,.380/0/3,0/4/0) +914@-16,1371@-16,1777@-16;20(.380/0/1,.380/0/2,.380/0/3,0/4/0) +985@-16,1371@-16,1777@-16;20(.380/0/1,.274/0/2,.380/0/3,0/4/0) +350@-19,440@-19;2(.1/.1/1+2);10(*/0/1+2) +350@-19,440@-19;2(.2/.2/1+2);10(*/0/1+2) +600@-19;*(.1/.1/1,.1/.1/1,.1/9.5/1) +350@-19;20(.1/.1/1,.1/9.7/1) +397@-19,507@-19;15(0/2/0,.2/.1/1,.1/2.1/2) + + + +60(2/4) +60(.3/.2,1/.2,.3/4) +60(.8/.4,.8/4) +60(.4/.2,.3/.2,.8/4) +60(.2/.2,.2/.2,.2/.2,1/4) +60(.2/.4,.2/.4,.2/4) +60(.4/.2,.4/.2,.4/4) +60(0.25/9.75) + + + +30(.3/3.7) +30(.1/.1, .1/9.7) +30(.1/.1, .3/.1, .1/9.3) +30(.1/.1,.1/.1,.1/9.5) +30(.3/.1,.1/.1,.3/9.1) +30(.1/.1,.3/.2,.3/9.1) +30(.3/.1,.3/.1,.1/9.1) +2.3(.3/2) + + + +Bellcore-dr1 +Bellcore-dr2 +Bellcore-dr3 +Bellcore-dr4 +Bellcore-dr5 +Bellcore-dr6 +Bellcore-dr7 +Bellcore-dr8 + + + +Sinusoid +20 +90 +440@-10 +Yes + + + +.1 +1.0 +0 +5 +4500 +90 +2 +0 +8 +4 +2 +.8 + + + + +#90 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +*99 + + + + + + + + +GMT + + + +start=3/8/7/2:0:0;end=11/1/7/2:0:0;save=1 + + + +600 + +-1 +-2 +-16 +.1 +Yes +Yes +Bellcore(N.Amer,China) +5 + +Yes + + + +<% +-- DEBUGGING +--require("session") +--io.write(session.serialize("values", values)) +%> diff --git a/templates/polycom-template.lua b/templates/polycom-template.lua new file mode 100644 index 0000000..5cfd226 --- /dev/null +++ b/templates/polycom-template.lua @@ -0,0 +1,312 @@ + + +<% +-- Polycom Configuration File Template +-- We use single quotes to avoid escaping XML's double quotes + +-- It is important that the first line be the XML declaration + +--[[ + Implemented parameters: + values = { + device = { + adminpassword + digitmap + digitmaptimeout + homepage + musiconhold + pcportenable + registrar + sntpserver + timezone + urldialingenable + } + regX (where X is a number 1-34) = { + extension = EXTEN + password = string + forwardall = EXTEN + forwardallenable = boolean + forwardbusy = EXTEN (allow URI?) + forwardbusyenable = boolean + forwardnoanswer = EXTEN + forwardnoanswerenable = boolean + } + -- Assuming that services will not be nil + services = { + callhistoryenable = boolean + forwarding = boolean + hotlinedestination = string + hotlineenable = boolean + } +--]] +%> + + + +<% --TODO: Do we want to enable locking? %> +<% --phoneLock.enabled="1" %> + +<% --- From features.cfg %> +bitmap.idleDisplay.name.SPIP650="WT.bmp" +bitmap.idleDisplay.name.SPIP550="WT.bmp" +<% --feature.autoLocalHold="1" -- trying default for now%> +feature.callPark.enabled="1" +feature.directedCallPickup.enabled="1" +feature.enhancedFeatureKeys.enabled="1" +feature.groupCallPickup.enabled="1" +feature.messaging.enabled="1" +<% -- Management of buddies, and own status %> +feature.presence.enabled="1" +<% -- Run-time downloading of ringers %> +feature.ringDownload.enabled="1" + +<% --- From sip-interop.cfg %> +<% -- Allow user to set Do Not Disturb (DND) per-registration %> +call.donotdisturb.perReg="1" +<% -- When a conference is put on hold, other parties continue to talk %> +call.localConferenceCallHold="1" +<% -- Disallow transfers during the proceeding state of a consultation call %> +voIpProt.SIP.allowTransferOnProceeding="0" +<% -- TODO needed???%> +<% --voIpProt.SIP.CID.sourcePreference="" %> +<% -- Send 486 (SIP Busy Here) when 'Reject' is pressed during a ringing call %> +voIpProt.SIP.use486forReject="1" +<% -- Set phone's requested registration period in seconds %> +voIpProt.server.1.expires="60" +voIpProt.server.2.expires="60" + + +<% --- From site.cfg %> +<% -- Allow the use of device.xxx options (Admin Guide A-30) %> +device.set="1" +<% -- Override default user password of '123' see Admin Guide 4-103 %> +<% -- only used for phone locking and to protect redundant 'Reboot' option %> +device.auth.localUserPassword="" +device.auth.localUserPassword.set="1" +<% -- Attempt to determine VLAN ID and negotiate power through LLDP %> +device.net.lldpEnabled="1" +<% -- Apply option configured in device.net.lldpEnabled (Admin Guide A-30) %> +device.net.lldpEnabled.set="1" +<% -- Automatic periodic polling of provisioning server for upgrades %> +prov.polling.enabled="1" +<% -- Polling time of day hh:mm. %> +prov.polling.time="02:00" +<% -- Do not reject RTP packets arriving from a non-SDP-negotiated IP address %> +<% -- Needed for some ATAs that do provide bad SDP in transfers to MOH %> +tcpIpApp.port.rtp.filterByIp="0" +<% -- Reject RTP packets arriving from a non-SDP-negotiated port %> +<% -- To provide some security despite disabling filterByIp above.t %> +tcpIpApp.port.rtp.filterByPort="1" +<% -- Headset preferred over speakerphone after first use, until disabled %> +up.headsetMode="1" +<% -- Intensity of LCD backlight when phone is idle. 0 = off. %> +up.backlight.idleIntensity="0" +<% -- Receive volume of handset remembered between calls %> +voice.volume.persist.handset="1" +<% -- Receive volume of headset remembered between calls %> +voice.volume.persist.headset="1" + + + + + +<% local values = ... %> + +<% +local function xml_attr (t, v) +if v ~= nil then + -- v could be a string, false, or a number + io.write(table.concat(t, '.') .. '="' .. tostring(v) .. '"\n') +end +end +%> + +<% + +xml_attr({ 'voIpProt.server.1.address' }, values.device.registrar) +xml_attr({ 'mb.main.home' }, values.device.homepage) +xml_attr({ 'voIpProt.SIP.musicOnHold.uri' }, values.device.musiconhold) +xml_attr({ 'dialplan.digitmap' }, values.device.digitmap) +xml_attr({ 'dialplan.digitmap.timeOut' }, values.device.digitmaptimeout) +xml_attr({ 'feature.urlDialing.enabled' }, values.device.urldialingenable) + +if not values.device.pcportenable then + -- set mode to '-1' which disables it + xml_attr({ 'device.net.etherModePC' }, '-1') + -- apply settings in 'device' parameter above + xml_attr({ 'device.net.etherModePC.set' }, '1') +end + +-- Override the default admin password of '456' +if values.device.adminpassword then + xml_attr({ 'device.auth.localAdminPassword' }, values.device.adminpassword) + xml_attr({ 'device.auth.localAdminPassword.set' }, true) +end + +---[=[ +-- Handle SNTP and Time Zone parameters +-- See http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html +-- TZ variable, with no leading colon +-- Syntax: stdoffset[dst[offset][,start[/time],end[/time]]] +-- Examples: 'GMT0' 'EST5EDT,M3.2.0,M11.1.0' '5' + +-- we can assume that values.device is not nil +-- since values.device.template is this file +if values.device.sntpserver then + xml_attr({ 'tcpIpApp.sntp.address' }, values.device.sntpserver) +end + + +-- Parse time zone variable +require('posixtz') +local tz = posixtz.parse(values.device.timezone) + +if tz then + + -- convert POSIX sign (W of GMT is '+') to Polycom (E of GMT is '+') + xml_attr({'tcpIpApp.sntp.gmtOffset'}, -1 * tz.offset.total) + + + + local function dstrule ( pos ) + local dstprefix = 'tcpIpApp.sntp.daylightSavings' + local t = tz.dst[pos] + + -- Handle explicit hour for DST change + -- (Polycom doesn't implement explicit min or sec) + -- (Polycom DST implementation assumes DST change is 1 hour) + if t.hour then + xml_attr({ dstprefix, pos, 'time' }, t.hour) + end + + if t.day then + -- there may be two of next line, Polycom uses first + xml_attr({ dstprefix, 'fixedDayEnable' }, true) + xml_attr({ dstprefix, pos, 'month' }, t.month) + xml_attr({ dstprefix, pos, 'date' }, t.day) + else + + -- there may be two of next line, Polycom uses first + xml_attr({ dstprefix, 'fixedDayEnable' }, false) + xml_attr({ dstprefix, pos, 'month' }, t.month) + + -- POSIX weekday is between 0 (Sun) and 6 (Sat) + -- Polycom dayOfWeek is 1=Sun, 7=Sat + xml_attr({ dstprefix, pos, 'dayOfWeek' }, tonumber(t.weekday) + 1) + + -- POSIX week from 1 to 5, where 1st,2nd..4th, and 5=last + if t.week == '5' then + xml_attr({ dstprefix, pos, 'dayOfWeek.lastInMonth' }, true) + else + -- Polycom uses 1, 8, 15, 22 for 1st, 2nd... 4th + local d = 7 * ( tonumber(t.week) - 1 ) + 1 + xml_attr({ dstprefix, pos, 'date' }, d) + end + end + + end + + if tz.dst then + xml_attr({'tcpIpApp.sntp.daylightSavings.enable'}, true) + + dstrule('start') + dstrule('stop') + end +end + +--]=] + + +-- Check 'services' params +local enable = {} +enable.forwarding = false +enable.hotline = false + +if values.services then + -- set variables so that we don't have to test values.services again + if not values.services.callhistoryenable then + xml_attr({ 'feature.callList.enabled' }, '0') + end + if values.services.forwarding then + enable.forwarding = true + end + if values.services.hotlineenable then + enable.hotline = true + end +end + + +-- Loop through Parameter Groups looking for 'reg' params +for pg, pg_t in pairs(values) do + +-- Is it of the form regX ? +local num = string.match(pg, 'reg(%d+)') +if num then + + + -- set Hotline on all possible registrations if it is configured + if enable.hotline then + local d = values.services.hotlinedestination + if d then + xml_attr({ 'call.autoOffHook', num, 'enabled' }, '1') + xml_attr({ 'call.autoOffHook', num, 'protocol' }, 'SIP') + xml_attr({ 'call.autoOffHook', num, 'contact' }, d) + end + end + + -- user part of From URI + xml_attr({ 'reg', num, 'address' }, pg_t.extension) + -- SIP authentication parameters + xml_attr({ 'reg', num, 'auth.userId' }, pg_t.extension) + xml_attr({ 'reg', num, 'auth.password' }, pg_t.password) + -- Caller ID string + xml_attr({ 'reg', num, 'displayName' }, pg_t.callerid) + + + -- From Admin_Guide_UCS_v3.3.0: + -- "The phone has a flexible call forward/diversion feature for each registration. In all cases, a call will only be diverted if a non-Null contact has been configured." + if enable.forwarding then + -- Although not documented, + -- Polycom phones send special options for + -- 'forward all calls', namely: + -- reg.x.fwdContact and reg.x.fwdStatus + + -- set forwardall as defined + xml_attr({ 'reg', num, 'fwdStatus' }, pg_t.forwardallenable) + xml_attr({ 'reg', num, 'fwdContact' }, pg_t.forwardall) + + -- set forwardnoanswer as defined + xml_attr({ 'reg', num, 'fwd.noanswer.status' }, pg_t.forwardnoanswerenable) + xml_attr({ 'reg', num, 'fwd.noanswer.contact' }, pg_t.forwardnoanswer) + xml_attr({ 'reg', num, 'fwd.noanswer.ringCount' }, '4') + -- set time in seconds before diversion + --xml_attr({ 'divert.noanswer', num, 'timeout' }, '20') + + -- set forwardbusy on DND and on busy, as defined + xml_attr({ 'reg', num, 'fwd.busy.status' }, pg_t.forwardbusyenable) + xml_attr({ 'divert.dnd', num, 'enabled' }, pg_t.forwardbusyenable) + xml_attr({ 'reg', num, 'fwd.busy.contact' }, pg_t.forwardbusy) + xml_attr({ 'divert.dnd', num, 'contact' }, pg_t.forwardbusy) + + else -- forwarding is not enabled + -- disable the soft-key menu for forwarding + xml_attr({ 'divert.fwd', num, 'enabled' }, '0') + end + + +end + +end + +%> + +/> + +<% +-- DEBUGGING +--require("session") +--local log, err = io.open("/root/polycom-template.log", "a") +--log:write(session.serialize("values", values)) +%> -- cgit v1.2.3