MCPcopy Create free account
hub / github.com/secdev/scapy / DNSSDResult

Class DNSSDResult

scapy/layers/dns.py:1949–2001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1947
1948
1949class DNSSDResult(SndRcvList):
1950 def __init__(self,
1951 res=None, # type: Optional[Union[_PacketList[QueryAnswer], List[QueryAnswer]]] # noqa: E501
1952 name="DNS-SD", # type: str
1953 stats=None # type: Optional[List[Type[Packet]]]
1954 ):
1955 SndRcvList.__init__(self, res, name, stats)
1956
1957 def show(self, types=['PTR', 'SRV'], alltypes=False):
1958 # type: (List[str], bool) -> None
1959 """
1960 Print the list of discovered services.
1961
1962 :param types: types to show. Default ['PTR', 'SRV']
1963 :param alltypes: show all types. Default False
1964 """
1965 if alltypes:
1966 types = None
1967 data = list() # type: List[Tuple[str | List[str], ...]]
1968
1969 resolve_mac = (
1970 self.res and isinstance(self.res[0][1].underlayer, Ether) and
1971 conf.manufdb
1972 )
1973
1974 header = ("IP", "Service")
1975 if resolve_mac:
1976 header = ("Mac",) + header
1977
1978 for _, r in self.res:
1979 attrs = []
1980 for attr in itertools.chain(r[DNS].an, r[DNS].ar):
1981 if types and dnstypes.get(attr.type) not in types:
1982 continue
1983 if isinstance(attr, DNSRRNSEC):
1984 attrs.append(attr.sprintf("%type%=%nextname%"))
1985 elif isinstance(attr, DNSRRSRV):
1986 attrs.append(attr.sprintf("%type%=(%target%,%port%)"))
1987 else:
1988 attrs.append(attr.sprintf("%type%=%rdata%"))
1989 ans = (r.src, attrs)
1990 if resolve_mac:
1991 mac = conf.manufdb._resolve_MAC(r.underlayer.src)
1992 data.append((mac,) + ans)
1993 else:
1994 data.append(ans)
1995
1996 print(
1997 pretty_list(
1998 data,
1999 [header],
2000 )
2001 )
2002
2003
2004@conf.commands.register

Callers 1

dnssdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…