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, known_headers, #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
68 69 70 71 72 73 74 75 |
# File 'lib/packetgen/header/mdns.rb', line 68 def added_to_packet(packet) mdns_idx = packet.headers.size packet.instance_eval "def mdnsize() @headers[#{mdns_idx}].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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/packetgen/header/mdns.rb', line 29 def mdnsize iph = ip_header(self) case iph when IP iph.dst = '224.0.0.251' llh = ll_header(self) mac = case llh when Eth llh[:dst] when Dot11 if llh.to_ds? llh[:mac3] else llh[:mac1] end end mac.from_human('01:00:5E:00:00:FB') when IPv6 iph.dst = 'ff02::fb' llh = ll_header(self) mac = case llh when Eth llh[:dst] when Dot11 if llh.to_ds? llh[:mac3] else llh[:mac1] end end mac.from_human('33:33:00:00:00:FB') end end |