本文整理汇总了Python中ryu.lib.mac.haddr_to_str函数的典型用法代码示例。如果您正苦于以下问题:Python haddr_to_str函数的具体用法?Python haddr_to_str怎么用?Python haddr_to_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了haddr_to_str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: actions_to_str
def actions_to_str(acts):
actions = []
for a in acts:
action_type = a.cls_action_type
if action_type == ofproto_v1_0.OFPAT_OUTPUT:
buf = 'OUTPUT:' + str(a.port)
elif action_type == ofproto_v1_0.OFPAT_SET_VLAN_VID:
buf = 'SET_VLAN_VID:' + str(a.vlan_vid)
elif action_type == ofproto_v1_0.OFPAT_SET_VLAN_PCP:
buf = 'SET_VLAN_PCP:' + str(a.vlan_pcp)
elif action_type == ofproto_v1_0.OFPAT_STRIP_VLAN:
buf = 'STRIP_VLAN'
elif action_type == ofproto_v1_0.OFPAT_SET_DL_SRC:
buf = 'SET_DL_SRC:' + haddr_to_str(a.dl_addr)
elif action_type == ofproto_v1_0.OFPAT_SET_DL_DST:
buf = 'SET_DL_DST:' + haddr_to_str(a.dl_addr)
elif action_type==65535:
if a.subtype==2:
buf = 'set_tunnel:'+str(a.tun_id)
else:
buf='resubmit:(,'+str(a.table)+')'
else:
buf='UNKNOWN'
actions.append(buf)
return actions
开发者ID:wei1225,项目名称:ryu_from_229,代码行数:26,代码来源:ofctl_v6.py
示例2: switch_configuration
def switch_configuration(self, ev):
print "Packet in: switch configuration"
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
dst, src, _eth_type = struct.unpack_from('!6s6sH', buffer(msg.data), 0)
dpid = datapath.id
self.mac2port.dpid_add(dpid)
LOG.info("Src MAC: %s; Dest MAC: %s", haddr_to_str(src), haddr_to_str(dst))
self.mac2port.port_add(dpid, msg.in_port, src)
out_port = self.mac2port.port_get(dpid, dst)
if out_port == None:
LOG.info("Output port not found")
out_port = ofproto.OFPP_FLOOD
actions = [datapath.ofproto_parser.OFPActionOutput(out_port)]
LOG.info("Input port: %s; Output port: %s", msg.in_port, out_port)
if out_port != ofproto.OFPP_FLOOD:
rule = nx_match.ClsRule()
rule.set_in_port(msg.in_port)
rule.set_dl_dst(dst)
rule.set_dl_src(src)
rule.set_nw_dscp(0)
datapath.send_flow_mod(
rule=rule, cookie=0, command=ofproto.OFPFC_ADD,
idle_timeout=0, hard_timeout=0,
priority=ofproto.OFP_DEFAULT_PRIORITY,
flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
datapath.send_packet_out(msg.buffer_id, msg.in_port, actions)
开发者ID:savi-dev,项目名称:ryu,代码行数:35,代码来源:configurable_device.py
示例3: packet_in_handler
def packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
dst, src, eth_type = struct.unpack_from('!6s6sH', buffer(msg.data), 0)
match = msg.match.fields
#for field in match:
#logger.info("FIELDS==> %s ",field.value)
logger.info("")
logger.info("----------------------------------------")
logger.info("*** PacketIn ***")
logger.info("in_port=%d, eth_type: %s", in_port, hex(eth_type))
logger.info("packet reason=%d buffer_id=%d", msg.reason, msg.buffer_id)
logger.info("packet in datapath_id=%s src=%s dst=%s",
msg.datapath.id, haddr_to_str(src), haddr_to_str(dst))
pkt = packet.Packet(msg.data) # get data of packet
eth = pkt.get_protocols(ethernet.ethernet)[0]
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
# verify if we have a valid buffer_id, if yes avoid to send both
# flow_mod & packet_out
if msg.buffer_id != ofproto.OFP_NO_BUFFER:
self.add_flow(datapath, 1, match, actions, msg.buffer_id)
return
else:
self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
in_port=in_port, actions=actions, data=data)
datapath.send_msg(out)
开发者ID:nguyenngocduy20,项目名称:vlan-ryu,代码行数:60,代码来源:vlan_reactive.py
示例4: match_eth_to_str
def match_eth_to_str(value, mask):
eth_str = mac.haddr_to_str(value)
if mask is not None:
eth_str = eth_str + '/' + mac.haddr_to_str(mask)
return eth_str
开发者ID:Aminiok,项目名称:ryu,代码行数:7,代码来源:ofctl_v1_3.py
示例5: _packet_in_handler
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
dst, src, _eth_type = struct.unpack_from('!6s6sH', buffer(msg.data), 0)
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
LOG.info("packet in %s %s %s %s",
dpid, haddr_to_str(src), haddr_to_str(dst), msg.in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = msg.in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [datapath.ofproto_parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
self.add_flow(datapath, msg.in_port, dst, actions)
out = datapath.ofproto_parser.OFPPacketOut(
datapath=datapath, buffer_id=msg.buffer_id, in_port=msg.in_port,
actions=actions)
datapath.send_msg(out)
开发者ID:dzwiedziu,项目名称:ryu,代码行数:31,代码来源:simple_switch.py
示例6: _forward_to_nw_id
def _forward_to_nw_id(self, msg, src, dst, nw_id, out_port):
assert out_port is not None
datapath = msg.datapath
if not self.nw.same_network(datapath.id, nw_id, out_port, NW_ID_EXTERNAL):
self.logger.debug(
"packet is blocked src %s dst %s " "from %d to %d on datapath %d",
haddr_to_str(src),
haddr_to_str(dst),
msg.in_port,
out_port,
datapath.id,
)
return
self.logger.debug(
"learned dpid %s in_port %d out_port " "%d src %s dst %s",
datapath.id,
msg.in_port,
out_port,
haddr_to_str(src),
haddr_to_str(dst),
)
actions = [datapath.ofproto_parser.OFPActionOutput(out_port)]
self._modflow_and_send_packet(msg, src, dst, actions)
开发者ID:ykaneko,项目名称:ryu,代码行数:25,代码来源:simple_isolation.py
示例7: _packet_in_handler
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
dst, src, _eth_type = struct.unpack_from('!6s6sH', buffer(msg.data), 0)
dpid = datapath.id
print 'mac_to_port',self.mac_to_port,'\n'
self.mac_to_port.setdefault(dpid, {})
print 'mac_to_port',self.mac_to_port,'\n'
LOG.info("packet in %s %s %s %s",
dpid, haddr_to_str(src), haddr_to_str(dst), msg.in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = msg.in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [datapath.ofproto_parser.OFPActionOutput(out_port)]
if out_port != ofproto.OFPP_FLOOD:
#self.add_flow(datapath, msg.in_port, dst, [datapath.ofproto_parser.OFPActionOutput(datapath.ofproto.OFPP_NORMAL)])
self.add_flow(datapath, msg.in_port, dst, actions)
#add a ipv6 flow table:
if _eth_type == ether.ETH_TYPE_IPV6:
#print _eth_type
pkt = Packet(array('B',msg.data))
for packet in pkt:
if isinstance(packet,array):
pass
else:
if packet.protocol_name=='ipv6':
ipv6_packet=packet
else:
pass
ipv6_src=self._binary_to_ipv6_format(ipv6_packet.src)
ipv6_dst=self._binary_to_ipv6_format(ipv6_packet.dst)
print ipv6_src,ipv6_dst
'''
# judge if src and dst addr is special
# eg: src [0,0,0,0] dst begin with 0xff01 or 0x ff02
if ipv6_src == [0,0,0,0] or ipv6_dst[0]&0xff010000 == 0xff010000 or ipv6_dst[0]&0xff020000 == 0xff020000:
print 'ipv6 reserved address\n'
#elif ipv6_dst[0]&0xfe800000 == 0xfe800000:
# print 'ipv6 dst address is Link-Local address'
else:
'''
rule={'ipv6_src':ipv6_src,'ipv6_dst':ipv6_dst}
self.nx_ipv6_add_flow(datapath,rule,actions)
print 'add a ipv6 flow entry'
out = datapath.ofproto_parser.OFPPacketOut(
datapath=datapath, buffer_id=msg.buffer_id, in_port=msg.in_port,
actions=actions)
datapath.send_msg(out)
开发者ID:leejian0612,项目名称:ipv6-managner-based-on-ryu,代码行数:59,代码来源:lee_ipv6_switch.py
示例8: _packet_in_handler
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
dst, src, _eth_type = struct.unpack_from('!6s6sH', buffer(msg.data), 0)
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
match = msg.match
in_port = 0
#iterate through fields - parser should handle this
#packet in dpid 20015998343868 from 08:00:27:15:d4:53 to ff:ff:ff:ff:ff:ff log_port 0 phy_port 0
#Field MTInPort(header=2147483652,length=8,n_bytes=4,value=2)
#Field MTEthType(header=2147486210,length=6,n_bytes=2,value=2054)
#Field MTArpOp(header=2147494402,length=6,n_bytes=2,value=1)
#Field MTMetadata(header=2147484680,length=12,n_bytes=8,value=18446744073709551615L)
#Field MTArpSha(header=2147495942,length=10,n_bytes=6,value="\x08\x00'\x15\xd4S")
#Field MTEthDst(header=2147485190,length=10,n_bytes=6,value='\xff\xff\xff\xff\xff\xff')
#Field MTArpSpa(header=2147494916,length=8,n_bytes=4,value=167772161)
#Field MTArpTha(header=2147496454,length=10,n_bytes=6,value='\x00\x00\x00\x00\x00\x00')
for o in match.fields:
if isinstance(o, ofproto_v1_2_parser.MTInPort):
in_port = o.value
break
self.logger.info("packet in dpid %s from %s to %s log_port %s",
dpid, haddr_to_str(src), haddr_to_str(dst),
in_port)
# do we know the mac?
if src not in self.mac_to_port[dpid]:
# learn the mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
# set a flow to table 0 to allow packets through to table 1
match = datapath.ofproto_parser.OFPMatch()
match.set_in_port(in_port)
match.set_dl_src(src)
instructions = [datapath.ofproto_parser.OFPInstructionGotoTable(1)]
self.add_flow(datapath, 0, match, instructions)
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
actions = [datapath.ofproto_parser.OFPActionOutput(out_port, 1500)]
match = datapath.ofproto_parser.OFPMatch()
match.set_dl_dst(dst)
instructions = [datapath.ofproto_parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
self.add_flow(datapath, 1, match, instructions, buffer_id=msg.buffer_id)
else:
out_port = ofproto_v1_2.OFPP_FLOOD
actions = [datapath.ofproto_parser.OFPActionOutput(out_port, 1500)]
out = datapath.ofproto_parser.OFPPacketOut(
datapath=datapath, buffer_id=msg.buffer_id, in_port=in_port,
actions=actions)
datapath.send_msg(out)
开发者ID:isomer,项目名称:ryu,代码行数:59,代码来源:simple_switch_12.py
示例9: packet_in_handler
def packet_in_handler(self, ev):
msg = ev.msg
dst, src, eth_type = struct.unpack_from('!6s6sH', buffer(msg.data), 0)
in_port = msg.match.fields[0].value
LOG.info("----------------------------------------")
LOG.info("* PacketIn")
LOG.info("in_port=%d, eth_type: %s", in_port, hex(eth_type))
LOG.info("packet reason=%d buffer_id=%d", msg.reason, msg.buffer_id)
LOG.info("packet in datapath_id=%s src=%s dst=%s",
msg.datapath.id, haddr_to_str(src), haddr_to_str(dst))
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:11,代码来源:test_vlan.py
示例10: match_to_str
def match_to_str(m):
return {'dl_dst': haddr_to_str(m.dl_dst),
'dl_src': haddr_to_str(m.dl_src),
'dl_type': m.dl_type,
'dl_vlan': m.dl_vlan,
'dl_vlan_pcp': m.dl_vlan_pcp,
'in_port': m.in_port,
'nw_dst': socket.inet_ntoa(struct.pack('!I', m.nw_dst)),
'nw_proto': m.nw_proto,
'nw_src': socket.inet_ntoa(struct.pack('!I', m.nw_src)),
'tp_src': m.tp_src,
'tp_dst': m.tp_dst}
开发者ID:relarge,项目名称:ryu,代码行数:12,代码来源:ofctl_v1_0.py
示例11: _flood_to_nw_id
def _flood_to_nw_id(self, msg, src, dst, nw_id):
datapath = msg.datapath
actions = []
self.logger.debug("dpid %s in_port %d src %s dst %s ports %s",
datapath.id, msg.in_port,
haddr_to_str(src), haddr_to_str(dst),
self.nw.dpids.get(datapath.id, {}).items())
for port_no in self.nw.filter_ports(datapath.id, msg.in_port,
nw_id, NW_ID_EXTERNAL):
self.logger.debug("port_no %s", port_no)
actions.append(datapath.ofproto_parser.OFPActionOutput(port_no))
self._modflow_and_send_packet(msg, src, dst, actions)
开发者ID:savi-dev,项目名称:ryu,代码行数:12,代码来源:simple_isolation.py
示例12: match_to_str
def match_to_str(m):
return {'dl_dst': haddr_to_str(m.dl_dst),
'dl_src': haddr_to_str(m.dl_src),
'dl_type': m.dl_type,
'dl_vlan': m.dl_vlan,
'dl_vlan_pcp': m.dl_vlan_pcp,
'in_port': m.in_port,
'nw_dst': nw_dst_to_str(m.wildcards, m.nw_dst),
'nw_proto': m.nw_proto,
'nw_src': nw_src_to_str(m.wildcards, m.nw_src),
'tp_src': m.tp_src,
'tp_dst': m.tp_dst}
开发者ID:Aminiok,项目名称:ryu,代码行数:12,代码来源:ofctl_v1_0.py
示例13: _decode_bridge_id
def _decode_bridge_id(bridge_id):
priority = (bridge_id << 12) & 0xf000
system_id_extension = (bridge_id >> 4) & 0xfff
mac_addr = (bridge_id >> 16) & 0xffffffffffff
mac_addr_list = [format((mac_addr >> (8 * i)) & 0xff, '02x')
for i in range(0, 6)]
mac_address = binascii.a2b_hex(''.join(mac_addr_list))
#TODO:
from ryu.lib import mac
print mac.haddr_to_str(mac_address)
return priority, system_id_extension, mac_address
开发者ID:watanabefumitaka,项目名称:src,代码行数:14,代码来源:bpdu.py
示例14: equal_match
def equal_match(key, value, cls_name, fields):
for field in fields:
if cls_name in str(field):
if key in ['dl_src', 'dl_dst', 'arp_sha', 'arp_tha',
'eth_src', 'eth_dst']:
eth, mask = _to_match_eth(value)
str_eth = mac.haddr_to_str(eth)
str_mask = mac.haddr_to_str(mask)
str_value = mac.haddr_to_str(field.value)
for i in range(0, 17):
if str_mask[i] == 'f':
eq_(str_eth[i], str_value[i])
else:
continue
eq_(mask, field.mask)
return
elif key in ['nw_src', 'nw_dst', 'ipv4_src', 'ipv4_dst',
'arp_spa', 'arp_tpa']:
ipv4, mask = _to_match_ip(value)
eq_(ipv4, field.value)
eq_(mask, field.mask)
return
elif key in ['ipv6_src', 'ipv6_dst']:
ipv6, mask = _to_match_ipv6(value)
for i in range(0, 8):
if mask[i] == 65535:
eq_(ipv6[i], field.value[i])
else:
continue
eq_(list(mask), field.mask)
return
elif key == 'ipv6_nd_target':
ipv6, mask = _to_match_ipv6(value)
for i in range(0, 8):
if mask[i] == 65535:
eq_(ipv6[i], field.value[i])
else:
continue
return
elif key == 'ipv6_nd_sll' or key == 'ipv6_nd_tll':
eq_(mac.haddr_to_bin(value), field.value)
return
elif key == 'metadata':
eq_(int(value, 16), field.value)
return
else:
eq_(value, field.value)
return
assert False
开发者ID:Aminiok,项目名称:ryu,代码行数:49,代码来源:test_ofctl.py
示例15: test_to_string
def test_to_string(self):
nd_opt = icmpv6.nd_option_la(self.nd_hw_src)
nd = icmpv6.nd_neighbor(
self.res, self.dst, self.nd_type, self.nd_length, nd_opt)
ic = icmpv6.icmpv6(self.type_, self.code, self.csum, nd)
nd_opt_values = {'hw_src': haddr_to_str(self.nd_hw_src),
'data': None}
_nd_opt_str = ','.join(['%s=%s' % (k, repr(nd_opt_values[k]))
for k, v in inspect.getmembers(nd_opt)
if k in nd_opt_values])
nd_opt_str = '%s(%s)' % (icmpv6.nd_option_la.__name__, _nd_opt_str)
nd_values = {'res': repr(nd.res),
'dst': repr(ipv6_to_str(self.dst)),
'type_': repr(self.nd_type),
'length': repr(self.nd_length),
'data': nd_opt_str}
_nd_str = ','.join(['%s=%s' % (k, nd_values[k])
for k, v in inspect.getmembers(nd)
if k in nd_values])
nd_str = '%s(%s)' % (icmpv6.nd_neighbor.__name__, _nd_str)
icmp_values = {'type_': repr(self.type_),
'code': repr(self.code),
'csum': repr('0x%x' % self.csum),
'data': nd_str}
_ic_str = ','.join(['%s=%s' % (k, icmp_values[k])
for k, v in inspect.getmembers(ic)
if k in icmp_values])
ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str)
eq_(str(ic), ic_str)
eq_(repr(ic), ic_str)
开发者ID:watanabefumitaka,项目名称:src,代码行数:34,代码来源:test_icmpv6.py
示例16: to_dict
def to_dict(self):
return {
"dpid": dpid_to_str(self.dpid),
"port_no": port_no_to_str(self.port_no),
"hw_addr": haddr_to_str(self.hw_addr),
"name": self.name.rstrip("\0"),
}
开发者ID:ykaneko,项目名称:ryu,代码行数:7,代码来源:switches.py
示例17: to_rest
def to_rest(openflow):
of_match = openflow[REST_MATCH]
mac_dontcare = mac.haddr_to_str(mac.DONTCARE)
ip_dontcare = '0.0.0.0'
match = {}
for key, value in of_match.items():
if key == REST_SRC_MAC or key == REST_DST_MAC:
if value == mac_dontcare:
continue
elif key == REST_SRC_IP or key == REST_DST_IP:
if value == ip_dontcare:
continue
elif value == 0:
continue
if key in Match._CONVERT:
conv = Match._CONVERT[key]
conv = dict((value, key) for key, value in conv.items())
match.setdefault(key, conv[value])
else:
match.setdefault(key, value)
return match
开发者ID:rnudechu,项目名称:ryu,代码行数:25,代码来源:rest_firewall.py
示例18: match_to_str
def match_to_str(ofmatch):
keys = {ofproto_v1_3.OXM_OF_IN_PORT: 'in_port',
ofproto_v1_3.OXM_OF_ETH_SRC: 'dl_src',
ofproto_v1_3.OXM_OF_ETH_DST: 'dl_dst',
ofproto_v1_3.OXM_OF_ETH_TYPE: 'dl_type',
ofproto_v1_3.OXM_OF_VLAN_VID: 'dl_vlan',
ofproto_v1_3.OXM_OF_IPV4_SRC: 'nw_src',
ofproto_v1_3.OXM_OF_IPV4_DST: 'nw_dst',
ofproto_v1_3.OXM_OF_IPV4_SRC_W: 'nw_src',
ofproto_v1_3.OXM_OF_IPV4_DST_W: 'nw_dst',
ofproto_v1_3.OXM_OF_IP_PROTO: 'nw_proto',
ofproto_v1_3.OXM_OF_TCP_SRC: 'tp_src',
ofproto_v1_3.OXM_OF_TCP_DST: 'tp_dst',
ofproto_v1_3.OXM_OF_UDP_SRC: 'tp_src',
ofproto_v1_3.OXM_OF_UDP_DST: 'tp_dst',
ofproto_v1_3.OXM_OF_METADATA: 'metadata',
ofproto_v1_3.OXM_OF_METADATA_W: 'metadata'}
match = {}
for match_field in ofmatch.fields:
key = keys[match_field.header]
if key == 'dl_src' or key == 'dl_dst':
value = mac.haddr_to_str(match_field.value)
elif key == 'nw_src' or key == 'nw_dst':
value = match_ip_to_str(match_field.value, match_field.mask)
elif key == 'metadata':
value = ('%d/%d' % (match_field.value, match_field.mask)
if match_field.mask else '%d' % match_field.value)
else:
value = match_field.value
match.setdefault(key, value)
return match
开发者ID:gaojinghua,项目名称:ryu,代码行数:33,代码来源:ofctl_v1_3.py
示例19: block_out_sample_in
def block_out_sample_in(self, stats):
ofproto = datapath.ofproto
#SRC BLOCK FLOW
src_mac = stats.match.dl_dst
if not src_mac == self.gateway_mac:
src_match = datapath.ofproto_parser.OFPMatch(dl_src=src_mac, dl_dst=self.gateway_mac)
src_flow = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=src_match, cookie=random_int(),
command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=2,
priority=0x6000,
flags=ofproto.OFPFF_SEND_FLOW_REM)
datapath.send_msg(src_flow)
eventlet.sleep(0.1)
# DST BLOCK FLOW - We only sample this flow for 1 second,
# Destination does not receive anything.
dst_mac = stats.match.dl_dst
if not dst_mac == self.gateway_mac:
dst_match = datapath.ofproto_parser.OFPMatch(dl_src=self.gateway_mac, dl_dst=dst_mac)
dst_actions = [datapath.ofproto_parser.OFPActionOutput(monitor_port)]
dst_flow = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=dst_match, cookie=random_int(),
command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=1,
priority=0x6000,
flags=ofproto.OFPFF_SEND_FLOW_REM, actions=dst_actions)
datapath.send_msg(dst_flow)
#Notify parser of this source/destination being blocked from this point on.
outgoing_block_mode_v1_dict[(haddr_to_str(src_mac))] = int(time.time() * 1000)
开发者ID:ConnorDillon,项目名称:openflowddos,代码行数:33,代码来源:ryu_controller.py
示例20: test_mac_haddr_to_str
def test_mac_haddr_to_str(self):
addr = "aa:aa:aa:aa:aa:aa"
val = b"\xaa\xaa\xaa\xaa\xaa\xaa"
res = mac.haddr_to_str(val)
eq_(addr, res)
开发者ID:John-Lin,项目名称:ryu,代码行数:7,代码来源:test_mac.py
注:本文中的ryu.lib.mac.haddr_to_str函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论