3f614fd6938dad58aa3a23ba1378ddb6a48a5d8c
[public/netxms.git] / src / java / netxms-client / src / main / java / org / netxms / client / IpAddressListElement.java
1 /**
2 *
3 */
4 package org.netxms.client;
5
6 import java.net.InetAddress;
7 import org.netxms.base.NXCPMessage;
8
9 /**
10 * Element of IP address list. Can represent either subnet or address range.
11 */
12 public class IpAddressListElement
13 {
14 public static final int SUBNET = 0;
15 public static final int RANGE = 1;
16
17 private int type;
18 private InetAddress addr1;
19 private InetAddress addr2;
20
21 /**
22 * Create new element
23 *
24 * @param type
25 * @param addr1
26 * @param addr2
27 */
28 public IpAddressListElement(int type, InetAddress addr1, InetAddress addr2)
29 {
30 this.type = type;
31 this.addr1 = addr1;
32 this.addr2 = addr2;
33 }
34
35 /**
36 * Create element from NXCP message
37 *
38 * @param msg NXCP message
39 * @param baseId base variable ID
40 */
41 protected IpAddressListElement(NXCPMessage msg, long baseId)
42 {
43 type = msg.getVariableAsInteger(baseId);
44 addr1 = msg.getVariableAsInetAddress(baseId + 1);
45 addr2 = msg.getVariableAsInetAddress(baseId + 2);
46 }
47
48 /**
49 * @return the type
50 */
51 public int getType()
52 {
53 return type;
54 }
55
56 /**
57 * Get first address (subnet base address or range start)
58 *
59 * @return the addr1
60 */
61 public InetAddress getAddr1()
62 {
63 return addr1;
64 }
65
66 /**
67 * Get second address (subnet mask or range last address)
68 *
69 * @return the addr2
70 */
71 public InetAddress getAddr2()
72 {
73 return addr2;
74 }
75 }