Search in sources :

Example 1 with EmberCurrentSecurityBitmask

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberConsoleSecurityStateCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
    if (networkManager.getNetworkState() != ZigBeeTransportState.ONLINE) {
        throw new IllegalStateException("Network state is " + networkManager.getNetworkState() + ". Unable to show security data.");
    }
    EmberNcp ncp = getEmberNcp(networkManager);
    Integer securityLevel = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_SECURITY_LEVEL);
    Integer rejoinTimeout = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_TC_REJOINS_USING_WELL_KNOWN_KEY_TIMEOUT_S);
    Integer trustCentreCacheSize = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE);
    Integer keyTableSize = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_KEY_TABLE_SIZE);
    Integer transientKeyTimeout = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_TRANSIENT_KEY_TIMEOUT_S);
    EmberCurrentSecurityState securityState = ncp.getCurrentSecurityState();
    EzspDecisionId trustCentrePolicy = ncp.getPolicy(EzspPolicyId.EZSP_TRUST_CENTER_POLICY);
    EzspDecisionId appKeyPolicy = ncp.getPolicy(EzspPolicyId.EZSP_APP_KEY_REQUEST_POLICY);
    EzspDecisionId trustCentreKeyPolicy = ncp.getPolicy(EzspPolicyId.EZSP_TC_KEY_REQUEST_POLICY);
    EzspDecisionId trustCentreRejoinPolicy = ncp.getPolicy(EzspPolicyId.EZSP_TC_REJOINS_USING_WELL_KNOWN_KEY_POLICY);
    EmberKeyStruct networkKey = ncp.getKey(EmberKeyType.EMBER_CURRENT_NETWORK_KEY);
    EmberKeyStruct linkKey = ncp.getKey(EmberKeyType.EMBER_TRUST_CENTER_LINK_KEY);
    List<EmberKeyStruct> keyTable = new ArrayList<>();
    for (int cnt = 0; cnt < keyTableSize; cnt++) {
        EmberKeyStruct key = ncp.getKeyTableEntry(cnt);
        if (key != null) {
            keyTable.add(key);
        }
    }
    out.println("Trust Centre Address       : " + securityState.getTrustCenterLongAddress());
    out.println("Security level             : " + securityLevel);
    out.println("Rejoin timeout             : " + rejoinTimeout);
    out.println("Key table size             : " + keyTableSize);
    out.println("Trust Centre cache size    : " + trustCentreCacheSize);
    out.println("Transient key timeout      : " + transientKeyTimeout);
    out.println("Application Key Policy     : " + appKeyPolicy);
    out.println("Trust Centre Policy        : " + trustCentrePolicy);
    out.println("Trust Centre Key Policy    : " + trustCentreKeyPolicy);
    out.println("Trust Centre Rejoin Policy : " + trustCentreRejoinPolicy);
    out.print("Security state flags       : ");
    boolean first = true;
    for (EmberCurrentSecurityBitmask state : securityState.getBitmask()) {
        if (!first) {
            out.print("                           : ");
        }
        first = false;
        out.println(state);
    }
    if (first) {
        out.println();
    }
    out.println();
    out.println("Key Type                        IEEE Address      Key Data                          In Cnt    Out Cnt   Seq");
    out.println(printKey(linkKey));
    out.println(printKey(networkKey));
    for (EmberKeyStruct key : keyTable) {
        out.println(printKey(key));
    }
}
Also used : EmberCurrentSecurityBitmask(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask) EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp) EzspDecisionId(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId) ArrayList(java.util.ArrayList) EmberKeyStruct(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyStruct) EmberCurrentSecurityState(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityState)

Example 2 with EmberCurrentSecurityBitmask

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspDeserializer method deserializeEmberCurrentSecurityBitmask.

public Set<EmberCurrentSecurityBitmask> deserializeEmberCurrentSecurityBitmask() {
    Set<EmberCurrentSecurityBitmask> list = new HashSet<EmberCurrentSecurityBitmask>();
    int value = deserializeUInt16();
    for (EmberCurrentSecurityBitmask bitmask : EmberCurrentSecurityBitmask.values()) {
        // Ignore UNKNOWN
        if (bitmask == EmberCurrentSecurityBitmask.UNKNOWN) {
            continue;
        }
        if ((value & bitmask.getKey()) != 0) {
            list.add(bitmask);
        }
    }
    return list;
}
Also used : EmberCurrentSecurityBitmask(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask) HashSet(java.util.HashSet)

Example 3 with EmberCurrentSecurityBitmask

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspSerializer method serializeEmberCurrentSecurityBitmask.

public void serializeEmberCurrentSecurityBitmask(Set<EmberCurrentSecurityBitmask> securityBitmask) {
    int value = 0;
    for (EmberCurrentSecurityBitmask bitmask : securityBitmask) {
        value |= bitmask.getKey();
    }
    buffer[length++] = value & 0xFF;
    buffer[length++] = (value >> 8) & 0xFF;
}
Also used : EmberCurrentSecurityBitmask(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask)

Aggregations

EmberCurrentSecurityBitmask (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask)3 EmberNcp (com.zsmartsystems.zigbee.dongle.ember.EmberNcp)1 EmberCurrentSecurityState (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityState)1 EmberKeyStruct (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyStruct)1 EzspDecisionId (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1