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 username = peer:option(Value, "username", "Authorization ID")
38 password = peer:option(Value, "secret", "Authorization Password")
39 password.password = true
41 register = peer:option(ListValue, "register", "Register with peer")
42 register:value("yes", "on")
43 register:value("no", "off")
45 regext = peer:option(Value, "registerextension", "Extension to register (optional)")
46 regext:depends({register="yes"})
48 didval = peer:option(ListValue, "_did", "Number of assigned DID numbers")
49 for i=1,24 do didval:value(i) end
57 cbimap = Map("asterisk", "asterisk", "")
60 cbimap.uci:foreach("asterisk", "sip",
62 if s.type == "peer" then
64 s.info = ast.sip.peer(s.name)
70 sip_table = cbimap:section(Table, sip_peers, "SIP Trunks")
71 sip_table.template = "cbi/tblsection"
72 sip_table.extedit = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
74 name = sip_table:option(DummyValue, "name")
75 user = sip_table:option(DummyValue, "username")
77 host = sip_table:option(DummyValue, "host")
78 function host.cfgvalue(self, s)
79 if sip_peers[s].info.address then
80 return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
86 context = sip_table:option(DummyValue, "context")
87 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
89 nat = sip_table:option(DummyValue, "nat")
90 function nat.cfgvalue(self, s)
91 return sip_peers[s].info.Nat or "none"
94 online = sip_table:option(DummyValue, "online")
95 function online.cfgvalue(self, s)
96 if sip_peers[s].info.online == nil then
99 return sip_peers[s].info.online and "yes" or "no"
103 delay = sip_table:option(DummyValue, "delay")
104 function delay.cfgvalue(self, s)
105 if sip_peers[s].info.online then
106 return "%i ms" % sip_peers[s].info.delay