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 | |
Jonathan Hart | 61ba937 | 2013-05-19 20:10:29 -0700 | [diff] [blame] | 10 | public Prefix(byte[] addr, int masklen) throws UnknownHostException { |
| 11 | //try { |
| 12 | address = InetAddress.getByAddress(addr); |
| 13 | //} catch (UnknownHostException e) { |
| 14 | // System.out.println("InetAddress exception"); |
| 15 | // return; |
| 16 | //} |
pingping-lin | a2cbfad | 2013-03-07 08:39:21 +0800 | [diff] [blame] | 17 | this.masklen = masklen; |
Jonathan Hart | 61ba937 | 2013-05-19 20:10:29 -0700 | [diff] [blame] | 18 | //System.out.println(address.toString() + "/" + masklen); |
pingping-lin | a2cbfad | 2013-03-07 08:39:21 +0800 | [diff] [blame] | 19 | } |
Jonathan Hart | 61ba937 | 2013-05-19 20:10:29 -0700 | [diff] [blame] | 20 | |
| 21 | public Prefix(String str, int masklen) throws UnknownHostException { |
| 22 | //try { |
| 23 | address = InetAddress.getByName(str); |
| 24 | //} catch (UnknownHostException e) { |
| 25 | // System.out.println("InetAddress exception"); |
| 26 | // return; |
| 27 | //} |
pingping-lin | a2cbfad | 2013-03-07 08:39:21 +0800 | [diff] [blame] | 28 | this.masklen = masklen; |
| 29 | } |
Jonathan Hart | 61ba937 | 2013-05-19 20:10:29 -0700 | [diff] [blame] | 30 | |
pingping-lin | a2cbfad | 2013-03-07 08:39:21 +0800 | [diff] [blame] | 31 | public byte [] getAddress() { |
| 32 | return address.getAddress(); |
| 33 | } |
| 34 | } |