Yotam Harchol | 4d63468 | 2013-09-26 13:21:06 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.types; |
| 2 | |
| 3 | public abstract class IPAddress<F extends IPAddress<F>> implements OFValueType<F> { |
| 4 | |
| 5 | public enum IpVersion { |
| 6 | IPv4, |
| 7 | IPv6 |
| 8 | } |
| 9 | |
| 10 | public abstract IpVersion getIpVersion(); |
| 11 | |
| 12 | public static IPAddress<?> of(String ip) { |
| 13 | if (ip.indexOf('.') != -1) |
| 14 | return IPv4Address.of(ip); |
| 15 | else if (ip.indexOf(':') != -1) |
| 16 | return IPv6Address.of(ip); |
| 17 | else |
| 18 | throw new IllegalArgumentException("IP Address not well formed: " + ip); |
| 19 | } |
| 20 | |
| 21 | } |