mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
mpm: Use receiving socket for sending response
The receiving socket can be used to send responses. This allows setting firewall rules for USRP detection.
This commit is contained in:
parent
c9944cb7ee
commit
159c21b75c
@ -62,8 +62,7 @@ def _discovery_process(state, discovery_addr):
|
||||
# FIXME really, we should only bind to the subnet but I haven't gotten that
|
||||
# working yet
|
||||
sock.bind((("0.0.0.0", MPM_DISCOVERY_PORT)))
|
||||
send_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
send_sock.setsockopt(socket.IPPROTO_IP, IP_MTU_DISCOVER, IP_PMTUDISC_DO)
|
||||
sock.setsockopt(socket.IPPROTO_IP, IP_MTU_DISCOVER, IP_PMTUDISC_DO)
|
||||
|
||||
# TODO yeah I know that's not how you do this
|
||||
discovery_addr_prefix = discovery_addr.replace('.255', '')
|
||||
@ -83,17 +82,16 @@ def _discovery_process(state, discovery_addr):
|
||||
resp_str = create_response_string(state)
|
||||
send_data = resp_str
|
||||
log.trace("Return data: %s", send_data)
|
||||
send_sock.sendto(send_data, sender)
|
||||
sock.sendto(send_data, sender)
|
||||
elif data.strip(b"\0").startswith(b"MPM-ECHO"):
|
||||
log.debug("Received echo request from {sender}"
|
||||
.format(sender=sender[0]))
|
||||
send_data = data
|
||||
try:
|
||||
send_sock.sendto(send_data, sender)
|
||||
sock.sendto(send_data, sender)
|
||||
except OSError as ex:
|
||||
log.warning("ECHO send error: %s", str(ex))
|
||||
except Exception as err:
|
||||
log.error("Unexpected error: `%s' Type: `%s'", str(err), type(err))
|
||||
sock.close()
|
||||
send_sock.close()
|
||||
exit(1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user