Class: Procfs2::ProcNetUdpSocket
- Inherits:
-
Object
- Object
- Procfs2::ProcNetUdpSocket
- Defined in:
- lib/procfs2/proc_net_udp_socket.rb
Constant Summary collapse
- HEADERS =
%i[ id local_address_port remote_address_port state transmit_receive_queue timer_and_jiffies retransmit uid timeout inode socket_reference_count socket_location drops ].freeze
- STATE_STR =
{ 0 => 'UNKNOWN', 1 => 'ESTABLISHED', 2 => 'SYN_SENT', 3 => 'SYN_RECV', 4 => 'FIN_WAIT1', 5 => 'FIN_WAIT2', 6 => 'TIME_WAIT', 7 => 'CLOSE', 8 => 'CLOSE_WAIT', 9 => 'LAST_ACK', 10 => 'LISTEN', 11 => 'CLOSING', 12 => 'NEW_SYN_RECV', 13 => 'MAX_STATE' }.freeze
Instance Attribute Summary collapse
-
#drops ⇒ Object
readonly
Returns the value of attribute drops.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#inode ⇒ Object
readonly
Returns the value of attribute inode.
-
#local_address ⇒ Object
readonly
Returns the value of attribute local_address.
-
#local_port ⇒ Object
readonly
Returns the value of attribute local_port.
-
#receive_queue ⇒ Object
readonly
Returns the value of attribute receive_queue.
-
#remote_address ⇒ Object
readonly
Returns the value of attribute remote_address.
-
#remote_port ⇒ Object
readonly
Returns the value of attribute remote_port.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#transmit_queue ⇒ Object
readonly
Returns the value of attribute transmit_queue.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, local_address:, local_port:, remote_address:, remote_port:, state:, transmit_queue:, receive_queue:, uid:, inode:, drops:, **extra) ⇒ ProcNetUdpSocket
constructor
A new instance of ProcNetUdpSocket.
- #state_str ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(id:, local_address:, local_port:, remote_address:, remote_port:, state:, transmit_queue:, receive_queue:, uid:, inode:, drops:, **extra) ⇒ ProcNetUdpSocket
Returns a new instance of ProcNetUdpSocket.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 41 def initialize(id:, local_address:, local_port:, remote_address:, remote_port:, state:, transmit_queue:, receive_queue:, uid:, inode:, drops:, **extra) @id = id @local_address = local_address @local_port = local_port @remote_address = remote_address @remote_port = remote_port @state = state @transmit_queue = transmit_queue @receive_queue = receive_queue @uid = uid @inode = inode @drops = drops @extra = extra end |
Instance Attribute Details
#drops ⇒ Object (readonly)
Returns the value of attribute drops.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def drops @drops end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def id @id end |
#inode ⇒ Object (readonly)
Returns the value of attribute inode.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def inode @inode end |
#local_address ⇒ Object (readonly)
Returns the value of attribute local_address.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def local_address @local_address end |
#local_port ⇒ Object (readonly)
Returns the value of attribute local_port.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def local_port @local_port end |
#receive_queue ⇒ Object (readonly)
Returns the value of attribute receive_queue.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def receive_queue @receive_queue end |
#remote_address ⇒ Object (readonly)
Returns the value of attribute remote_address.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def remote_address @remote_address end |
#remote_port ⇒ Object (readonly)
Returns the value of attribute remote_port.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def remote_port @remote_port end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def state @state end |
#transmit_queue ⇒ Object (readonly)
Returns the value of attribute transmit_queue.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def transmit_queue @transmit_queue end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
38 39 40 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 38 def uid @uid end |
Class Method Details
.build_from_line(line) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 67 def build_from_line(line) info = HEADERS.zip(line.strip.split).to_h = {} [:id] = info[:id].chomp(':').to_i [:local_address], [:local_port] = parse_address_hex(info[:local_address_port]) [:remote_address], [:remote_port] = parse_address_hex(info[:remote_address_port]) [:state] = info[:state].hex [:transmit_queue], [:receive_queue] = info[:transmit_receive_queue].split(':').map(&:hex) [:timer_active], [:jiffries] = info[:timer_and_jiffies].split(':').map(&:hex) [:retransmit] = info[:retransmit].hex [:uid] = info[:uid].to_i [:timeout] = info[:timeout].to_i [:inode] = info[:inode].to_i [:socket_reference_count] = info[:socket_reference_count].to_i [:socket_location] = info[:socket_location] [:drops] = info[:drops].to_i new(**) end |
.parse_address_hex(address_port_hex) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 88 def parse_address_hex(address_port_hex) address_hex, port_hex = address_port_hex.split(':') address = [address_hex[6..7], address_hex[4..5], address_hex[2..3], address_hex[0..1]].map(&:hex).join('.') port = port_hex.hex [address, port] end |
Instance Method Details
#state_str ⇒ Object
62 63 64 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 62 def state_str STATE_STR[state] end |
#type ⇒ Object
58 59 60 |
# File 'lib/procfs2/proc_net_udp_socket.rb', line 58 def type 'udp' end |