Module: Bindef::Extras::TLV
- Included in:
- Bindef
- Defined in:
- lib/bindef/extras/tlv.rb
Overview
Potentially useful TLV (tag-length-value) commands.
Writing a single sufficiently generic TLV command without really abusing Ruby's syntax is hard. Instead, we provide specialized commands for empirically common TLV widths.
Instance Method Summary collapse
-
#tlv_u16(type, hsh) ⇒ Object
Emit a
uint16_t
type, auint16_t
length, and a value. -
#tlv_u32(type, hsh) ⇒ Object
Emit a
uint32_t
type, auint32_t
length, and a value. -
#tlv_u8(type, hsh) ⇒ Object
Emit a
uint8_t
type, auint8_t
length, and a value.
Instance Method Details
#tlv_u16(type, hsh) ⇒ Object
Emit a uint16_t
type, a uint16_t
length, and a value.
31 32 33 34 35 36 37 38 39 |
# File 'lib/bindef/extras/tlv.rb', line 31 def tlv_u16(type, hsh) u16 type cmd, value = hsh.shift send cmd, value do |blob| u16 blob.bytesize end end |
#tlv_u32(type, hsh) ⇒ Object
Emit a uint32_t
type, a uint32_t
length, and a value.
45 46 47 48 49 50 51 52 53 |
# File 'lib/bindef/extras/tlv.rb', line 45 def tlv_u32(type, hsh) u32 type cmd, value = hsh.shift send cmd, value do |blob| u32 blob.bytesize end end |
#tlv_u8(type, hsh) ⇒ Object
Emit a uint8_t
type, a uint8_t
length, and a value.
17 18 19 20 21 22 23 24 25 |
# File 'lib/bindef/extras/tlv.rb', line 17 def tlv_u8(type, hsh) u8 type cmd, value = hsh.shift send cmd, value do |blob| u8 blob.bytesize end end |