Changeset 5440

Show
Ignore:
Timestamp:
03/10/08 16:27:07 (5 months ago)
Author:
hdm
Message:

Patches from Sandor Szucs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/lib/scruby/const.rb

    r5349 r5440  
    3434        # Constants for Ethernet 
    3535        ETHERTYPE_IPv4 = 0x800 
    36         ETHERTYPE_ALL = { ETHERTYPE_IPv4 => "IPv4"} 
     36        ETHERTYPE_ARP = 0x806  
     37        ETHERTYPE_ALL = { ETHERTYPE_IPv4 => "IPv4", 
     38                          ETHERTYPE_ARP => "ARP"} 
    3739 
    3840        # Constants for BSD loopback interfaces 
  • framework3/trunk/lib/scruby/dissector.rb

    r5349 r5440  
    5252                 
    5353        end 
    54  
     54         
     55        # Dissector for ARP  
     56        class ARP<Layer 
     57                Scruby.register_dissector(self) 
     58                def method_missing(method, *args) 
     59                        return Scruby.field(method, *args) 
     60                end 
     61           
     62                attr_accessor  :hw_type, :ptype, :hwlen, :plen, :op, :hwsrc, :psrc, :pdst, :hwdst, :pdst 
     63 
     64                @@request = {"who-has"=>1, "is-at"=>2, "RARP-req"=>3, "RARP-rep"=>4,  
     65                                "Dyn-RARP-req"=>5, "Dyn-RAR-rep"=>6, "Dyn-RARP-err"=>7,  
     66                                "InARP-req"=>8, "InARP-rep"=>9} 
     67 
     68                def init 
     69                        @protocol = 'ARP' 
     70                        @fields_desc = [ XShortField("hwtype", 0x0001),  
     71                                        XShortEnumField("ptype",  ETHERTYPE_IPv4, ETHERTYPE_ALL), 
     72                                        ByteField("hwlen", 6),  
     73                                        ByteField("plen", 4),   
     74                                        ShortField("op", @@request["who-has"]),    
     75                                        MACField("hwsrc", '00:00:00:00:00:00'),  
     76                                        IPField("psrc", '127.0.0.1'),             
     77                                        MACField("hwdst", '00:00:00:00:00:00'),      
     78                                        IPField("pdst", '127.0.0.1') ]             
     79                end 
     80 
     81                def pre_send(underlayer, payload) 
     82                        if underlayer.is_a?(Ether) 
     83                                underlayer.type = ETHERTYPE_ARP 
     84                        end 
     85                end 
     86        end      
     87     
     88   
    5589        # Dissector for IPv4 
    5690        class IP<Layer 
     
    400434                'Ether' =>  
    401435                [ 
    402                         ['type', ETHERTYPE_IPv4, IP] 
     436                        ['type', ETHERTYPE_IPv4, IP], 
     437                        ['type', ETHERTYPE_ARP, ARP] 
    403438                ], 
    404439 
     
    450485=============================== 
    451486        ANI 
     487        ARP 
    452488        ClassicBSDLoopback 
    453489        Ether