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