Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [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 | */ |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 16 | package org.onosproject.openflow.controller; |
| 17 | |
Jimmy Jin | e9b7a02 | 2016-08-12 16:56:48 -0700 | [diff] [blame] | 18 | import io.netty.buffer.ByteBuf; |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 19 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 20 | import org.projectfloodlight.openflow.protocol.OFType; |
| 21 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 22 | |
| 23 | import com.google.common.hash.PrimitiveSink; |
Jimmy Jin | e9b7a02 | 2016-08-12 16:56:48 -0700 | [diff] [blame] | 24 | |
| 25 | import java.util.Arrays; |
| 26 | |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 27 | /** |
| 28 | * Used to support for the third party privacy flow rule. |
| 29 | * it implements OFMessage interface to use exist adapter API. |
| 30 | */ |
| 31 | public class ThirdPartyMessage implements OFMessage { |
| 32 | |
| 33 | private final byte[] payLoad; //privacy flow rule |
| 34 | |
| 35 | public ThirdPartyMessage(byte[] payLoad) { |
| 36 | this.payLoad = payLoad; |
| 37 | } |
| 38 | |
| 39 | public byte[] payLoad() { |
| 40 | return payLoad; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public void putTo(PrimitiveSink sink) { |
| 45 | // Do nothing here for now. |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public OFVersion getVersion() { |
| 50 | // Do nothing here for now. |
| 51 | return null; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public OFType getType() { |
| 56 | // Do nothing here for now. |
| 57 | return null; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public long getXid() { |
| 62 | // Do nothing here for now. |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | @Override |
Jimmy Jin | e9b7a02 | 2016-08-12 16:56:48 -0700 | [diff] [blame] | 67 | public void writeTo(ByteBuf byteBuf) { |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 68 | // Do nothing here for now. |
| 69 | } |
| 70 | |
| 71 | @Override |
Jimmy Jin | e9b7a02 | 2016-08-12 16:56:48 -0700 | [diff] [blame] | 72 | public boolean equalsIgnoreXid(Object obj) { |
| 73 | return Arrays.equals(payLoad, ((ThirdPartyMessage) obj).payLoad()); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public int hashCodeIgnoreXid() { |
Yuta HIGUCHI | fbd9ae9 | 2018-01-24 23:39:06 -0800 | [diff] [blame^] | 78 | return Arrays.hashCode(payLoad); |
Jimmy Jin | e9b7a02 | 2016-08-12 16:56:48 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | @Override |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 82 | public Builder createBuilder() { |
| 83 | // Do nothing here for now. |
| 84 | return null; |
| 85 | } |
| 86 | |
| 87 | } |