add methods to directly set MacAddress
Change-Id: Idab9dce493927d8943789177830df630f3b1326a
diff --git a/utils/misc/src/main/java/org/onlab/packet/Ethernet.java b/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
index 70a52e2..96ec021 100644
--- a/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
+++ b/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
@@ -18,6 +18,8 @@
package org.onlab.packet;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashMap;
@@ -86,6 +88,17 @@
* @param destMac the destination MAC to set
* @return the Ethernet frame
*/
+ public Ethernet setDestinationMACAddress(final MacAddress destMac) {
+ this.destinationMACAddress = checkNotNull(destMac);
+ return this;
+ }
+
+ /**
+ * Sets the destination MAC address.
+ *
+ * @param destMac the destination MAC to set
+ * @return the Ethernet frame
+ */
public Ethernet setDestinationMACAddress(final byte[] destMac) {
this.destinationMACAddress = MacAddress.valueOf(destMac);
return this;
@@ -126,6 +139,17 @@
* @param sourceMac the source MAC to set
* @return the Ethernet frame
*/
+ public Ethernet setSourceMACAddress(final MacAddress sourceMac) {
+ this.sourceMACAddress = checkNotNull(sourceMac);
+ return this;
+ }
+
+ /**
+ * 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;