The second patch of an estimated 4 to complete the COPS message refactoring as descri...
[packetcable.git] / packetcable-driver / src / main / java / org / umu / cops / stack / COPSIpv4OutInterface.java
1 /*
2  * Copyright (c) 2003 University of Murcia.  All rights reserved.
3  * --------------------------------------------------------------
4  * For more information, please see <http://www.umu.euro6ix.org/>.
5  */
6
7 package org.umu.cops.stack;
8
9 import org.umu.cops.stack.COPSObjHeader.CNum;
10 import org.umu.cops.stack.COPSObjHeader.CType;
11
12 /**
13  * COPS IPv4 Output Interface (RFC 2748)
14  *
15  * The Out-Interface is used to identify the outgoing interface to which
16  * a specific request applies and the address for where the forwarded
17  * message is to be sent. For flows or messages destined to the PEP's
18  * local host, the loop back address and ifindex are used.  The Out-
19  * Interface has the same formats as the In-Interface Object.
20  *
21  * This Interface object is also used to identify the outgoing
22  * (forwarding) interface via its ifindex. The ifindex may be used to
23  * differentiate between sub-interfaces and unnumbered interfaces (see
24  * RSVP's LIH for an example). When SNMP is supported by the PEP, this
25  * ifindex integer MUST correspond to the same integer value for the
26  * interface in the SNMP MIB-II interface index table.
27  *
28  * Note: The ifindex specified in the Out-Interface is typically
29  * relative to the flow of the underlying protocol messages. The ifindex
30  * is the one on which a protocol message is about to be forwarded.
31  *
32  * C-Num = 4
33  *
34  * C-Type = 1, IPv4 Address + Interface
35  *
36  * Same C-Type format as the In-Interface object. The IPv4 address
37  * specifies the IP address to which the outgoing message is going. The
38  * ifindex is used to refer to the MIB-II defined local outgoing
39  * interface on the PEP.
40  * C-Type = 2, IPv6 Address + Interface
41  *
42  * Same C-Type format as the In-Interface object. For this type of the
43  * interface object, the IPv6 address specifies the IP address to which
44  * the outgoing message is going. The ifindex is used to refer to the
45  * MIB-II defined local outgoing interface on the PEP.
46  */
47 public class COPSIpv4OutInterface extends COPSIpv4Interface {
48
49     /**
50      * Constructor generally used for sending messages
51      * @param ifindex - the interface value
52      * @param addr - the IPv4 address
53      * @throws java.lang.IllegalArgumentException
54      */
55     public COPSIpv4OutInterface(final COPSIpv4Address addr, final int ifindex) {
56         this(new COPSObjHeader(CNum.OUTINTF, CType.DEF), addr, ifindex);
57     }
58
59     /**
60      * Constructor generally used when parsing the bytes of an inbound COPS message but can also be used when the
61      * COPSObjHeader information is known
62      * @param objHdr - the object header
63      * @param ifindex - the interface value
64      * @param addr - the IPv4 address
65      * @throws java.lang.IllegalArgumentException
66      */
67     protected COPSIpv4OutInterface(final COPSObjHeader objHdr, final COPSIpv4Address addr, final int ifindex) {
68         super(objHdr, addr, ifindex);
69     }
70
71     /**
72      * Creates this object from a byte array
73      * @param objHdrData - the header
74      * @param dataPtr - the data to parse
75      * @return - a new Timer
76      * @throws java.lang.IllegalArgumentException
77      */
78     public static COPSIpv4OutInterface parse(final COPSObjHeaderData objHdrData, final byte[] dataPtr) {
79         return new COPSIpv4OutInterface(objHdrData.header, COPSIpv4Interface.parseAddress(dataPtr),
80                 COPSIpv4Interface.parseIfIndex(dataPtr));
81     }
82
83     public boolean isInInterface() { return false; }
84 }
85
86