本文整理汇总了Python中ryu.lib.packet.ipv6.ipv6函数的典型用法代码示例。如果您正苦于以下问题:Python ipv6函数的具体用法?Python ipv6怎么用?Python ipv6使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ipv6函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_default_args
def test_default_args(self):
ip = ipv6.ipv6()
buf = ip.serialize(bytearray(), None)
res = struct.unpack(ipv6.ipv6._PACK_STR, str(buf))
eq_(res[0], 6 << 28)
eq_(res[1], 0)
eq_(res[2], 6)
eq_(res[3], 255)
eq_(res[4], addrconv.ipv6.text_to_bin('::'))
eq_(res[5], addrconv.ipv6.text_to_bin('::'))
# with extension header
ip = ipv6.ipv6(
nxt=0, ext_hdrs=[
ipv6.hop_opts(58, 0, [
ipv6.option(5, 2, '\x00\x00'),
ipv6.option(1, 0, None)])])
buf = ip.serialize(bytearray(), None)
res = struct.unpack(ipv6.ipv6._PACK_STR + '8s', str(buf))
eq_(res[0], 6 << 28)
eq_(res[1], 8)
eq_(res[2], 0)
eq_(res[3], 255)
eq_(res[4], addrconv.ipv6.text_to_bin('::'))
eq_(res[5], addrconv.ipv6.text_to_bin('::'))
eq_(res[6], '\x3a\x00\x05\x02\x00\x00\x01\x00')
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:28,代码来源:test_ipv6.py
示例2: create_packet
def create_packet(self, vid, mld):
self.logger.debug("")
# VLAN
vln = vlan.vlan(vid=vid, ethertype=ether.ETH_TYPE_IPV6)
# Hop-By-Hop
ext_headers = [ipv6.hop_opts(nxt=inet.IPPROTO_ICMPV6, data=[
ipv6.option(type_=5, len_=2, data="\x00\x00"),
ipv6.option(type_=1, len_=0)])]
# MLDV2_Query
if type(mld) == icmpv6.mldv2_query:
eth_dst = self.QUERY_DST
ip_dst = self.QUERY_DST_IP
if mld.address != "::":
ip_str = netaddr.ip.IPAddress(mld.address).\
format(netaddr.ipv6_verbose())
eth_dst = "33:33:" + ip_str[30:32] + ":" + \
ip_str[32:34] + ":" + ip_str[35:37] + ":" + ip_str[37:39]
ip_dst = mld.address
# ETHER
eth = ethernet.ethernet(
ethertype=ether.ETH_TYPE_8021Q,
src=self.ifinfo[self.IF_KEY_MAC], dst=eth_dst)
# IPV6 with ExtensionHeader
ip6 = ipv6.ipv6(
src=self.ifinfo[self.IF_KEY_IP6], dst=ip_dst,
hop_limit=1, nxt=inet.IPPROTO_HOPOPTS, ext_hdrs=ext_headers)
# MLD Query
icmp6 = icmpv6_extend(
type_=icmpv6.MLD_LISTENER_QUERY, data=mld)
# MLDV2_Report
elif type(mld) == icmpv6.mldv2_report:
# ETHER
eth = ethernet.ethernet(
ethertype=ether.ETH_TYPE_8021Q,
src=self.ifinfo[self.IF_KEY_MAC], dst=self.REPORT_DST)
# IPV6 with ExtensionHeader
ip6 = ipv6.ipv6(
src=self.ifinfo[self.IF_KEY_IP6], dst=self.REPORT_DST_IP,
hop_limit=1, nxt=inet.IPPROTO_HOPOPTS, ext_hdrs=ext_headers)
# MLD Report
icmp6 = icmpv6_extend(
type_=icmpv6.MLDV2_LISTENER_REPORT, data=mld)
# ether - vlan - ipv6 - icmpv6 ( - mldv2 )
sendpkt = eth / vln / ip6 / icmp6
sendpkt.serialize()
self.logger.debug("created packet(ryu) : %s", str(sendpkt))
return sendpkt
开发者ID:ntts-clo,项目名称:mld-ryu,代码行数:58,代码来源:mld_process.py
示例3: control_plane_icmpv6_handler
def control_plane_icmpv6_handler(self, in_port, vlan, eth_src,
ipv6_pkt, icmpv6_pkt):
flowmods = []
pkt = self.build_ethernet_pkt(
eth_src, in_port, vlan, ether.ETH_TYPE_IPV6)
if icmpv6_pkt.type_ == icmpv6.ND_NEIGHBOR_SOLICIT:
dst = icmpv6_pkt.data.dst
ipv6_reply = ipv6.ipv6(
src=dst,
dst=ipv6_pkt.src,
nxt=inet.IPPROTO_ICMPV6,
hop_limit=ipv6_pkt.hop_limit)
pkt.add_protocol(ipv6_reply)
icmpv6_reply = icmpv6.icmpv6(
type_=icmpv6.ND_NEIGHBOR_ADVERT,
data=icmpv6.nd_neighbor(
dst=dst,
option=icmpv6.nd_option_tla(hw_src=self.FAUCET_MAC),
res=7))
pkt.add_protocol(icmpv6_reply)
pkt.serialize()
flowmods.extend([self.valve_packetout(in_port, pkt.data)])
elif icmpv6_pkt.type_ == icmpv6.ND_NEIGHBOR_ADVERT:
resolved_ip_gw = ipaddr.IPv6Address(icmpv6_pkt.data.dst)
self.logger.info('ND response %s for %s', eth_src, resolved_ip_gw)
is_updated = None
if resolved_ip_gw in vlan.nd_cache:
cached_eth_dst = vlan.nd_cache[resolved_ip_gw].eth_src
if cached_eth_dst != eth_src:
is_updated = True
else:
is_updated = False
for ip_dst, ip_gw in vlan.ipv6_routes.iteritems():
if ip_gw == resolved_ip_gw:
flowmods.extend(
self.add_resolved_route(
ether.ETH_TYPE_IPV6, vlan, vlan.nd_cache,
ip_gw, ip_dst, eth_src,is_updated))
elif icmpv6_pkt.type_ == icmpv6.ICMPV6_ECHO_REQUEST:
dst = ipv6_pkt.dst
ipv6_reply = ipv6.ipv6(
src=dst,
dst=ipv6_pkt.src,
nxt=inet.IPPROTO_ICMPV6,
hop_limit=ipv6_pkt.hop_limit)
pkt.add_protocol(ipv6_reply)
icmpv6_reply = icmpv6.icmpv6(
type_=icmpv6.ICMPV6_ECHO_REPLY,
data=icmpv6.echo(
id_=icmpv6_pkt.data.id,
seq=icmpv6_pkt.data.seq,
data=icmpv6_pkt.data.data))
pkt.add_protocol(icmpv6_reply)
pkt.serialize()
flowmods.extend([self.valve_packetout(in_port, pkt.data)])
return flowmods
开发者ID:onfsdn,项目名称:firewall,代码行数:58,代码来源:valve.py
示例4: test_default_args
def test_default_args(self):
la = icmpv6.nd_option_sla()
buf = la.serialize()
res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, str(buf))
eq_(res[0], icmpv6.ND_OPTION_SLA)
eq_(res[1], len(icmpv6.nd_option_sla()) / 8)
eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00'))
# with nd_neighbor
prev = ipv6(nxt=inet.IPPROTO_ICMPV6)
ic = icmpv6.icmpv6(
type_=icmpv6.ND_NEIGHBOR_ADVERT,
data=icmpv6.nd_neighbor(
option=icmpv6.nd_option_tla()))
prev.serialize(ic, None)
buf = ic.serialize(bytearray(), prev)
res = struct.unpack(icmpv6.icmpv6._PACK_STR, str(buf[:4]))
eq_(res[0], icmpv6.ND_NEIGHBOR_ADVERT)
eq_(res[1], 0)
eq_(res[2], icmpv6_csum(prev, buf))
res = struct.unpack(icmpv6.nd_neighbor._PACK_STR, str(buf[4:24]))
eq_(res[0], 0)
eq_(res[1], addrconv.ipv6.text_to_bin('::'))
res = struct.unpack(icmpv6.nd_option_tla._PACK_STR, str(buf[24:]))
eq_(res[0], icmpv6.ND_OPTION_TLA)
eq_(res[1], len(icmpv6.nd_option_tla()) / 8)
eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00'))
# with nd_router_solicit
prev = ipv6(nxt=inet.IPPROTO_ICMPV6)
ic = icmpv6.icmpv6(
type_=icmpv6.ND_ROUTER_SOLICIT,
data=icmpv6.nd_router_solicit(
option=icmpv6.nd_option_sla()))
prev.serialize(ic, None)
buf = ic.serialize(bytearray(), prev)
res = struct.unpack(icmpv6.icmpv6._PACK_STR, str(buf[:4]))
eq_(res[0], icmpv6.ND_ROUTER_SOLICIT)
eq_(res[1], 0)
eq_(res[2], icmpv6_csum(prev, buf))
res = struct.unpack(icmpv6.nd_router_solicit._PACK_STR, str(buf[4:8]))
eq_(res[0], 0)
res = struct.unpack(icmpv6.nd_option_sla._PACK_STR, str(buf[8:]))
eq_(res[0], icmpv6.ND_OPTION_SLA)
eq_(res[1], len(icmpv6.nd_option_sla()) / 8)
eq_(res[2], addrconv.mac.text_to_bin('00:00:00:00:00:00'))
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:57,代码来源:test_icmpv6.py
示例5: setUp_with_routing_type3
def setUp_with_routing_type3(self):
self.routing_nxt = 6
self.routing_size = 6
self.routing_type = 3
self.routing_seg = 2
self.routing_cmpi = 0
self.routing_cmpe = 0
self.routing_adrs = ["2001:db8:dead::1", "2001:db8:dead::2",
"2001:db8:dead::3"]
self.routing = ipv6.routing_type3(
self.routing_nxt, self.routing_size,
self.routing_type, self.routing_seg,
self.routing_cmpi, self.routing_cmpe,
self.routing_adrs)
self.ext_hdrs = [self.routing]
self.payload_length += len(self.routing)
self.nxt = ipv6.routing.TYPE
self.ip = ipv6.ipv6(
self.version, self.traffic_class, self.flow_label,
self.payload_length, self.nxt, self.hop_limit, self.src,
self.dst, self.ext_hdrs)
self.buf = struct.pack(
ipv6.ipv6._PACK_STR, self.v_tc_flow,
self.payload_length, self.nxt, self.hop_limit,
addrconv.ipv6.text_to_bin(self.src),
addrconv.ipv6.text_to_bin(self.dst))
self.buf += self.routing.serialize()
开发者ID:AkiraSuu,项目名称:ryu,代码行数:27,代码来源:test_ipv6.py
示例6: create_packet
def create_packet(self, src, dst, srcip, dstip, mld):
self.logger.debug("")
# ETHER
eth = ethernet.ethernet(
# ethertype=ether.ETH_TYPE_8021Q, dst=dst, src=src)
ethertype=ether.ETH_TYPE_IPV6, dst=dst, src=src)
# TODO
"""
# VLAN
vln = vlan.vlan(vid=100, ethertype=ether.ETH_TYPE_IPV6)
"""
# IPV6 with Hop-By-Hop
ext_headers = [ipv6.hop_opts(nxt=inet.IPPROTO_ICMPV6,
data=[ipv6.option(type_=5, len_=2, data="\x00\x00"),
ipv6.option(type_=1, len_=0)])]
ip6 = ipv6.ipv6(src=srcip, dst=dstip, hop_limit=1,
nxt=inet.IPPROTO_HOPOPTS, ext_hdrs=ext_headers)
# MLDV2
if type(mld) == icmpv6.mldv2_query:
icmp6 = icmpv6_extend(
type_=icmpv6.MLD_LISTENER_QUERY, data=mld)
elif type(mld) == icmpv6.mldv2_report:
icmp6 = icmpv6_extend(
type_=icmpv6.MLDV2_LISTENER_REPORT, data=mld)
# ether - vlan - ipv6 - icmpv6 ( - mldv2 )
# sendpkt = eth / vln / ip6 / icmp6
sendpkt = eth / ip6 / icmp6
sendpkt.serialize()
self.logger.debug("created packet(ryu) : %s", str(sendpkt))
return sendpkt
开发者ID:t-koshiba,项目名称:trial,代码行数:34,代码来源:mld_process.py
示例7: _send_icmp_NS
def _send_icmp_NS(self, datapath, outport_no, dst_ip):
src_mac_addr = \
str(self.dpid_to_switch[datapath.id].ports[outport_no].hw_addr)
src_ip = \
str(self.dpid_to_switch[datapath.id].ports[outport_no].gateway.gw_ipv6)
p = packet.Packet()
dst_mac, dst_ip_multicast = self._generate_dst_for_NS(dst_ip)
dst_mac = str(dst_mac)
dst_ip_multicast = str(dst_ip_multicast)
dst_ip = str(dst_ip)
e = ethernet.ethernet(dst = dst_mac, src = src_mac_addr,
ethertype = ether.ETH_TYPE_IPV6)
ip6 = ipv6.ipv6(version = 6, traffic_class = 0, flow_label = 0,
# 4byte ICMP header, 4byte reserved, 16byte target address,
# 8byte "source link-layer address" option
# next header value for ICMPv6 is 58
payload_length = 32, nxt = 58, hop_limit = 255,
src = src_ip, dst = dst_ip_multicast)
# source link-layer address
sla_addr = icmpv6.nd_option_sla(hw_src = src_mac_addr)
# ns for neighbor solicit; res for reserved, but actually is a flag,
# see comments on "nd_option_tla" above
ns = icmpv6.nd_neighbor(res = 4, dst = dst_ip, data = sla_addr)
ic6 = icmpv6.icmpv6(type_ = icmpv6.ND_NEIGHBOR_SOLICIT, code = 0,
# checksum = 0 then ryu calculate for you
csum = 0, data = ns)
p.add_protocol(e)
p.add_protocol(ip6)
p.add_protocol(ic6)
p.serialize()
datapath.send_packet_out(in_port = ofproto_v1_0.OFPP_NONE,
actions = [datapath.ofproto_parser.OFPActionOutput(outport_no)],
data = p.data)
开发者ID:cannium,项目名称:openflow_routing_framework,代码行数:33,代码来源:routing.py
示例8: test_regist_multicast_info
def test_regist_multicast_info(self):
"""
self.logger.debug("")
# TODO p-inしたReportの情報をメモリ上に保持する
"""
# TODO 実装待ち
self.mld_proc.regist_multicast_info(ipv6.ipv6())
开发者ID:t-koshiba,项目名称:trial,代码行数:7,代码来源:test_mld_process.py
示例9: setUp_with_dst_opts
def setUp_with_dst_opts(self):
self.opt1_type = 5
self.opt1_len = 2
self.opt1_data = '\x00\x00'
self.opt2_type = 1
self.opt2_len = 0
self.opt2_data = None
self.options = [
ipv6.option(self.opt1_type, self.opt1_len, self.opt1_data),
ipv6.option(self.opt2_type, self.opt2_len, self.opt2_data),
]
self.dst_opts_nxt = 6
self.dst_opts_size = 0
self.dst_opts = ipv6.dst_opts(
self.dst_opts_nxt, self.dst_opts_size, self.options)
self.ext_hdrs = [self.dst_opts]
self.payload_length += len(self.dst_opts)
self.nxt = ipv6.dst_opts.TYPE
self.ip = ipv6.ipv6(
self.version, self.traffic_class, self.flow_label,
self.payload_length, self.nxt, self.hop_limit, self.src,
self.dst, self.ext_hdrs)
self.buf = struct.pack(
ipv6.ipv6._PACK_STR, self.v_tc_flow,
self.payload_length, self.nxt, self.hop_limit,
addrconv.ipv6.text_to_bin(self.src),
addrconv.ipv6.text_to_bin(self.dst))
self.buf += self.dst_opts.serialize()
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:28,代码来源:test_ipv6.py
示例10: nd_advert
def nd_advert(vid, eth_src, eth_dst, src_ip, dst_ip):
"""Return IPv6 neighbor avertisement packet.
Args:
vid (int or None): VLAN VID to use (or None).
eth_src (str): source Ethernet MAC address.
eth_dst (str): destination Ethernet MAC address.
src_ip (ipaddress.IPv6Address): source IPv6 address.
dst_ip (ipaddress.IPv6Address): destination IPv6 address.
Returns:
ryu.lib.packet.ethernet: Serialized IPv6 neighbor discovery packet.
"""
pkt = build_pkt_header(
vid, eth_src, eth_dst, valve_of.ether.ETH_TYPE_IPV6)
ipv6_icmp6 = ipv6.ipv6(
src=src_ip,
dst=dst_ip,
nxt=valve_of.inet.IPPROTO_ICMPV6,
hop_limit=IPV6_MAX_HOP_LIM)
pkt.add_protocol(ipv6_icmp6)
icmpv6_nd_advert = icmpv6.icmpv6(
type_=icmpv6.ND_NEIGHBOR_ADVERT,
data=icmpv6.nd_neighbor(
dst=src_ip,
option=icmpv6.nd_option_tla(hw_src=eth_src), res=7))
pkt.add_protocol(icmpv6_nd_advert)
pkt.serialize()
return pkt
开发者ID:trungdtbk,项目名称:faucet,代码行数:28,代码来源:valve_packet.py
示例11: _handle_icmp
def _handle_icmp(self, datapath, port, pkt_ethernet, pkt_ipv, pkt_icmp):
# if pkt_icmp.type != icmp.ICMP_ECHO_REQUEST:
pkt = packet.Packet()
pkt.add_protocol(ethernet.ethernet(ethertype=pkt_ethernet.ethertype,
# dst=pkt_ethernet.src,
# src=self.hw_addr))
dst=pkt_ethernet.dst,
src=pkt_ethernet.src))
# pkt.add_protocol(ipv4.ipv4(dst=pkt_ipv4.src,
# src=self.ip_addr,
# proto=pkt_ipv4.proto))
""" IPv6 update
pkt.add_protocol(ipv4.ipv4(dst=pkt_ipv.src,
src=pkt_ethernet.src,
proto=pkt_ipv.proto))
pkt.add_protocol(icmp.icmp(type_=icmp.ICMP_ECHO_REPLY,
code=icmp.ICMP_ECHO_REPLY_CODE,
csum=0,
data=pkt_icmp.data))
"""
pkt.add_protocol(ipv6.ipv6(dst=pkt_ipv.dst,
src=pkt_ipv.src))
pkt.add_protocol(icmpv6.icmpv6(type_=icmpv6.ICMPV6_ECHO_REPLY,
csum=0,
data=pkt_icmp.data))
self._send_packet(datapath, port, pkt)
开发者ID:takeuchi17401,项目名称:performance_test,代码行数:28,代码来源:sendMLD.py
示例12: build_pkt
def build_pkt(pkt):
layers = []
if 'arp_target_ip' in pkt:
ethertype = 0x806
layers.append(arp.arp(dst_ip=pkt['arp_target_ip']))
elif 'ipv6_src' in pkt:
ethertype = 0x86DD
layers.append(ipv6.ipv6(src=pkt['ipv6_src'], dst=pkt['ipv6_src']))
else:
ethertype = 0x800
if 'ipv4_src' in pkt:
net = ipv4.ipv4(src=pkt['ipv4_src'], dst=pkt['ipv4_dst'])
else:
net = ipv4.ipv4()
layers.append(net)
if 'vid' in pkt:
tpid = 0x8100
layers.append(vlan.vlan(vid=pkt['vid'], ethertype=ethertype))
else:
tpid = ethertype
eth = ethernet.ethernet(
dst=pkt['eth_dst'],
src=pkt['eth_src'],
ethertype=tpid)
layers.append(eth)
result = packet.Packet()
for layer in layers:
result.add_protocol(layer)
return result
开发者ID:Baloc,项目名称:faucet,代码行数:29,代码来源:test_valve.py
示例13: createPacket
def createPacket(self, src, dst, srcip, dstip):
# create send packet
# ether - vlan - ipv6 - icmpv6 ( - mldv2 )
sendpkt = packet.Packet()
sendpkt.add_protocol(ethernet.ethernet(
ethertype=ether.ETH_TYPE_8021Q, dst=dst, src=src))
sendpkt.add_protocol(vlan.vlan(
pcp=0, cfi=0, vid=100, ethertype=ether.ETH_TYPE_IPV6))
sendpkt.add_protocol(ipv6.ipv6(
src=srcip, dst=dstip, nxt=inet.IPPROTO_ICMPV6))
sendpkt.add_protocol(icmpv6.icmpv6(
type_=icmpv6.ICMPV6_MEMBERSHIP_QUERY,
data=icmpv6.mldv2_query(address='::')))
'''
sendpkt.add_protocol(icmpv6.icmpv6(
type_=icmpv6.MLDV2_LISTENER_REPORT,
data=icmpv6.mldv2_report(
record_num=2, records=[
icmpv6.mldv2_report_group(type_=1, address='::'),
icmpv6.mldv2_report_group(type_=2, address='::')])))
'''
sendpkt.serialize()
return sendpkt
开发者ID:t-koshiba,项目名称:trial,代码行数:25,代码来源:send_packet_to_asyncoresrv.py
示例14: icmpv6_echo_reply
def icmpv6_echo_reply(eth_src, eth_dst, vid, src_ip, dst_ip, hop_limit,
id_, seq, data):
"""Return IPv6 ICMP echo reply packet.
Args:
eth_src (str): source Ethernet MAC address.
eth_dst (str): destination Ethernet MAC address.
vid (int or None): VLAN VID to use (or None).
src_ip (ipaddr.IPv6Address): source IPv6 address.
dst_ip (ipaddr.IPv6Address): destination IPv6 address.
hop_limit (int): IPv6 hop limit.
id_ (int): identifier for echo reply.
seq (int): sequence number for echo reply.
data (str): payload for echo reply.
Returns:
ryu.lib.packet.ethernet: Serialized IPv6 ICMP echo reply packet.
"""
pkt = build_pkt_header(
eth_src, eth_dst, vid, ether.ETH_TYPE_IPV6)
ipv6_reply = ipv6.ipv6(
src=src_ip,
dst=dst_ip,
nxt=inet.IPPROTO_ICMPV6,
hop_limit=hop_limit)
pkt.add_protocol(ipv6_reply)
icmpv6_reply = icmpv6.icmpv6(
type_=icmpv6.ICMPV6_ECHO_REPLY,
data=icmpv6.echo(id_=id_, seq=seq, data=data))
pkt.add_protocol(icmpv6_reply)
pkt.serialize()
return pkt
开发者ID:Baloc,项目名称:faucet,代码行数:31,代码来源:valve_packet.py
示例15: __init__
def __init__(self, mac_src, mac_dst, ipv6_src, ipv6_dst, ipv6_tgt):
"""
================ =========================================================
Input Parameter Description
================ =========================================================
mac_src String instance
mac_dst String instance
ipv6_src String instance
ipv6_dst String instance
ipv6_tgt String instance
================ =========================================================
================ =========================================================
Attribute Description
================ =========================================================
pkt The Neighbor Solicitation generated packet
================ =========================================================
"""
self.pkt = packet.Packet()
e = ethernet.ethernet(mac_dst, mac_src, ether.ETH_TYPE_IPV6)
i6 = ipv6.ipv6(src=ipv6_src, dst=ipv6_dst, nxt=inet.IPPROTO_ICMPV6)
ic = icmpv6.icmpv6(
type_=icmpv6.ND_NEIGHBOR_SOLICIT,
data=icmpv6.nd_neighbor(dst=ipv6_tgt, option=icmpv6.nd_option_sla(hw_src=mac_src)),
)
self.pkt.add_protocol(e)
self.pkt.add_protocol(i6)
self.pkt.add_protocol(ic)
开发者ID:wuyouke,项目名称:openflow-dmm,代码行数:29,代码来源:ndisc.py
示例16: nd_reply
def nd_reply(eth_src, eth_dst, vid, src_ip, dst_ip, hop_limit):
"""Return IPv6 neighbor discovery reply packet.
Args:
eth_src (str): source Ethernet MAC address.
eth_dst (str): destination Ethernet MAC address.
vid (int or None): VLAN VID to use (or None).
src_ip (ipaddr.IPv6Address): source IPv6 address.
dst_ip (ipaddr.IPv6Address): destination IPv6 address.
hop_limit (int): IPv6 hop limit.
Returns:
ryu.lib.packet.ethernet: Serialized IPv6 neighbor discovery packet.
"""
pkt = build_pkt_header(
eth_src, eth_dst, vid, ether.ETH_TYPE_IPV6)
ipv6_reply = ipv6.ipv6(
src=src_ip,
dst=dst_ip,
nxt=inet.IPPROTO_ICMPV6,
hop_limit=hop_limit)
pkt.add_protocol(ipv6_reply)
icmpv6_reply = icmpv6.icmpv6(
type_=icmpv6.ND_NEIGHBOR_ADVERT,
data=icmpv6.nd_neighbor(
dst=src_ip,
option=icmpv6.nd_option_tla(hw_src=eth_src), res=7))
pkt.add_protocol(icmpv6_reply)
pkt.serialize()
return pkt
开发者ID:Baloc,项目名称:faucet,代码行数:29,代码来源:valve_packet.py
示例17: nd_request
def nd_request(eth_src, vid, src_ip, dst_ip):
"""Return IPv6 neighbor discovery request packet.
Args:
eth_src (str): source Ethernet MAC address.
vid (int or None): VLAN VID to use (or None).
src_ip (ipaddr.IPv6Address): source IPv6 address.
dst_ip (ipaddr.IPv6Address): requested IPv6 address.
Returns:
ryu.lib.packet.ethernet: Serialized IPv6 neighbor discovery packet.
"""
nd_mac = ipv6_link_eth_mcast(dst_ip)
ip_gw_mcast = ipv6_solicited_node_from_ucast(dst_ip)
pkt = build_pkt_header(eth_src, nd_mac, vid, ether.ETH_TYPE_IPV6)
ipv6_pkt = ipv6.ipv6(
src=str(src_ip), dst=ip_gw_mcast, nxt=inet.IPPROTO_ICMPV6)
pkt.add_protocol(ipv6_pkt)
icmpv6_pkt = icmpv6.icmpv6(
type_=icmpv6.ND_NEIGHBOR_SOLICIT,
data=icmpv6.nd_neighbor(
dst=dst_ip,
option=icmpv6.nd_option_sla(hw_src=eth_src)))
pkt.add_protocol(icmpv6_pkt)
pkt.serialize()
return pkt
开发者ID:Baloc,项目名称:faucet,代码行数:25,代码来源:valve_packet.py
示例18: test_send_multicast_info
def test_send_multicast_info(self):
"""
self.logger.debug("")
self.regist_multicast_info(pkt)
# TODO p-outの情報を設定したReportを生成する
# sendpkt = self.create_mldreport(("", ""))
# self.send_packet_to_ryu(sendpkt)
"""
# TODO 実装待ち
self.mld_proc.send_multicast_info(ipv6.ipv6())
开发者ID:t-koshiba,项目名称:trial,代码行数:10,代码来源:test_mld_process.py
示例19: createPacket
def createPacket(self, src, dst, srcip, dstip):
# create send packet
sendpkt = packet.Packet()
sendpkt.add_protocol(ethernet.ethernet(ethertype=ether.ETH_TYPE_8021Q, dst=dst, src=src))
sendpkt.add_protocol(vlan.vlan(pcp=0, cfi=0, vid=100, ethertype=ether.ETH_TYPE_IPV6))
sendpkt.add_protocol(ipv6.ipv6(src=srcip, dst=dstip, nxt=inet.IPPROTO_ICMPV6))
sendpkt.add_protocol(icmpv6.icmpv6(type_=icmpv6.ICMPV6_MEMBERSHIP_QUERY,
data=icmpv6.mldv2_query(address='ff38::1')))
sendpkt.serialize()
return sendpkt
开发者ID:takeuchi17401,项目名称:performance_test,代码行数:10,代码来源:send_mldv2_persec_ipv4.py
示例20: test_serialize
def test_serialize(self):
src_ipv6 = netaddr.IPAddress("fe80::200:ff:fe00:ef").packed
dst_ipv6 = netaddr.IPAddress("fe80::200:ff:fe00:1").packed
prev = ipv6(6, 0, 0, 4, 58, 255, src_ipv6, dst_ipv6)
buf = self.icmp.serialize(bytearray(), prev)
(type_, code, csum) = struct.unpack(self.icmp._PACK_STR, buffer(buf))
eq_(type_, self.type_)
eq_(code, self.code)
eq_(csum, self.csum)
开发者ID:routeflow,项目名称:ryu,代码行数:11,代码来源:test_icmpv6.py
注:本文中的ryu.lib.packet.ipv6.ipv6函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论