Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.codec.impl; |
| 17 | |
| 18 | import org.onosproject.codec.CodecContext; |
| 19 | import org.onosproject.codec.JsonCodec; |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 20 | import org.onosproject.net.flow.criteria.Criterion; |
| 21 | import org.slf4j.Logger; |
| 22 | import org.slf4j.LoggerFactory; |
| 23 | |
| 24 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 25 | |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 26 | /** |
| 27 | * Criterion codec. |
| 28 | */ |
Ray Milkey | 540b2ce | 2015-02-04 17:50:20 -0800 | [diff] [blame] | 29 | public final class CriterionCodec extends JsonCodec<Criterion> { |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 30 | |
Ray Milkey | 9c9cde4 | 2018-01-12 14:22:06 -0800 | [diff] [blame] | 31 | private static final Logger log = |
Ray Milkey | 73ba84a | 2015-02-04 17:08:41 -0800 | [diff] [blame] | 32 | LoggerFactory.getLogger(CriterionCodec.class); |
| 33 | |
Ray Milkey | 9c9cde4 | 2018-01-12 14:22:06 -0800 | [diff] [blame] | 34 | static final String TYPE = "type"; |
| 35 | static final String ETH_TYPE = "ethType"; |
| 36 | static final String MAC = "mac"; |
Seyeon Jeong | 8f01414 | 2020-02-26 12:51:03 -0800 | [diff] [blame] | 37 | static final String MAC_MASK = "macMask"; |
Ray Milkey | 9c9cde4 | 2018-01-12 14:22:06 -0800 | [diff] [blame] | 38 | static final String PORT = "port"; |
| 39 | static final String METADATA = "metadata"; |
Ray Milkey | 73ba84a | 2015-02-04 17:08:41 -0800 | [diff] [blame] | 40 | |
Ray Milkey | 9c9cde4 | 2018-01-12 14:22:06 -0800 | [diff] [blame] | 41 | static final String VLAN_ID = "vlanId"; |
| 42 | static final String INNER_VLAN_ID = "innerVlanId"; |
| 43 | static final String INNER_PRIORITY = "innerPriority"; |
| 44 | static final String PRIORITY = "priority"; |
| 45 | static final String IP_DSCP = "ipDscp"; |
| 46 | static final String IP_ECN = "ipEcn"; |
| 47 | static final String PROTOCOL = "protocol"; |
| 48 | static final String IP = "ip"; |
| 49 | static final String TCP_PORT = "tcpPort"; |
| 50 | static final String TCP_MASK = "tcpMask"; |
| 51 | static final String UDP_PORT = "udpPort"; |
| 52 | static final String UDP_MASK = "udpMask"; |
| 53 | static final String SCTP_PORT = "sctpPort"; |
| 54 | static final String SCTP_MASK = "sctpMask"; |
| 55 | static final String ICMP_TYPE = "icmpType"; |
| 56 | static final String ICMP_CODE = "icmpCode"; |
| 57 | static final String FLOW_LABEL = "flowLabel"; |
| 58 | static final String ICMPV6_TYPE = "icmpv6Type"; |
| 59 | static final String ICMPV6_CODE = "icmpv6Code"; |
| 60 | static final String TARGET_ADDRESS = "targetAddress"; |
| 61 | static final String LABEL = "label"; |
| 62 | static final String BOS = "bos"; |
| 63 | static final String EXT_HDR_FLAGS = "exthdrFlags"; |
| 64 | static final String LAMBDA = "lambda"; |
| 65 | static final String GRID_TYPE = "gridType"; |
| 66 | static final String CHANNEL_SPACING = "channelSpacing"; |
| 67 | static final String SPACING_MULIPLIER = "spacingMultiplier"; |
| 68 | static final String SLOT_GRANULARITY = "slotGranularity"; |
| 69 | static final String OCH_SIGNAL_ID = "ochSignalId"; |
| 70 | static final String TUNNEL_ID = "tunnelId"; |
| 71 | static final String OCH_SIGNAL_TYPE = "ochSignalType"; |
| 72 | static final String ODU_SIGNAL_ID = "oduSignalId"; |
| 73 | static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber"; |
| 74 | static final String TRIBUTARY_SLOT_LEN = "tributarySlotLen"; |
| 75 | static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap"; |
| 76 | static final String ODU_SIGNAL_TYPE = "oduSignalType"; |
Frank Wang | 74ce2c1 | 2018-04-11 20:26:45 +0800 | [diff] [blame] | 77 | static final String PI_MATCHES = "matches"; |
| 78 | static final String PI_MATCH_FIELD_ID = "field"; |
| 79 | static final String PI_MATCH_TYPE = "match"; |
| 80 | static final String PI_MATCH_VALUE = "value"; |
| 81 | static final String PI_MATCH_PREFIX = "prefixLength"; |
| 82 | static final String PI_MATCH_MASK = "mask"; |
| 83 | static final String PI_MATCH_HIGH_VALUE = "highValue"; |
| 84 | static final String PI_MATCH_LOW_VALUE = "lowValue"; |
Seyeon Jeong | 8d3cad2 | 2020-02-28 01:17:34 -0800 | [diff] [blame] | 85 | static final String EXTENSION = "extension"; |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 86 | |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 87 | @Override |
| 88 | public ObjectNode encode(Criterion criterion, CodecContext context) { |
Ray Milkey | 6d7968e | 2015-07-06 14:30:02 -0700 | [diff] [blame] | 89 | EncodeCriterionCodecHelper encoder = new EncodeCriterionCodecHelper(criterion, context); |
Ray Milkey | d43fe45 | 2015-05-29 09:35:12 -0700 | [diff] [blame] | 90 | return encoder.encode(); |
| 91 | } |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 92 | |
Ray Milkey | d43fe45 | 2015-05-29 09:35:12 -0700 | [diff] [blame] | 93 | @Override |
| 94 | public Criterion decode(ObjectNode json, CodecContext context) { |
Ray Milkey | 6d7968e | 2015-07-06 14:30:02 -0700 | [diff] [blame] | 95 | DecodeCriterionCodecHelper decoder = new DecodeCriterionCodecHelper(json); |
Ray Milkey | d43fe45 | 2015-05-29 09:35:12 -0700 | [diff] [blame] | 96 | return decoder.decode(); |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 97 | } |
Ray Milkey | c95bb9d | 2015-01-06 10:28:24 -0800 | [diff] [blame] | 98 | } |