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)
| 45 | self.transport.getHandle().sendto(data, ( ip, port )) |
| 46 | |
| 47 | def queryName(self, name, ip = '', port = 137, timeout = 30): |
| 48 | """ |
| 49 | Send a query on the network and hopes that if machine matching the *name* will reply with its IP address. |
| 50 | |
| 51 | :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. |
| 52 | If the NBNSProtocol instance was instianted with broadcast=False, then you should provide a target IP to send the query. |
| 53 | :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. |
| 54 | :param integer/float timeout: Number of seconds to wait for a reply, after which the returned Deferred instance will be called with a NetBIOSTimeout exception. |
| 55 | :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a list of IP addresses in dotted notation (aaa.bbb.ccc.ddd). |
| 56 | On timeout, the errback function will be called with a Failure instance wrapping around a NetBIOSTimeout exception |
| 57 | """ |
| 58 | trn_id = random.randint(1, 0xFFFF) |
| 59 | while True: |
| 60 | if trn_id not in self.pending_trns: |
| 61 | break |
| 62 | else: |
| 63 | trn_id = (trn_id + 1) & 0xFFFF |
| 64 | |
| 65 | data = self.prepareNameQuery(trn_id, name) |
| 66 | if self.broadcast and not ip: |
| 67 | ip = '<broadcast>' |
| 68 | elif not ip: |
| 69 | self.log.warning('queryName: ip parameter is empty. OS might not transmit this query to the network') |
| 70 | |
| 71 | self.write(data, ip, port) |
| 72 | |
| 73 | d = defer.Deferred() |
| 74 | self.pending_trns[trn_id] = ( time.time()+timeout, name, d ) |
| 75 | return d |
| 76 | |
| 77 | def queryIPForName(self, ip, port = 137, timeout = 30): |
| 78 | """ |
nothing calls this directly
no test coverage detected