Loading automotive/can/1.0/default/libnetdevice/include/libnetdevice/libnetdevice.h +8 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,14 @@ bool del(std::string dev); */ std::optional<hwaddr_t> getHwAddr(const std::string& ifname); /** * Changes interface's hardware address. * * \param ifname Interface name * \param hwaddr New hardware address to set */ bool setHwAddr(const std::string& ifname, hwaddr_t hwaddr); } // namespace android::netdevice bool operator==(const android::netdevice::hwaddr_t lhs, const unsigned char rhs[ETH_ALEN]); automotive/can/1.0/default/libnetdevice/libnetdevice.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,16 @@ std::optional<hwaddr_t> getHwAddr(const std::string& ifname) { return hwaddr; } bool setHwAddr(const std::string& ifname, hwaddr_t hwaddr) { auto ifr = ifreqs::fromName(ifname); // fetch sa_family if (!ifreqs::send(SIOCGIFHWADDR, ifr)) return false; memcpy(ifr.ifr_hwaddr.sa_data, hwaddr.data(), hwaddr.size()); return ifreqs::send(SIOCSIFHWADDR, ifr); } } // namespace android::netdevice bool operator==(const android::netdevice::hwaddr_t lhs, const unsigned char rhs[ETH_ALEN]) { Loading Loading
automotive/can/1.0/default/libnetdevice/include/libnetdevice/libnetdevice.h +8 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,14 @@ bool del(std::string dev); */ std::optional<hwaddr_t> getHwAddr(const std::string& ifname); /** * Changes interface's hardware address. * * \param ifname Interface name * \param hwaddr New hardware address to set */ bool setHwAddr(const std::string& ifname, hwaddr_t hwaddr); } // namespace android::netdevice bool operator==(const android::netdevice::hwaddr_t lhs, const unsigned char rhs[ETH_ALEN]);
automotive/can/1.0/default/libnetdevice/libnetdevice.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,16 @@ std::optional<hwaddr_t> getHwAddr(const std::string& ifname) { return hwaddr; } bool setHwAddr(const std::string& ifname, hwaddr_t hwaddr) { auto ifr = ifreqs::fromName(ifname); // fetch sa_family if (!ifreqs::send(SIOCGIFHWADDR, ifr)) return false; memcpy(ifr.ifr_hwaddr.sa_data, hwaddr.data(), hwaddr.size()); return ifreqs::send(SIOCSIFHWADDR, ifr); } } // namespace android::netdevice bool operator==(const android::netdevice::hwaddr_t lhs, const unsigned char rhs[ETH_ALEN]) { Loading