MCPcopy Index your code
hub / github.com/secdev/scapy / dnssd

Function dnssd

scapy/layers/dns.py:2005–2028  ·  view source on GitHub ↗

Performs a DNS-SD (RFC6763) request :param service: the service name to query (e.g. _spotify-connect._tcp.local) :param af: the transport to use. socket.AF_INET or socket.AF_INET6 :param qtype: the type to use in the mDNS. Either TXT, PTR or SRV. :param iface: the interface to

(service="_services._dns-sd._udp.local",
          af=socket.AF_INET,
          qtype="PTR",
          iface=None,
          verbose=2,
          timeout=3)

Source from the content-addressed store, hash-verified

2003
2004@conf.commands.register
2005def dnssd(service="_services._dns-sd._udp.local",
2006 af=socket.AF_INET,
2007 qtype="PTR",
2008 iface=None,
2009 verbose=2,
2010 timeout=3):
2011 """
2012 Performs a DNS-SD (RFC6763) request
2013
2014 :param service: the service name to query (e.g. _spotify-connect._tcp.local)
2015 :param af: the transport to use. socket.AF_INET or socket.AF_INET6
2016 :param qtype: the type to use in the mDNS. Either TXT, PTR or SRV.
2017 :param iface: the interface to do this discovery on.
2018 """
2019 if af == socket.AF_INET:
2020 pkt = IP(dst=ScopedIP("224.0.0.251", iface), ttl=255)
2021 elif af == socket.AF_INET6:
2022 pkt = IPv6(dst=ScopedIP("ff02::fb", iface))
2023 else:
2024 return
2025 pkt /= UDP(sport=5353, dport=5353)
2026 pkt /= DNS(rd=0, qd=[DNSQR(qname=service, qtype=qtype)])
2027 ans, _ = sr(pkt, multi=True, timeout=timeout, verbose=verbose)
2028 return DNSSDResult(ans.res)

Callers

nothing calls this directly

Calls 8

IPClass · 0.90
ScopedIPFunction · 0.90
IPv6Class · 0.90
UDPClass · 0.90
srFunction · 0.90
DNSClass · 0.85
DNSQRClass · 0.85
DNSSDResultClass · 0.85

Tested by

no test coverage detected