Class: Mu::Pcap::SCTP::Parameter::IpAddress
- Inherits:
-
Mu::Pcap::SCTP::Parameter
- Object
- Packet
- Mu::Pcap::SCTP::Parameter
- Mu::Pcap::SCTP::Parameter::IpAddress
- Defined in:
- lib/diy/parser/mu/pcap/sctp/parameter/ip_address.rb
Constant Summary
Constants inherited from Packet
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Mu::Pcap::SCTP::Parameter
Attributes inherited from Packet
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ IpAddress
constructor
A new instance of IpAddress.
- #to_s ⇒ Object
Methods inherited from Mu::Pcap::SCTP::Parameter
dummy_parameter, #padded_size, #write
Methods inherited from Packet
#==, #deepdup, #flow_id, isolate_l7, normalize, #payload_bytes, #to_bytes
Constructor Details
#initialize ⇒ IpAddress
Returns a new instance of IpAddress.
13 14 15 16 17 |
# File 'lib/diy/parser/mu/pcap/sctp/parameter/ip_address.rb', line 13 def initialize super @value = nil end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/diy/parser/mu/pcap/sctp/parameter/ip_address.rb', line 11 def value @value end |
Class Method Details
.from_bytes(type, size, bytes) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/diy/parser/mu/pcap/sctp/parameter/ip_address.rb', line 19 def self.from_bytes type, size, bytes # Basic validation if PARAM_IPV4 == type Pcap.assert(size == 8, "Invalid IPv4 address: 4 != #{size}") else Pcap.assert(size == 20, "Invalid IPv6 address: 16 != #{size}") end # Create IP address parameter ip_address = IpAddress.new ip_address.type = type ip_address.size = size ip_address.value = IPAddr.new_ntoh(bytes[0, size - 4]) # Set raw payload ip_address.payload_raw = bytes[0, size - 4] # Return the result return ip_address end |
Instance Method Details
#to_s ⇒ Object
40 41 42 |
# File 'lib/diy/parser/mu/pcap/sctp/parameter/ip_address.rb', line 40 def to_s return "address(%s)" % [@value] end |