aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm
diff options
context:
space:
mode:
authorPhilipp Homann <3265572+PhilippHomann@users.noreply.github.com>2022-02-04 10:26:14 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2022-03-02 13:06:23 -0600
commit159c21b75c6efa0952e8d446341b7a037593c350 (patch)
tree6ab931edf0448ffb312cdb0e7b2f4b63670d0e54 /mpm/python/usrp_mpm
parentc9944cb7ee21d7bffc147e6af548071b16ce792c (diff)
downloaduhd-159c21b75c6efa0952e8d446341b7a037593c350.tar.gz
uhd-159c21b75c6efa0952e8d446341b7a037593c350.tar.bz2
uhd-159c21b75c6efa0952e8d446341b7a037593c350.zip
mpm: Use receiving socket for sending response
The receiving socket can be used to send responses. This allows setting firewall rules for USRP detection.
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r--mpm/python/usrp_mpm/discovery.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/mpm/python/usrp_mpm/discovery.py b/mpm/python/usrp_mpm/discovery.py
index a9f165ed3..9a216c974 100644
--- a/mpm/python/usrp_mpm/discovery.py
+++ b/mpm/python/usrp_mpm/discovery.py
@@ -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)