blob: 7ba014b044d4f17fe877a01a65afb0d7ef9baf71 [file] [log] [blame]
pingping-lina2cbfad2013-03-07 08:39:21 +08001package net.floodlightcontroller.bgproute;
2
3import java.net.InetAddress;
4import java.net.UnknownHostException;
5
6public 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}