diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-26 11:45:56 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-26 11:45:56 -0700 |
commit | 08f6b21ce7cc4aa4069b4461785fc7173bed2998 (patch) | |
tree | 8856af9e8af41a28245266290dfe29d053938a00 /host/lib/usrp/usrp2/usrp2_impl.cpp | |
parent | 24bd27b90d06820d858c008cff915319873321c5 (diff) | |
download | uhd-08f6b21ce7cc4aa4069b4461785fc7173bed2998.tar.gz uhd-08f6b21ce7cc4aa4069b4461785fc7173bed2998.tar.bz2 uhd-08f6b21ce7cc4aa4069b4461785fc7173bed2998.zip |
added interface address discovery
Diffstat (limited to 'host/lib/usrp/usrp2/usrp2_impl.cpp')
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 85d73e83a..f04ae8d2c 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -15,9 +15,11 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +#include <uhd/transport/if_addrs.hpp> +#include <uhd/utils.hpp> #include <boost/format.hpp> +#include <boost/foreach.hpp> #include <boost/bind.hpp> -#include <uhd/utils.hpp> #include <iostream> #include "usrp2_impl.hpp" @@ -36,7 +38,21 @@ STATIC_BLOCK(register_usrp2_device){ uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){ device_addrs_t usrp2_addrs; - if (not hint.has_key("addr")) return usrp2_addrs; + //if no address was specified, send a broadcast on each interface + if (not hint.has_key("addr")){ + BOOST_FOREACH(const if_addrs_t &if_addrs, get_if_addrs()){ + //create a new hint with this broadcast address + device_addr_t new_hint = hint; + new_hint["addr"] = if_addrs.bcast; + + //call discover with the new hint and append results + device_addrs_t new_usrp2_addrs = usrp2::discover(new_hint); + usrp2_addrs.insert(usrp2_addrs.begin(), + new_usrp2_addrs.begin(), new_usrp2_addrs.end() + ); + } + return usrp2_addrs; + } //create a udp transport to communicate //TODO if an addr is not provided, search all interfaces? |