Send a query on the network and hopes that if machine matching the *name* will reply with its IP address. :param string ip: If the NBNSProtocol instance was instianted with broadcast=True, then this parameter can be an empty string. We will leave it to the OS to determine an approp
(self, name, ip = '', port = 137, timeout = 30)
| 37 | self.sock.sendto(data, ( ip, port )) |
| 38 | |
| 39 | def queryName(self, name, ip = '', port = 137, timeout = 30): |
| 40 | """ |
| 41 | Send a query on the network and hopes that if machine matching the *name* will reply with its IP address. |
| 42 | |
| 43 | :param string ip: If the NBNSProtocol instance was instianted with broadcast=True, then this parameter can be an empty string. We will leave it to the OS to determine an appropriate broadcast address. |
| 44 | If the NBNSProtocol instance was instianted with broadcast=False, then you should provide a target IP to send the query. |
| 45 | :param integer port: The NetBIOS-NS port (IANA standard defines this port to be 137). You should not touch this parameter unless you know what you are doing. |
| 46 | :param integer/float timeout: Number of seconds to wait for a reply, after which the method will return None |
| 47 | :return: A list of IP addresses in dotted notation (aaa.bbb.ccc.ddd). On timeout, returns None. |
| 48 | """ |
| 49 | assert self.sock, 'Socket is already closed' |
| 50 | |
| 51 | trn_id = random.randint(1, 0xFFFF) |
| 52 | data = self.prepareNameQuery(trn_id, name) |
| 53 | if self.broadcast and not ip: |
| 54 | ip = '<broadcast>' |
| 55 | elif not ip: |
| 56 | self.log.warning('queryName: ip parameter is empty. OS might not transmit this query to the network') |
| 57 | |
| 58 | self.write(data, ip, port) |
| 59 | |
| 60 | return self._pollForNetBIOSPacket(trn_id, timeout) |
| 61 | |
| 62 | def queryIPForName(self, ip, port = 137, timeout = 30): |
| 63 | """ |
nothing calls this directly
no test coverage detected