예제 #1
0
            def _deleteicmpflows(subnetinfo):
                    ipaddress,macaddress,_,networkid = subnetinfo

                    return [
                        ofdef.ofp_flow_mod(
                            cookie = 0x2,
                            cookie_mask = 0xffffffffffffffff,
                            table_id = l3input,
                            command = ofdef.OFPFC_DELETE,
                            priority = ofdef.OFP_DEFAULT_PRIORITY + 1,
                            buffer_id = ofdef.OFP_NO_BUFFER,
                            out_port = ofdef.OFPP_ANY,
                            out_group = ofdef.OFPG_ANY,
                            match = ofdef.ofp_match_oxm(
                                oxm_fields = [
                                    ofdef.create_oxm(ofdef.NXM_NX_REG4,networkid),
                                    ofdef.create_oxm(ofdef.OXM_OF_ETH_DST,mac_addr_bytes(macaddress)),
                                    ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,ofdef.ETHERTYPE_IP),
                                    ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,ip4_addr_bytes(ipaddress)),
                                    ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,ofdef.IPPROTO_ICMP),
                                    ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_TYPE,8),
                                    ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_CODE,0)
                                ]
                            )
                        )
                    ]
예제 #2
0
 def _createicmpflows(ipaddress, macaddress, networkid):
     return [
         ofdef.ofp_flow_mod(
             cookie=0x2,
             cookie_mask=0xffffffffffffffff,
             table_id=l3input,
             command=ofdef.OFPFC_ADD,
             # icmp to router matcher same as ip forward to router
             # so priority + 1
             priority=ofdef.OFP_DEFAULT_PRIORITY + 1,
             buffer_id=ofdef.OFP_NO_BUFFER,
             out_port=ofdef.OFPP_ANY,
             out_group=ofdef.OFPG_ANY,
             match=ofdef.ofp_match_oxm(oxm_fields=[
                 match_network(networkid),
                 ofdef.create_oxm(ofdef.OXM_OF_ETH_DST,
                                  mac_addr_bytes(macaddress)),
                 ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,
                                  ofdef.ETHERTYPE_IP),
                 ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,
                                  ip4_addr_bytes(ipaddress)),
                 ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,
                                  ofdef.IPPROTO_ICMP),
                 ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_TYPE, 8),
                 ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_CODE, 0)
             ]),
             instructions=[
                 ofdef.ofp_instruction_actions(actions=[
                     ofdef.ofp_action_output(
                         port=ofdef.OFPP_CONTROLLER,
                         max_len=ofdef.OFPCML_NO_BUFFER)
                 ])
             ])
     ]
예제 #3
0
 def _deleteicmpflows(ipaddress, macaddress, networkid):
     return [
         ofdef.ofp_flow_mod(
             cookie=0x2,
             cookie_mask=0xffffffffffffffff,
             table_id=l3input,
             command=ofdef.OFPFC_DELETE,
             priority=ofdef.OFP_DEFAULT_PRIORITY + 1,
             buffer_id=ofdef.OFP_NO_BUFFER,
             out_port=ofdef.OFPP_ANY,
             out_group=ofdef.OFPG_ANY,
             match=ofdef.ofp_match_oxm(oxm_fields=[
                 ofdef.create_oxm(ofdef.NXM_NX_REG4, networkid),
                 ofdef.create_oxm(ofdef.OXM_OF_ETH_DST,
                                  mac_addr_bytes(macaddress)),
                 ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,
                                  ofdef.ETHERTYPE_IP),
                 ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,
                                  ip4_addr_bytes(ipaddress)),
                 ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,
                                  ofdef.IPPROTO_ICMP),
                 ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_TYPE, 8),
                 ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_CODE, 0)
             ]))
     ]
예제 #4
0
 def _createicmpflows(subnetinfo):
     ipaddress, macaddress, _, networkid = subnetinfo
     return [
         ofdef.ofp_flow_mod(
             cookie=0x2,
             cookie_mask=0xffffffffffffffff,
             table_id=l3input,
             command=ofdef.OFPFC_ADD,
             # icmp to router matcher same as ip forward to router
             # so priority + 1
             priority=ofdef.OFP_DEFAULT_PRIORITY + 1,
             buffer_id=ofdef.OFP_NO_BUFFER,
             out_port=ofdef.OFPP_ANY,
             out_group=ofdef.OFPG_ANY,
             match=ofdef.ofp_match_oxm(oxm_fields=[
                 match_network(networkid),
                 ofdef.create_oxm(ofdef.OXM_OF_ETH_DST,
                                  mac_addr_bytes(macaddress)),
                 ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,
                                  ofdef.ETHERTYPE_IP),
                 ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,
                                  ip4_addr_bytes(ipaddress)),
                 ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,
                                  ofdef.IPPROTO_ICMP),
                 ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_TYPE, 8),
                 ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_CODE, 0)
             ]),
             instructions=[
                 ofdef.ofp_instruction_actions(actions=[
                     ofdef.nx_action_reg_move(
                         n_bits=48,
                         src=ofdef.OXM_OF_ETH_SRC,
                         dst=ofdef.OXM_OF_ETH_DST),
                     ofdef.ofp_action_set_field(
                         field=ofdef.create_oxm(
                             ofdef.OXM_OF_ETH_SRC,
                             ofdef.mac_addr(macaddress))),
                     ofdef.nx_action_reg_move(
                         n_bits=32,
                         src=ofdef.OXM_OF_IPV4_SRC,
                         dst=ofdef.OXM_OF_IPV4_DST),
                     ofdef.ofp_action_set_field(
                         field=ofdef.create_oxm(
                             ofdef.OXM_OF_IPV4_SRC,
                             ofdef.ip4_addr(ipaddress))),
                     ofdef.ofp_action_set_field(
                         field=ofdef.create_oxm(
                             ofdef.OXM_OF_ICMPV4_TYPE,
                             ICMP_ECHOREPLY)),
                     ofdef.ofp_action_nw_ttl(nw_ttl=128),
                     ofdef.ofp_action_output(
                         port=ofdef.OFPP_IN_PORT)
                 ])
             ])
     ]
