blob: 6c4c651893d0b9fbb25ffe7c3f962b15696a3e1a [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
3import net.floodlightcontroller.util.IPv4;
4
5/**
6 * The class representing an IPv4 network address.
7 */
8public class IPv4Net {
9 private IPv4 address; // The IPv4 address
10 private short prefixLen; // The prefix length
11
12 /**
13 * Default constructor.
14 */
15 public IPv4Net() {
16 this.prefixLen = 0;
17 }
18
19 /**
20 * Constructor for a given address and prefix length.
21 *
22 * @param address the address to use.
23 * @param prefixLen the prefix length to use.
24 */
25 public IPv4Net(IPv4 address, short prefixLen) {
26 this.address = address;
27 this.prefixLen = prefixLen;
28 }
29
30 /**
31 * Get the address value of the IPv4Net address.
32 *
33 * @return the address value of the IPv4Net address.
34 */
35 public IPv4 address() { return address; }
36
37 /**
38 * Get the prefix length value of the IPv4Net address.
39 *
40 * @return the prefix length value of the IPv4Net address.
41 */
42 public short prefixLen() { return prefixLen; }
43
44 /**
45 * Set the value of the IPv4Net address.
46 *
47 * @param address the address to use.
48 * @param prefixLen the prefix length to use.
49 */
50 public void setValue(IPv4 address, short prefixLen) {
51 this.address = address;
52 this.prefixLen = prefixLen;
53 }
54
55 /**
56 * Convert the IPv4Net value to an "address/prefixLen" string.
57 *
58 * @return the IPv4Net value as an "address/prefixLen" string.
59 */
60 @Override
61 public String toString() {
62 String ret = "";
63 // TODO: Implement it!
64 return ret;
65 }
66}