Class: FFI::VixDiskLib::SafeConnectParams
- Inherits:
-
Object
- Object
- FFI::VixDiskLib::SafeConnectParams
- Defined in:
- lib/ffi-vix_disk_lib/safe_connect_params.rb
Constant Summary collapse
- UidPasswd =
API::UidPasswdCreds
- SessionId =
API::SessionIdCreds
Instance Attribute Summary collapse
-
#connect_params ⇒ Object
readonly
Returns the value of attribute connect_params.
Class Method Summary collapse
-
.read(ffi_connect_parms) ⇒ Object
Read a ConnectParams structure returned from the FFI layer from VixDiskLib_GetConnectParams into a ruby hash.
-
.read_creds(cred_type, conn_parms, ffi_creds) ⇒ Object
Read a ConnectParams Creds sub-structure returned from the FFI layer from VixDiskLib_GetConnectParams into a ruby hash.
- .set_params(id_symbol, name_symbol, creds, params) ⇒ Object
Instance Method Summary collapse
-
#initialize(in_conn_parms) ⇒ SafeConnectParams
constructor
Read the contents of a ConnectParams structure into FFI memory for use when calling out to VixDiskLib.
- #set_param(in_conn_parms, symbol) ⇒ Object
Constructor Details
#initialize(in_conn_parms) ⇒ SafeConnectParams
Read the contents of a ConnectParams structure into FFI memory for use when calling out to VixDiskLib
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ffi-vix_disk_lib/safe_connect_params.rb', line 22 def initialize(in_conn_parms) conn_parms = FFI::MemoryPointer.new(API::ConnectParams, 1, true) @connect_params = conn_parms set_param(in_conn_parms, :vmxSpec) # Increment structure pointer to server_name set_param(in_conn_parms, :serverName) # Increment structure pointer to thumbPrint set_param(in_conn_parms, :thumbPrint) # Increment structure pointer to privateUse conn_parms = @connect_params + API::ConnectParams.offset_of(:privateUse) conn_parms.write_long(in_conn_parms[:privateUse]) unless in_conn_parms[:privateUse].nil? # Increment structure pointer to credType cred_type = in_conn_parms[:credType] conn_parms = @connect_params + API::ConnectParams.offset_of(:credType) conn_parms.write_int(cred_type) unless cred_type.nil? get_safe_creds(cred_type, in_conn_parms, @connect_params + API::ConnectParams.offset_of(:creds)) conn_parms = @connect_params + API::ConnectParams.offset_of(:port) conn_parms.write_uint32(in_conn_parms[:port]) unless in_conn_parms[:port].nil? conn_parms.write_uint32(0) if API::VERSION_MAJOR > 5 @connect_params end |
Instance Attribute Details
#connect_params ⇒ Object (readonly)
Returns the value of attribute connect_params.
10 11 12 |
# File 'lib/ffi-vix_disk_lib/safe_connect_params.rb', line 10 def connect_params @connect_params end |
Class Method Details
.read(ffi_connect_parms) ⇒ Object
Read a ConnectParams structure returned from the FFI layer from VixDiskLib_GetConnectParams into a ruby hash.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ffi-vix_disk_lib/safe_connect_params.rb', line 48 def self.read(ffi_connect_parms) out_connect_parms = {} spec_ptr = ffi_connect_parms.get_pointer(API::ConnectParams.offset_of(:vmxSpec)) out_connect_parms[:vmxSpec] = spec_ptr.read_string unless spec_ptr.null? serv_ptr = ffi_connect_parms.get_pointer(API::ConnectParams.offset_of(:serverName)) out_connect_parms[:serverName] = serv_ptr.read_string unless serv_ptr.null? thumb_ptr = ffi_connect_parms.get_pointer(API::ConnectParams.offset_of(:thumbPrint)) out_connect_parms[:thumbPrint] = thumb_ptr.read_string unless thumb_ptr.null? out_connect_parms[:privateUse] = ffi_connect_parms.get_long(API::ConnectParams.offset_of(:privateUse)) out_connect_parms[:credType] = ffi_connect_parms.get_long(API::ConnectParams.offset_of(:credType)) cred_type = out_connect_parms[:credType] read_creds(cred_type, out_connect_parms, ffi_connect_parms + API::ConnectParams.offset_of(:creds)) out_connect_parms end |
.read_creds(cred_type, conn_parms, ffi_creds) ⇒ Object
Read a ConnectParams Creds sub-structure returned from the FFI layer from VixDiskLib_GetConnectParams into a ruby hash.
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ffi-vix_disk_lib/safe_connect_params.rb', line 72 def self.read_creds(cred_type, conn_parms, ffi_creds) if cred_type == API::CredType[:VIXDISKLIB_CRED_UID] set_params(:uid, :userName, ffi_creds, conn_parms) set_params(:uid, :password, ffi_creds, conn_parms) elsif cred_type == API::CredType[:VIXDISKLIB_CRED_SESSIONID] set_params(:sessionId, :cookie, ffi_creds, conn_parms) set_params(:sessionId, :sessionUserName, ffi_creds, conn_parms) set_params(:sessionId, :key, ffi_creds, conn_parms) elsif cred_type == API::CredType[:VIXDISKLIB_CRED_TICKETID] set_params(:ticketId, :dummy, ffi_creds, conn_parms) end end |
.set_params(id_symbol, name_symbol, creds, params) ⇒ Object
63 64 65 66 |
# File 'lib/ffi-vix_disk_lib/safe_connect_params.rb', line 63 def self.set_params(id_symbol, name_symbol, creds, params) pointer = creds + API::Creds.offset_of(id_symbol) + UidPasswd.offset_of(name_symbol) params[name_symbol] = read_safe_str_from_mem(pointer) end |
Instance Method Details
#set_param(in_conn_parms, symbol) ⇒ Object
12 13 14 15 16 |
# File 'lib/ffi-vix_disk_lib/safe_connect_params.rb', line 12 def set_param(in_conn_parms, symbol) conn_parms = @connect_params + API::ConnectParams.offset_of(symbol) memory_pointer = get_mem_ptr_from_str(in_conn_parms[symbol]) conn_parms.put_pointer(0, memory_pointer) end |