@Override public int hashCode() { return Long.hashCode(toLong()); }
/** * 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(); }
/** * Constructs an agent configuration for a given device. * * @param deviceId access device ID * @param oltMacInfo a map of olt chips and their mac address * @param agentMac the MAC address of the agent * @param vtnLocation the location of the agent */ public AccessAgentData(DeviceId deviceId, Map<ConnectPoint, MacAddress> oltMacInfo, MacAddress agentMac, Optional<ConnectPoint> vtnLocation) { this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING); this.oltMacInfo = ImmutableMap.copyOf(checkNotNull(oltMacInfo, OLT_INFO_MISSING)); this.agentMac = checkNotNull(agentMac, AGENT_MAC_MISSING); this.vtnLocation = checkNotNull(vtnLocation, VTN_MISSING); this.sortedOltChips = oltMacInfo.entrySet().stream() .sorted((e1, e2) -> Long.compare(e1.getValue().toLong(), e2.getValue().toLong())) .map(e -> Pair.of(e.getKey(), e.getValue())) .collect(Collectors.toList()); }
@Override public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { IPv6NDLinkLayerAddressCriterion c = (IPv6NDLinkLayerAddressCriterion) criterion; initAsExactMatch(copyFrom(c.mac().toLong()), bitWidth); } }
@Override public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { ArpHaCriterion c = (ArpHaCriterion) criterion; initAsExactMatch(copyFrom(c.mac().toLong()), bitWidth); } }
private OFAction buildL2Modification(Instruction i) { L2ModificationInstruction l2m = (L2ModificationInstruction) i; ModEtherInstruction eth; switch (l2m.subtype()) { case ETH_DST: eth = (ModEtherInstruction) l2m; return factory().actions().setDlDst(MacAddress.of(eth.mac().toLong())); case ETH_SRC: eth = (ModEtherInstruction) l2m; return factory().actions().setDlSrc(MacAddress.of(eth.mac().toLong())); case VLAN_ID: ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m; return factory().actions().setVlanVid(VlanVid.ofVlan(vlanId.vlanId().toShort())); case VLAN_PCP: ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m; return factory().actions().setVlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); case VLAN_POP: return factory().actions().stripVlan(); case VLAN_PUSH: return null; default: log.warn("Unimplemented action type {}.", l2m.subtype()); break; } return null; }
case ETH_DST: eth = (L2ModificationInstruction.ModEtherInstruction) l2m; oxm = factory.oxms().ethDst(MacAddress.of(eth.mac().toLong())); break; case ETH_SRC: eth = (L2ModificationInstruction.ModEtherInstruction) l2m; oxm = factory.oxms().ethSrc(MacAddress.of(eth.mac().toLong())); break; case VLAN_ID:
ethCriterion = (EthCriterion) c; mBuilder.setExact(MatchField.ETH_DST, MacAddress.of(ethCriterion.mac().toLong())); break; case ETH_DST_MASKED: ethCriterion = (EthCriterion) c; mBuilder.setMasked(MatchField.ETH_DST, MacAddress.of(ethCriterion.mac().toLong()), MacAddress.of(ethCriterion.mask().toLong())); break; case ETH_SRC: ethCriterion = (EthCriterion) c; mBuilder.setExact(MatchField.ETH_SRC, MacAddress.of(ethCriterion.mac().toLong())); break; case ETH_SRC_MASKED: ethCriterion = (EthCriterion) c; mBuilder.setMasked(MatchField.ETH_SRC, MacAddress.of(ethCriterion.mac().toLong()), MacAddress.of(ethCriterion.mask().toLong())); break; case ETH_TYPE: (IPv6NDLinkLayerAddressCriterion) c; mBuilder.setExact(MatchField.IPV6_ND_SLL, MacAddress.of(llAddressCriterion.mac().toLong())); break; case IPV6_ND_TLL:
case ARP_SHA: ModArpEthInstruction ei = (ModArpEthInstruction) i; oxm = factory().oxms().arpSha(MacAddress.of(ei.mac().toLong())); break; case ARP_OP: