本文整理汇总了Python中ryu.lib.mac.haddr_to_bin函数的典型用法代码示例。如果您正苦于以下问题:Python haddr_to_bin函数的具体用法?Python haddr_to_bin怎么用?Python haddr_to_bin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了haddr_to_bin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_flow
def add_flow(self, datapath, in_port, eth, ip_v4, actions):
ofproto = datapath.ofproto
idleTimeout = 2
hardTimeout = 2
if(ip_v4):
nw_src = self.ipv4_text_to_int(ip_v4.src)
nw_dst = self.ipv4_text_to_int(ip_v4.dst)
match = datapath.ofproto_parser.OFPMatch(
in_port=in_port,
dl_type=eth.ethertype,
dl_src=haddr_to_bin(eth.src),
dl_dst=haddr_to_bin(eth.dst),
nw_proto=ip_v4.proto,
nw_src=nw_src,
nw_dst=nw_dst,
)
else:
match = datapath.ofproto_parser.OFPMatch(
in_port=in_port, dl_type=eth.ethertype,
dl_src=haddr_to_bin(eth.src),
dl_dst=haddr_to_bin(eth.dst),)
idleTimeout = 2
hardTimeout = 2
mod = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=match, cookie=0,
command=ofproto.OFPFC_ADD, idle_timeout=idleTimeout, hard_timeout=hardTimeout,
priority=ofproto.OFP_DEFAULT_PRIORITY,
flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
datapath.send_msg(mod)
开发者ID:rafaelsilvag,项目名称:Rypace,代码行数:34,代码来源:rypace_switch_v01.py
示例2: __init__
def __init__(self, flags=0, root_priority=DEFAULT_BRIDGE_PRIORITY,
root_system_id_extension=0,
root_mac_address=haddr_to_bin('00:00:00:00:00:00'),
root_path_cost=0, bridge_priority=DEFAULT_BRIDGE_PRIORITY,
bridge_system_id_extension=0,
bridge_mac_address=haddr_to_bin('00:00:00:00:00:00'),
port_priority=DEFAULT_PORT_PRIORITY, port_number=0,
message_age=0, max_age=DEFAULT_MAX_AGE,
hello_time=DEFAULT_HELLO_TIME,
forward_delay=DEFAULT_FORWARD_DELAY):
self.flags = flags
self.root_priority = root_priority
self.root_system_id_extension = root_system_id_extension
self.root_mac_address = root_mac_address
self.root_path_cost = root_path_cost
self.bridge_priority = bridge_priority
self.bridge_system_id_extension = bridge_system_id_extension
self.bridge_mac_address = bridge_mac_address
self.port_priority = port_priority
self.port_number = port_number
self.message_age = message_age
self.max_age = max_age
self.hello_time = hello_time
self.forward_delay = forward_delay
super(ConfigurationBPDUs, self).__init__()
开发者ID:watanabefumitaka,项目名称:src,代码行数:26,代码来源:bpdu.py
示例3: rewrite_gw_patch
def rewrite_gw_patch(datapath, port_a, port_g, auth_mac, gw_mac, priority=0):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
"""
GUESTLAN -> AUTHLAN 認証サーバ意外へのパケットは全てMACアドレスを書き換えて、認証サーバへ
AUTHLAN -> GUESTLAN 認証サーバ意外へ宛先が向いていたパケットをゲートウェイのMACアドレスに書き換え返す
"""
"""
1.認証サーバをGWとすり替えるエントリの追加
"""
match_a = parser.OFPMatch(in_port=port_a, eth_type=0x800, ip_proto=inet.IPPROTO_TCP, tcp_src=80)
match_g = parser.OFPMatch(in_port=port_g, eth_type=0x800, ip_proto=inet.IPPROTO_TCP, tcp_dst=80)
action_a = parser.OFPMatchField.make(ofproto.OXM_OF_ETH_SRC, haddr_to_bin(gw_mac))
action_g = parser.OFPMatchField.make(ofproto.OXM_OF_ETH_DST, haddr_to_bin(auth_mac))
actions_a = [parser.OFPActionSetField(action_a), parser.OFPActionOutput(port_g)]
actions_g = [parser.OFPActionSetField(action_g), parser.OFPActionOutput(port_a)]
inst_a = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions_a)]
inst_g = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions_g)]
mod_a = parser.OFPFlowMod(datapath=datapath, priority=priority, match=match_a, instructions=inst_a)
mod_g = parser.OFPFlowMod(datapath=datapath, priority=priority, match=match_g, instructions=inst_g)
datapath.send_msg(mod_a)
datapath.send_msg(mod_g)
开发者ID:BenjaminUJun,项目名称:Switch,代码行数:29,代码来源:switch.py
示例4: to_actions
def to_actions(dp, acts):
actions = []
for a in acts:
action_type = a.get('type')
if action_type == 'OUTPUT':
out_port = int(a.get('port', ofproto_v1_0.OFPP_NONE))
max_len = int(a.get('max_len', 65535))
actions.append(dp.ofproto_parser.OFPActionOutput(
out_port, max_len=max_len))
elif action_type == 'SET_VLAN_VID':
vlan_vid = int(a.get('vlan_vid', 0xffff))
actions.append(dp.ofproto_parser.OFPActionVlanVid(vlan_vid))
elif action_type == 'SET_VLAN_PCP':
vlan_pcp = int(a.get('vlan_pcp', 0))
actions.append(dp.ofproto_parser.OFPActionVlanPcp(vlan_pcp))
elif action_type == 'STRIP_VLAN':
actions.append(dp.ofproto_parser.OFPActionStripVlan())
elif action_type == 'SET_DL_SRC':
dl_src = haddr_to_bin(a.get('dl_src'))
actions.append(dp.ofproto_parser.OFPActionSetDlSrc(dl_src))
elif action_type == 'SET_DL_DST':
dl_dst = haddr_to_bin(a.get('dl_dst'))
actions.append(dp.ofproto_parser.OFPActionSetDlDst(dl_dst))
else:
LOG.debug('Unknown action type')
return actions
开发者ID:Aminiok,项目名称:ryu,代码行数:27,代码来源:ofctl_v1_0.py
示例5: build_of_actions
def build_of_actions(self,inport,action_list):
### BUILD OF ACTIONS
of_actions = []
for actions in action_list:
outport = actions['outport']
del actions['outport']
if 'srcmac' in actions:
of_actions.append(ofproto_v1_0_parser.OFPActionSetDlSrc(haddr_to_bin(actions['srcmac'])))
if 'dstmac' in actions:
of_actions.append(ofproto_v1_0_parser.OFPActionSetDlDst(haddr_to_bin(actions['dstmac'])))
if 'srcip' in actions:
of_actions.append(ofproto_v1_0_parser.OFPActionSetNwSrc(self.ipv4_to_int(actions['srcip'])))
if 'dstip' in actions:
of_actions.append(ofproto_v1_0_parser.OFPActionSetNwDst(self.ipv4_to_int(actions['dstip'])))
if 'srcport' in actions:
of_actions.append(ofproto_v1_0_parser.OFPActionSetTpSrc(actions['srcport']))
if 'dstport' in actions:
of_actions.append(ofproto_v1_0_parser.OFPActionSetTpDst(actions['dstport']))
if 'vlan_id' in actions:
if actions['vlan_id'] is None:
of_actions.append(ofproto_v1_0_parser.OFPActionStripVlan())
else:
of_actions.append(ofproto_v1_0_parser.OFPActionVlanVid(vlan_vid=actions['vlan_id']))
if 'vlan_pcp' in actions:
if actions['vlan_pcp'] is None:
if not actions['vlan_id'] is None:
raise RuntimeError("vlan_id and vlan_pcp must be set together!")
pass
else:
of_actions.append(ofproto_v1_0_parser.OFPActionVlanPcp(vlan_pcp=actions['vlan_pcp']))
if (not inport is None) and (outport == inport):
of_actions.append(ofproto_v1_0_parser.OFPActionOutput(ofproto_v1_0.OFPP_IN_PORT))
else:
of_actions.append(ofproto_v1_0_parser.OFPActionOutput(outport))
return of_actions
开发者ID:ChristosKon,项目名称:pyretic-IPv6,代码行数:35,代码来源:ryu_shim.py
示例6: _mod_routing_flow
def _mod_routing_flow(self, command, cookie, priority, out_port, dl_vlan=0,
nw_src=0, src_mask=32, nw_dst=0, dst_mask=32,
src_mac=0, dst_mac=0, idle_timeout=0, dec_ttl=False,
eth_type=ether.ETH_TYPE_IP, in_port=None,
out_group=None):
ofp_parser = self.dp.ofproto_parser
actions = []
if dec_ttl:
actions.append(ofp_parser.NXActionDecTtl())
if src_mac:
if type(src_mac) == str:
src_mac = haddr_to_bin(src_mac)
actions.append(ofp_parser.OFPActionSetDlSrc(src_mac))
if dst_mac:
if type(dst_mac) == str:
dst_mac = haddr_to_bin(dst_mac)
actions.append(ofp_parser.OFPActionSetDlDst(dst_mac))
if out_port is not None:
actions.append(ofp_parser.OFPActionOutput(out_port))
if out_group is not None:
self.logger.warning('Group is not supported in OFP: %d',
self.ofp.OFP_VERSION)
self._mod_flow(command, cookie, priority, eth_type=eth_type,
dl_vlan=dl_vlan,
nw_src=nw_src, src_mask=src_mask,
nw_dst=nw_dst, dst_mask=dst_mask,
idle_timeout=idle_timeout, actions=actions,
in_port=in_port)
开发者ID:BenjaminUJun,项目名称:ryuo,代码行数:30,代码来源:ofctl.py
示例7: _build_vlan
def _build_vlan(self):
src_mac = mac.haddr_to_bin('00:07:0d:af:f4:54')
dst_mac = mac.haddr_to_bin('00:00:00:00:00:00')
ethertype = ether.ETH_TYPE_8021Q
e = ethernet(dst_mac, src_mac, ethertype)
version = 4
header_length = 20
tos = 0
total_length = 24
identification = 0x8a5d
flags = 0
offset = 1480
ttl = 64
proto = inet.IPPROTO_ICMP
csum = 0xa7f2
src = int(netaddr.IPAddress('131.151.32.21'))
dst = int(netaddr.IPAddress('131.151.32.129'))
option = 'TEST'
ip = ipv4(version, header_length, tos, total_length, identification,
flags, offset, ttl, proto, csum, src, dst, option)
p = Packet()
p.add_protocol(e)
p.add_protocol(self.v)
p.add_protocol(ip)
p.serialize()
return p
开发者ID:09zwcbupt,项目名称:ryu,代码行数:30,代码来源:test_vlan.py
示例8: switch_features_handler
def switch_features_handler(self, ev):
datapath = ev.msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
msg = ev.msg
print 'OFPSwitchFeatures receive: datapath_id=0x%016x n_buffers=%d n_tables=%d auxiliary_id=%d capabilities=0x%08x' % (msg.datapath_id, msg.n_buffers, msg.n_tables,msg.auxiliary_id, msg.capabilities)
# install table-miss flow entry
#
# We specify NO BUFFER to max_len of the output action due to
# OVS bug. At this moment, if we specify a lesser number, e.g.,
# 128, OVS will send Packet-In with invalid buffer_id and
# truncated packet data. In that case, we cannot output packets
# correctly.
match = parser.OFPMatch()
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,max_len=40)]
self.add_flow(datapath, 0, match, actions,0)
match1 = parser.OFPMatch()
mac_src1 = mac.haddr_to_bin('00:00:00:00:00:00')
mac_dst1 = mac.haddr_to_bin('00:00:00:00:00:01')
mac_mask = mac.haddr_to_bin('ff:ff:ff:ff:ff:ff')
match1.set_dl_src_masked(mac_src1,mac_mask)
match1.set_dl_dst_masked(mac_dst1,mac_mask)
actions1 = [parser.OFPActionOutput(port=2)]
self.add_flow(datapath,0,match1,actions1,0)
match2 = parser.OFPMatch()
mac_src2 = mac.haddr_to_bin('00:00:00:00:00:01')
mac_dst2 = mac.haddr_to_bin('00:00:00:00:00:00')
match2.set_dl_src_masked(mac_src2,mac_mask)
match2.set_dl_dst_masked(mac_dst2,mac_mask)
actions2 = [parser.OFPActionOutput(port=1)]
self.add_flow(datapath,1,match2,actions2,0)
开发者ID:JunanDang,项目名称:CAB_SDN_HELPER,代码行数:34,代码来源:table_overflow.py
示例9: build_of_match
def build_of_match(self,datapath,inport,pred):
### BUILD OF MATCH
rule = OF10Match()
if inport != None:
rule.in_port = inport
if 'srcmac' in pred:
rule.dl_src = haddr_to_bin(pred['srcmac'])
if 'dstmac' in pred:
rule.dl_dst = haddr_to_bin(pred['dstmac'])
if 'ethtype' in pred:
rule.dl_type = pred['ethtype']
if 'vlan_id' in pred:
rule.dl_vlan = pred['vlan_id']
if 'vlan_pcp' in pred:
rule.dl_vlan_pcp = pred['vlan_pcp']
if 'protocol' in pred:
rule.nw_proto = pred['protocol']
if 'srcip' in pred:
rule.nw_src = self.ipv4_to_int(pred['srcip'])
if 'dstip' in pred:
rule.nw_dst = self.ipv4_to_int(pred['dstip'])
if 'tos' in pred:
rule.nw_tos = pred['tos']
if 'srcport' in pred:
rule.tp_src = pred['srcport']
if 'dstport' in pred:
rule.tp_dst = pred['dstport']
match_tuple = rule.match_tuple()
match = datapath.ofproto_parser.OFPMatch(*match_tuple)
return match
开发者ID:doriguzzi,项目名称:pyretic,代码行数:32,代码来源:ryu_client.py
示例10: _nwtp_forwarding
def _nwtp_forwarding(self, ev):
msg = ev.msg
datapath = msg.datapath
dpid = msg.datapath.id
ofproto = datapath.ofproto
pkt = packet.Packet(msg.data)
eth = pkt.get_protocol(ethernet.ethernet)
nw_pkt = pkt.get_protocol(ipv4.ipv4)
tp_pkt = pkt.get_protocol(tcp.tcp)
dlsrc = eth.src
dldst = eth.dst
nwsrc = nw_pkt.src
nwdst = nw_pkt.dst
tpsrc = tp_pkt.src_port
tpdst = tp_pkt.dst_port
if not dldst in self.mac_to_port[dpid]:
return True
outport = self.mac_to_port[dpid][dldst]
match = datapath.ofproto_parser.OFPMatch(dl_src=haddr_to_bin(dlsrc),
dl_dst=haddr_to_bin(dldst),
dl_type=self.IP_TYPE,
nw_src=ipv4_to_int(nwsrc),
nw_dst=ipv4_to_int(nwdst),
nw_proto=self.TCP_PROTO,
tp_src=tpsrc,
tp_dst=tpdst)
actions = [datapath.ofproto_parser.OFPActionOutput(outport)]
self.add_flow(datapath, self.nwtp_priority, match, actions)
return False
开发者ID:LZUSDN,项目名称:SmartProxy,代码行数:29,代码来源:proxy2.py
示例11: block_traffic_by_default
def block_traffic_by_default(self, dp):
ofproto = dp.ofproto
parser = dp.ofproto_parser
match = parser.OFPMatch(dl_type=ether.ETH_TYPE_IP, dl_src=haddr_to_bin("00:00:00:00:00:02"), dl_dst=haddr_to_bin("00:00:00:00:00:03"))
mod = parser.OFPFlowMod(datapath = dp, match = match, cookie=0, command=ofproto.OFPFC_ADD, hard_timeout = 0, priority=ofproto.OFP_DEFAULT_PRIORITY, actions = [])
dp.send_msg(mod)
secondmatch = parser.OFPMatch(dl_type=ether.ETH_TYPE_IP, dl_dst=haddr_to_bin("00:00:00:00:00:03"), dl_src=haddr_to_bin("00:00:00:00:00:02"))
mod = parser.OFPFlowMod(datapath = dp, match = secondmatch, cookie=0, command=ofproto.OFPFC_ADD, hard_timeout = 0, priority=ofproto.OFP_DEFAULT_PRIORITY, actions = [])
dp.send_msg(mod)
开发者ID:Sy4z,项目名称:OpenFlow-Switch,代码行数:9,代码来源:simple_switch.py
示例12: to_ofp_match
def to_ofp_match(self):
kwargs = self.__dict__.copy()
if self.dl_src is not None:
kwargs["dl_src"] = haddr_to_bin(self.dl_src)
if self.dl_dst is not None:
kwargs["dl_dst"] = haddr_to_bin(self.dl_dst)
return OFPMatch(**kwargs)
开发者ID:shimojo-lab,项目名称:flowsieve,代码行数:9,代码来源:acl_result.py
示例13: build_rule
def build_rule(in_port=None, nw_dst=None, nw_src=None, nw_proto=None,
dl_dst=None, dl_src=None, registers=None, tun_id=None,
dl_type=None):
rule = ClsRule()
if in_port is not None:
rule.set_in_port(in_port)
if dl_dst is not None:
dl_dst = haddr_to_bin(dl_dst)
rule.set_dl_dst(dl_dst)
if dl_src is not None:
dl_src = haddr_to_bin(dl_src)
rule.set_dl_src(dl_src)
if dl_type is None and (nw_dst is not None or nw_src is not None):
dl_type = ether_types.ETH_TYPE_IP
if dl_type is not None:
rule.set_dl_type(dl_type)
if nw_dst is not None:
if isinstance(nw_dst, dict):
nw_dst = nw_dst['destination']
if isinstance(nw_dst, six.string_types):
nw_dst = ip.ipv4_to_int(nw_dst)
if isinstance(nw_dst, tuple):
rule.set_nw_dst_masked(nw_dst[0], nw_dst[1])
else:
rule.set_nw_dst(nw_dst)
if nw_src is not None:
if isinstance(nw_src, dict):
nw_src = nw_src['destination']
if isinstance(nw_src, six.string_types):
nw_src = ip.ipv4_to_int(nw_src)
if isinstance(nw_src, tuple):
rule.set_nw_src_masked(nw_src[0], nw_src[1])
else:
rule.set_nw_src(nw_src)
if registers is not None:
for k, v in registers.iteritems():
rule.set_reg(k, v)
if tun_id is not None:
rule.set_tun_id(tun_id)
if nw_proto is not None:
rule.set_nw_proto(nw_proto)
return rule
开发者ID:alanquillin,项目名称:pytexas2015,代码行数:57,代码来源:flows.py
示例14: _to_match_eth
def _to_match_eth(value):
eth_mask = value.split('/')
# MAC address
eth = mac.haddr_to_bin(eth_mask[0])
# mask
mask = mac.haddr_to_bin('ff:ff:ff:ff:ff:ff')
if len(eth_mask) == 2:
mask = mac.haddr_to_bin(eth_mask[1])
return eth, mask
开发者ID:Aminiok,项目名称:ryu,代码行数:9,代码来源:test_ofctl.py
示例15: add_flow_eth
def add_flow_eth(self, datapath, msg, flow_actions, **kwargs):
"""
Add an ethernet (non-IP) flow table entry to a switch.
Returns 1 for success or 0 for any type of error
Required kwargs are:
priority (0)
buffer_id (None)
idle_timeout (5)
hard_timeout (0)
Uses Ethertype in match to prevent matching against IPv4
or IPv6 flows
"""
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
pkt = packet.Packet(msg.data)
eth = pkt.get_protocol(ethernet.ethernet)
in_port=flow_actions['in_port']
idle_timeout=kwargs['idle_timeout']
hard_timeout=kwargs['hard_timeout']
buffer_id=kwargs['buffer_id']
priority=kwargs['priority']
#*** Build a match that is dependant on the IP and OpenFlow versions:
if (eth.ethertype != 0x0800 and
ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION):
match = self.get_flow_match(datapath, ofproto.OFP_VERSION,
in_port=in_port,
dl_src=haddr_to_bin(eth.src),
dl_dst=haddr_to_bin(eth.dst),
dl_type=eth.ethertype)
self.logger.debug("event=add_flow ofv=%s match_type=Non-IP "
"match=%s", ofproto.OFP_VERSION, match)
elif (eth.ethertype != 0x0800 and
ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION):
match = self.get_flow_match(datapath, ofproto.OFP_VERSION,
in_port=in_port,
dl_src=eth.src,
dl_dst=eth.dst,
dl_type=eth.ethertype)
self.logger.debug("event=add_flow ofv=%s match_type=Non-IP "
"match=%s", ofproto.OFP_VERSION, match)
else:
#*** Possibly an unsupported OF version. Log and return 0:
self.logger.error("event=add_flow error=E1000028 Did not compute. "
"ofv=%s pkt=%s", ofproto.OFP_VERSION, pkt)
return 0
#*** Get the actions to install for the match:
actions = self.get_actions(datapath, ofproto.OFP_VERSION,
flow_actions['out_port'], flow_actions['out_queue'])
self.logger.debug("actions=%s", actions)
#*** Now have a match and actions so call add_flow to instantiate it:
_result = self.add_flow(datapath, match, actions,
priority=priority, buffer_id=buffer_id,
idle_timeout=idle_timeout,
hard_timeout=hard_timeout)
self.logger.debug("result is %s", _result)
return _result
开发者ID:EnjoyHacking,项目名称:nmeta,代码行数:56,代码来源:controller_abstraction.py
示例16: _packet_in_handler
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
pkt = packet.Packet(msg.data)
eth = pkt.get_protocol(ethernet.ethernet)
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, {})
self.logger.info("packet in %s %s %s %s", dpid, src, 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]
# install a flow to avoid packet_in next time
#ARP Packets......................................................................
if eth.ethertype == ETH_ARP:
match = datapath.ofproto_parser.OFPMatch(in_port=msg.in_port, dl_type = ETH_ARP,
dl_src=haddr_to_bin(src), dl_dst=haddr_to_bin(dst))
self.add_flow(datapath, match, out_port, 5, 0)
self.forwardPacket(msg, out_port)
# IP Packets.......................................................................
if eth.ethertype == ETH_IP:
match = datapath.ofproto_parser.OFPMatch(in_port=msg.in_port, dl_type = ETH_IP,
dl_src=haddr_to_bin(src), dl_dst=haddr_to_bin(dst))
if (msg.in_port in FW_INPORTS) or (self.match_in_states(out_port, match, datapath)):
if msg.in_port in FW_INPORTS:
self.add_match_state(out_port, match)
self.add_flow(datapath, match, out_port, 5, 0)
self.forwardPacket(msg, out_port)
else :
#DROP packets
#add flow and packet_out with no actions
self.add_flow(datapath, match, None, 5, 0)
#flood packet if ARP..................................................................
else:
out_port = ofproto.OFPP_FLOOD
if eth.ethertype == ETH_ARP:
#if packet is ARP, foward packet (flood ports)
self.forwardPacket(msg, out_port)
开发者ID:pablomuri,项目名称:ryu_stealth_firewall,代码行数:54,代码来源:statefull_firewall.py
示例17: isaValidadSubnet
def isaValidadSubnet(ipdest,ipsrc):
if ipdest in self.ip_mac_port.keys():
masc= self.ip_mac_port[ipdest][0]
hola = haddr_to_bin(masc)
ip1bin = haddr_to_bin(ipdest)
ip2bin = haddr_to_bin(ipsrc)
for i in hola
if(i==1)
if ip1bin[i]!=ip2bin[i]
return false
return true
开发者ID:AndresCidoncha,项目名称:LabRedes,代码行数:12,代码来源:ryu_flood_example.py
示例18: to_match_eth
def to_match_eth(value):
eth_mask = value.split("/")
# MAC address
eth = mac.haddr_to_bin(eth_mask[0])
# mask
mask = mac.haddr_to_bin("ff:ff:ff:ff:ff:ff")
if len(eth_mask) == 2:
mask = mac.haddr_to_bin(eth_mask[1])
return eth, mask
开发者ID:dyson-yamashita,项目名称:ryu,代码行数:12,代码来源:ofctl_v1_2.py
示例19: add_flow2
def add_flow2(self, datapath, in_port, src, dst, actions):
ofproto = datapath.ofproto
match = datapath.ofproto_parser.OFPMatch(
in_port=in_port, dl_src = haddr_to_bin(src), dl_dst=haddr_to_bin(dst))
mod = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=match, 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_msg(mod)
开发者ID:kyuhojeong,项目名称:ipop-openflow-integration,代码行数:13,代码来源:ipop-integration-switch.py
示例20: to_actions
def to_actions(dp, acts):
actions = []
for a in acts:
action_type = a.get('type')
if action_type == 'OUTPUT':
port = UTIL.ofp_port_from_user(
a.get('port', ofproto_v1_0.OFPP_NONE))
# NOTE: The reason of this magic number (0xffe5)
# is because there is no good constant in of1.0.
# The same value as OFPCML_MAX of of1.2 and of1.3 is used.
max_len = int(a.get('max_len', 0xffe5))
actions.append(dp.ofproto_parser.OFPActionOutput(port, max_len))
elif action_type == 'SET_VLAN_VID':
vlan_vid = int(a.get('vlan_vid', 0xffff))
actions.append(dp.ofproto_parser.OFPActionVlanVid(vlan_vid))
elif action_type == 'SET_VLAN_PCP':
vlan_pcp = int(a.get('vlan_pcp', 0))
actions.append(dp.ofproto_parser.OFPActionVlanPcp(vlan_pcp))
elif action_type == 'STRIP_VLAN':
actions.append(dp.ofproto_parser.OFPActionStripVlan())
elif action_type == 'SET_DL_SRC':
dl_src = haddr_to_bin(a.get('dl_src'))
actions.append(dp.ofproto_parser.OFPActionSetDlSrc(dl_src))
elif action_type == 'SET_DL_DST':
dl_dst = haddr_to_bin(a.get('dl_dst'))
actions.append(dp.ofproto_parser.OFPActionSetDlDst(dl_dst))
elif action_type == 'SET_NW_SRC':
nw_src = ipv4_to_int(a.get('nw_src'))
actions.append(dp.ofproto_parser.OFPActionSetNwSrc(nw_src))
elif action_type == 'SET_NW_DST':
nw_dst = ipv4_to_int(a.get('nw_dst'))
actions.append(dp.ofproto_parser.OFPActionSetNwDst(nw_dst))
elif action_type == 'SET_NW_TOS':
nw_tos = int(a.get('nw_tos', 0))
actions.append(dp.ofproto_parser.OFPActionSetNwTos(nw_tos))
elif action_type == 'SET_TP_SRC':
tp_src = int(a.get('tp_src', 0))
actions.append(dp.ofproto_parser.OFPActionSetTpSrc(tp_src))
elif action_type == 'SET_TP_DST':
tp_dst = int(a.get('tp_dst', 0))
actions.append(dp.ofproto_parser.OFPActionSetTpDst(tp_dst))
elif action_type == 'ENQUEUE':
port = UTIL.ofp_port_from_user(
a.get('port', ofproto_v1_0.OFPP_NONE))
queue_id = UTIL.ofp_queue_from_user(a.get('queue_id', 0))
actions.append(dp.ofproto_parser.OFPActionEnqueue(port, queue_id))
else:
LOG.error('Unknown action type')
return actions
开发者ID:Huangmachi,项目名称:ryu,代码行数:50,代码来源:ofctl_v1_0.py
注:本文中的ryu.lib.mac.haddr_to_bin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论