Sha256: ac9fc635e5d2e50dad87831618e8f8ad8df04e99a68ecfd4d304fcbea97d6f60

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require_relative 'header/sent'
class PacketViaDMEM
  class Sent < Packet

    def initialize packet, debug
      @debug           = debug
      @type            = :sent
      @original        = packet.dup
      @header          = Header::Sent.new
      @popped, @packet = parse_packet packet
    end

    private

    def parse_packet pkt
      head = pkt.shift(4).join.to_i(16)
      @header.msg_type            = (head & 0xffffffff) >> 28
      @header.statistics          = head[27] == 1
      @header.increment_reference = head[26] == 1
      @header.fragment_info       = head[25] == 1
      @header.drop_hash           = head[24] == 1
      @header.decrement_reference = head[23] == 1
      @header.prequeue_priority   = head[22] == 1
      @header.offset              = (head & 0x3fffff) >> 13
      @header.table               = (head & 0x1fff)

      head = pkt.shift(4).join.to_i(16)
      raise Packet::NoPayload, "#{@original.join(' ')} had no payload" unless pkt[0]
      @header.color               = (head & 0x7fffffff) >> 29
      @header.queue_drop_opcode   = (head & 0xcffffff)  >> 27
      @header.queue_system        = (head & 0x3ffffff)  >> 24
      @header.life                = (head & 0x7fffff)   >> 21
      @header.queue_number        = (head & 0x1fffff)

      pop, push = get_pop_push pkt, @header
      popped_and_packet pkt, pop, push
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
packet_via_dmem-0.0.12 lib/packet_via_dmem/sent.rb