Class: PacketGen::Header::MDNS
- Inherits:
-
DNS
- Object
- Types::Fields
- Base
- DNS
- PacketGen::Header::MDNS
- Defined in:
- lib/packetgen/header/mdns.rb
Overview
Multicast DNS.
See DNS for header format.
Constant Summary collapse
- UDP_PORT =
Port number for mDNS over UDP
5353
Constants inherited from DNS
DNS::OPCODES, DNS::RCODES, DNS::TCP_PORT
Instance Attribute Summary
Attributes inherited from DNS
#aa, #ad, #an, #ancount, #ar, #arcount, #cd, #id, #ns, #nscount, #opcode, #qd, #qdcount, #qr, #ra, #rcode, #rd, #tc, #u16
Instance Method Summary collapse
- #added_to_packet(packet) ⇒ Object private
-
#mdnsize ⇒ Object
Fixup IP header according to RFC 6762: * set ethernet multicast address to
01:00:5E:00:00:FB
(for IPv4) or33:33:00:00:00:FB
(for IPv6), * set IPv4 address to 224.0.0.251 or IPv6 address to ff02::fb.
Methods inherited from DNS
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header
Methods included from PacketGen::Headerable
included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read
Methods inherited from Types::Fields
#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #inspect, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Method Details
#added_to_packet(packet) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method is used internally by PacketGen and should not be directly called
47 48 49 50 51 52 53 54 |
# File 'lib/packetgen/header/mdns.rb', line 47 def added_to_packet(packet) mdns_idx = packet.headers.size packet.instance_eval "def mdnsize() @headers[#{mdns_idx}].mdnsize; end" # def mdnsize() @headers[4].mdnsize; end return unless packet.is? 'UDP' return unless packet.udp.sport.zero? packet.udp.sport = UDP_PORT end |
#mdnsize ⇒ Object
Fixup IP header according to RFC 6762:
-
set ethernet multicast address to
01:00:5E:00:00:FB
(for IPv4) or33:33:00:00:00:FB
(for IPv6), -
set IPv4 address to 224.0.0.251 or IPv6 address to ff02::fb.
This method may be called as:
# first way
pkt.mdns.mdnsize
# second way
pkt.mdnsize
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/packetgen/header/mdns.rb', line 30 def mdnsize iph = ip_header(self) case iph when IP iph.dst = '224.0.0.251' dst_mac.from_human('01:00:5E:00:00:FB') when IPv6 iph.dst = 'ff02::fb' dst_mac.from_human('33:33:00:00:00:FB') end end |