コード例 #1
0
ファイル: dhcpserver.py プロジェクト: missuzhang/vlcp
 def _create_flows2(nid, serveraddr):
     return ofdef.ofp_flow_mod(
         cookie=0x1,
         cookie_mask=0xffffffffffffffff,
         table_id=l3,
         command=ofdef.OFPFC_ADD,
         priority=ofdef.OFP_DEFAULT_PRIORITY,
         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(nid) + [
             ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,
                              ofdef.ETHERTYPE_IP),
             ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,
                              ofdef.IPPROTO_UDP),
             ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,
                              ip4_addr_bytes(serveraddr)),
             ofdef.create_oxm(ofdef.OXM_OF_UDP_DST, 67)
         ]),
         instructions=[
             ofdef.ofp_instruction_actions(actions=[
                 ofdef.ofp_action_output(
                     port=ofdef.OFPP_CONTROLLER,
                     max_len=ofdef.OFPCML_NO_BUFFER)
             ])
         ])
コード例 #2
0
ファイル: icmpresponder.py プロジェクト: hubo1016/vlcp
            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)
                                ]
                            )
                        )
                    ]
コード例 #3
0
ファイル: icmpresponder.py プロジェクト: vtanrun/vlcp
 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)
                 ])
             ])
     ]
コード例 #4
0
ファイル: icmpresponder.py プロジェクト: vtanrun/vlcp
 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)
             ]))
     ]
コード例 #5
0
ファイル: dhcpserver.py プロジェクト: hubo1016/vlcp
 def _create_flows2(nid, serveraddr):
     return ofdef.ofp_flow_mod(cookie = 0x1,
                                cookie_mask = 0xffffffffffffffff,
                                table_id = l3,
                                command = ofdef.OFPFC_ADD,
                                priority = ofdef.OFP_DEFAULT_PRIORITY,
                                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(nid) +
                                                 [ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE, ofdef.ETHERTYPE_IP),
                                                 ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO, ofdef.IPPROTO_UDP),
                                                 ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,
                                                                  ip4_addr_bytes(serveraddr)),
                                                 ofdef.create_oxm(ofdef.OXM_OF_UDP_DST, 67)
                                                 ]
                                         ),
                                instructions = [
                                     ofdef.ofp_instruction_actions(
                                                 actions = [
                                                     ofdef.ofp_action_output(port = ofdef.OFPP_CONTROLLER,
                                                                             max_len = ofdef.OFPCML_NO_BUFFER
                                                                             )
                                                 ]
                                             )
                                         ]
                                )
コード例 #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.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)
                 ])
             ])
     ]
コード例 #7
0
ファイル: dhcpserver.py プロジェクト: missuzhang/vlcp
 def _delete_flows2(nid, serveraddr):
     return ofdef.ofp_flow_mod(
         cookie=0x1,
         cookie_mask=0xffffffffffffffff,
         table_id=l3,
         command=ofdef.OFPFC_DELETE,
         priority=ofdef.OFP_DEFAULT_PRIORITY,
         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(nid) + [
             ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE,
                              ofdef.ETHERTYPE_IP),
             ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO,
                              ofdef.IPPROTO_UDP),
             ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,
                              ip4_addr_bytes(serveraddr)),
             ofdef.create_oxm(ofdef.OXM_OF_UDP_DST, 67)
         ]))
コード例 #8
0
ファイル: dhcpserver.py プロジェクト: hubo1016/vlcp
 def _delete_flows2(nid, serveraddr):
     return ofdef.ofp_flow_mod(cookie = 0x1,
                                    cookie_mask = 0xffffffffffffffff,
                                    table_id = l3,
                                    command = ofdef.OFPFC_DELETE,
                                    priority = ofdef.OFP_DEFAULT_PRIORITY,
                                    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(nid) +
                                                     [ofdef.create_oxm(ofdef.OXM_OF_ETH_TYPE, ofdef.ETHERTYPE_IP),
                                                     ofdef.create_oxm(ofdef.OXM_OF_IP_PROTO, ofdef.IPPROTO_UDP),
                                                     ofdef.create_oxm(ofdef.OXM_OF_IPV4_DST,
                                                                      ip4_addr_bytes(serveraddr)),
                                                     ofdef.create_oxm(ofdef.OXM_OF_UDP_DST, 67)
                                                     ]
                                             )
                                    )
コード例 #9
0
ファイル: icmpresponder.py プロジェクト: hubo1016/vlcp
 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
                         )
                     ]
                 )
             ]
         )
     ]
コード例 #10
0
ファイル: icmpresponder.py プロジェクト: hubo1016/vlcp
 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
                         )
                     ]
                 )
             ]
         )
     ]