blob: 98cd3bd6a93170824f25157d7516eb01394d1b50 [file] [log] [blame]
Ray Milkeyc95bb9d2015-01-06 10:28:24 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.codec.impl;
17
18import org.onosproject.codec.CodecContext;
19import org.onosproject.codec.JsonCodec;
Ray Milkeyc95bb9d2015-01-06 10:28:24 -080020import org.onosproject.net.flow.criteria.Criterion;
21import org.slf4j.Logger;
22import org.slf4j.LoggerFactory;
23
24import com.fasterxml.jackson.databind.node.ObjectNode;
25
Ray Milkeyc95bb9d2015-01-06 10:28:24 -080026/**
27 * Criterion codec.
28 */
Ray Milkey540b2ce2015-02-04 17:50:20 -080029public final class CriterionCodec extends JsonCodec<Criterion> {
Ray Milkeyc95bb9d2015-01-06 10:28:24 -080030
Ray Milkey73ba84a2015-02-04 17:08:41 -080031 protected static final Logger log =
32 LoggerFactory.getLogger(CriterionCodec.class);
33
Ray Milkeyd43fe452015-05-29 09:35:12 -070034 protected static final String TYPE = "type";
35 protected static final String ETH_TYPE = "ethType";
36 protected static final String MAC = "mac";
37 protected static final String PORT = "port";
38 protected static final String METADATA = "metadata";
Ray Milkey73ba84a2015-02-04 17:08:41 -080039
Ray Milkeyd43fe452015-05-29 09:35:12 -070040 protected static final String VLAN_ID = "vlanId";
41 protected static final String PRIORITY = "priority";
42 protected static final String IP_DSCP = "ipDscp";
43 protected static final String IP_ECN = "ipEcn";
44 protected static final String PROTOCOL = "protocol";
45 protected static final String IP = "ip";
46 protected static final String TCP_PORT = "tcpPort";
47 protected static final String UDP_PORT = "udpPort";
48 protected static final String SCTP_PORT = "sctpPort";
49 protected static final String ICMP_TYPE = "icmpType";
50 protected static final String ICMP_CODE = "icmpCode";
51 protected static final String FLOW_LABEL = "flowLabel";
52 protected static final String ICMPV6_TYPE = "icmpv6Type";
53 protected static final String ICMPV6_CODE = "icmpv6Code";
54 protected static final String TARGET_ADDRESS = "targetAddress";
55 protected static final String LABEL = "label";
56 protected static final String EXT_HDR_FLAGS = "exthdrFlags";
57 protected static final String LAMBDA = "lambda";
58 protected static final String GRID_TYPE = "gridType";
59 protected static final String CHANNEL_SPACING = "channelSpacing";
60 protected static final String SPACING_MULIPLIER = "spacingMultiplier";
61 protected static final String SLOT_GRANULARITY = "slotGranularity";
62 protected static final String OCH_SIGNAL_ID = "ochSignalId";
alshabiba3a476d2015-04-10 14:35:38 -070063
Ray Milkeyc95bb9d2015-01-06 10:28:24 -080064 @Override
65 public ObjectNode encode(Criterion criterion, CodecContext context) {
Ray Milkeyd43fe452015-05-29 09:35:12 -070066 EncodeCriterionCodec encoder = new EncodeCriterionCodec(criterion, context);
67 return encoder.encode();
68 }
Ray Milkeyc95bb9d2015-01-06 10:28:24 -080069
Ray Milkeyd43fe452015-05-29 09:35:12 -070070 @Override
71 public Criterion decode(ObjectNode json, CodecContext context) {
72 DecodeCriterionCodec decoder = new DecodeCriterionCodec(json);
73 return decoder.decode();
Ray Milkeyc95bb9d2015-01-06 10:28:24 -080074 }
alshabiba3a476d2015-04-10 14:35:38 -070075
76
Ray Milkeyc95bb9d2015-01-06 10:28:24 -080077}