Skip to content

Commit

Permalink
Merge pull request #1530 from SCADA-LTS/feature/#1494_snmp_support_2_5_2
Browse files Browse the repository at this point in the history
Feature/#1494 snmp support for Scada-LTS Version 2.5.2
  • Loading branch information
radek2s authored Feb 5, 2021
2 parents 0c1fb27 + 9d4033e commit 9b1ef9c
Show file tree
Hide file tree
Showing 25 changed files with 3,404 additions and 3,073 deletions.
230 changes: 168 additions & 62 deletions WebContent/WEB-INF/jsp/dataSourceEdit/editSnmp.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,74 @@
var version = $get("snmpVersion");
if (version == <c:out value="<%= SnmpConstants.version3 %>"/>) {
show("version3Fields");
show("trapSection");
hide("version12Fields");
}
else {
} else if (version == <c:out value="<%= SnmpConstants.version1 %>"/>) {
hide("version3Fields");
show("version12Fields");
hide("trapSection");
} else {
hide("version3Fields");
show("version12Fields");
show("trapSection");
}
}
function securityLevelChange() {
var securityLevel = $get("securityLevel");
if (securityLevel === "1") {
hide("authFieldsProtocol")
hide("authFieldsPassphrase")
hide("privFieldsProtocol")
hide("privFieldsPassphrase")
} else if (securityLevel === "2") {
show("authFieldsProtocol")
show("authFieldsPassphrase")
hide("privFieldsProtocol")
hide("privFieldsPassphrase")
} else if (securityLevel === "3") {
show("authFieldsProtocol")
show("authFieldsPassphrase")
show("privFieldsProtocol")
show("privFieldsPassphrase")
}
}
function snmpTest() {
$set("snmpTestMessage", "<fmt:message key="dsEdit.snmp.gettingValue"/>");
snmpTestButton(true);
DataSourceEditDwr.snmpGetOid($get("snmpTestOid"), $get("host"), $get("port"), $get("snmpVersion"),
$get("community"), $get("securityName"), $get("authProtocol"), $get("authPassphrase"),
$get("privProtocol"), $get("privPassphrase"), $get("engineId"), $get("contextEngineId"),
DataSourceEditDwr.snmpGetOid($get("snmpTestOid"), $get("host"), $get("port"), $get("snmpVersion"),
$get("community"), $get("securityName"), $get("authProtocol"), $get("authPassphrase"),
$get("privProtocol"), $get("privPassphrase"), $get("securityLevel"),
$get("contextName"), $get("retries"), $get("timeout"), snmpTestCB);
}
function snmpWalk() {
$set("snmpTestMessage", "<fmt:message key="dsEdit.snmp.gettingValue"/>");
snmpWalkButton(true);
DataSourceEditDwr.snmpWalkOid($get("snmpWalkOid"), $get("host"), $get("port"), $get("snmpVersion"),
$get("community"), $get("securityName"), $get("authProtocol"), $get("authPassphrase"),
$get("privProtocol"), $get("privPassphrase"), $get("securityLevel"),
$get("contextName"), $get("retries"), $get("timeout"), snmpWalkCB);
}
function snmpTestCB() {
setTimeout(snmpTestUpdate, 1000);
}
function snmpWalkCB() {
setTimeout(snmpWalkUpdate, 1000);
}
function snmpTestUpdate() {
DataSourceEditDwr.snmpGetOidUpdate(snmpTestUpdateCB);
}
function snmpWalkUpdate() {
DataSourceEditDwr.snmpGetWalkUpdate(snmpWalkUpdateCB);
}
function snmpTestUpdateCB(result) {
if (result) {
$set("snmpTestMessage", result);
Expand All @@ -60,29 +103,55 @@
else
snmpTestCB();
}
function snmpWalkUpdateCB(result) {
if (result) {
$set("snmpWalkMessage", result);
snmpWalkButton(false);
}
else
snmpWalkCB();
}
function snmpTestButton(testing) {
setDisabled($("snmpTestBtn"), testing);
}
function snmpWalkButton(testing) {
setDisabled($("snmpWalkBtn"), testing);
}
function initImpl() {
versionChange();
securityLevelChange();
snmpTestButton(false);
toggleTrapSetting();
}
function toggleTrapSetting() {
var checkbox = document.getElementById("trapEnabled");
if(checkbox.checked) {
show("trapSectionPort")
show("trapSectionAddress")
} else {
hide("trapSectionPort")
hide("trapSectionAddress")
}
}
function saveDataSourceImpl() {
DataSourceEditDwr.saveSnmpDataSource($get("dataSourceName"), $get("dataSourceXid"), $get("updatePeriods"),
$get("updatePeriodType"), $get("host"), $get("port"), $get("snmpVersion"), $get("community"),
$get("securityName"), $get("authProtocol"), $get("authPassphrase"), $get("privProtocol"),
$get("privPassphrase"), $get("engineId"), $get("contextEngineId"), $get("contextName"), $get("retries"),
$get("timeout"), $get("trapPort"), $get("localAddress"), saveDataSourceCB);
$get("privPassphrase"), $get("securityLevel"), $get("contextName"), $get("retries"),
$get("timeout"), $get("trapEnabled"), $get("trapPort"), $get("localAddress"), saveDataSourceCB);
}
function appendPointListColumnFunctions(pointListColumnHeaders, pointListColumnFunctions) {
pointListColumnHeaders[pointListColumnHeaders.length] = "<fmt:message key="dsEdit.snmp.oid"/>";
pointListColumnFunctions[pointListColumnFunctions.length] = function(p) { return p.pointLocator.oid; };
}
function editPointCBImpl(locator) {
$set("oid", locator.oid);
$set("dataTypeId", locator.dataTypeId);
Expand All @@ -91,19 +160,19 @@
$set("trapOnly", locator.trapOnly ? "true" : "false");
dataTypeChanged();
}
function savePointImpl(locator) {
delete locator.settable;
locator.oid = $get("oid");
locator.dataTypeId = $get("dataTypeId");
locator.binary0Value = $get("binary0Value");
locator.setType = $get("setType");
locator.trapOnly = $get("trapOnly") == "true";
DataSourceEditDwr.saveSnmpPointLocator(currentPoint.id, $get("xid"), $get("name"), locator, savePointCB);
}
function dataTypeChanged() {
display("binary0ValueRow", $get("dataTypeId") == <c:out value="<%= DataTypes.BINARY %>"/>);
}
Expand All @@ -121,17 +190,27 @@
</sst:select>
</td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.host"/></td>
<td class="formField"><input id="host" type="text" value="${dataSource.host}"/></td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.port"/></td>
<td class="formField"><input id="port" type="text" value="${dataSource.port}"/></td>
</tr>


<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.retries"/></td>
<td class="formField"><input id="retries" type="text" value="${dataSource.retries}"/></td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.timeout"/></td>
<td class="formField"><input id="timeout" type="text" value="${dataSource.timeout}"/></td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.version"/></td>
<td class="formField">
Expand All @@ -142,37 +221,53 @@
</sst:select>
</td>
</tr>

<tbody id="version12Fields" style="display:none;">
<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.community"/></td>
<td class="formField"><input id="community" type="text" value="${dataSource.community}"/></td>
</tr>
</tbody>

<tbody id="version3Fields" style="display:none;">

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.securityName"/></td>
<td class="formField"><input id="securityName" type="text" value="${dataSource.securityName}"/></td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.sl.label"/></td>
<td class="formField">
<sst:select id="securityLevel" value="${dataSource.securityLevel}" onchange="securityLevelChange()">
<sst:option value="1"><fmt:message key="dsEdit.snmp.sl.noauthnopriv"/></sst:option>
<sst:option value="2"><fmt:message key="dsEdit.snmp.sl.authnopriv"/></sst:option>
<sst:option value="3"><fmt:message key="dsEdit.snmp.sl.authpriv"/></sst:option>
</sst:select>
</td>
</tr>

<tr id="authFieldsProtocol">
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.authProtocol"/></td>
<td class="formField">
<sst:select id="authProtocol" value="${dataSource.authProtocol}">
<sst:option value="<%= SnmpDataSourceVO.AuthProtocols.NONE %>"><fmt:message key="dsEdit.snmp.none"/></sst:option>
<sst:option value="<%= SnmpDataSourceVO.AuthProtocols.MD5 %>">MD5</sst:option>
<sst:option value="<%= SnmpDataSourceVO.AuthProtocols.SHA %>">SHA</sst:option>
<sst:option value="<%= SnmpDataSourceVO.AuthProtocols.HMAC128SHA224 %>">HMAC128 SHA224</sst:option>
<sst:option value="<%= SnmpDataSourceVO.AuthProtocols.HMAC192SHA256 %>">HMAC192 SHA256</sst:option>
<sst:option value="<%= SnmpDataSourceVO.AuthProtocols.HMAC256SHA384 %>">HMAC256 SHA384</sst:option>
<sst:option value="<%= SnmpDataSourceVO.AuthProtocols.HMAC384SHA512 %>">HMAC384 SHA512</sst:option>
</sst:select>
</td>
</tr>
<tr>

<tr id="authFieldsPassphrase">
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.authPassphrase"/></td>
<td class="formField"><input id="authPassphrase" type="text" value="${dataSource.authPassphrase}"/></td>
</tr>
<tr>

<tr id="privFieldsProtocol">
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.privProtocol"/></td>
<td class="formField">
<sst:select id="privProtocol" value="${dataSource.privProtocol}">
Expand All @@ -181,72 +276,83 @@
<sst:option value="<%= SnmpDataSourceVO.PrivProtocols.AES128 %>">AES128</sst:option>
<sst:option value="<%= SnmpDataSourceVO.PrivProtocols.AES192 %>">AES192</sst:option>
<sst:option value="<%= SnmpDataSourceVO.PrivProtocols.AES256 %>">AES256</sst:option>

<sst:option value="<%= SnmpDataSourceVO.PrivProtocols.DES3 %>">3DES</sst:option>
<sst:option value="<%= SnmpDataSourceVO.PrivProtocols.AES192With3DES %>">AES192With3DES</sst:option>
<sst:option value="<%= SnmpDataSourceVO.PrivProtocols.AES256With3DES %>">AES256With3DES</sst:option>
</sst:select>
</td>
</tr>
<tr>

<tr id="privFieldsPassphrase">
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.privPassphrase"/></td>
<td class="formField"><input id="privPassphrase" type="text" value="${dataSource.privPassphrase}"/></td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.engineId"/></td>
<td class="formField"><input id="engineId" type="text" value="${dataSource.engineId}"/></td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.contextEngine"/></td>
<td class="formField"><input id="contextEngineId" type="text" value="${dataSource.contextEngineId}"/></td>
</tr>


<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.contextName"/></td>
<td class="formField"><input id="contextName" type="text" value="${dataSource.contextName}"/></td>
</tr>
</tbody>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.retries"/></td>
<td class="formField"><input id="retries" type="text" value="${dataSource.retries}"/></td>
</tr>

<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.timeout"/></td>
<td class="formField"><input id="timeout" type="text" value="${dataSource.timeout}"/></td>

</tbody>

<tr id="trapSection">
<td class="formLabel"><fmt:message key="dsEdit.snmp.trapPortEnabled"/></td>
<td class="formField"><sst:checkbox id="trapEnabled" selectedValue="${dataSource.trapEnabled}" onclick="toggleTrapSetting()"/></td>
</tr>
<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.trapPort"/></td>

<tr id="trapSectionPort">
<td class="formLabel"><fmt:message key="dsEdit.snmp.trapPort"/></td>
<td class="formField"><input id="trapPort" type="text" value="${dataSource.trapPort}"/></td>
</tr>
<tr>
<td class="formLabelRequired"><fmt:message key="dsEdit.snmp.localAddress"/></td>

<tr id="trapSectionAddress">
<td class="formLabel"><fmt:message key="dsEdit.snmp.localAddress"/></td>
<td class="formField"><input id="localAddress" type="text" value="${dataSource.localAddress}"/></td>
</tr>
</table>
<tag:dsEvents/>
</div>
</td>

<td valign="top">
<div class="borderDiv marB">
<table>
<tr><td colspan="2" class="smallTitle"><fmt:message key="dsEdit.snmp.testing"/></td></tr>

<tr>
<td class="formLabel"><fmt:message key="dsEdit.snmp.oid"/></td>
<td class="formField"><input type="text" id="snmpTestOid"/></td>
</tr>

<tr>
<td colspan="2" align="center">
<input id="snmpTestBtn" type="button" value="<fmt:message key="dsEdit.snmp.test"/>" onclick="snmpTest();"/>
</td>
</tr>

<tr><td colspan="2" id="snmpTestMessage" class="formError"></td></tr>

<!--
<tr>
<td colspan="2" class="smallTitle"><fmt:message key="dsEdit.snmp.walking"/></td>
</tr>
<tr>
<td class="formLabel"><fmt:message key="dsEdit.snmp.oidWalk"/></td>
<td class="formField"><input type="text" id="snmpWalkOid"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input id="snmpWalkBtn" type="button" value="<fmt:message key="dsEdit.snmp.walk"/>" onclick="snmpWalk();"/>
</td>
</tr>
<tr>
<td colspan="2" id="snmpWalkMessage" class="formError"></td>
</tr> -->

<%@ include file="/WEB-INF/jsp/dataSourceEdit/dsFoot.jspf" %>

<tag:pointList pointHelpId="snmpPP">
Expand Down
Binary file removed WebContent/WEB-INF/lib/SNMP4J.jar
Binary file not shown.
Binary file added WebContent/WEB-INF/lib/snmp4j-2.8.6.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<path id="Web App Libraries.libraryclasspath">
<pathelement location="WebContent/WEB-INF/lib/OneWireAPI.jar"/>
<pathelement location="WebContent/WEB-INF/lib/RXTXcomm.jar"/>
<pathelement location="WebContent/WEB-INF/lib/SNMP4J.jar"/>
<pathelement location="WebContent/WEB-INF/lib/snmp4j-2.8.6.jar"/>
<pathelement location="WebContent/WEB-INF/lib/activation.jar"/>
<pathelement location="WebContent/WEB-INF/lib/alpha24j.jar"/>
<pathelement location="WebContent/WEB-INF/lib/axis.jar"/>
Expand Down
Loading

0 comments on commit 9b1ef9c

Please sign in to comment.