alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | ce2a03d | 2017-08-03 19:21:03 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
alshabib | b452fd7 | 2015-04-22 20:46:20 -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 | */ |
| 16 | package org.onosproject.driver.handshaker; |
| 17 | |
| 18 | import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; |
| 19 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
| 20 | import org.projectfloodlight.openflow.protocol.OFMessage; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 21 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 22 | |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Default driver to fallback on if no other driver is available. |
| 25 | */ |
Madan Jampani | 1b8ea34 | 2015-05-27 17:22:59 -0700 | [diff] [blame] | 26 | public class DefaultSwitchHandshaker extends AbstractOpenFlowSwitch { |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 27 | |
| 28 | private static final int LOWEST_PRIORITY = 0; |
| 29 | |
| 30 | @Override |
| 31 | public Boolean supportNxRole() { |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 32 | return false; |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public void startDriverHandshake() { |
| 37 | if (factory().getVersion() == OFVersion.OF_10) { |
| 38 | OFFlowAdd.Builder fmBuilder = factory().buildFlowAdd(); |
| 39 | fmBuilder.setPriority(LOWEST_PRIORITY); |
alshabib | a2df7b2a | 2015-05-06 13:57:10 -0700 | [diff] [blame] | 40 | sendHandshakeMessage(fmBuilder.build()); |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public void processDriverHandshakeMessage(OFMessage m) {} |
| 46 | |
| 47 | @Override |
| 48 | public boolean isDriverHandshakeComplete() { |
| 49 | return true; |
| 50 | } |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 51 | } |