Class: TIPCNameSeq
- Inherits:
-
Object
- Object
- TIPCNameSeq
- Defined in:
- lib/tipcsocket.rb
Overview
Represents a TIPC port name sequence address of the form <type, lower bound, upper bound>.
From the TIPC Programmer’s Guide:
A port name sequence consists of a 32-bit type field and a pair of 32-bit
instance fields, and represents the set of port names from {type,lower bound}
through {type,upper bound}, inclusive. The lower bound of a name sequence
cannot be larger than the upper bound.
Instance Attribute Summary collapse
-
#addrtype ⇒ Object
readonly
Returns the value of attribute addrtype.
-
#family ⇒ Object
readonly
Returns the value of attribute family.
-
#lower ⇒ Object
Returns the value of attribute lower.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#type ⇒ Object
Returns the value of attribute type.
-
#upper ⇒ Object
Returns the value of attribute upper.
Class Method Summary collapse
-
.unpack(bytes) ⇒ Object
Create a new TIPCNameSeq instance from a 12 byte binary string containing a TIPC name sequence.
-
.unpack_addr(bytes) ⇒ Object
Create a new TIPCNameSeq instance from a 16 byte binary string containing a TIPC address.
Instance Method Summary collapse
-
#initialize(type, lower, upper, scope = TIPCSocket::Constants::TIPC_NODE_SCOPE) ⇒ TIPCNameSeq
constructor
Create a new TIPCNameSeq instance.
-
#pack ⇒ Object
Pack an instance of a TIPCNameSeq.
-
#pack_addr ⇒ Object
Pack an instance of a TIPCNameSeq as a 16 byte TIPC network address suitable for passing to one of the standard Socket methods (connect, send, etc.).
Constructor Details
#initialize(type, lower, upper, scope = TIPCSocket::Constants::TIPC_NODE_SCOPE) ⇒ TIPCNameSeq
Create a new TIPCNameSeq instance.
Parameters
* type - arbitrary 32 bit type value
* lower - 32-bit lower bound of the name sequence
* upper - 32-bit upper bound of the name sequence
* scope - the scope (zone, cluster, or node) to use when packing
this name as a TIPC address (optional)
200 201 202 203 204 205 206 207 |
# File 'lib/tipcsocket.rb', line 200 def initialize(type, lower, upper, scope = TIPCSocket::Constants::TIPC_NODE_SCOPE) @family = Socket::Constants::AF_TIPC @addrtype = TIPCSocket::Constants::TIPC_ADDR_NAMESEQ @type = type @lower = lower @upper = upper @scope = scope end |
Instance Attribute Details
#addrtype ⇒ Object (readonly)
Returns the value of attribute addrtype.
189 190 191 |
# File 'lib/tipcsocket.rb', line 189 def addrtype @addrtype end |
#family ⇒ Object (readonly)
Returns the value of attribute family.
189 190 191 |
# File 'lib/tipcsocket.rb', line 189 def family @family end |
#lower ⇒ Object
Returns the value of attribute lower.
190 191 192 |
# File 'lib/tipcsocket.rb', line 190 def lower @lower end |
#scope ⇒ Object
Returns the value of attribute scope.
190 191 192 |
# File 'lib/tipcsocket.rb', line 190 def scope @scope end |
#type ⇒ Object
Returns the value of attribute type.
190 191 192 |
# File 'lib/tipcsocket.rb', line 190 def type @type end |
#upper ⇒ Object
Returns the value of attribute upper.
190 191 192 |
# File 'lib/tipcsocket.rb', line 190 def upper @upper end |
Class Method Details
.unpack(bytes) ⇒ Object
Create a new TIPCNameSeq instance from a 12 byte binary string containing a TIPC name sequence.
Parameters
* bytes - 12 byte string containing TIPC name sequence
259 260 261 262 |
# File 'lib/tipcsocket.rb', line 259 def self.unpack(bytes) data = bytes.unpack("L3") self.new(data[0], data[1], data[2]) end |
.unpack_addr(bytes) ⇒ Object
Create a new TIPCNameSeq instance from a 16 byte binary string containing a TIPC address.
Parameters
* bytes - 16 byte string containing TIPC address
249 250 251 252 |
# File 'lib/tipcsocket.rb', line 249 def self.unpack_addr(bytes) data = bytes.unpack("SCcL3") self.new(data[3], data[4], data[5], data[2]) end |
Instance Method Details
#pack ⇒ Object
Pack an instance of a TIPCNameSeq.
Produces an 12 byte string with the following format:
* type - uint32 (4 bytes)
* lower - uint32 (4 bytes)
* upper - uint32 (4 bytes)
236 237 238 239 240 241 242 |
# File 'lib/tipcsocket.rb', line 236 def pack [ self.type, self.lower, self.upper ].pack("L3") end |
#pack_addr ⇒ Object
Pack an instance of a TIPCNameSeq as a 16 byte TIPC network address suitable for passing to one of the standard Socket methods (connect, send, etc.).
Produces a 16 byte binary string with the following format:
* family - unsigned short (2 bytes)
* addrtype - unsigned char (1 byte)
* scope - signed char (1 byte)
* type - uint32 (4 bytes)
* lower - uint32 (4 bytes)
* upper - uint32 (4 bytes)
219 220 221 222 223 224 225 226 227 228 |
# File 'lib/tipcsocket.rb', line 219 def pack_addr [ self.family, self.addrtype, self.scope, self.type, self.lower, self.upper ].pack("SCcL3") end |