Sha256: 42a94f9ff3fcea23c7b38f242512dcc1fdb45e12a2ec037e3e84d62e325d611e

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

# http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net

module Mu
class Pcap

class IP < Packet
    IPPROTO_TCP      = 6
    IPPROTO_UDP      = 17
    IPPROTO_HOPOPTS  = 0
    IPPROTO_ROUTING  = 43
    IPPROTO_FRAGMENT = 44
    IPPROTO_AH       = 51
    IPPROTO_NONE     = 59
    IPPROTO_DSTOPTS  = 60
    IPPROTO_SCTP     = 132

    attr_accessor :src, :dst

    def initialize src=nil, dst=nil
        super()
        @src = src
        @dst = dst
    end

    def v4?
        return false
    end

    def v6?
        return false
    end

    def proto
        raise NotImplementedError
    end

    def pseudo_header payload_length
        raise NotImplementedError
    end

    def == other
        return super &&
            self.src    == other.src &&
            self.dst    == other.dst
    end

    def self.checksum bytes
        if bytes.size & 1 == 1
            bytes = bytes + "\0"
        end 
        sum = 0
        bytes.unpack("n*").each {|n| sum += n }
        sum = (sum & 0xffff) + (sum >> 16 & 0xffff)
        ~sum & 0xffff
    end
end

end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
DIY-pcap-0.4.1 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.8 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.6 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.5 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.4 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.3 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.2 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.1 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.3.0 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.2.8 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.2.7 lib/diy/parser/mu/pcap/ip.rb
DIY-pcap-0.2.6 lib/diy/parser/mu/pcap/ip.rb
pcapr-local-0.2.0 lib/mu/pcap/ip.rb
pcapr-local-0.1.13 lib/mu/pcap/ip.rb
pcapr-local-0.1.12 lib/mu/pcap/ip.rb
pcapr-local-0.1.11 lib/mu/pcap/ip.rb
pcapr-local-0.1.10 lib/mu/pcap/ip.rb