@@ -62,7 +62,7 @@ IfaceMgr::instancePtr() {
6262}
6363
6464Iface::Iface (const std::string& name, unsigned int ifindex)
65- : name_(name), ifindex_(ifindex), mac_len_(0 ), hardware_type_(0 ),
65+ : name_(name), ifindex_(ifindex), mac_len_(0 ), bcast_mac_len_( 0 ), hardware_type_(0 ),
6666 flag_loopback_ (false ), flag_up_(false ), flag_running_(false ),
6767 flag_multicast_(false ), flag_broadcast_(false ), flags_(0 ),
6868 inactive4_(false ), inactive6_(false ) {
@@ -142,6 +142,21 @@ Iface::getPlainMac() const {
142142 return (tmp.str ());
143143}
144144
145+ std::string
146+ Iface::getPlainBcastMac () const {
147+ ostringstream tmp;
148+ tmp.fill (' 0' );
149+ tmp << hex;
150+ for (int i = 0 ; i < bcast_mac_len_; i++) {
151+ tmp.width (2 );
152+ tmp << static_cast <int >(bcast_mac_[i]);
153+ if (i < bcast_mac_len_-1 ) {
154+ tmp << " :" ;
155+ }
156+ }
157+ return (tmp.str ());
158+ }
159+
145160void Iface::setMac (const uint8_t * mac, size_t len) {
146161 if (len > MAX_MAC_LEN) {
147162 isc_throw (OutOfRange, " Interface " << getFullName ()
@@ -155,6 +170,19 @@ void Iface::setMac(const uint8_t* mac, size_t len) {
155170 }
156171}
157172
173+ void Iface::setBcastMac (const uint8_t * mac, size_t len) {
174+ if (len > MAX_MAC_LEN) {
175+ isc_throw (OutOfRange, " Interface " << getFullName ()
176+ << " was detected to have link address of length "
177+ << len << " , but maximum supported length is "
178+ << MAX_MAC_LEN);
179+ }
180+ bcast_mac_len_ = len;
181+ if (len > 0 ) {
182+ memcpy (bcast_mac_, mac, len);
183+ }
184+ }
185+
158186bool Iface::delAddress (const isc::asiolink::IOAddress& addr) {
159187 for (AddressCollection::iterator a = addrs_.begin (); a != addrs_.end (); ++a) {
160188 if (a->get () == addr) {
@@ -791,7 +819,8 @@ IfaceMgr::printIfaces(std::ostream& out /*= std::cout*/) {
791819
792820 out << " Detected interface " << iface->getFullName ()
793821 << " , hwtype=" << iface->getHWType ()
794- << " , mac=" << iface->getPlainMac ();
822+ << " , mac=" << iface->getPlainMac ()
823+ << " , bcast=" << iface->getPlainBcastMac ();
795824 out << " , flags=" << hex << iface->flags_ << dec << " ("
796825 << (iface->flag_loopback_ ?" LOOPBACK " :" " )
797826 << (iface->flag_up_ ?" UP " :" " )
0 commit comments