Class: 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
Add
#mdnsize
method topacket
. -
#mdnsize ⇒ void
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 to224.0.0.251
or IPv6 address toff02::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, #to_s
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
Add #mdnsize
method to packet
. This method calls #mdnsize.
54 55 56 57 58 59 60 61 |
# File 'lib/packetgen/header/mdns.rb', line 54 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 ⇒ void
This method returns an undefined value.
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 toff02::fb
.
This method may be called as:
# first way
pkt.mdns.mdnsize
# second way
pkt.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/packetgen/header/mdns.rb', line 36 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 |