diff options
author | Michael West <michael.west@ettus.com> | 2018-08-23 17:09:00 -0700 |
---|---|---|
committer | Brent Stapleton <bstapleton@g.hmc.edu> | 2018-10-25 09:57:16 -0700 |
commit | adfd3d9598eb23751cd9a7a53acce6c16261e828 (patch) | |
tree | 959cbfcc71f82615ef0094908c1239c33c75880e /host/lib/usrp | |
parent | 1256821f3e61ec677cd4b4e75be14f0f376f5215 (diff) | |
download | uhd-adfd3d9598eb23751cd9a7a53acce6c16261e828.tar.gz uhd-adfd3d9598eb23751cd9a7a53acce6c16261e828.tar.bz2 uhd-adfd3d9598eb23751cd9a7a53acce6c16261e828.zip |
X300: Prevent duplicate MAC and IP addresses from being programmed in MB
EEPROM
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/x300/x300_mb_eeprom.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/host/lib/usrp/x300/x300_mb_eeprom.cpp b/host/lib/usrp/x300/x300_mb_eeprom.cpp index b8fb59538..7bff3d782 100644 --- a/host/lib/usrp/x300/x300_mb_eeprom.cpp +++ b/host/lib/usrp/x300/x300_mb_eeprom.cpp @@ -130,11 +130,34 @@ mboard_eeprom_t x300_impl::get_mb_eeprom(uhd::i2c_iface::sptr iface) return mb_eeprom; } - void x300_impl::set_mb_eeprom( i2c_iface::sptr iface, const mboard_eeprom_t &mb_eeprom ) { + const mboard_eeprom_t curr_eeprom = get_mb_eeprom(iface); + + // Check for duplicate MAC and IP addresses + const std::vector<std::string> mac_keys{ + "mac-addr0", + "mac-addr1" + }; + const std::vector<std::string> ip_keys{ + "ip-addr0", + "ip-addr1", + "ip-addr2", + "ip-addr3" + }; + + //make sure there are no duplicate values + if (check_for_duplicates<uhd::mac_addr_t>( + "X300", mb_eeprom, curr_eeprom,"MAC address", mac_keys) or + check_for_duplicates<boost::asio::ip::address_v4>( + "X300", mb_eeprom, curr_eeprom, "IP address", ip_keys)) + { + throw uhd::value_error( + "Duplicate values not permitted - write to EEPROM aborted"); + } + //parse the revision number if (mb_eeprom.has_key("revision")) iface->write_eeprom( X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision), @@ -195,4 +218,3 @@ void x300_impl::set_mb_eeprom( string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN) ); } - |