diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2020-02-19 19:53:59 +0900 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2020-02-19 20:34:05 +0900 |
commit | 32336c98689bcfe363390cf8398619dc66fe3107 (patch) | |
tree | 9aba5f9e05c906dc086ea7a827387eeb83176e79 /common/moduleutils/src | |
parent | 21907e1cdc3dc9f86c4446d7e111a6637aefcec4 (diff) |
Add a hasMacAddress member to InterfaceParams.
This is a convenience function for callers who would like to know
whether the interface has a MAC address. It is needed because the
constructed object will have a MAC address of 02:00:00:00:00:00
if the interface did not have a MAC address.
Test: added minimal unit test coverage
Change-Id: I422422d032afbbabcf8594def76702bb053f0a96
Diffstat (limited to 'common/moduleutils/src')
-rw-r--r-- | common/moduleutils/src/android/net/util/InterfaceParams.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/moduleutils/src/android/net/util/InterfaceParams.java b/common/moduleutils/src/android/net/util/InterfaceParams.java index 3ba02b5..7e05a8d 100644 --- a/common/moduleutils/src/android/net/util/InterfaceParams.java +++ b/common/moduleutils/src/android/net/util/InterfaceParams.java @@ -38,6 +38,7 @@ import java.net.SocketException; public class InterfaceParams { public final String name; public final int index; + public final boolean hasMacAddress; public final MacAddress macAddr; public final int defaultMtu; @@ -69,7 +70,8 @@ public class InterfaceParams { checkArgument((index > 0), "invalid interface index"); this.name = name; this.index = index; - this.macAddr = (macAddr != null) ? macAddr : MacAddress.fromBytes(new byte[] { + this.hasMacAddress = (macAddr != null); + this.macAddr = hasMacAddress ? macAddr : MacAddress.fromBytes(new byte[] { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 }); this.defaultMtu = (defaultMtu > IPV6_MIN_MTU) ? defaultMtu : IPV6_MIN_MTU; } |