Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -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 | import structlog |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 17 | from twisted.internet.defer import inlineCallbacks, returnValue |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 18 | |
| 19 | import loxi.of13 as ofp |
| 20 | from converter import to_loxi, pb2dict, to_grpc |
| 21 | |
| 22 | log = structlog.get_logger() |
| 23 | |
| 24 | |
| 25 | class OpenFlowProtocolError(Exception): pass |
| 26 | |
| 27 | |
| 28 | class OpenFlowProtocolHandler(object): |
| 29 | |
sathishg | bbb9099 | 2017-06-23 09:52:29 +0530 | [diff] [blame] | 30 | ofp_version = [4] # OFAgent supported versions |
| 31 | |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 32 | def __init__(self, datapath_id, device_id, agent, cxn, rpc): |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 33 | """ |
| 34 | The upper half of the OpenFlow protocol, focusing on message |
| 35 | exchanges. |
| 36 | :param agent: Reference to the Agent() instance, can be used to |
| 37 | indicate critical errors to break the connection. |
| 38 | :param cxn: The lower level message serdes part of the OF protocol. |
| 39 | :param rpc: The application level stub on which RPC calls |
| 40 | are made as result of processing incoming OpenFlow request messages. |
| 41 | """ |
| 42 | self.datapath_id = datapath_id |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 43 | self.device_id = device_id |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 44 | self.agent = agent |
| 45 | self.cxn = cxn |
| 46 | self.rpc = rpc |
sgovinda | cc73678 | 2017-05-02 20:06:37 +0530 | [diff] [blame] | 47 | self.role = None |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 48 | |
| 49 | @inlineCallbacks |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 50 | def start(self): |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 51 | """A new call is made after a fresh reconnect""" |
| 52 | |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 53 | log.debug('starting') |
| 54 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 55 | try: |
sathishg | bbb9099 | 2017-06-23 09:52:29 +0530 | [diff] [blame] | 56 | support = False |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 57 | # send initial hello message |
sathishg | bbb9099 | 2017-06-23 09:52:29 +0530 | [diff] [blame] | 58 | self.cxn.send(ofp.message.hello(elements=[ofp.common.hello_elem_versionbitmap( |
| 59 | bitmaps = [ofp.common.hello_elem_bitmap(self.ofp_version)])])) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 60 | # expect to receive a hello message |
| 61 | msg = yield self.cxn.recv_class(ofp.message.hello) |
sathishg | bbb9099 | 2017-06-23 09:52:29 +0530 | [diff] [blame] | 62 | # supports only ofp_versions till 31 and single bitmap. |
| 63 | if msg: |
| 64 | support = ofp.util.verify_version_support(msg,self.ofp_version) |
| 65 | if not support: |
| 66 | self.cxn.send(ofp.message.hello_failed_error_msg( |
| 67 | xid=msg.xid, code=ofp.OFPHFC_INCOMPATIBLE, |
| 68 | data='i support only 1.3')) |
| 69 | log.error('peer-do-not-support-OpenFlow-version',self.ofp_version) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 70 | |
sathishg | bbb9099 | 2017-06-23 09:52:29 +0530 | [diff] [blame] | 71 | while support: |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 72 | req = yield self.cxn.recv_any() |
| 73 | handler = self.main_handlers.get(req.type, None) |
| 74 | if handler: |
| 75 | handler(self, req) |
| 76 | else: |
| 77 | log.error('cannot-handle', |
| 78 | request=req, xid=req.xid, type=req.type) |
| 79 | |
| 80 | except Exception, e: |
| 81 | log.exception('exception', e=e) |
| 82 | |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 83 | log.info('started') |
| 84 | returnValue(self) |
| 85 | |
| 86 | def stop(self): |
| 87 | log.debug('stopping') |
| 88 | pass # nothing to do yet |
| 89 | log.info('stopped') |
| 90 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 91 | def handle_echo_request(self, req): |
| 92 | self.cxn.send(ofp.message.echo_reply(xid=req.xid)) |
| 93 | |
| 94 | @inlineCallbacks |
| 95 | def handle_feature_request(self, req): |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 96 | device_info = yield self.rpc.get_device_info(self.device_id) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 97 | kw = pb2dict(device_info.switch_features) |
| 98 | self.cxn.send(ofp.message.features_reply( |
| 99 | xid=req.xid, |
| 100 | datapath_id=self.datapath_id, |
| 101 | **kw)) |
| 102 | |
| 103 | def handle_stats_request(self, req): |
| 104 | handler = self.stats_handlers.get(req.stats_type, None) |
| 105 | if handler: |
| 106 | handler(self, req) |
| 107 | else: |
| 108 | raise OpenFlowProtocolError( |
| 109 | 'Cannot handle stats request type "{}"'.format(req.stats_type)) |
| 110 | |
| 111 | def handle_barrier_request(self, req): |
alshabib | c3fb494 | 2017-01-26 15:34:24 -0800 | [diff] [blame] | 112 | # not really doing barrier yet, but we respond |
| 113 | # see https://jira.opencord.org/browse/CORD-823 |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 114 | self.cxn.send(ofp.message.barrier_reply(xid=req.xid)) |
| 115 | |
| 116 | def handle_experimenter_request(self, req): |
| 117 | raise NotImplementedError() |
| 118 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 119 | def handle_flow_mod_request(self, req): |
sgovinda | cc73678 | 2017-05-02 20:06:37 +0530 | [diff] [blame] | 120 | if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL: |
| 121 | try: |
| 122 | grpc_req = to_grpc(req) |
| 123 | except Exception, e: |
| 124 | log.exception('failed-to-convert', e=e) |
| 125 | else: |
| 126 | return self.rpc.update_flow_table(self.device_id, grpc_req) |
| 127 | |
| 128 | elif self.role == ofp.OFPCR_ROLE_SLAVE: |
| 129 | self.cxn.send(ofp.message.bad_request_error_msg(code=ofp.OFPBRC_IS_SLAVE)) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 130 | |
Koray Kokten | 8592a23 | 2018-08-27 07:41:14 +0000 | [diff] [blame] | 131 | |
| 132 | def handle_meter_mod_request(self, req): |
| 133 | if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL: |
| 134 | try: |
| 135 | grpc_req = to_grpc(req) |
| 136 | except Exception, e: |
| 137 | log.exception('failed-to-convert-meter-mod-request', e=e) |
| 138 | else: |
| 139 | return self.rpc.update_meter_mod_table(self.device_id, grpc_req) |
| 140 | |
| 141 | elif self.role == ofp.OFPCR_ROLE_SLAVE: |
| 142 | self.cxn.send(ofp.message.bad_request_error_msg(code=ofp.OFPBRC_IS_SLAVE)) |
| 143 | |
| 144 | @inlineCallbacks |
| 145 | def handle_meter_stats_request(self, req): |
| 146 | try: |
| 147 | meter_stats = yield self.rpc.get_meter_stats(self.device_id) |
| 148 | meter_stats = [to_loxi(m) for m in meter_stats] |
| 149 | of_message = ofp.message.meter_stats_reply(xid=req.xid, entries=meter_stats) |
| 150 | self.cxn.send(of_message) |
| 151 | except Exception, e: |
| 152 | log.exception("failed-meter-stats-request", req=req, e=e) |
| 153 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 154 | def handle_get_async_request(self, req): |
| 155 | raise NotImplementedError() |
| 156 | |
| 157 | def handle_get_config_request(self, req): |
| 158 | self.cxn.send(ofp.message.get_config_reply( |
| 159 | xid=req.xid, |
| 160 | miss_send_len=ofp.OFPCML_NO_BUFFER |
| 161 | )) |
| 162 | |
Zsolt Haraszti | 8a77438 | 2016-10-24 18:25:54 -0700 | [diff] [blame] | 163 | @inlineCallbacks |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 164 | def handle_group_mod_request(self, req): |
sgovinda | cc73678 | 2017-05-02 20:06:37 +0530 | [diff] [blame] | 165 | if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL: |
| 166 | yield self.rpc.update_group_table(self.device_id, to_grpc(req)) |
| 167 | elif self.role == ofp.OFPCR_ROLE_SLAVE: |
| 168 | self.cxn.send(ofp.message.bad_request_error_msg(code=ofp.OFPBRC_IS_SLAVE)) |
| 169 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 170 | def handle_role_request(self, req): |
sgovinda | cc73678 | 2017-05-02 20:06:37 +0530 | [diff] [blame] | 171 | if req.role == ofp.OFPCR_ROLE_MASTER or req.role == ofp.OFPCR_ROLE_SLAVE: |
sathishg | 00433e5 | 2017-05-23 16:07:41 +0530 | [diff] [blame] | 172 | if self.agent.generation_is_defined and ( |
| 173 | ((req.generation_id - self.agent.cached_generation_id) & 0xffffffffffffffff) if abs( |
| 174 | req.generation_id - self.agent.cached_generation_id) > 0x7fffffffffffffff else ( |
| 175 | req.generation_id - self.agent.cached_generation_id)) < 0: |
| 176 | self.cxn.send(ofp.message.bad_request_error_msg(code=ofp.OFPRRFC_STALE)) |
| 177 | else: |
| 178 | self.agent.generation_is_defined = True |
| 179 | self.agent.cached_generation_id = req.generation_id |
| 180 | self.role = req.role |
| 181 | self.cxn.send(ofp.message.role_reply( |
| 182 | xid=req.xid, role=req.role, generation_id=req.generation_id)) |
sgovinda | cc73678 | 2017-05-02 20:06:37 +0530 | [diff] [blame] | 183 | elif req.role == ofp.OFPCR_ROLE_EQUAL: |
sathishg | 00433e5 | 2017-05-23 16:07:41 +0530 | [diff] [blame] | 184 | self.role = req.role |
| 185 | self.cxn.send(ofp.message.role_reply( |
| 186 | xid=req.xid, role=req.role)) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 187 | |
| 188 | def handle_packet_out_request(self, req): |
sgovinda | cc73678 | 2017-05-02 20:06:37 +0530 | [diff] [blame] | 189 | if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL: |
| 190 | self.rpc.send_packet_out(self.device_id, to_grpc(req)) |
| 191 | |
| 192 | elif self.role == ofp.OFPCR_ROLE_SLAVE: |
| 193 | self.cxn.send(ofp.message.bad_request_error_msg(code=ofp.OFPBRC_IS_SLAVE)) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 194 | |
| 195 | def handle_set_config_request(self, req): |
alshabib | c3fb494 | 2017-01-26 15:34:24 -0800 | [diff] [blame] | 196 | # Handle set config appropriately |
| 197 | # https://jira.opencord.org/browse/CORD-826 |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 198 | pass |
| 199 | |
Jonathan Hart | 8d21c32 | 2018-04-17 07:42:02 -0700 | [diff] [blame] | 200 | @inlineCallbacks |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 201 | def handle_port_mod_request(self, req): |
Jonathan Hart | 8d21c32 | 2018-04-17 07:42:02 -0700 | [diff] [blame] | 202 | if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL: |
| 203 | port = yield self.rpc.get_port(self.device_id, str(req.port_no)) |
| 204 | |
| 205 | if port.ofp_port.config & ofp.OFPPC_PORT_DOWN != \ |
| 206 | req.config & ofp.OFPPC_PORT_DOWN: |
| 207 | if req.config & ofp.OFPPC_PORT_DOWN: |
| 208 | self.rpc.disable_port(self.device_id, port.id) |
| 209 | else: |
| 210 | self.rpc.enable_port(self.device_id, port.id) |
| 211 | |
| 212 | elif self.role == ofp.OFPCR_ROLE_SLAVE: |
| 213 | self.cxn.send(ofp.message.bad_request_error_msg(code=ofp.OFPBRC_IS_SLAVE)) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 214 | |
| 215 | def handle_table_mod_request(self, req): |
| 216 | raise NotImplementedError() |
| 217 | |
| 218 | def handle_queue_get_config_request(self, req): |
| 219 | raise NotImplementedError() |
| 220 | |
| 221 | def handle_set_async_request(self, req): |
| 222 | raise NotImplementedError() |
| 223 | |
| 224 | def handle_aggregate_request(self, req): |
| 225 | raise NotImplementedError |
| 226 | |
| 227 | @inlineCallbacks |
| 228 | def handle_device_description_request(self, req): |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 229 | device_info = yield self.rpc.get_device_info(self.device_id) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 230 | kw = pb2dict(device_info.desc) |
| 231 | self.cxn.send(ofp.message.desc_stats_reply(xid=req.xid, **kw)) |
| 232 | |
| 233 | def handle_experimenter_stats_request(self, req): |
| 234 | raise NotImplementedError() |
| 235 | |
| 236 | @inlineCallbacks |
| 237 | def handle_flow_stats_request(self, req): |
Zsolt Haraszti | 3578a1c | 2017-01-10 15:29:02 -0800 | [diff] [blame] | 238 | try: |
| 239 | flow_stats = yield self.rpc.list_flows(self.device_id) |
| 240 | self.cxn.send(ofp.message.flow_stats_reply( |
| 241 | xid=req.xid, entries=[to_loxi(f) for f in flow_stats])) |
| 242 | except Exception, e: |
| 243 | log.exception('failed-flow-stats-request', req=req) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 244 | |
Zsolt Haraszti | 8a77438 | 2016-10-24 18:25:54 -0700 | [diff] [blame] | 245 | @inlineCallbacks |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 246 | def handle_group_stats_request(self, req): |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 247 | group_stats = yield self.rpc.list_groups(self.device_id) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 248 | self.cxn.send(ofp.message.group_stats_reply( |
alshabib | f4fb268 | 2017-01-12 00:32:56 -0600 | [diff] [blame] | 249 | xid=req.xid, entries=[to_loxi(g.stats) for g in group_stats])) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 250 | |
alshabib | f4fb268 | 2017-01-12 00:32:56 -0600 | [diff] [blame] | 251 | @inlineCallbacks |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 252 | def handle_group_descriptor_request(self, req): |
alshabib | f4fb268 | 2017-01-12 00:32:56 -0600 | [diff] [blame] | 253 | group_stats = yield self.rpc.list_groups(self.device_id) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 254 | self.cxn.send(ofp.message.group_desc_stats_reply( |
alshabib | f4fb268 | 2017-01-12 00:32:56 -0600 | [diff] [blame] | 255 | xid=req.xid, entries=[to_loxi(g.desc) for g in group_stats])) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 256 | |
| 257 | def handle_group_features_request(self, req): |
| 258 | raise NotImplementedError() |
| 259 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 260 | def handle_meter_config_request(self, req): |
| 261 | raise NotImplementedError() |
| 262 | |
| 263 | def handle_meter_features_request(self, req): |
alshabib | 81824e3 | 2016-12-21 21:43:45 -0800 | [diff] [blame] | 264 | self.cxn.send(ofp.message.bad_request_error_msg()) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 265 | |
Nicolas Palpacuer | fd7b8b1 | 2018-06-15 13:58:06 -0400 | [diff] [blame] | 266 | @inlineCallbacks |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 267 | def handle_port_stats_request(self, req): |
Nicolas Palpacuer | fd7b8b1 | 2018-06-15 13:58:06 -0400 | [diff] [blame] | 268 | try: |
| 269 | ports = yield self.rpc.list_ports(self.device_id) |
| 270 | port_stats = [to_loxi(p.ofp_port_stats) for p in ports] |
| 271 | of_message = ofp.message.port_stats_reply( |
| 272 | xid=req.xid,entries=port_stats) |
| 273 | self.cxn.send(of_message) |
| 274 | except: |
| 275 | log.exception('failed-port_stats-request', req=req) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 276 | |
| 277 | @inlineCallbacks |
| 278 | def handle_port_desc_request(self, req): |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 279 | port_list = yield self.rpc.get_port_list(self.device_id) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 280 | self.cxn.send(ofp.message.port_desc_stats_reply( |
| 281 | xid=req.xid, |
| 282 | #flags=None, |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 283 | entries=[to_loxi(port.ofp_port) for port in port_list] |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 284 | )) |
| 285 | |
| 286 | def handle_queue_stats_request(self, req): |
| 287 | raise NotImplementedError() |
| 288 | |
| 289 | def handle_table_stats_request(self, req): |
alshabib | c3fb494 | 2017-01-26 15:34:24 -0800 | [diff] [blame] | 290 | table_stats = [] # see https://jira.opencord.org/browse/CORD-825 |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 291 | self.cxn.send(ofp.message.table_stats_reply( |
| 292 | xid=req.xid, entries=table_stats)) |
| 293 | |
| 294 | def handle_table_features_request(self, req): |
| 295 | raise NotImplementedError() |
| 296 | |
| 297 | stats_handlers = { |
| 298 | ofp.OFPST_AGGREGATE: handle_aggregate_request, |
| 299 | ofp.OFPST_DESC: handle_device_description_request, |
| 300 | ofp.OFPST_EXPERIMENTER: handle_experimenter_stats_request, |
| 301 | ofp.OFPST_FLOW: handle_flow_stats_request, |
| 302 | ofp.OFPST_GROUP: handle_group_stats_request, |
| 303 | ofp.OFPST_GROUP_DESC: handle_group_descriptor_request, |
| 304 | ofp.OFPST_GROUP_FEATURES: handle_group_features_request, |
| 305 | ofp.OFPST_METER: handle_meter_stats_request, |
| 306 | ofp.OFPST_METER_CONFIG: handle_meter_config_request, |
| 307 | ofp.OFPST_METER_FEATURES: handle_meter_features_request, |
| 308 | ofp.OFPST_PORT: handle_port_stats_request, |
| 309 | ofp.OFPST_PORT_DESC: handle_port_desc_request, |
| 310 | ofp.OFPST_QUEUE: handle_queue_stats_request, |
| 311 | ofp.OFPST_TABLE: handle_table_stats_request, |
| 312 | ofp.OFPST_TABLE_FEATURES: handle_table_features_request |
| 313 | } |
| 314 | |
| 315 | main_handlers = { |
| 316 | ofp.OFPT_BARRIER_REQUEST: handle_barrier_request, |
| 317 | ofp.OFPT_ECHO_REQUEST: handle_echo_request, |
| 318 | ofp.OFPT_FEATURES_REQUEST: handle_feature_request, |
| 319 | ofp.OFPT_EXPERIMENTER: handle_experimenter_request, |
| 320 | ofp.OFPT_FLOW_MOD: handle_flow_mod_request, |
| 321 | ofp.OFPT_GET_ASYNC_REQUEST: handle_get_async_request, |
| 322 | ofp.OFPT_GET_CONFIG_REQUEST: handle_get_config_request, |
| 323 | ofp.OFPT_GROUP_MOD: handle_group_mod_request, |
| 324 | ofp.OFPT_METER_MOD: handle_meter_mod_request, |
| 325 | ofp.OFPT_PACKET_OUT: handle_packet_out_request, |
| 326 | ofp.OFPT_PORT_MOD: handle_port_mod_request, |
| 327 | ofp.OFPT_QUEUE_GET_CONFIG_REQUEST: handle_queue_get_config_request, |
| 328 | ofp.OFPT_ROLE_REQUEST: handle_role_request, |
| 329 | ofp.OFPT_SET_ASYNC: handle_set_async_request, |
| 330 | ofp.OFPT_SET_CONFIG: handle_set_config_request, |
| 331 | ofp.OFPT_STATS_REQUEST: handle_stats_request, |
| 332 | ofp.OFPT_TABLE_MOD: handle_table_mod_request, |
| 333 | } |
| 334 | |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 335 | def forward_packet_in(self, ofp_packet_in): |
sgovinda | cc73678 | 2017-05-02 20:06:37 +0530 | [diff] [blame] | 336 | if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL: |
| 337 | log.info('sending-packet-in', ofp_packet_in=ofp_packet_in) |
| 338 | self.cxn.send(to_loxi(ofp_packet_in)) |
Zsolt Haraszti | 217a12e | 2016-12-19 16:37:55 -0800 | [diff] [blame] | 339 | |
| 340 | def forward_port_status(self, ofp_port_status): |
| 341 | self.cxn.send(to_loxi(ofp_port_status)) |