Updates to support new TrafficProfiles that require a user-specified Direction in...
[packetcable.git] / packetcable-driver / src / main / java / org / pcmm / gates / IExtendedClassifier.java
1 /*
2  * Copyright (c) 2015 Cable Television Laboratories, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.pcmm.gates;
10
11 import java.net.InetAddress;
12
13 /**
14  * The Extended Classifier object specifies the packet matching rules associated with a Gate, but includes more
15  * detailed information for matching traffic, as well adding, modifying, deleting, activating and inactivating Classifiers.
16  * As defined in sections 6.4.3.1 and 6.4.3.2, for Unicast Gates multiple Extended Classifier objects may be included
17  * in the Gate-Set to allow for complex classifier rules. However, since the ordering of objects in a message and the
18  * order of processing those objects is not mandated, and AM SHOULD NOT send a GateSet with multiple Extended
19  * Classifiers with the same ClassifierID, yet different Actions. When an AM is using Extended Classifier objects, at
20  * least one Extended Classifier is allowed. For Multicast Gates, only one Extended Classifier is required to be supported.
21  * Since the Extended Classifier is based on the DOCSIS IP Classifier, all DOCSIS classifier semantics apply, with the
22  * exception that at least one Extended Classifier be present in a Gate-Set message.
23  *
24  * Message length including header == 40
25  */
26 public interface IExtendedClassifier extends IClassifier {
27
28     byte STYPE = 2;
29
30     /**
31      * Returns the IP Source Mask value
32      * @return - the InetAddress object
33      */
34     InetAddress getIPSourceMask();
35
36     /**
37      * Returns the IP Destination Mask value
38      * @return - the InetAddress object
39      */
40     InetAddress getIPDestinationMask();
41
42     /**
43      * Returns the Start Source Port value
44      * @return - the port number
45      */
46     short getSourcePortStart();
47
48     /**
49      * Returns the End Source Port value
50      * @return - the port number
51      */
52     short getSourcePortEnd();
53
54     /**
55      * Returns the Start Destination Port value
56      * @return - the port number
57      */
58     short getDestinationPortStart();
59
60     /**
61      * Returns the End Destination Port value
62      * @return - the port number
63      */
64     short getDestinationPortEnd();
65
66     /**
67      * The ID value of this classifier
68      * @return - the ID
69      */
70     short getClassifierID();
71
72     /**
73      * The activation state
74      * @return
75      */
76     ActivationState getActivationState();
77
78
79     Action getAction();
80
81     /**
82      * The valid activation state values
83      */
84     enum ActivationState {
85
86         INACTIVE((byte) 0), ACTIVE((byte) 1);
87
88         ActivationState(byte value) {
89             this.value = value;
90         }
91
92         public byte getValue() {
93             return value;
94         }
95
96         public static ActivationState valueOf(byte v) {
97             switch (v) {
98                 case 0:
99                     return ActivationState.INACTIVE;
100                 case 1:
101                     return ActivationState.ACTIVE;
102                 default:
103                     throw new IllegalArgumentException("not supported value");
104             }
105         }
106
107         private byte value;
108
109     }
110
111     /**
112      * For the Extended Classifier or the IPv6, the Action field is a
113      * 1 byte unsigned integer with the following values:
114      * <ul>
115      *     <li>0x00, Add classifier</li>
116      *     <li>0x01, Replace classifier</li>
117      *     <li>0x02, Delete classifier</li>
118      *     <li>0x03, No change</li>
119      * </ul>
120      *
121      */
122      enum Action {
123         ADD,
124         REPLACE,
125         DELETE,
126         NO_CHANGE;
127
128         public byte getByte(){
129             return (byte)this.ordinal();
130         }
131
132         public static Action getFromByte(byte action) {
133             if (action >= 0 && action < Action.values().length) {
134                 return Action.values()[action];
135             }
136             throw new IllegalArgumentException("action byte out of range[0..3]: " + action);
137         }
138     }
139
140 }