2 LuCI - Lua Configuration Interface
4 Copyright 2008 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 local ast = require("luci.asterisk")
22 cbimap = Map("asterisk", "Edit SIP Trunk")
24 peer = cbimap:section(NamedSection, arg[1])
29 back = peer:option(DummyValue, "_overview", "Back to trunk overview")
31 back.titleref = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip")
33 sipdomain = peer:option(Value, "host", "SIP Domain")
34 sipport = peer:option(Value, "port", "SIP Port")
35 sipport.default = 5060
37 sipnat = peer:option(Flag, "nat", "NAT between this device and provider")
38 sipnat.enabled = "yes"
39 sipnat.disabled = "no"
41 username = peer:option(Value, "username", "Authorization ID")
42 password = peer:option(Value, "secret", "Authorization Password")
43 password.password = true
45 register = peer:option(ListValue, "register", "Register with peer")
46 register:value("yes", "on")
47 register:value("no", "off")
49 regext = peer:option(Value, "registerextension", "Extension to register (optional)")
50 regext:depends({register="yes"})
52 didval = peer:option(ListValue, "_did", "Number of assigned DID numbers")
53 for i=1,24 do didval:value(i) end
61 cbimap = Map("asterisk", "asterisk", "")
64 cbimap.uci:foreach("asterisk", "sip",
66 if s.type == "peer" then
68 s.info = ast.sip.peer(s.name)
74 sip_table = cbimap:section(Table, sip_peers, "SIP Trunks")
75 sip_table.template = "cbi/tblsection"
76 sip_table.extedit = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
78 name = sip_table:option(DummyValue, "name")
79 user = sip_table:option(DummyValue, "username")
81 host = sip_table:option(DummyValue, "host")
82 function host.cfgvalue(self, s)
83 if sip_peers[s].info.address then
84 return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
90 context = sip_table:option(DummyValue, "context")
91 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
93 nat = sip_table:option(DummyValue, "nat")
94 function nat.cfgvalue(self, s)
95 return sip_peers[s].info.Nat or "none"
98 online = sip_table:option(DummyValue, "online")
99 function online.cfgvalue(self, s)
100 if sip_peers[s].info.online == nil then
103 return sip_peers[s].info.online
104 and "yes" or "no (%s)" % sip_peers[s].info.Status:lower()
108 delay = sip_table:option(DummyValue, "delay")
109 function delay.cfgvalue(self, s)
110 if sip_peers[s].info.online then
111 return "%i ms" % sip_peers[s].info.delay