blob: a4dedb911d4fab24e09ebc73ddaf530c4d23e6f6 [file] [log] [blame]
sdn6b37e222018-05-10 17:31:31 +09001/*
2 * Copyright 2018-present Open Networking Foundation
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.driver.handshaker;
17
18import org.onosproject.openflow.controller.RoleState;
19import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
20import org.onosproject.openflow.controller.driver.SwitchStateException;
21import org.projectfloodlight.openflow.protocol.OFFlowAdd;
22import org.projectfloodlight.openflow.protocol.OFMessage;
23import org.projectfloodlight.openflow.protocol.OFVersion;
24import org.slf4j.Logger;
25import org.slf4j.LoggerFactory;
26
27public class JuniperSwitchHandshaker extends AbstractOpenFlowSwitch {
28
29 private static final int LOWEST_PRIORITY = 0;
30 protected final Logger log = LoggerFactory.getLogger(getClass());
31
32 @Override
33 public Boolean supportNxRole() {
34 return false;
35 }
36
37
38 @Override
39 public void startDriverHandshake() {
40 if (factory().getVersion() == OFVersion.OF_10) {
41 OFFlowAdd.Builder fmBuilder = factory().buildFlowAdd();
42 fmBuilder.setPriority(LOWEST_PRIORITY);
43 sendHandshakeMessage(fmBuilder.build());
44 }
45 log.debug("Juniper Switch Operating OF version {}", factory().getVersion());
46 }
47
48 @Override
49 public boolean isDriverHandshakeComplete() {
50 return true;
51 }
52
53
54 @Override
55 public void processDriverHandshakeMessage(OFMessage m) {
56 log.debug("Juniper Switch: processDriverHandshakeMessage for sw {}", getStringId());
57 }
58
59
60 @Override
61 public void setRole(RoleState role) {
62 // Juniper switch dosen't support OpenFlow Role Request/Reply message
63 log.warn("Juniper switch dosen't support OpenFlow Role Request/Reply message");
64 if (this.role == null) {
65 this.role = role;
66 }
67 }
68
69
70 @Override
71 public void handleRole(OFMessage m) throws SwitchStateException {
72 // Juniper switch dosen't support OpenFlow Role Request/Reply message
73 log.warn("Juniper switch dosen't support OpenFlow Role Request/Reply message");
74 }
75
76}