Refine search
@Override public Set<Host> getHosts(MacAddress mac) { Set<Host> macset = new HashSet<>(); for (Host h : hosts.values()) { if (h.mac().equals(mac)) { macset.add(h); } } return macset; }
/** * Accepts a MAC address and returns the corresponding long, where the MAC * bytes are set on the lower order bytes of the long. * * @param macAddress MAC address as a byte array * @return a long containing the mac address bytes */ public static long toLong(final byte[] macAddress) { return MacAddress.valueOf(macAddress).toLong(); }
/** * Gets the access agent configuration for this device. * * @return access agent configuration */ public AccessAgentData getAgent() { JsonNode olts = node.get(OLTS); Map<ConnectPoint, MacAddress> oltMacInfo = Maps.newHashMap(); olts.fields().forEachRemaining(item -> oltMacInfo.put( ConnectPoint.deviceConnectPoint(item.getKey()), MacAddress.valueOf(item.getValue().asText()))); MacAddress agentMac = MacAddress.valueOf(node.path(AGENT_MAC).asText()); JsonNode vtn = node.path(VTN_LOCATION); Optional<ConnectPoint> vtnLocation; if (vtn.isMissingNode()) { vtnLocation = Optional.empty(); } else { vtnLocation = Optional.of(ConnectPoint.deviceConnectPoint(vtn.asText())); } return new AccessAgentData(subject(), oltMacInfo, agentMac, vtnLocation); }
JsonNode portInfo = json.get(PORT); if (portInfo == null) { portInfo = json; String status = portInfo.path(STATUS).asText(); String name = portInfo.path(NAME).asText(); boolean adminStateUp = portInfo.path(ADMIN_STATUS).asBoolean(); String networkId = portInfo.path(NETWORK_ID).asText(); try { addressPairs.put(IpAddress.valueOf(addrPair.path(IP_ADDRESS).asText()), MacAddress.valueOf(addrPair.path(MAC_ADDRESS).asText())); } catch (IllegalArgumentException e) { log.debug("Invalid address pair {}", addrPair.toString()); .tenantId(tenantId) .deviceOwner(deviceOwner) .macAddress(MacAddress.valueOf(macStr)) .fixedIps(fixedIpMap) .id(id)
String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE), InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText(); String mac = nullIsIllegal(json.get(InstructionCodec.MAC), InstructionCodec.MAC + InstructionCodec.MISSING_MEMBER_MESSAGE).asText(); return Instructions.modL2Src(MacAddress.valueOf(mac)); } else if (subType.equals(L2ModificationInstruction.L2SubType.ETH_DST.name())) { String mac = nullIsIllegal(json.get(InstructionCodec.MAC), InstructionCodec.MAC + InstructionCodec.MISSING_MEMBER_MESSAGE).asText(); return Instructions.modL2Dst(MacAddress.valueOf(mac)); } else if (subType.equals(L2ModificationInstruction.L2SubType.VLAN_ID.name())) { short vlanId = (short) nullIsIllegal(json.get(InstructionCodec.VLAN_ID),
@Override public ObjectNode encode(Host host, CodecContext context) { checkNotNull(host, "Host cannot be null"); final JsonCodec<HostLocation> locationCodec = context.codec(HostLocation.class); final ObjectNode result = context.mapper().createObjectNode() .put("id", host.id().toString()) .put("mac", host.mac().toString()) .put("vlan", host.vlan().toString()) .put("innerVlan", host.innerVlan().toString()) .put("outerTpid", host.tpid().toString()) .put("configured", host.configured()); final ArrayNode jsonIpAddresses = result.putArray("ipAddresses"); for (final IpAddress ipAddress : host.ipAddresses()) { jsonIpAddresses.add(ipAddress.toString()); } result.set("ipAddresses", jsonIpAddresses); final ArrayNode jsonLocations = result.putArray("locations"); for (final HostLocation location : host.locations()) { jsonLocations.add(locationCodec.encode(location, context)); } result.set("locations", jsonLocations); return annotate(result, host, context); }
/** * Sets the source MAC address. * * @param sourceMac the source MAC to set * @return the Ethernet frame */ public Ethernet setSourceMACAddress(final byte[] sourceMac) { this.sourceMACAddress = MacAddress.valueOf(sourceMac); return this; }
MacAddress srcMac = MacAddress.valueOf(arp.getSenderHardwareAddress()); OpenstackPortInfo portInfo = openstackPortInfoCollection.stream() .filter(p -> p.ip().equals(sourceIp) && p.mac().equals(srcMac)).findFirst().orElse(null); IpAddress targetIp = Ip4Address.valueOf(arp.getTargetProtocolAddress());
/** * Gets the destination MAC address. * * @return the destination MAC as a byte array */ public byte[] getDestinationMACAddress() { return this.destinationMACAddress.toBytes(); }
@Override public int hashCode() { return Long.hashCode(toLong()); }
if (!context.dstMac().isBroadcast() && !intf.mac().equals(MacAddress.NONE) && !intf.mac().equals(context.dstMac())) { matches = false;
@Override public String toString() { return address.toString(); }
/** * @return True is the Ethernet frame is multicast, False otherwise */ public boolean isMulticast() { return this.destinationMACAddress.isMulticast(); }
(ethDst.mac().isBroadcast() || ethDst.mac().isMulticast());