/** * Return the MAC address to be set as a {@link MacAddress} instance. * * @return A {@link MacAddress} instance. */ public final MacAddress getMacAddress() { return address.getMacAddress(); }
/** * Convert the given {@link EtherAddress} instance into a * {@link MacAddress} instance. * * @param ea An {@link EtherAddress} instance. * @return A {@link MacAddress} instance or null. */ private MacAddress encode(EtherAddress ea) { return (ea == null) ? null : ea.getMacAddress(); }
/** * Return a hex string which represents this ethernet address. * * <p> * Note that below description of return value of this method is * written for REST API document. * </p> * * @return * A string representation of a MAC address. * * <p> * A MAC address is represented by hexadecimal notation with * {@code ':'} inserted between octets. * (e.g. {@code "11:22:33:aa:bb:cc"}) * </p> */ @XmlValue public String getText() { return getMacAddress().getValue(); }
/** * Return a MD-SAL MAC address. * * @return A {@link MacAddress} instance. * Note that {@code null} is returned if no MAC address is * configured in this instance. */ public MacAddress getMacAddress() { long mac = getAddress(); if (mac == UNDEFINED) { return null; } EtherAddress eaddr = new EtherAddress(mac); return eaddr.getMacAddress(); }
/** * Search for a MAC address table entry specified by the given MAC address * in the MAC address table. * * @param ctx MD-SAL datastore transaction context. * @param eaddr An {@link EtherAddress} instance that specifies the * MAC address. * @return A {@link MacEntry} instance if found. * {@code null} if not found. * @throws VTNException An error occurred. */ private MacEntry getMacEntry(TxContext ctx, EtherAddress eaddr) throws VTNException { // Multicast address should never be found in the MAC address table. MacEntry ment = null; if (eaddr.isUnicast()) { BridgeIdentifier<Vbridge> vbrId = getIdentifier(); ReadWriteTransaction tx = ctx.getReadWriteTransaction(); InstanceIdentifier<MacTableEntry> path = getMacEntryPath(vbrId, eaddr.getMacAddress()); Optional<MacTableEntry> opt = DataStoreUtils.read(tx, path); if (opt.isPresent()) { ment = new CurrentMacEntry(eaddr, opt.get()); } } return ment; }
/** * Return a {@link VtnEtherMatchBuilder} instance which contains the flow * conditions configured in this instance. * * @return A {@link VtnEtherMatchBuilder} instance. */ public VtnEtherMatchBuilder toVtnEtherMatchBuilder() { VtnEtherMatchBuilder builder = new VtnEtherMatchBuilder(); if (sourceAddress != null) { builder.setSourceAddress(sourceAddress.getMacAddress()); } if (destinationAddress != null) { builder.setDestinationAddress(destinationAddress.getMacAddress()); } if (etherType != null) { Long type = NumberUtils.toLong(etherType); builder.setEtherType(new EtherType(type)); } if (vlanId != null) { builder.setVlanId(new VlanId(vlanId)); } if (vlanPriority != null) { builder.setVlanPcp(new VlanPcp(vlanPriority)); } return builder; }
ReadWriteTransaction tx = pctx.getTxContext(). getReadWriteTransaction(); tx.delete(oper, getMacEntryPath(vbrId, eaddr.getMacAddress()));
/** * Return the MAC address table entry to be put into the MD-SAL datastore. * * @return A {@link MacTableEntry} instance. */ @Override public MacTableEntry getNewEntry() { SalPort sport = getPort(); MacTableEntryBuilder builder = new MacTableEntryBuilder(). setMacAddress(getEtherAddress().getMacAddress()). setNode(sport.getNodeId()). setPortId(String.valueOf(sport.getPortNumber())). setPortName(portName). setVlanId(getVlanId()). setEntryData(mapPath); return set(builder).build(); } }
/** * Learn the source MAC address of the given packet. * * @param pctx A runtime context for a received packet. * @param vnode A {@link VirtualMapNode} instance that specifies the * virtual mapping that maps the packet. * @throws VTNException An error occurred. */ private void learnMacAddress(PacketContext pctx, VirtualMapNode vnode) throws VTNException { EtherAddress src = pctx.getSourceAddress(); if (isMacAddressValid(pctx, src)) { MacAddress mac = src.getMacAddress(); InstanceIdentifier<MacTableEntry> path = getMacEntryPath(getIdentifier(), mac); MacEntry ment = addMacEntry(pctx, path, src, vnode); if (pctx.isIPv4() && ment.needIpProbe()) { // Try to detect IP address of the given host. pctx.probeInetAddress(); } MacTableEntry newEnt = ment.getNewEntry(); if (newEnt != null) { // Put the new entry. TxContext ctx = pctx.getTxContext(); ReadWriteTransaction tx = ctx.getReadWriteTransaction(); LogicalDatastoreType oper = LogicalDatastoreType.OPERATIONAL; tx.put(oper, path, newEnt, false); } } }
} else { EthernetSource src = new EthernetSourceBuilder(). setAddress(sourceAddress.getMacAddress()).build(); ematch = create((EthernetMatchBuilder)null). setEthernetSource(src); setAddress(destinationAddress.getMacAddress()).build(); ematch = create(ematch).setEthernetDestination(dst);
builder.setControllerMacAddress(mac.getMacAddress());