作者简介:刘敬一,盛科网络SDN交换机产品线测试主管
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ljyfree@ubuntu:~/scapy-2.3.2/scapy$ cd contrib/ ljyfree@ubuntu:~/scapy-2.3.2/scapy/contrib$ ljyfree@ubuntu:~/scapy-2.3.2/scapy/contrib$ more vxlan.py # RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): # A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks # http://tools.ietf.org/html/rfc7348 # scapy.contrib.description = VXLAN # scapy.contrib.status = loads from scapy.packet import Packet, bind_layers from scapy.layers.l2 import Ether from scapy.layers.inet import UDP from scapy.fields import FlagsField, XByteField, ThreeBytesField _VXLAN_FLAGS = ['R' for i in range(0, 24)] + ['R', 'R', 'R', 'I', 'R', 'R', 'R', 'R', 'R'] class VXLAN(Packet): name = "VXLAN" fields_desc = [FlagsField("flags", 0x08000000, 32, _VXLAN_FLAGS), ThreeBytesField("vni", 0), XByteField("reserved", 0x00)] def mysummary(self): return self.sprintf("VXLAN (vni=%VXLAN.vni%)") bind_layers(UDP, VXLAN, dport=4789) bind_layers(VXLAN, Ether) ljyfree@ubuntu:~/scapy-2.3.2/scapy/contrib$ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ljyfree@ubuntu:~/scapy-2.3.2/scapy/contrib$ more all.py from scapy.config import conf from scapy.error import log_loading import logging log = logging.getLogger("scapy.loading") def _import_star(m): mod = __import__(m, globals, locals) for k,v in mod.__dict__.iteritems: globals[k] = v _contrib_modules_ = ["bgp","igmp","igmpv3","ldp","mpls","ospf","ripng","rsvp", "vxlan"] for _l in _contrib_modules_: log_loading.debug("Loading module %s" % _l) try: _import_star(_l) except Exception,e: log.warning("can't import module %s: %s" % (_l,e)) ljyfree@ubuntu:~/scapy-2.3.2/scapy/contrib$ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ljyfree@ubuntu:~/scapy-2.3.2$ scapy INFO: Can't import python gnuplot wrapper . Won't be able to plot. INFO: Can't import PyX. Won't be able to use psdump or pdfdump. WARNING: No route found for IPv6 destination :: (no default route?) WARNING: can't import module igmp: name 'IP' is not defined IGMPv3 is still under development - Nov 2010 WARNING: can't import module igmpv3: name 'IP' is not defined WARNING: can't import module ospf: name 'IP6Field' is not defined Welcome to Scapy (2.3.2) >>> >>> >>> p = Ether/IP/UDP/VXLAN >>> p.show ###[ Ethernet ]### dst= ff:ff:ff:ff:ff:ff src= 00:00:00:00:00:00 type= 0x800 ###[ IP ]### version= 4 ihl= None tos= 0x0 len= None id= 1 flags= frag= 0 ttl= 64 proto= udp chksum= None src= 127.0.0.1 dst= 127.0.0.1 \options\ ###[ UDP ]### sport= domain dport= 4789 len= None chksum= None ###[ VXLAN ]### flags= I vni= 0 reserved= 0x0 >>> |
欢迎光临 51学通信论坛2017新版 (http://bbs.51xuetongxin.com/) | Powered by Discuz! X3 |