742 lines
36 KiB
Java
742 lines
36 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.tridium.net.HttpUtil
|
|
* javax.baja.data.BIDataValue
|
|
* javax.baja.file.BIFile
|
|
* javax.baja.file.FilePath
|
|
* javax.baja.naming.SlotPath
|
|
* javax.baja.sys.BFacets
|
|
* javax.baja.sys.BString
|
|
* javax.baja.sys.BValue
|
|
* javax.baja.sys.BajaRuntimeException
|
|
* javax.baja.sys.Context
|
|
* javax.baja.sys.LocalizableRuntimeException
|
|
* javax.baja.sys.Property
|
|
* javax.baja.sys.SlotCursor
|
|
* javax.baja.util.Lexicon
|
|
* javax.baja.xml.XContent
|
|
* javax.baja.xml.XElem
|
|
* javax.baja.xml.XException
|
|
* javax.baja.xml.XParser
|
|
*/
|
|
package com.tridium.platform.tcpip;
|
|
|
|
import com.tridium.net.HttpUtil;
|
|
import com.tridium.platform.daemon.BDaemonSession;
|
|
import com.tridium.platform.daemon.DaemonFileUtil;
|
|
import com.tridium.platform.daemon.file.BCacheAccessPolicy;
|
|
import com.tridium.platform.daemon.message.ByteArrayFileTransferElement;
|
|
import com.tridium.platform.daemon.message.DaemonMessage;
|
|
import com.tridium.platform.daemon.message.FileTransferMessage;
|
|
import com.tridium.platform.daemon.message.GetFileMessage;
|
|
import com.tridium.platform.daemon.message.XmlResponseMessage;
|
|
import com.tridium.platform.tcpip.BTcpIpAdapterSettings;
|
|
import com.tridium.platform.tcpip.BTcpIpHostSettings;
|
|
import java.io.InputStream;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import javax.baja.data.BIDataValue;
|
|
import javax.baja.file.BIFile;
|
|
import javax.baja.file.FilePath;
|
|
import javax.baja.naming.SlotPath;
|
|
import javax.baja.sys.BFacets;
|
|
import javax.baja.sys.BString;
|
|
import javax.baja.sys.BValue;
|
|
import javax.baja.sys.BajaRuntimeException;
|
|
import javax.baja.sys.Context;
|
|
import javax.baja.sys.LocalizableRuntimeException;
|
|
import javax.baja.sys.Property;
|
|
import javax.baja.sys.SlotCursor;
|
|
import javax.baja.util.Lexicon;
|
|
import javax.baja.xml.XContent;
|
|
import javax.baja.xml.XElem;
|
|
import javax.baja.xml.XException;
|
|
import javax.baja.xml.XParser;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class TcpUtil {
|
|
static /* synthetic */ Class class$com$tridium$platform$tcpip$BTcpIpAdapterSettings;
|
|
static /* synthetic */ Class class$javax$baja$sys$BString;
|
|
|
|
public static void loadFromSession(BTcpIpHostSettings bTcpIpHostSettings, BDaemonSession bDaemonSession) throws Exception {
|
|
InputStream inputStream = bDaemonSession.getInputStream(new DaemonMessage(){
|
|
|
|
public final String getMessageString() {
|
|
return "tcpip";
|
|
}
|
|
});
|
|
TcpUtil.updateFields(bTcpIpHostSettings, XParser.make((InputStream)inputStream).parse());
|
|
BIFile bIFile = bDaemonSession.getFileSpace().findFile(new FilePath("/"), BCacheAccessPolicy.cacheOnly);
|
|
FilePath filePath = bIFile == null ? new FilePath("!etc/hosts") : new FilePath("/etc/hosts");
|
|
InputStream inputStream2 = bDaemonSession.getInputStream(new GetFileMessage(filePath, bDaemonSession.getFileSpace()));
|
|
if (inputStream2 != null) {
|
|
bTcpIpHostSettings.loadHostFileContents(inputStream2);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Unable to fully structure code
|
|
*/
|
|
public static XElem getHostSettingsXml(BTcpIpHostSettings var0) {
|
|
block7: {
|
|
var2_1 = new XElem("tcpIpSettings");
|
|
var3_2 = false;
|
|
var2_1.addAttr("hostname", var0.getHostName());
|
|
var2_1.addAttr("isReadonly", String.valueOf(var0.getIsReadonly()));
|
|
var2_1.addAttr("usesAdapterLevelSettings", String.valueOf(var0.getUsesAdapterLevelSettings()));
|
|
var4_3 = null;
|
|
var5_4 = var0.getAdapters().getProperties();
|
|
if (true) ** GOTO lbl16
|
|
do {
|
|
if ((var4_3 = (BTcpIpAdapterSettings)var5_4.get()).getIsIpv6Supported()) {
|
|
var3_2 = true;
|
|
break;
|
|
}
|
|
lbl16:
|
|
// 3 sources
|
|
|
|
if ((v0 = TcpUtil.class$com$tridium$platform$tcpip$BTcpIpAdapterSettings) != null) continue;
|
|
v0 = TcpUtil.class("[Lcom.tridium.platform.tcpip.BTcpIpAdapterSettings;", false);
|
|
} while (var5_4.next(v0));
|
|
if (var3_2) {
|
|
var2_1.addAttr("niagaraUsesIpv6", String.valueOf(var0.getNiagaraUsesIpv6()));
|
|
var2_1.addAttr("isIPv6Readonly", String.valueOf(var0.getIsIPv6Readonly()));
|
|
} else {
|
|
var2_1.addAttr("niagaraUsesIpv6", "false");
|
|
var2_1.addAttr("isIPv6Readonly", "true");
|
|
}
|
|
if (var0.getUsesAdapterLevelSettings()) break block7;
|
|
var2_1.addAttr("domain", var0.getDomain());
|
|
var2_1.addAttr("defaultGateway", var0.getDefaultGateway());
|
|
var5_4 = new XElem("dnsHosts");
|
|
var5_4.addAttr("limit", String.valueOf(var0.getMaxDnsHosts()));
|
|
var6_5 = var0.getDnsHosts().getProperties();
|
|
if (true) ** GOTO lbl45
|
|
do {
|
|
var1_6 = new XElem("dnsHost");
|
|
var1_6.addAttr("ipAddress", var6_5.get().toString());
|
|
var5_4.addContent((XContent)var1_6);
|
|
lbl45:
|
|
// 2 sources
|
|
|
|
if ((v1 = TcpUtil.class$javax$baja$sys$BString) != null) continue;
|
|
v1 = TcpUtil.class("[Ljavax.baja.sys.BString;", false);
|
|
} while (var6_5.next(v1));
|
|
var2_1.addContent((XContent)var5_4);
|
|
if (!var3_2) break block7;
|
|
var2_1.addAttr("ipv6DefaultGateway", var0.getIpv6DefaultGateway());
|
|
var6_5 = new XElem("ipv6DnsHosts");
|
|
var6_5.addAttr("limit", String.valueOf(var0.getMaxDnsHosts()));
|
|
var7_7 = var0.getIpv6DnsHosts().getProperties();
|
|
if (true) ** GOTO lbl64
|
|
do {
|
|
var1_6 = new XElem("ipv6DnsHost");
|
|
var1_6.addAttr("ipv6Address", var7_7.get().toString());
|
|
var6_5.addContent((XContent)var1_6);
|
|
lbl64:
|
|
// 2 sources
|
|
|
|
if ((v2 = TcpUtil.class$javax$baja$sys$BString) != null) continue;
|
|
v2 = TcpUtil.class("[Ljavax.baja.sys.BString;", false);
|
|
} while (var7_7.next(v2));
|
|
var2_1.addContent((XContent)var6_5);
|
|
}
|
|
var5_4 = new XElem("adapters");
|
|
var6_5 = var0.getAdapters().getProperties();
|
|
if (true) ** GOTO lbl76
|
|
do {
|
|
var5_4.addContent((XContent)TcpUtil.getAdapterSettingsXml((BTcpIpAdapterSettings)var6_5.get(), var0.getUsesAdapterLevelSettings()));
|
|
lbl76:
|
|
// 2 sources
|
|
|
|
if ((v3 = TcpUtil.class$com$tridium$platform$tcpip$BTcpIpAdapterSettings) != null) continue;
|
|
v3 = TcpUtil.class("[Lcom.tridium.platform.tcpip.BTcpIpAdapterSettings;", false);
|
|
} while (var6_5.next(v3));
|
|
var2_1.addContent((XContent)var5_4);
|
|
return var2_1;
|
|
}
|
|
|
|
public static void updateFields(BTcpIpHostSettings bTcpIpHostSettings, XElem xElem) {
|
|
Object object;
|
|
Object object2;
|
|
String string;
|
|
block23: {
|
|
string = null;
|
|
try {
|
|
string = xElem.get("hostname");
|
|
if (string == null || string.trim().length() == 0) {
|
|
string = "localhost";
|
|
}
|
|
}
|
|
catch (XException xException) {
|
|
string = xElem.get("hostName", "localhost");
|
|
if (string != null && string.trim().length() != 0) break block23;
|
|
string = "localhost";
|
|
}
|
|
}
|
|
bTcpIpHostSettings.setHostName(string);
|
|
bTcpIpHostSettings.setIsReadonly(xElem.getb("isReadonly", false));
|
|
bTcpIpHostSettings.setUsesAdapterLevelSettings(xElem.getb("usesAdapterLevelSettings", true));
|
|
boolean bl = false;
|
|
XElem[] xElemArray = xElem.elem("adapters").elems("adapter");
|
|
int n = 0;
|
|
while (n < xElemArray.length) {
|
|
if (xElemArray[n].getb("ipv6Supported", false)) {
|
|
bl = true;
|
|
break;
|
|
}
|
|
++n;
|
|
}
|
|
if (bl) {
|
|
bTcpIpHostSettings.setNiagaraUsesIpv6(xElem.getb("niagaraUsesIpv6", false));
|
|
bTcpIpHostSettings.setIsIPv6Readonly(xElem.getb("isIPv6Readonly", true));
|
|
} else {
|
|
bTcpIpHostSettings.setNiagaraUsesIpv6(false);
|
|
bTcpIpHostSettings.setIsIPv6Readonly(true);
|
|
}
|
|
if (!bTcpIpHostSettings.getUsesAdapterLevelSettings()) {
|
|
bTcpIpHostSettings.setDefaultGateway(xElem.get("defaultGateway"));
|
|
bTcpIpHostSettings.setDomain(xElem.get("domain"));
|
|
String string2 = null;
|
|
object2 = xElem.elem("dnsHosts");
|
|
XElem[] xElemArray2 = object2.elems("dnsHost");
|
|
bTcpIpHostSettings.setMaxDnsHosts(object2.geti("limit", 2));
|
|
object = new HashSet();
|
|
int n2 = 0;
|
|
while (n2 < xElemArray2.length) {
|
|
string2 = SlotPath.escape((String)xElemArray2[n2].get("ipAddress"));
|
|
((HashSet)object).add(string2);
|
|
if (bTcpIpHostSettings.getDnsHosts().getSlot(string2) == null) {
|
|
bTcpIpHostSettings.getDnsHosts().add(string2, (BValue)BString.make((String)xElemArray2[n2].get("ipAddress")), 1, (Context)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"platform:IpHostFE")));
|
|
}
|
|
++n2;
|
|
}
|
|
Property[] propertyArray = bTcpIpHostSettings.getDnsHosts().getPropertiesArray();
|
|
int n3 = 0;
|
|
while (n3 < propertyArray.length) {
|
|
if (!((HashSet)object).contains(propertyArray[n3].getName())) {
|
|
bTcpIpHostSettings.getDnsHosts().remove(propertyArray[n3].getName());
|
|
}
|
|
++n3;
|
|
}
|
|
if (bl) {
|
|
bTcpIpHostSettings.setIpv6DefaultGateway(xElem.get("ipv6DefaultGateway", ""));
|
|
XElem xElem2 = xElem.elem("ipv6DnsHosts");
|
|
if (xElem2 == null) {
|
|
bTcpIpHostSettings.getIpv6DnsHosts().removeAll();
|
|
} else {
|
|
XElem[] xElemArray3 = xElem2.elems("ipv6DnsHost");
|
|
HashSet<String> hashSet = new HashSet<String>();
|
|
int n4 = 0;
|
|
while (n4 < xElemArray3.length) {
|
|
string2 = SlotPath.escape((String)xElemArray3[n4].get("ipv6Address"));
|
|
hashSet.add(string2);
|
|
if (bTcpIpHostSettings.getIpv6DnsHosts().getSlot(string2) == null) {
|
|
bTcpIpHostSettings.getIpv6DnsHosts().add(string2, (BValue)BString.make((String)xElemArray3[n4].get("ipv6Address")), 1, (Context)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"platform:IpHostFE")));
|
|
}
|
|
++n4;
|
|
}
|
|
Property[] propertyArray2 = bTcpIpHostSettings.getIpv6DnsHosts().getPropertiesArray();
|
|
int n5 = 0;
|
|
while (n5 < propertyArray2.length) {
|
|
if (!hashSet.contains(propertyArray2[n5].getName())) {
|
|
bTcpIpHostSettings.getIpv6DnsHosts().remove(propertyArray2[n5].getName());
|
|
}
|
|
++n5;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
HashSet<String> hashSet = new HashSet<String>();
|
|
object2 = null;
|
|
xElemArray = xElem.elem("adapters").elems("adapter");
|
|
int n6 = 0;
|
|
while (n6 < xElemArray.length) {
|
|
object = SlotPath.escape((String)xElemArray[n6].get("id"));
|
|
hashSet.add((String)object);
|
|
object2 = (BTcpIpAdapterSettings)bTcpIpHostSettings.getAdapters().get((String)object);
|
|
if (object2 == null) {
|
|
object2 = new BTcpIpAdapterSettings();
|
|
bTcpIpHostSettings.getAdapters().add((String)object, (BValue)object2);
|
|
}
|
|
TcpUtil.updateFields((BTcpIpAdapterSettings)((Object)object2), xElemArray[n6]);
|
|
++n6;
|
|
}
|
|
Property[] propertyArray = bTcpIpHostSettings.getAdapters().getPropertiesArray();
|
|
int n7 = 0;
|
|
while (n7 < propertyArray.length) {
|
|
if (!hashSet.contains(propertyArray[n7].getName())) {
|
|
bTcpIpHostSettings.getAdapters().remove(propertyArray[n7].getName());
|
|
}
|
|
++n7;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Unable to fully structure code
|
|
*/
|
|
public static XElem getAdapterSettingsXml(BTcpIpAdapterSettings var0, boolean var1_1) {
|
|
block10: {
|
|
var2_2 = new XElem("adapter");
|
|
var2_2.addAttr("id", var0.getAdapterId());
|
|
var2_2.addAttr("enabled", String.valueOf(var0.getIsAdapterEnabled()));
|
|
var2_2.addAttr("canDisable", String.valueOf(var0.getCanDisableAdapter()));
|
|
var2_2.addAttr("desc", var0.getDescription());
|
|
var2_2.addAttr("macAddress", var0.getMediaAccessControlAddress());
|
|
var2_2.addAttr("ipAddress", var0.getIpAddress());
|
|
var2_2.addAttr("subnetMask", var0.getSubnetMask());
|
|
var2_2.addAttr("canUseDhcp", String.valueOf(var0.getCanUseDhcp()));
|
|
if (var1_1) {
|
|
var2_2.addAttr("defaultGateway", var0.getDefaultGateway());
|
|
var2_2.addAttr("domain", var0.getDomain());
|
|
}
|
|
var2_2.addAttr("ipv6Supported", String.valueOf(var0.getIsIpv6Supported()));
|
|
if (var0.getIsIpv6Supported()) {
|
|
var2_2.addAttr("canDisableIpv6", String.valueOf(var0.getCanDisableIpv6()));
|
|
var2_2.addAttr("ipv6Enabled", String.valueOf(var0.getIsIpv6Enabled()));
|
|
var2_2.addAttr("canUseIpv6Dhcp", String.valueOf(var0.getCanUseIpv6Dhcp()));
|
|
if (var0.getIsIpv6Enabled()) {
|
|
var2_2.addAttr("ipv6Address", var0.getIpv6Address());
|
|
var2_2.addAttr("ipv6SubnetPrefixLength", String.valueOf(var0.getIpv6SubnetPrefixLength()));
|
|
if (var1_1) {
|
|
var2_2.addAttr("ipv6DefaultGateway", var0.getIpv6DefaultGateway());
|
|
}
|
|
}
|
|
}
|
|
if (var0.getCanUseDhcp()) {
|
|
var2_2.addAttr("dhcpEnabled", String.valueOf(var0.getIsDhcpEnabled()));
|
|
if (var0.getIsDhcpEnabled()) {
|
|
var2_2.addAttr("dhcpHost", var0.getDhcpHost());
|
|
var2_2.addAttr("dhcpLeaseGranted", var0.getDhcpLeaseGranted());
|
|
var2_2.addAttr("dhcpLeaseExpires", var0.getDhcpLeaseExpires());
|
|
}
|
|
}
|
|
if (var0.getIsIpv6Enabled() && var0.getCanUseIpv6Dhcp()) {
|
|
var2_2.addAttr("ipv6DhcpEnabled", String.valueOf(var0.getIsIpv6DhcpEnabled()));
|
|
if (var0.getIsIpv6DhcpEnabled()) {
|
|
var2_2.addAttr("ipv6DhcpHost", var0.getIpv6DhcpHost());
|
|
var2_2.addAttr("ipv6DhcpLeaseGranted", var0.getIpv6DhcpLeaseGranted());
|
|
var2_2.addAttr("ipv6DhcpLeaseExpires", var0.getIpv6DhcpLeaseExpires());
|
|
}
|
|
}
|
|
if (!var1_1) break block10;
|
|
var3_3 = new XElem("dnsHosts");
|
|
var3_3.addAttr("limit", String.valueOf(var0.getMaxDnsHosts()));
|
|
var4_4 = var0.getDnsHosts().getProperties();
|
|
if (true) ** GOTO lbl72
|
|
do {
|
|
var5_5 = new XElem("dnsHost");
|
|
var5_5.addAttr("ipAddress", var4_4.get().toString());
|
|
var3_3.addContent((XContent)var5_5);
|
|
lbl72:
|
|
// 2 sources
|
|
|
|
if ((v0 = TcpUtil.class$javax$baja$sys$BString) != null) continue;
|
|
v0 = TcpUtil.class("[Ljavax.baja.sys.BString;", false);
|
|
} while (var4_4.next(v0));
|
|
var2_2.addContent((XContent)var3_3);
|
|
if (!var0.getIsIpv6Enabled()) break block10;
|
|
var4_4 = new XElem("ipv6DnsHosts");
|
|
var4_4.addAttr("limit", String.valueOf(var0.getMaxDnsHosts()));
|
|
var5_5 = var0.getIpv6DnsHosts().getProperties();
|
|
if (true) ** GOTO lbl89
|
|
do {
|
|
var6_6 = new XElem("ipv6DnsHost");
|
|
var6_6.addAttr("ipv6Address", var5_5.get().toString());
|
|
var4_4.addContent((XContent)var6_6);
|
|
lbl89:
|
|
// 2 sources
|
|
|
|
if ((v1 = TcpUtil.class$javax$baja$sys$BString) != null) continue;
|
|
v1 = TcpUtil.class("[Ljavax.baja.sys.BString;", false);
|
|
} while (var5_5.next(v1));
|
|
var2_2.addContent((XContent)var4_4);
|
|
}
|
|
return var2_2;
|
|
}
|
|
|
|
public static void updateFields(BTcpIpAdapterSettings bTcpIpAdapterSettings, XElem xElem) {
|
|
int n;
|
|
Property[] propertyArray;
|
|
Object object;
|
|
XElem xElem2;
|
|
bTcpIpAdapterSettings.setAdapterId(xElem.get("id"));
|
|
bTcpIpAdapterSettings.setIsAdapterEnabled(xElem.getb("enabled", true));
|
|
bTcpIpAdapterSettings.setCanDisableAdapter(xElem.getb("canDisable", false));
|
|
bTcpIpAdapterSettings.setDescription(xElem.get("desc"));
|
|
bTcpIpAdapterSettings.setMediaAccessControlAddress(xElem.get("macAddress", "Unavailable"));
|
|
bTcpIpAdapterSettings.setIpAddress(xElem.get("ipAddress"));
|
|
bTcpIpAdapterSettings.setSubnetMask(xElem.get("subnetMask"));
|
|
boolean bl = xElem.getb("canUseDhcp", true);
|
|
boolean bl2 = xElem.getb("ipv6Supported", false);
|
|
boolean bl3 = false;
|
|
if (bl2 && xElem.getb("ipv6Enabled", false)) {
|
|
bl3 = true;
|
|
}
|
|
boolean bl4 = bl3;
|
|
boolean bl5 = false;
|
|
if (bl2 && xElem.getb("canDisableIpv6", false)) {
|
|
bl5 = true;
|
|
}
|
|
boolean bl6 = bl5;
|
|
boolean bl7 = xElem.getb("canUseIpv6Dhcp", false);
|
|
bTcpIpAdapterSettings.setCanUseDhcp(bl);
|
|
bTcpIpAdapterSettings.setIsIpv6Supported(bl2);
|
|
bTcpIpAdapterSettings.setIsIpv6Enabled(bl4);
|
|
bTcpIpAdapterSettings.setCanDisableIpv6(bl6);
|
|
bTcpIpAdapterSettings.setCanUseIpv6Dhcp(bl7);
|
|
if (xElem.get("domain", null) != null) {
|
|
bTcpIpAdapterSettings.setDomain(xElem.get("domain"));
|
|
}
|
|
if (xElem.get("defaultGateway", null) != null) {
|
|
bTcpIpAdapterSettings.setDefaultGateway(xElem.get("defaultGateway"));
|
|
}
|
|
if (bl4) {
|
|
if (xElem.get("ipv6Address", null) != null) {
|
|
bTcpIpAdapterSettings.setIpv6Address(xElem.get("ipv6Address"));
|
|
}
|
|
if (xElem.get("ipv6DefaultGateway", null) != null) {
|
|
bTcpIpAdapterSettings.setIpv6DefaultGateway(xElem.get("ipv6DefaultGateway"));
|
|
}
|
|
if (xElem.get("ipv6SubnetPrefixLength", null) != null) {
|
|
bTcpIpAdapterSettings.setIpv6SubnetPrefixLength(xElem.geti("ipv6SubnetPrefixLength"));
|
|
}
|
|
}
|
|
boolean bl8 = false;
|
|
if (bl && xElem.getb("dhcpEnabled", false)) {
|
|
bl8 = true;
|
|
}
|
|
bTcpIpAdapterSettings.setIsDhcpEnabled(bl8);
|
|
boolean bl9 = false;
|
|
if (bl7 && xElem.getb("ipv6DhcpEnabled", false)) {
|
|
bl9 = true;
|
|
}
|
|
bTcpIpAdapterSettings.setIsIpv6DhcpEnabled(bl9);
|
|
if (bTcpIpAdapterSettings.getIsDhcpEnabled()) {
|
|
bTcpIpAdapterSettings.setDhcpHost(xElem.get("dhcpHost", "n/a"));
|
|
bTcpIpAdapterSettings.setDhcpLeaseGranted(xElem.get("dhcpLeaseGranted", "n/a"));
|
|
bTcpIpAdapterSettings.setDhcpLeaseExpires(xElem.get("dhcpLeaseExpires", "n/a"));
|
|
} else {
|
|
bTcpIpAdapterSettings.setDhcpHost("n/a");
|
|
bTcpIpAdapterSettings.setDhcpLeaseGranted("n/a");
|
|
bTcpIpAdapterSettings.setDhcpLeaseExpires("n/a");
|
|
}
|
|
if (bl4) {
|
|
if (bTcpIpAdapterSettings.getIsIpv6DhcpEnabled()) {
|
|
bTcpIpAdapterSettings.setIpv6DhcpHost(xElem.get("ipv6DhcpHost", "n/a"));
|
|
bTcpIpAdapterSettings.setIpv6DhcpLeaseGranted(xElem.get("ipv6DhcpLeaseGranted", "n/a"));
|
|
bTcpIpAdapterSettings.setIpv6DhcpLeaseExpires(xElem.get("ipv6DhcpLeaseExpires", "n/a"));
|
|
} else {
|
|
bTcpIpAdapterSettings.setIpv6DhcpHost("n/a");
|
|
bTcpIpAdapterSettings.setIpv6DhcpLeaseGranted("n/a");
|
|
bTcpIpAdapterSettings.setIpv6DhcpLeaseExpires("n/a");
|
|
}
|
|
}
|
|
String string = null;
|
|
XElem xElem3 = xElem.elem("dnsHosts");
|
|
if (xElem3 != null) {
|
|
xElem2 = xElem3.elems("dnsHost");
|
|
bTcpIpAdapterSettings.setMaxDnsHosts(xElem3.geti("limit", 2));
|
|
object = new HashSet();
|
|
int n2 = 0;
|
|
while (n2 < ((XElem)xElem2).length) {
|
|
string = SlotPath.escape((String)xElem2[n2].get("ipAddress"));
|
|
((HashSet)object).add(string);
|
|
if (bTcpIpAdapterSettings.getDnsHosts().getSlot(string) == null) {
|
|
bTcpIpAdapterSettings.getDnsHosts().add(string, (BValue)BString.make((String)xElem2[n2].get("ipAddress")), 1, (Context)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"platform:IpHostFE")));
|
|
}
|
|
++n2;
|
|
}
|
|
propertyArray = bTcpIpAdapterSettings.getDnsHosts().getPropertiesArray();
|
|
n = 0;
|
|
while (n < propertyArray.length) {
|
|
if (!((HashSet)object).contains(propertyArray[n].getName())) {
|
|
bTcpIpAdapterSettings.getDnsHosts().remove(propertyArray[n].getName());
|
|
}
|
|
++n;
|
|
}
|
|
}
|
|
if (bl4 && (xElem2 = xElem.elem("ipv6DnsHosts")) != null) {
|
|
object = xElem2.elems("ipv6DnsHost");
|
|
propertyArray = new HashSet();
|
|
n = 0;
|
|
while (n < ((XElem[])object).length) {
|
|
string = SlotPath.escape((String)object[n].get("ipv6Address"));
|
|
propertyArray.add(string);
|
|
if (bTcpIpAdapterSettings.getIpv6DnsHosts().getSlot(string) == null) {
|
|
bTcpIpAdapterSettings.getIpv6DnsHosts().add(string, (BValue)BString.make((String)object[n].get("ipv6Address")), 1, (Context)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"platform:IpHostFE")));
|
|
}
|
|
++n;
|
|
}
|
|
Property[] propertyArray2 = bTcpIpAdapterSettings.getIpv6DnsHosts().getPropertiesArray();
|
|
int n3 = 0;
|
|
while (n3 < propertyArray2.length) {
|
|
if (!propertyArray.contains(propertyArray2[n3].getName())) {
|
|
bTcpIpAdapterSettings.getIpv6DnsHosts().remove(propertyArray2[n3].getName());
|
|
}
|
|
++n3;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static BTcpIpHostSettings updateAdapterNames(BTcpIpHostSettings bTcpIpHostSettings, BTcpIpHostSettings bTcpIpHostSettings2, BTcpIpHostSettings bTcpIpHostSettings3) throws Exception {
|
|
BTcpIpAdapterSettings bTcpIpAdapterSettings;
|
|
String string;
|
|
if (!bTcpIpHostSettings3.getUsesAdapterLevelSettings()) {
|
|
return bTcpIpHostSettings3;
|
|
}
|
|
BTcpIpHostSettings bTcpIpHostSettings4 = (BTcpIpHostSettings)bTcpIpHostSettings3.newCopy();
|
|
HashMap<String, String> hashMap = new HashMap<String, String>();
|
|
SlotCursor slotCursor = bTcpIpHostSettings.getAdapters().getProperties();
|
|
while (slotCursor.next()) {
|
|
string = SlotPath.unescape((String)slotCursor.property().getName());
|
|
if (string.charAt(0) != '{') {
|
|
return bTcpIpHostSettings4;
|
|
}
|
|
bTcpIpAdapterSettings = (BTcpIpAdapterSettings)slotCursor.get();
|
|
if (hashMap.put(bTcpIpAdapterSettings.getIpAddress(), string) == null) continue;
|
|
throw new LocalizableRuntimeException("platform", "CannotSaveTcpChangesError.duplicateIpAddress", new Object[]{bTcpIpAdapterSettings.getIpAddress()});
|
|
}
|
|
slotCursor = bTcpIpHostSettings2.getAdapters().getProperties();
|
|
while (slotCursor.next()) {
|
|
string = SlotPath.unescape((String)slotCursor.property().getName());
|
|
bTcpIpAdapterSettings = (BTcpIpAdapterSettings)slotCursor.get();
|
|
String string2 = (String)hashMap.get(bTcpIpAdapterSettings.getIpAddress());
|
|
if (string2 == null) {
|
|
throw new LocalizableRuntimeException("platform", "CannotSaveTcpChangesError.cannotTranslateAdapterAddress", new Object[]{bTcpIpAdapterSettings.getIpAddress()});
|
|
}
|
|
BTcpIpAdapterSettings bTcpIpAdapterSettings2 = (BTcpIpAdapterSettings)bTcpIpHostSettings4.getAdapters().get(SlotPath.escape((String)string2));
|
|
bTcpIpHostSettings4.getAdapters().rename(bTcpIpAdapterSettings2.getPropertyInParent(), SlotPath.escape((String)string));
|
|
bTcpIpAdapterSettings2.setAdapterId(string);
|
|
hashMap.remove(bTcpIpAdapterSettings.getIpAddress());
|
|
}
|
|
if (hashMap.size() > 0) {
|
|
throw new LocalizableRuntimeException("platform", "CannotSaveTcpChangesError.cannotTranslateAdapterAddress", new Object[]{hashMap.keySet().iterator().next()});
|
|
}
|
|
return bTcpIpHostSettings4;
|
|
}
|
|
|
|
public static BTcpIpHostSettings updateAdapterNames(BTcpIpHostSettings bTcpIpHostSettings, BDaemonSession bDaemonSession, BTcpIpHostSettings bTcpIpHostSettings2) throws Exception {
|
|
if (!bTcpIpHostSettings2.getUsesAdapterLevelSettings()) {
|
|
return bTcpIpHostSettings2;
|
|
}
|
|
BTcpIpHostSettings bTcpIpHostSettings3 = new BTcpIpHostSettings();
|
|
TcpUtil.loadFromSession(bTcpIpHostSettings3, bDaemonSession);
|
|
return TcpUtil.updateAdapterNames(bTcpIpHostSettings, bTcpIpHostSettings3, bTcpIpHostSettings2);
|
|
}
|
|
|
|
/*
|
|
* Unable to fully structure code
|
|
* Could not resolve type clashes
|
|
*/
|
|
public static void saveToSession(BTcpIpHostSettings var0, BDaemonSession var1_1, boolean var2_2) throws Exception {
|
|
block8: {
|
|
if (var0 == null) {
|
|
return;
|
|
}
|
|
var3_3 = var1_1.getHostProperties();
|
|
if (var3_3.getOsName().startsWith("win") && var0.getHostName().length() > 15) {
|
|
throw new BajaRuntimeException(Lexicon.make((String)"platform").getText("TcpIpHostSettings.invalidHostName"));
|
|
}
|
|
if (var3_3.getVmVendor().equalsIgnoreCase("IBM Corporation") && var0.getNiagaraUsesIpv6()) {
|
|
throw new BajaRuntimeException(Lexicon.make((String)"platform").getText("TcpIpHostSettings.cannotUseIPv6"));
|
|
}
|
|
if (!var3_3.getOsName().startsWith("qnx")) break block8;
|
|
var4_4 = 0;
|
|
var5_6 /* !! */ = var0.getAdapters().getProperties();
|
|
if (true) ** GOTO lbl15
|
|
do {
|
|
if ((var6_7 = (BTcpIpAdapterSettings)var5_6 /* !! */ .get()).getIsDhcpEnabled()) {
|
|
++var4_4;
|
|
}
|
|
lbl15:
|
|
// 4 sources
|
|
|
|
if ((v0 = TcpUtil.class$com$tridium$platform$tcpip$BTcpIpAdapterSettings) != null) continue;
|
|
v0 = TcpUtil.class("[Lcom.tridium.platform.tcpip.BTcpIpAdapterSettings;", false);
|
|
} while (var5_6 /* !! */ .next(v0));
|
|
if (var4_4 > 1) {
|
|
throw new BajaRuntimeException(Lexicon.make((String)"platform").getText("TcpIpHostSettings.multipleDhcpAdapters"));
|
|
}
|
|
}
|
|
var1_1.sendMessage(new UpdateTcpIpHostMessage(var0));
|
|
var4_5 = var0.getAdapters().loadSlots().getProperties();
|
|
while (var4_5.next()) {
|
|
var5_6 /* !! */ = (BTcpIpAdapterSettings)var4_5.get();
|
|
var1_1.sendMessage(new UpdateTcpIpAdapterMessage((BTcpIpAdapterSettings)var5_6 /* !! */ ));
|
|
}
|
|
if (!var3_3.getOsName().toLowerCase().startsWith("linux") && var2_2) {
|
|
var4_5 = var1_1.getFileSpace().findFile(new FilePath("/"), BCacheAccessPolicy.cacheOnly);
|
|
var5_6 /* !! */ = var4_5 == null ? new FilePath("!etc/hosts") : new FilePath("/etc/hosts");
|
|
var6_7 = new FileTransferMessage(var1_1.getFileSpace());
|
|
var6_7.addElement(new ByteArrayFileTransferElement((FilePath)var5_6 /* !! */ , var0.getHostFileContents().getBytes(), var1_1.getFileSpace()));
|
|
DaemonFileUtil.transfer(var1_1, (FileTransferMessage)var6_7, null);
|
|
}
|
|
}
|
|
|
|
static /* synthetic */ Class class(String string, boolean bl) {
|
|
try {
|
|
Class<?> clazz = Class.forName(string);
|
|
if (!bl) {
|
|
clazz = clazz.getComponentType();
|
|
}
|
|
return clazz;
|
|
}
|
|
catch (ClassNotFoundException classNotFoundException) {
|
|
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
private static class UpdateTcpIpHostMessage
|
|
extends XmlResponseMessage {
|
|
private StringBuffer path = new StringBuffer("tcpip?update=true");
|
|
static /* synthetic */ Class class$com$tridium$platform$tcpip$BTcpIpAdapterSettings;
|
|
|
|
public String getMessageString() {
|
|
return this.path.toString();
|
|
}
|
|
|
|
static /* synthetic */ Class class(String string, boolean bl) {
|
|
try {
|
|
Class<?> clazz = Class.forName(string);
|
|
if (!bl) {
|
|
clazz = clazz.getComponentType();
|
|
}
|
|
return clazz;
|
|
}
|
|
catch (ClassNotFoundException classNotFoundException) {
|
|
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Unable to fully structure code
|
|
*/
|
|
public UpdateTcpIpHostMessage(BTcpIpHostSettings var1_1) {
|
|
super();
|
|
this.path.append("&hostname=").append(HttpUtil.encodeUrl((String)var1_1.getHostName()));
|
|
var2_2 = false;
|
|
var4_3 = var1_1.getAdapters().getProperties();
|
|
if (true) ** GOTO lbl12
|
|
do {
|
|
if ((var3_4 = (BTcpIpAdapterSettings)var4_3.get()).getIsIpv6Enabled()) {
|
|
var2_2 = true;
|
|
break;
|
|
}
|
|
lbl12:
|
|
// 3 sources
|
|
|
|
if ((v0 = UpdateTcpIpHostMessage.class$com$tridium$platform$tcpip$BTcpIpAdapterSettings) != null) continue;
|
|
v0 = UpdateTcpIpHostMessage.class("[Lcom.tridium.platform.tcpip.BTcpIpAdapterSettings;", false);
|
|
} while (var4_3.next(v0));
|
|
if (var2_2) {
|
|
this.path.append("&niagaraUsesIpv6=").append(var1_1.getNiagaraUsesIpv6());
|
|
} else {
|
|
this.path.append("&niagaraUsesIpv6=false");
|
|
}
|
|
if (!var1_1.getUsesAdapterLevelSettings()) {
|
|
this.path.append("&domain=").append(HttpUtil.encodeUrl((String)var1_1.getDomain()));
|
|
this.path.append("&defaultGateway=").append(HttpUtil.encodeUrl((String)var1_1.getDefaultGateway().toString()));
|
|
var4_3 = new StringBuffer();
|
|
var5_5 = var1_1.getDnsHosts().loadSlots().getProperties();
|
|
while (var5_5.next()) {
|
|
if (var4_3.length() > 0) {
|
|
var4_3.append("%2C");
|
|
}
|
|
var4_3.append(HttpUtil.encodeUrl((String)var5_5.get().toString()));
|
|
}
|
|
this.path.append("&dnsHosts=").append(var4_3.toString());
|
|
if (var2_2) {
|
|
this.path.append("&ipv6DefaultGateway=").append(HttpUtil.encodeUrl((String)var1_1.getIpv6DefaultGateway()));
|
|
var5_5 = new StringBuffer();
|
|
var6_6 = var1_1.getIpv6DnsHosts().loadSlots().getProperties();
|
|
while (var6_6.next()) {
|
|
if (var5_5.length() > 0) {
|
|
var5_5.append("%2C");
|
|
}
|
|
var5_5.append(HttpUtil.encodeUrl((String)var6_6.get().toString()));
|
|
}
|
|
this.path.append("&ipv6DnsHosts=").append(var5_5.toString());
|
|
} else {
|
|
this.path.append("&ipv6DefaultGateway=");
|
|
this.path.append("&ipv6DnsHosts=");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static class UpdateTcpIpAdapterMessage
|
|
extends XmlResponseMessage {
|
|
private StringBuffer path = new StringBuffer("tcpip?update=true");
|
|
|
|
public String getMessageString() {
|
|
String string = this.path.toString();
|
|
return string;
|
|
}
|
|
|
|
public UpdateTcpIpAdapterMessage(BTcpIpAdapterSettings bTcpIpAdapterSettings) {
|
|
SlotCursor slotCursor;
|
|
StringBuffer stringBuffer;
|
|
this.path.append("&adapterId=").append(HttpUtil.encodeUrl((String)bTcpIpAdapterSettings.getAdapterId()));
|
|
this.path.append("&enabled=").append(String.valueOf(bTcpIpAdapterSettings.getIsAdapterEnabled()));
|
|
if (bTcpIpAdapterSettings.getCanUseDhcp()) {
|
|
this.path.append("&dhcpEnabled=").append(String.valueOf(bTcpIpAdapterSettings.getIsDhcpEnabled()));
|
|
}
|
|
if (bTcpIpAdapterSettings.getIsIpv6Supported()) {
|
|
if (bTcpIpAdapterSettings.getCanDisableIpv6()) {
|
|
this.path.append("&ipv6Enabled=").append(String.valueOf(bTcpIpAdapterSettings.getIsIpv6Enabled()));
|
|
}
|
|
if (bTcpIpAdapterSettings.getCanUseIpv6Dhcp()) {
|
|
StringBuffer stringBuffer2 = this.path.append("&ipv6DhcpEnabled=");
|
|
boolean bl = false;
|
|
if (bTcpIpAdapterSettings.getIsIpv6Enabled() && bTcpIpAdapterSettings.getIsIpv6DhcpEnabled()) {
|
|
bl = true;
|
|
}
|
|
stringBuffer2.append(String.valueOf(bl));
|
|
}
|
|
}
|
|
if (!bTcpIpAdapterSettings.getIsDhcpEnabled()) {
|
|
this.path.append("&ipAddress=").append(HttpUtil.encodeUrl((String)bTcpIpAdapterSettings.getIpAddress().toString()));
|
|
this.path.append("&subnetMask=").append(HttpUtil.encodeUrl((String)bTcpIpAdapterSettings.getSubnetMask().toString()));
|
|
if (bTcpIpAdapterSettings.getUsesAdapterLevelSettings()) {
|
|
this.path.append("&defaultGateway=").append(HttpUtil.encodeUrl((String)bTcpIpAdapterSettings.getDefaultGateway().toString()));
|
|
this.path.append("&domain=").append(HttpUtil.encodeUrl((String)bTcpIpAdapterSettings.getDomain()));
|
|
stringBuffer = new StringBuffer();
|
|
slotCursor = bTcpIpAdapterSettings.getDnsHosts().loadSlots().getProperties();
|
|
while (slotCursor.next()) {
|
|
if (stringBuffer.length() > 0) {
|
|
stringBuffer.append("%2C");
|
|
}
|
|
stringBuffer.append(HttpUtil.encodeUrl((String)slotCursor.get().toString()));
|
|
}
|
|
this.path.append("&dnsHosts=").append(stringBuffer.toString());
|
|
}
|
|
}
|
|
if (bTcpIpAdapterSettings.getIsIpv6Enabled() && !bTcpIpAdapterSettings.getIsIpv6DhcpEnabled()) {
|
|
this.path.append("&ipv6Address=").append(HttpUtil.encodeUrl((String)bTcpIpAdapterSettings.getIpv6Address().toString()));
|
|
this.path.append("&ipv6SubnetPrefixLength=").append(String.valueOf(bTcpIpAdapterSettings.getIpv6SubnetPrefixLength()));
|
|
if (bTcpIpAdapterSettings.getUsesAdapterLevelSettings()) {
|
|
this.path.append("&ipv6DefaultGateway=").append(HttpUtil.encodeUrl((String)bTcpIpAdapterSettings.getIpv6DefaultGateway().toString()));
|
|
stringBuffer = new StringBuffer();
|
|
slotCursor = bTcpIpAdapterSettings.getIpv6DnsHosts().loadSlots().getProperties();
|
|
while (slotCursor.next()) {
|
|
if (stringBuffer.length() > 0) {
|
|
stringBuffer.append("%2C");
|
|
}
|
|
stringBuffer.append(HttpUtil.encodeUrl((String)slotCursor.get().toString()));
|
|
}
|
|
this.path.append("&ipv6DnsHosts=").append(stringBuffer.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|