Ticket #31: scapy.patch

File scapy.patch, 3.7 kB (added by craig@freescale.com, 2 years ago)

Patch which adds support for MPLS and IGMPv2 Packet headers

  • ./scapy.py

    old new  
    1919##                                                                         ## 
    2020############################################################################# 
    2121 
     22# Revision 1.0.5.1F  2006/10/17 16:50:19  yl 
     23# - Added MPLS and IGMPv2 by Yi Lei 
    2224# 
    2325# $Log: scapy.py,v $ 
    2426# Revision 1.0.5.1  2006/10/19 15:56:43  pbi 
     
    17301732 
    17311733from __future__ import generators 
    17321734 
    1733 RCSID="$Id: scapy.py,v 1.0.5.1 2006/10/19 15:56:43 pbi Exp $" 
     1735RCSID="$Id: scapy.py,v 1.0.5.1F 2006/10/19 15:56:43 pbi Exp $" 
    17341736 
    17351737VERSION = RCSID.split()[2]+"beta" 
    17361738 
     
    80538055                   ShortEnumField("RR_CLASS",1,{1:"INTERNET"}), 
    80548056                   IntField("TTL",0), 
    80558057                   ShortField("RDLENGTH",83), 
    8056                   ByteField("NUM_NAMES",1)] 
     8058                  ByteField("NUM_NAMES",1)] 
    80578059 
    80588060# Service for Node Status Response 
    80598061class NBNSNodeStatusResponseService(Packet): 
     
    85038505                    IntField("padding2", 0) ] 
    85048506 
    85058507 
     8508class MPLS(Packet): 
     8509    name = "MPLS" 
     8510    fields_desc =  [ BitField("label", 3, 20), 
     8511                     BitField("cos", 0, 3), 
     8512                     BitField("s", 1, 1), 
     8513                     ByteField("ttl", 0)  ] 
     8514 
     8515igmptypes = { 0x11 : "membership query", 
     8516              0x16 : "version 2 membership report", 
     8517              0x17 : "leave group", 
     8518              0x12 : "version 1 membership report" } 
     8519 
     8520class IGMPV2(Packet): 
     8521    name = "IGMPV2" 
     8522    fields_desc = [ ByteEnumField("type",0x11, igmptypes), 
     8523                    ByteField("maxResTime",1600), 
     8524                    XShortField("chksum", None), 
     8525                    IPField("gda", "0.0.0.0")] 
     8526    def post_build(self, p, pay): 
     8527        p += pay 
     8528        if self.chksum is None: 
     8529            ck = checksum(p) 
     8530            p = p[:2]+chr(ck>>8)+chr(ck&0xff)+p[4:] 
     8531        return p 
    85068532 
     8533     
    85078534################# 
    85088535## Bind layers ## 
    85098536################# 
     
    85598586                ( Ether,  EAPOL,    { "type" : 0x888e, "dst" : "01:80:c2:00:00:03" } ), 
    85608587                ( Ether,  PPPoED,   { "type" : 0x8863 } ), 
    85618588                ( Ether,  PPPoE,    { "type" : 0x8864 } ), 
     8589                ( Ether,  MPLS,    { "type" : 0x8847 } ), 
     8590                ( MPLS,   IP,       { }                 ),                   
    85628591                ( CookedLinux,  LLC,      { "proto" : 0x007a } ), 
    85638592                ( CookedLinux,  Dot1Q,    { "proto" : 0x8100 } ), 
    85648593                ( CookedLinux,  Ether,    { "proto" : 0x0001 } ), 
     
    85858614                ( IPerror,IPerror,  { "frag" : 0, "proto" : socket.IPPROTO_IP   } ), 
    85868615                ( IPerror,ICMPerror,{ "frag" : 0, "proto" : socket.IPPROTO_ICMP } ), 
    85878616                ( IPerror,TCPerror, { "frag" : 0, "proto" : socket.IPPROTO_TCP  } ), 
    8588                 ( IPerror,UDPerror, { "frag" : 0, "proto" : socket.IPPROTO_UDP  } ), 
     8617                ( IPerror,UDPerror, { "frag" : 0, "proto" : socket.IPPROTO_UDP  } ),                              
    85898618                ( IP,     IP,       { "frag" : 0, "proto" : socket.IPPROTO_IP   } ), 
    85908619                ( IP,     ICMP,     { "frag" : 0, "proto" : socket.IPPROTO_ICMP } ), 
    85918620                ( IP,     TCP,      { "frag" : 0, "proto" : socket.IPPROTO_TCP  } ), 
    85928621                ( IP,     UDP,      { "frag" : 0, "proto" : socket.IPPROTO_UDP  } ), 
    85938622                ( IP,     GRE,      { "frag" : 0, "proto" : socket.IPPROTO_GRE  } ), 
     8623                ( IP,     IGMPV2,   { "frag" : 0, "proto" : socket.IPPROTO_IGMP } ), 
    85948624                ( UDP,    MGCP,     { "dport" : 2727 } ), 
    85958625                ( UDP,    MGCP,     { "sport" : 2727 } ), 
    85968626                ( UDP,    DNS,      { "dport" : 53 } ),