pingping-lin | a2cbfad | 2013-03-07 08:39:21 +0800 | [diff] [blame] | 1 | package net.floodlightcontroller.bgproute; |
| 2 | |
| 3 | import java.net.InetAddress; |
| 4 | import java.net.UnknownHostException; |
| 5 | |
| 6 | public class Prefix { |
| 7 | public int masklen; |
| 8 | protected InetAddress address; |
| 9 | |
| 10 | Prefix(byte[] addr, int masklen) { |
| 11 | try { |
| 12 | address = InetAddress.getByAddress(addr); |
| 13 | } catch (UnknownHostException e) { |
| 14 | System.out.println("InetAddress exception"); |
| 15 | return; |
| 16 | } |
| 17 | this.masklen = masklen; |
| 18 | System.out.println(address.toString() + "/" + masklen); |
| 19 | } |
| 20 | |
| 21 | Prefix(String str, int masklen) { |
| 22 | try { |
| 23 | address = InetAddress.getByName(str); |
| 24 | //System.out.println(address.toString()); |
| 25 | } catch (UnknownHostException e) { |
| 26 | System.out.println("InetAddress exception"); |
| 27 | return; |
| 28 | } |
| 29 | this.masklen = masklen; |
| 30 | } |
| 31 | |
| 32 | public byte [] getAddress() { |
| 33 | return address.getAddress(); |
| 34 | } |
| 35 | } |