Committed by
Gerrit Code Review
Support more instruction type in EncodeInstructionCodecHelper
Change-Id: Ifb790f0b1e2afb0396633034d1f6d62a120a9a46
Showing
2 changed files
with
26 additions
and
10 deletions
| ... | @@ -125,25 +125,21 @@ public final class EncodeInstructionCodecHelper { | ... | @@ -125,25 +125,21 @@ public final class EncodeInstructionCodecHelper { |
| 125 | (L2ModificationInstruction.ModEtherInstruction) l2Instruction; | 125 | (L2ModificationInstruction.ModEtherInstruction) l2Instruction; |
| 126 | result.put(InstructionCodec.MAC, modEtherInstruction.mac().toString()); | 126 | result.put(InstructionCodec.MAC, modEtherInstruction.mac().toString()); |
| 127 | break; | 127 | break; |
| 128 | - | ||
| 129 | case VLAN_ID: | 128 | case VLAN_ID: |
| 130 | final L2ModificationInstruction.ModVlanIdInstruction modVlanIdInstruction = | 129 | final L2ModificationInstruction.ModVlanIdInstruction modVlanIdInstruction = |
| 131 | (L2ModificationInstruction.ModVlanIdInstruction) l2Instruction; | 130 | (L2ModificationInstruction.ModVlanIdInstruction) l2Instruction; |
| 132 | result.put(InstructionCodec.VLAN_ID, modVlanIdInstruction.vlanId().toShort()); | 131 | result.put(InstructionCodec.VLAN_ID, modVlanIdInstruction.vlanId().toShort()); |
| 133 | break; | 132 | break; |
| 134 | - | ||
| 135 | case VLAN_PCP: | 133 | case VLAN_PCP: |
| 136 | final L2ModificationInstruction.ModVlanPcpInstruction modVlanPcpInstruction = | 134 | final L2ModificationInstruction.ModVlanPcpInstruction modVlanPcpInstruction = |
| 137 | (L2ModificationInstruction.ModVlanPcpInstruction) l2Instruction; | 135 | (L2ModificationInstruction.ModVlanPcpInstruction) l2Instruction; |
| 138 | result.put(InstructionCodec.VLAN_PCP, modVlanPcpInstruction.vlanPcp()); | 136 | result.put(InstructionCodec.VLAN_PCP, modVlanPcpInstruction.vlanPcp()); |
| 139 | break; | 137 | break; |
| 140 | - | ||
| 141 | case MPLS_LABEL: | 138 | case MPLS_LABEL: |
| 142 | final L2ModificationInstruction.ModMplsLabelInstruction modMplsLabelInstruction = | 139 | final L2ModificationInstruction.ModMplsLabelInstruction modMplsLabelInstruction = |
| 143 | (L2ModificationInstruction.ModMplsLabelInstruction) l2Instruction; | 140 | (L2ModificationInstruction.ModMplsLabelInstruction) l2Instruction; |
| 144 | result.put(InstructionCodec.MPLS_LABEL, modMplsLabelInstruction.label().toInt()); | 141 | result.put(InstructionCodec.MPLS_LABEL, modMplsLabelInstruction.label().toInt()); |
| 145 | break; | 142 | break; |
| 146 | - | ||
| 147 | case MPLS_PUSH: | 143 | case MPLS_PUSH: |
| 148 | final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions = | 144 | final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions = |
| 149 | (L2ModificationInstruction.PushHeaderInstructions) l2Instruction; | 145 | (L2ModificationInstruction.PushHeaderInstructions) l2Instruction; |
| ... | @@ -151,13 +147,18 @@ public final class EncodeInstructionCodecHelper { | ... | @@ -151,13 +147,18 @@ public final class EncodeInstructionCodecHelper { |
| 151 | result.put(InstructionCodec.ETHERNET_TYPE, | 147 | result.put(InstructionCodec.ETHERNET_TYPE, |
| 152 | pushHeaderInstructions.ethernetType().toShort()); | 148 | pushHeaderInstructions.ethernetType().toShort()); |
| 153 | break; | 149 | break; |
| 154 | - | ||
| 155 | case TUNNEL_ID: | 150 | case TUNNEL_ID: |
| 156 | final L2ModificationInstruction.ModTunnelIdInstruction modTunnelIdInstruction = | 151 | final L2ModificationInstruction.ModTunnelIdInstruction modTunnelIdInstruction = |
| 157 | (L2ModificationInstruction.ModTunnelIdInstruction) l2Instruction; | 152 | (L2ModificationInstruction.ModTunnelIdInstruction) l2Instruction; |
| 158 | result.put(InstructionCodec.TUNNEL_ID, modTunnelIdInstruction.tunnelId()); | 153 | result.put(InstructionCodec.TUNNEL_ID, modTunnelIdInstruction.tunnelId()); |
| 159 | break; | 154 | break; |
| 160 | - | 155 | + case MPLS_BOS: |
| 156 | + final L2ModificationInstruction.ModMplsBosInstruction modMplsBosInstruction = | ||
| 157 | + (L2ModificationInstruction.ModMplsBosInstruction) l2Instruction; | ||
| 158 | + result.put(InstructionCodec.MPLS_BOS, modMplsBosInstruction.mplsBos()); | ||
| 159 | + case MPLS_POP: | ||
| 160 | + case DEC_MPLS_TTL: | ||
| 161 | + break; | ||
| 161 | default: | 162 | default: |
| 162 | log.info("Cannot convert L2 subtype of {}", l2Instruction.subtype()); | 163 | log.info("Cannot convert L2 subtype of {}", l2Instruction.subtype()); |
| 163 | break; | 164 | break; |
| ... | @@ -181,14 +182,16 @@ public final class EncodeInstructionCodecHelper { | ... | @@ -181,14 +182,16 @@ public final class EncodeInstructionCodecHelper { |
| 181 | (L3ModificationInstruction.ModIPInstruction) l3Instruction; | 182 | (L3ModificationInstruction.ModIPInstruction) l3Instruction; |
| 182 | result.put(InstructionCodec.IP, modIPInstruction.ip().toString()); | 183 | result.put(InstructionCodec.IP, modIPInstruction.ip().toString()); |
| 183 | break; | 184 | break; |
| 184 | - | ||
| 185 | case IPV6_FLABEL: | 185 | case IPV6_FLABEL: |
| 186 | final L3ModificationInstruction.ModIPv6FlowLabelInstruction | 186 | final L3ModificationInstruction.ModIPv6FlowLabelInstruction |
| 187 | modFlowLabelInstruction = | 187 | modFlowLabelInstruction = |
| 188 | (L3ModificationInstruction.ModIPv6FlowLabelInstruction) l3Instruction; | 188 | (L3ModificationInstruction.ModIPv6FlowLabelInstruction) l3Instruction; |
| 189 | result.put(InstructionCodec.FLOW_LABEL, modFlowLabelInstruction.flowLabel()); | 189 | result.put(InstructionCodec.FLOW_LABEL, modFlowLabelInstruction.flowLabel()); |
| 190 | break; | 190 | break; |
| 191 | - | 191 | + case TTL_IN: |
| 192 | + case TTL_OUT: | ||
| 193 | + case DEC_TTL: | ||
| 194 | + break; | ||
| 192 | default: | 195 | default: |
| 193 | log.info("Cannot convert L3 subtype of {}", l3Instruction.subtype()); | 196 | log.info("Cannot convert L3 subtype of {}", l3Instruction.subtype()); |
| 194 | break; | 197 | break; |
| ... | @@ -210,14 +213,12 @@ public final class EncodeInstructionCodecHelper { | ... | @@ -210,14 +213,12 @@ public final class EncodeInstructionCodecHelper { |
| 210 | (L4ModificationInstruction.ModTransportPortInstruction) l4Instruction; | 213 | (L4ModificationInstruction.ModTransportPortInstruction) l4Instruction; |
| 211 | result.put(InstructionCodec.TCP_PORT, modTcpPortInstruction.port().toInt()); | 214 | result.put(InstructionCodec.TCP_PORT, modTcpPortInstruction.port().toInt()); |
| 212 | break; | 215 | break; |
| 213 | - | ||
| 214 | case UDP_DST: | 216 | case UDP_DST: |
| 215 | case UDP_SRC: | 217 | case UDP_SRC: |
| 216 | final L4ModificationInstruction.ModTransportPortInstruction modUdpPortInstruction = | 218 | final L4ModificationInstruction.ModTransportPortInstruction modUdpPortInstruction = |
| 217 | (L4ModificationInstruction.ModTransportPortInstruction) l4Instruction; | 219 | (L4ModificationInstruction.ModTransportPortInstruction) l4Instruction; |
| 218 | result.put(InstructionCodec.UDP_PORT, modUdpPortInstruction.port().toInt()); | 220 | result.put(InstructionCodec.UDP_PORT, modUdpPortInstruction.port().toInt()); |
| 219 | break; | 221 | break; |
| 220 | - | ||
| 221 | default: | 222 | default: |
| 222 | log.info("Cannot convert L4 subtype of {}", l4Instruction.subtype()); | 223 | log.info("Cannot convert L4 subtype of {}", l4Instruction.subtype()); |
| 223 | break; | 224 | break; |
| ... | @@ -225,6 +226,16 @@ public final class EncodeInstructionCodecHelper { | ... | @@ -225,6 +226,16 @@ public final class EncodeInstructionCodecHelper { |
| 225 | } | 226 | } |
| 226 | 227 | ||
| 227 | /** | 228 | /** |
| 229 | + * Encode a extension instruction. | ||
| 230 | + * | ||
| 231 | + * @param result json node that the instruction attributes are added to | ||
| 232 | + */ | ||
| 233 | + private void encodeExtension(ObjectNode result) { | ||
| 234 | + // TODO Support extension in REST API | ||
| 235 | + log.info("Cannot convert instruction type of EXTENSION"); | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + /** | ||
| 228 | * Encodes the given instruction into JSON. | 239 | * Encodes the given instruction into JSON. |
| 229 | * | 240 | * |
| 230 | * @return JSON object node representing the instruction | 241 | * @return JSON object node representing the instruction |
| ... | @@ -283,6 +294,10 @@ public final class EncodeInstructionCodecHelper { | ... | @@ -283,6 +294,10 @@ public final class EncodeInstructionCodecHelper { |
| 283 | encodeL4(result); | 294 | encodeL4(result); |
| 284 | break; | 295 | break; |
| 285 | 296 | ||
| 297 | + case EXTENSION: | ||
| 298 | + encodeExtension(result); | ||
| 299 | + break; | ||
| 300 | + | ||
| 286 | default: | 301 | default: |
| 287 | log.info("Cannot convert instruction type of {}", instruction.type()); | 302 | log.info("Cannot convert instruction type of {}", instruction.type()); |
| 288 | break; | 303 | break; | ... | ... |
| ... | @@ -38,6 +38,7 @@ public final class InstructionCodec extends JsonCodec<Instruction> { | ... | @@ -38,6 +38,7 @@ public final class InstructionCodec extends JsonCodec<Instruction> { |
| 38 | protected static final String VLAN_ID = "vlanId"; | 38 | protected static final String VLAN_ID = "vlanId"; |
| 39 | protected static final String VLAN_PCP = "vlanPcp"; | 39 | protected static final String VLAN_PCP = "vlanPcp"; |
| 40 | protected static final String MPLS_LABEL = "label"; | 40 | protected static final String MPLS_LABEL = "label"; |
| 41 | + protected static final String MPLS_BOS = "bos"; | ||
| 41 | protected static final String IP = "ip"; | 42 | protected static final String IP = "ip"; |
| 42 | protected static final String FLOW_LABEL = "flowLabel"; | 43 | protected static final String FLOW_LABEL = "flowLabel"; |
| 43 | protected static final String LAMBDA = "lambda"; | 44 | protected static final String LAMBDA = "lambda"; | ... | ... |
-
Please register or login to post a comment