예제 #5
0
 def __init__(self, parent):
     HttpHandler.__init__(self, parent.scheduler, False, parent.vhostbind)
     self._parent = parent
     self._logger = parent._logger
     self._macbase = uint64.create(
         create_binary(mac_addr_bytes(self._parent.mactemplate), 8))
     cidrrange = parent.cidrrange
     try:
         subnet, mask = parse_ip4_network(cidrrange)
         if not (0 <= mask <= 24):
             raise ValueError
     except Exception:
         self._logger.warning(
             'Invalid CIDR range: %r. Using default 10.0.0.0/8', cidrrange)
         subnet = ip4_addr('10.0.0.0')
         mask = 8
     self.cidrrange_subnet = subnet
     self.cidrrange_mask = mask
     self.cidrrange_end = (1 << (24 - mask))
     self.pooltimeout = parent.pooltimeout
     self.iptimeout = parent.iptimeout
     self._reqid = 0
예제 #6
0
 def _createicmpflows(subnetinfo):
     ipaddress,macaddress,_,networkid = subnetinfo
     return [
         ofdef.ofp_flow_mod(
             cookie = 0x2,
             cookie_mask = 0xffffffffffffffff,
             table_id = l3input,
             command = ofdef.OFPFC_ADD,
             # icmp to router matcher same as ip forward to router
             # so priority + 1
             priority = ofdef.OFP_DEFAULT_PRIORITY + 1,
             buffer_id = ofdef.OFP_NO_BUFFER,
             out_port = ofdef.OFPP_ANY,
             out_group = ofdef.OFPG_ANY,
             match = ofdef.ofp_match_oxm(
                 oxm_fields = [
                     match_network(networkid),
                     ofdef.create_oxm(ofdef.OXM_OF_ETH_DST,mac_addr_bytes(macaddress)),
                     ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,ofdef.ETHERTYPE_IP),
                     ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,ip4_addr_bytes(ipaddress)),
                     ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,ofdef.IPPROTO_ICMP),
                     ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_TYPE,8),
                     ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_CODE,0)
                 ]
             ),
             instructions = [
                 ofdef.ofp_instruction_actions(
                     actions = [
                         ofdef.ofp_action_output(
                             port = ofdef.OFPP_CONTROLLER,
                             max_len = ofdef.OFPCML_NO_BUFFER
                         )
                     ]
                 )
             ]
         )
     ]
예제 #7
0
 def _createicmpflows(subnetinfo):
     ipaddress,macaddress,_,networkid = subnetinfo
     return [
         ofdef.ofp_flow_mod(
             cookie = 0x2,
             cookie_mask = 0xffffffffffffffff,
             table_id = l3input,
             command = ofdef.OFPFC_ADD,
             # icmp to router matcher same as ip forward to router
             # so priority + 1
             priority = ofdef.OFP_DEFAULT_PRIORITY + 1,
             buffer_id = ofdef.OFP_NO_BUFFER,
             out_port = ofdef.OFPP_ANY,
             out_group = ofdef.OFPG_ANY,
             match = ofdef.ofp_match_oxm(
                 oxm_fields = [
                     match_network(networkid),
                     ofdef.create_oxm(ofdef.OXM_OF_ETH_DST,mac_addr_bytes(macaddress)),
                     ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,ofdef.ETHERTYPE_IP),
                     ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,ip4_addr_bytes(ipaddress)),
                     ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,ofdef.IPPROTO_ICMP),
                     ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_TYPE,8),
                     ofdef.create_oxm(ofdef.OXM_OF_ICMPV4_CODE,0)
                 ]
             ),
             instructions = [
                 ofdef.ofp_instruction_actions(
                     actions = [
                         ofdef.nx_action_reg_move(
                             n_bits = 48,
                             src = ofdef.OXM_OF_ETH_SRC,
                             dst = ofdef.OXM_OF_ETH_DST
                         ),
                         ofdef.ofp_action_set_field(
                             field = ofdef.create_oxm(
                                 ofdef.OXM_OF_ETH_SRC,
                                 ofdef.mac_addr(macaddress)
                             )
                         ),
                         ofdef.nx_action_reg_move(
                             n_bits = 32,
                             src = ofdef.OXM_OF_IPV4_SRC,
                             dst = ofdef.OXM_OF_IPV4_DST
                         ),
                         ofdef.ofp_action_set_field(
                             field = ofdef.create_oxm(
                                 ofdef.OXM_OF_IPV4_SRC,
                                 ofdef.ip4_addr(ipaddress)
                             )
                         ),
                         ofdef.ofp_action_set_field(
                             field = ofdef.create_oxm(
                                 ofdef.OXM_OF_ICMPV4_TYPE,
                                 ICMP_ECHOREPLY
                             )
                         ),
                         ofdef.ofp_action_nw_ttl(
                             nw_ttl = 128
                         ),
                         ofdef.ofp_action_output(
                             port = ofdef.OFPP_IN_PORT
                         )
                     ]
                 )
             ]
         )
     ]
예제 #8
0
 def __init__(self, parent):
     HttpHandler.__init__(self, parent.scheduler, False, parent.vhostbind)
     self._parent = parent
     self._logger = parent._logger
     self._macbase = uint64.create(
         create_binary(mac_addr_bytes(self._parent.mactemplate), 8))