Sha256: 09606b3e8c8240419ee815c1c1aa07cf7031ca94090cef4862acbbb7969330af

Contents?: true

Size: 829 Bytes

Versions: 5

Compression:

Stored size: 829 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Solaris
      module FFI
        module Ioctl
          extend ::FFI::Library
          ffi_lib ::FFI::Library::LIBC, 'socket'

          attach_function :ioctl_base, :ioctl, %i[int int pointer], :int
          attach_function :open_socket, :socket, %i[int int int], :int
          attach_function :close_socket, :shutdown, %i[int int], :int
          attach_function :inet_ntop, %i[int pointer pointer uint], :string

          def self.ioctl(call_const, pointer, address_family = AF_INET)
            fd = Ioctl.open_socket(address_family, SOCK_DGRAM, 0)
            begin
              ioctl_base(fd, call_const, pointer)
            ensure
              Ioctl.close_socket(fd, 2)
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facter-4.5.1 lib/facter/resolvers/solaris/ffi/functions.rb
facter-4.5.0 lib/facter/resolvers/solaris/ffi/functions.rb
facter-4.4.3 lib/facter/resolvers/solaris/ffi/functions.rb
facter-4.4.2 lib/facter/resolvers/solaris/ffi/functions.rb
facter-4.4.1 lib/facter/resolvers/solaris/ffi/functions.rb