Module: PacketGen
- Defined in:
- lib/packetgen.rb,
lib/packetgen/pcap.rb,
lib/packetgen/proto.rb,
lib/packetgen/types.rb,
lib/packetgen/utils.rb,
lib/packetgen/config.rb,
lib/packetgen/header.rb,
lib/packetgen/inject.rb,
lib/packetgen/packet.rb,
lib/packetgen/pcapng.rb,
lib/packetgen/capture.rb,
lib/packetgen/inspect.rb,
lib/packetgen/version.rb,
lib/packetgen/header/ip.rb,
lib/packetgen/types/int.rb,
lib/packetgen/types/oui.rb,
lib/packetgen/types/tlv.rb,
lib/packetgen/header/arp.rb,
lib/packetgen/header/dns.rb,
lib/packetgen/header/dns.rb,
lib/packetgen/header/eap.rb,
lib/packetgen/header/eth.rb,
lib/packetgen/header/gre.rb,
lib/packetgen/header/llc.rb,
lib/packetgen/header/mld.rb,
lib/packetgen/header/tcp.rb,
lib/packetgen/header/tcp.rb,
lib/packetgen/header/udp.rb,
lib/packetgen/headerable.rb,
lib/packetgen/pcapng/epb.rb,
lib/packetgen/pcapng/idb.rb,
lib/packetgen/pcapng/shb.rb,
lib/packetgen/pcapng/spb.rb,
lib/packetgen/types/enum.rb,
lib/packetgen/deprecation.rb,
lib/packetgen/header/base.rb,
lib/packetgen/header/dhcp.rb,
lib/packetgen/header/icmp.rb,
lib/packetgen/header/igmp.rb,
lib/packetgen/header/ipv6.rb,
lib/packetgen/header/ipv6.rb,
lib/packetgen/header/mdns.rb,
lib/packetgen/header/sctp.rb,
lib/packetgen/header/sctp.rb,
lib/packetgen/header/snmp.rb,
lib/packetgen/header/tftp.rb,
lib/packetgen/pcapng/file.rb,
lib/packetgen/types/array.rb,
lib/packetgen/header/bootp.rb,
lib/packetgen/header/dot11.rb,
lib/packetgen/header/dot1q.rb,
lib/packetgen/header/dot1x.rb,
lib/packetgen/header/mldv2.rb,
lib/packetgen/pcapng/block.rb,
lib/packetgen/types/fields.rb,
lib/packetgen/types/string.rb,
lib/packetgen/header/dhcpv6.rb,
lib/packetgen/header/dns/rr.rb,
lib/packetgen/header/icmpv6.rb,
lib/packetgen/header/igmpv3.rb,
lib/packetgen/header/ospfv2.rb,
lib/packetgen/header/ospfv3.rb,
lib/packetgen/types/cstring.rb,
lib/packetgen/header/dns/opt.rb,
lib/packetgen/header/eap/md5.rb,
lib/packetgen/header/eap/tls.rb,
lib/packetgen/header/ip/addr.rb,
lib/packetgen/unknown_packet.rb,
lib/packetgen/header/dns/name.rb,
lib/packetgen/header/eap/fast.rb,
lib/packetgen/header/eap/ttls.rb,
lib/packetgen/pcaprub_wrapper.rb,
lib/packetgen/types/fieldable.rb,
lib/packetgen/header/asn1_base.rb,
lib/packetgen/header/igmpv3/mq.rb,
lib/packetgen/header/igmpv3/mr.rb,
lib/packetgen/header/ip/option.rb,
lib/packetgen/header/ipv6/addr.rb,
lib/packetgen/header/mldv2/mlq.rb,
lib/packetgen/header/mldv2/mlr.rb,
lib/packetgen/types/int_string.rb,
lib/packetgen/header/dns/option.rb,
lib/packetgen/header/dot11/data.rb,
lib/packetgen/header/http/verbs.rb,
lib/packetgen/header/ip/options.rb,
lib/packetgen/header/ospfv2/lsa.rb,
lib/packetgen/header/ospfv3/lsa.rb,
lib/packetgen/header/sctp/chunk.rb,
lib/packetgen/header/sctp/chunk.rb,
lib/packetgen/header/sctp/error.rb,
lib/packetgen/header/tcp/option.rb,
lib/packetgen/types/length_from.rb,
lib/packetgen/utils/arp_spoofer.rb,
lib/packetgen/header/dhcp/option.rb,
lib/packetgen/header/dhcpv6/duid.rb,
lib/packetgen/header/tcp/options.rb,
lib/packetgen/types/abstract_tlv.rb,
lib/packetgen/header/dhcp/options.rb,
lib/packetgen/header/dhcpv6/relay.rb,
lib/packetgen/header/dns/question.rb,
lib/packetgen/header/http/headers.rb,
lib/packetgen/header/http/request.rb,
lib/packetgen/header/ospfv2/hello.rb,
lib/packetgen/header/ospfv3/hello.rb,
lib/packetgen/header/dhcpv6/option.rb,
lib/packetgen/header/dns/qdsection.rb,
lib/packetgen/header/dns/rrsection.rb,
lib/packetgen/header/dot11/control.rb,
lib/packetgen/header/dot11/element.rb,
lib/packetgen/header/http/response.rb,
lib/packetgen/header/ospfv2/ls_ack.rb,
lib/packetgen/header/ospfv3/ls_ack.rb,
lib/packetgen/header/sctp/padded32.rb,
lib/packetgen/pcapng/unknown_block.rb,
lib/packetgen/header/dhcpv6/options.rb,
lib/packetgen/header/dot11/sub_mngt.rb,
lib/packetgen/header/ipv6/extension.rb,
lib/packetgen/header/sctp/parameter.rb,
lib/packetgen/header/ipv6/hop_by_hop.rb,
lib/packetgen/header/dot11/management.rb,
lib/packetgen/header/ospfv2/ls_update.rb,
lib/packetgen/header/ospfv3/ls_update.rb,
lib/packetgen/header/ospfv2/ls_request.rb,
lib/packetgen/header/ospfv2/lsa_header.rb,
lib/packetgen/header/ospfv3/ls_request.rb,
lib/packetgen/header/ospfv3/lsa_header.rb,
lib/packetgen/header/ospfv3/ipv6_prefix.rb,
lib/packetgen/header/igmpv3/group_record.rb,
lib/packetgen/header/ospfv2/db_description.rb,
lib/packetgen/header/ospfv3/db_description.rb,
lib/packetgen/header/mldv2/mcast_address_record.rb
Overview
This file is part of PacketGen See github.com/lemontree55/packetgen for more informations Copyright © 2016 Sylvain Daubert <[email protected]> Copyright © 2024 LemonTree55 <[email protected]> This program is published under MIT license.
Defined Under Namespace
Modules: Deprecation, Header, Headerable, Inject, Inspect, PCAPRUBWrapper, Pcap, PcapNG, Proto, Types, Utils Classes: BindingError, Capture, Config, Error, FormatError, Packet, ParseError, UnknownPacket, WireError
Constant Summary collapse
- VERSION =
PacketGen version
'3.3.3'
Class Method Summary collapse
-
.capture(**kwargs) {|packet, timestamp| ... } ⇒ Array<Packet>
Shortcut for Packet.capture Same arguments as Capture#initialize.
-
.default_iface ⇒ String
Get default network interface (ie. first non-loopback declared interface).
-
.force_binary(str) ⇒ String
Force binary encoding for
str
. -
.gen(protocol, options = {}) ⇒ Packet
Shortcut for Packet.gen.
-
.header(protocol, options = {}) ⇒ Header::Base
Shortcut to get a header class.
-
.loopback_iface ⇒ String
Get loopback network interface.
-
.parse(binary_str, first_header: nil) ⇒ Packet
Shortcut for Packet.parse.
-
.read(filename) ⇒ Array<Packet>
Shortcut for Packet.read.
-
.write(filename, packets) ⇒ void
Shortcut for Packet.write.
Class Method Details
.capture(**kwargs) {|packet, timestamp| ... } ⇒ Array<Packet>
Shortcut for PacketGen::Packet.capture Same arguments as PacketGen::Capture#initialize
72 73 74 |
# File 'lib/packetgen.rb', line 72 def self.capture(**kwargs) Packet.capture(**kwargs) { |packet| yield packet if block_given? } end |
.default_iface ⇒ String
Get default network interface (ie. first non-loopback declared interface)
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/packetgen.rb', line 100 def self.default_iface return @default_iface if defined? @default_iface @default_iface = Interfacez.raw_interface_addresses.each do |iface| next unless iface.broadaddr next unless Interfacez.ipv4_address_of(iface.name) next unless Interfacez.ipv6_address_of(iface.name) break iface.name end end |
.force_binary(str) ⇒ String
Force binary encoding for str
94 95 96 |
# File 'lib/packetgen.rb', line 94 def self.force_binary(str) str.dup.force_encoding(Encoding::BINARY) end |
.gen(protocol, options = {}) ⇒ Packet
Shortcut for PacketGen::Packet.gen
53 54 55 |
# File 'lib/packetgen.rb', line 53 def self.gen(protocol, ={}) Packet.gen protocol, end |
.header(protocol, options = {}) ⇒ Header::Base
Shortcut to get a header class
129 130 131 |
# File 'lib/packetgen.rb', line 129 def self.header(protocol, ={}) Header.get_header_class_by_name(protocol).new() end |
.loopback_iface ⇒ String
Get loopback network interface
114 115 116 |
# File 'lib/packetgen.rb', line 114 def self.loopback_iface Interfacez.loopback end |
.parse(binary_str, first_header: nil) ⇒ Packet
Shortcut for PacketGen::Packet.parse
61 62 63 |
# File 'lib/packetgen.rb', line 61 def self.parse(binary_str, first_header: nil) Packet.parse binary_str, first_header: first_header end |
.read(filename) ⇒ Array<Packet>
Shortcut for PacketGen::Packet.read
79 80 81 |
# File 'lib/packetgen.rb', line 79 def self.read(filename) Packet.read filename end |
.write(filename, packets) ⇒ void
This method returns an undefined value.
Shortcut for PacketGen::Packet.write
87 88 89 |
# File 'lib/packetgen.rb', line 87 def self.write(filename, packets) Packet.write filename, packets end |