Committed by
Gerrit Code Review
Using Validation util function
Change-Id: I675e453e8d565966e8d0f23a6aa678a3c6dfb2e8
Showing
2 changed files
with
6 additions
and
6 deletions
... | @@ -21,6 +21,7 @@ import java.util.Objects; | ... | @@ -21,6 +21,7 @@ import java.util.Objects; |
21 | import org.jboss.netty.buffer.ChannelBuffer; | 21 | import org.jboss.netty.buffer.ChannelBuffer; |
22 | import org.onlab.packet.Ip4Address; | 22 | import org.onlab.packet.Ip4Address; |
23 | import org.onosproject.bgpio.exceptions.BGPParseException; | 23 | import org.onosproject.bgpio.exceptions.BGPParseException; |
24 | +import org.onosproject.bgpio.util.Validation; | ||
24 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
25 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
26 | 27 | ||
... | @@ -53,7 +54,7 @@ public class IPv4AddressTlv implements BGPValueType { | ... | @@ -53,7 +54,7 @@ public class IPv4AddressTlv implements BGPValueType { |
53 | * | 54 | * |
54 | * @return Ipv4 address of interface/neighbor | 55 | * @return Ipv4 address of interface/neighbor |
55 | */ | 56 | */ |
56 | - public Ip4Address getValue() { | 57 | + public Ip4Address address() { |
57 | return address; | 58 | return address; |
58 | } | 59 | } |
59 | 60 | ||
... | @@ -97,8 +98,7 @@ public class IPv4AddressTlv implements BGPValueType { | ... | @@ -97,8 +98,7 @@ public class IPv4AddressTlv implements BGPValueType { |
97 | * @throws BGPParseException while parsing IPv4AddressTlv | 98 | * @throws BGPParseException while parsing IPv4AddressTlv |
98 | */ | 99 | */ |
99 | public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException { | 100 | public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException { |
100 | - //TODO: use Validation.toInetAddress once Validation is merged | 101 | + InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb); |
101 | - InetAddress ipAddress = (InetAddress) cb.readBytes(LENGTH); | ||
102 | if (ipAddress.isMulticastAddress()) { | 102 | if (ipAddress.isMulticastAddress()) { |
103 | throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null); | 103 | throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null); |
104 | } | 104 | } | ... | ... |
... | @@ -21,6 +21,7 @@ import java.util.Objects; | ... | @@ -21,6 +21,7 @@ import java.util.Objects; |
21 | import org.jboss.netty.buffer.ChannelBuffer; | 21 | import org.jboss.netty.buffer.ChannelBuffer; |
22 | import org.onlab.packet.Ip6Address; | 22 | import org.onlab.packet.Ip6Address; |
23 | import org.onosproject.bgpio.exceptions.BGPParseException; | 23 | import org.onosproject.bgpio.exceptions.BGPParseException; |
24 | +import org.onosproject.bgpio.util.Validation; | ||
24 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
25 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
26 | 27 | ||
... | @@ -53,7 +54,7 @@ public class IPv6AddressTlv implements BGPValueType { | ... | @@ -53,7 +54,7 @@ public class IPv6AddressTlv implements BGPValueType { |
53 | * | 54 | * |
54 | * @return Ipv6 address of interface/neighbor | 55 | * @return Ipv6 address of interface/neighbor |
55 | */ | 56 | */ |
56 | - public Ip6Address getValue() { | 57 | + public Ip6Address address() { |
57 | return address; | 58 | return address; |
58 | } | 59 | } |
59 | 60 | ||
... | @@ -97,8 +98,7 @@ public class IPv6AddressTlv implements BGPValueType { | ... | @@ -97,8 +98,7 @@ public class IPv6AddressTlv implements BGPValueType { |
97 | * @throws BGPParseException while parsing IPv6AddressTlv | 98 | * @throws BGPParseException while parsing IPv6AddressTlv |
98 | */ | 99 | */ |
99 | public static IPv6AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException { | 100 | public static IPv6AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException { |
100 | - //TODO: use Validation.toInetAddress once Validation is merged | 101 | + InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb); |
101 | - InetAddress ipAddress = (InetAddress) cb.readBytes(LENGTH); | ||
102 | if (ipAddress.isMulticastAddress()) { | 102 | if (ipAddress.isMulticastAddress()) { |
103 | throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null); | 103 | throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null); |
104 | } | 104 | } | ... | ... |
-
Please register or login to post a comment