Sha256: be54174a87eabf35ff3ca8cd01658eec198d3942ad0e5bf846c828c1b4127a7a
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# coding: utf-8 # frozen_string_literal: true # This file is part of PacketGen # See https://github.com/lemontree55/packetgen for more informations # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> # Copyright (C) 2024 LemonTree55 <lenontree@proton.me> # This program is published under MIT license. require 'socket' module PacketGen # Module handling some helper methods for well_known protocols # @author Sylvain Daubert # @since 2.1.2 module Proto # @private cache information used by {.getprotobyname} and # {.getprotobynumber} def self.prepare_cache proto_constants = Socket.constants.grep(/IPPROTO_/) @cache = {} proto_constants.each do |const_sym| name = const_sym.to_s[8..].downcase number = Socket.const_get(const_sym) @cache[name] = number end end prepare_cache # Get protocol number from its name # @param [String] name # @return [Integer,nil] return nil for unknown protocol names def self.getprotobyname(name) @cache[name] end # Get protocol name from its number # @param [Integer] num # @return [String,nil] return nil for unknown protocol numbers def self.getprotobynumber(num) @cache.key(num) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
packetgen-4.0.0 | lib/packetgen/proto.rb |