/** * @return the node MAC address in byte array format */ public byte[] getMacAddress() { return HexEncode.bytesFromHexString(this.address); }
private byte[] getSourceMACFromNodeID(String nodeId) { byte[] cid = HexEncode.bytesFromHexString(nodeId); byte[] sourceMac = new byte[6]; int pos = cid.length - sourceMac.length; if (pos >= 0) { System.arraycopy(cid, pos, sourceMac, 0, sourceMac.length); } return sourceMac; }
private byte[] getSourceMACFromNodeID(String nodeId) { byte[] cid = HexEncode.bytesFromHexString(nodeId); byte[] sourceMac = new byte[6]; int pos = cid.length - sourceMac.length; if (pos >= 0) { System.arraycopy(cid, pos, sourceMac, 0, sourceMac.length); } return sourceMac; }
/** * Creates the ChassisID TLV value including the subtype and ChassisID * string * * @param nodeId * node identifier string * @return the ChassisID TLV value in byte array */ static public byte[] createChassisIDTLVValue(String nodeId) { byte[] nid = HexEncode.bytesFromHexString(nodeId); byte[] cid = new byte[6]; int srcPos = 0, dstPos = 0; if (nid.length > cid.length) { srcPos = nid.length - cid.length; } else { dstPos = cid.length - nid.length; } System.arraycopy(nid, srcPos, cid, dstPos, cid.length); byte[] cidValue = new byte[cid.length + chassisIDSubType.length]; System.arraycopy(chassisIDSubType, 0, cidValue, 0, chassisIDSubType.length); System.arraycopy(cid, 0, cidValue, chassisIDSubType.length, cid.length); return cidValue; }
@Override public Status addStaticHost(String networkAddress, String dataLayerAddress, NodeConnector nc, String vlan) { try { InetAddress ip = InetAddress.getByName(networkAddress); short vl = 0; if (vlan != null && !vlan.isEmpty()) { vl = Short.decode(vlan); if (vl < 1 || vl > 4095) { return new Status(StatusCode.BADREQUEST, "Host vlan out of range [1 - 4095]"); } } return addStaticHostReq(ip, HexEncode.bytesFromHexString(dataLayerAddress), nc, vl); } catch (UnknownHostException e) { logger.debug("Invalid host IP specified when adding static host", e); return new Status(StatusCode.BADREQUEST, "Invalid Host IP Address"); } catch (NumberFormatException nfe) { logger.debug("Invalid host vlan or MAC specified when adding static host", nfe); return new Status(StatusCode.BADREQUEST, "Invalid Host vLan/MAC"); } }
|| values[0].equals("eth_dst")) { this.dataLayerDestination = HexEncode .bytesFromHexString(values[1]); dlDestState = MatchFieldState.MATCH_FIELD_ONLY; match_len += 10; } else if (values[0].equals(STR_DL_SRC) || values[0].equals("eth_src")) { this.dataLayerSource = HexEncode.bytesFromHexString(values[1]); dlSourceState = MatchFieldState.MATCH_FIELD_ONLY; match_len += 10;
@Override public Status removeStaticHostUsingIPAndMac(String networkAddress, String macAddress) { try { if ((keyScheme != null) && (keyScheme.equals(HostIdFactory.DEFAULT_IP_KEY_SCHEME))) { return new Status(StatusCode.NOTALLOWED, "Host DB Key scheme used is not IP only scheme."); } InetAddress address = InetAddress.getByName(networkAddress); DataLinkAddress mac = new EthernetAddress(HexEncode.bytesFromHexString(macAddress)); return removeStaticHostReq(address, mac); } catch (UnknownHostException e) { logger.debug("Invalid IP Address when trying to remove host", e); return new Status(StatusCode.BADREQUEST, "Invalid IP Address when trying to remove host"); } catch (ConstructionException e) { // TODO Auto-generated catch block e.printStackTrace(); return new Status(StatusCode.BADREQUEST, "Invalid Input parameters have been passed."); } }
|| values[0].equals("eth_dst")) { this.dataLayerDestination = HexEncode .bytesFromHexString(values[1]); dlDestState = MatchFieldState.MATCH_FIELD_ONLY; match_len += 10; } else if (values[0].equals(STR_DL_SRC) || values[0].equals("eth_src")) { this.dataLayerSource = HexEncode.bytesFromHexString(values[1]); dlSourceState = MatchFieldState.MATCH_FIELD_ONLY; match_len += 10;
actionList.add(new SetDlSrc(HexEncode.bytesFromHexString(sstr.group(1)))); continue; actionList.add(new SetDlDst(HexEncode.bytesFromHexString(sstr.group(1)))); continue;
match.setField(MatchType.DL_SRC, HexEncode.bytesFromHexString(this.dlSrc)); match.setField(MatchType.DL_DST, HexEncode.bytesFromHexString(this.dlDst));