/
devicelist.cgi
executable file
·176 lines (152 loc) · 6.22 KB
/
devicelist.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/tclsh
source session.tcl
puts "Content-Type: text/xml; charset=iso-8859-1"
puts ""
puts -nonewline "<?xml version='1.0' encoding='ISO-8859-1' ?><deviceList>"
if {[info exists sid] && [check_session $sid]} {
set show_internal 0
set show_remote 0
set device_id 0
catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
if {0 != [regexp "^show_internal=(.*)$" $pair dummy val]} {
set show_internal $val
continue
}
if {0 != [regexp "^show_remote=(.*)$" $pair dummy val]} {
set show_remote $val
continue
}
if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
set device_id $val
continue
}
}
}
array set res [rega_script {
integer show_internal = "} $show_internal {";
integer show_remote = "} $show_remote {";
string device_id = "} $device_id {";
integer DIR_SENDER = 1;
integer DIR_RECEIVER = 2;
! string TYPE_VIRTUAL = "29";
string PARTNER_INVALID = "65535";
string sDevIdList;
string sDevId;
string sChnId;
string sDPId;
if( (device_id == 0) ) {
sDevIdList = root.Devices().EnumUsedIDs();
} else {
sDevIdList = device_id.Split(",");
}
foreach (sDevId, sDevIdList)
{
object oDevice = dom.GetObject(sDevId);
integer iDevInterfaceId = oDevice.Interface();
object oDeviceInterface = dom.GetObject(iDevInterfaceId);
boolean bDevReady = oDevice.ReadyConfig();
boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType()) || ("HmIP-RCV-50" == oDevice.HssType()) );
if( (oDeviceInterface) && (true == bDevReady) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
{
string sDevInterface = oDeviceInterface.Name();
string sDevType = oDevice.HssType();
Write("<device");
Write(" name='");WriteXML( oDevice.Name() );Write("'");
Write(" address='");WriteXML( oDevice.Address() );Write("'");
Write(" ise_id='" # sDevId # "'");
Write(" interface='" # sDevInterface # "'");
Write(" device_type='");WriteXML(sDevType);Write("'");
Write(" ready_config='" # bDevReady # "'");
Write(">");
foreach(sChnId, oDevice.Channels())
{
object oChannel = dom.GetObject(sChnId);
boolean show = false;
if (false == oChannel.Internal() ) {
show = true;
}
if ( show_internal == 1){
show = true;
}
if (show == true){
integer iChnDir = oChannel.ChnDirection();
string sChnDir = "UNKNOWN";
if (DIR_SENDER == iChnDir) { sChnDir = "SENDER"; }
if (DIR_RECEIVER == iChnDir) { sChnDir = "RECEIVER"; }
string sChnPartnerId = oChannel.ChnGroupPartnerId();
if (PARTNER_INVALID == sChnPartnerId) { sChnPartnerId = ""; }
boolean bChnAESAvailable = false;
if (0 != oChannel.ChnAESOperation()) { bChnAESAvailable = true; }
string sChnMode = "DEFAULT";
if (true == oChannel.ChnAESActive()) { sChnMode = "AES"; }
! boolean bChnReady = oChannel.ReadyConfig();
! integer iChnLinkCount = oChannel.ChnLinkCount();
! integer iChnProgramCount = oChannel.DPUsageCount();
! if (ID_ERROR == iChnProgramCount) { iChnProgramCount = 0; }
! boolean bChnVirtual = false;
! if (TYPE_VIRTUAL == sChnType) { bChnVirtual = true; }
! boolean bChnReadable = false;
! boolean bChnWritable = false;
! boolean bChnEventable = false;
! foreach (sDPId, oChannel.DPs())
! {
! object oDP = dom.GetObject(sDPId);
! if (false == oDP.Internal())
! {
! integer iDPOperations = oDP.Operations();
! if (OPERATION_READ & iDPOperations) { bChnReadable = true; }
! if (OPERATION_WRITE & iDPOperations) { bChnWritable = true; }
! if (OPERATION_EVENT & iDPOperations) { bChnEventable = true; }
! }
! }
!
Write("<channel name='");WriteXML( oChannel.Name() );Write("'");
Write(" type='");WriteXML( oChannel.ChannelType() );Write("'");
Write(" address='");WriteXML( oChannel.Address() );Write("'");
Write(" ise_id='" # sChnId # "'");
Write(" direction='" # sChnDir # "'");
Write(" parent_device='" # oChannel.Device() # "'");
Write(" index='" # oChannel.ChnNumber() # "'");
Write(" group_partner='" # sChnPartnerId # "'");
Write(" aes_available='" # bChnAESAvailable # "'");
Write(" transmission_mode='" # sChnMode # "'");
! Write(" archive='" # oChannel.ChnArchive() # "'");
if (false == oChannel.Internal()) {
Write(" visible='" # oChannel.Visible() # "'");
} else {
Write(" visible=''");
}
Write(" ready_config='" # oChannel.ReadyConfig() # "'");
! Write(" link_count='" # iChnLinkCount # "'");
! Write(" program_count='" # iChnProgramCount # "'");
! Write(" virtual='" # bChnVirtual # "'");
! Write(" readable='" # bChnReadable # "'");
! Write(" writable='" # bChnWritable # "'");
! Write(" eventable='" # bChnEventable # "'");
if (false == oChannel.Internal()) {
Write(" operate='");
if( oChannel.UserAccessRights(iulOtherThanAdmin) == iarFullAccess ) {
Write("true");
} else {
Write("false");
}
} else {
Write(" operate='");
}
Write("' />");
}
}
Write("</device>");
}
}
}]
if { $res(STDOUT) != "" } {
puts -nonewline $res(STDOUT)
}
} else {
puts -nonewline {<not_authenticated/>}
}
puts "</deviceList>"