Sha256: b2f8f6f305d151def1895ef1c5af510ce5ba5e673fc086ce1b5e0052e3d8dc36

Contents?: true

Size: 979 Bytes

Versions: 3

Compression:

Stored size: 979 Bytes

Contents

# encoding: utf-8

require 'pio/type/ip_address'

module Pio
  module Type
    # IP Version 4 Header Format
    module IPv4Header
      # rubocop:disable MethodLength
      def ipv4_header(options)
        class_eval do
          bit4 :ip_version, initial_value: 0x4
          bit4 :ip_header_length, initial_value: 0x5
          uint8 :ip_type_of_service, initial_value: 0
          uint16be :ip_total_length,
                   initial_value: options[:ip_total_length]
          uint16be :ip_identifier, initial_value: 0
          bit3 :ip_flag, initial_value: 0
          bit13 :ip_fragment, initial_value: 0
          uint8 :ip_ttl, initial_value: 128
          uint8 :ip_protocol, value: options[:ip_protocol]
          uint16be :ip_header_checksum,
                   initial_value: options[:ip_header_checksum]
          ip_address :ip_source_address
          ip_address :ip_destination_address
        end
      end
      # rubocop:enable MethodLength
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pio-0.8.1 lib/pio/type/ipv4_header.rb
pio-0.8.0 lib/pio/type/ipv4_header.rb
pio-0.7.0 lib/pio/type/ipv4_header.rb