Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c2468aa authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Android (Google) Code Review
Browse files

Merge changes from topics "libnl++-naming", "libnl++-socket"

* changes:
  Inclusive language for CAN bus HAL
  Netlink socket refactoring
  Update libnl++ class naming to match Android code style
  Implement attribute map.
parents d0e35245 09dc1b3f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ static bool match(const hidl_vec<CanMessageFilter>& filter, CanMessageId id, boo
                               satisfiesFilterFlag(rule.extendedFormat, isExtendedId);

        if (rule.exclude) {
            // Any excluded (blacklist) rule not being satisfied invalidates the whole filter set.
            // Any exclude rule being satisfied invalidates the whole filter set.
            if (satisfied) return false;
        } else {
            anyNonExcludeRulePresent = true;
+4 −4
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@

#include <android-base/logging.h>
#include <android-base/unique_fd.h>
#include <libnl++/NetlinkRequest.h>
#include <libnl++/NetlinkSocket.h>
#include <libnl++/MessageFactory.h>
#include <libnl++/Socket.h>

#include <linux/can.h>
#include <linux/can/error.h>
@@ -70,7 +70,7 @@ bool setBitrate(std::string ifname, uint32_t bitrate) {
    struct can_bittiming bt = {};
    bt.bitrate = bitrate;

    nl::NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK, NLM_F_REQUEST);
    nl::MessageFactory<struct ifinfomsg> req(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_ACK);

    const auto ifidx = nametoindex(ifname);
    if (ifidx == 0) {
@@ -90,7 +90,7 @@ bool setBitrate(std::string ifname, uint32_t bitrate) {
        }
    }

    nl::NetlinkSocket sock(NETLINK_ROUTE);
    nl::Socket sock(NETLINK_ROUTE);
    return sock.send(req) && sock.receiveAck();
}

+0 −2
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

#pragma once

#include <libnl++/nlbuf.h>

#include <linux/can.h>
#include <net/if.h>

+7 −7
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@
#include "ifreqs.h"

#include <android-base/logging.h>
#include <libnl++/NetlinkRequest.h>
#include <libnl++/NetlinkSocket.h>
#include <libnl++/MessageFactory.h>
#include <libnl++/Socket.h>

#include <linux/can.h>
#include <linux/rtnetlink.h>
@@ -62,8 +62,8 @@ bool down(std::string ifname) {
}

bool add(std::string dev, std::string type) {
    nl::NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK,
                                             NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
    nl::MessageFactory<struct ifinfomsg> req(RTM_NEWLINK,
                                             NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL | NLM_F_ACK);
    req.addattr(IFLA_IFNAME, dev);

    {
@@ -71,15 +71,15 @@ bool add(std::string dev, std::string type) {
        req.addattr(IFLA_INFO_KIND, type);
    }

    nl::NetlinkSocket sock(NETLINK_ROUTE);
    nl::Socket sock(NETLINK_ROUTE);
    return sock.send(req) && sock.receiveAck();
}

bool del(std::string dev) {
    nl::NetlinkRequest<struct ifinfomsg> req(RTM_DELLINK, NLM_F_REQUEST);
    nl::MessageFactory<struct ifinfomsg> req(RTM_DELLINK, NLM_F_REQUEST | NLM_F_ACK);
    req.addattr(IFLA_IFNAME, dev);

    nl::NetlinkSocket sock(NETLINK_ROUTE);
    nl::Socket sock(NETLINK_ROUTE);
    return sock.send(req) && sock.receiveAck();
}

+5 −5
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@
#include "common.h"

#include <android-base/logging.h>
#include <libnl++/NetlinkRequest.h>
#include <libnl++/NetlinkSocket.h>
#include <libnl++/MessageFactory.h>
#include <libnl++/Socket.h>

#include <linux/rtnetlink.h>

@@ -33,8 +33,8 @@ bool add(const std::string& eth, const std::string& vlan, uint16_t id) {
        return false;
    }

    nl::NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK,
                                             NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
    nl::MessageFactory<struct ifinfomsg> req(RTM_NEWLINK,
                                             NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL | NLM_F_ACK);
    req.addattr(IFLA_IFNAME, vlan);
    req.addattr<uint32_t>(IFLA_LINK, ethidx);

@@ -48,7 +48,7 @@ bool add(const std::string& eth, const std::string& vlan, uint16_t id) {
        }
    }

    nl::NetlinkSocket sock(NETLINK_ROUTE);
    nl::Socket sock(NETLINK_ROUTE);
    return sock.send(req) && sock.receiveAck();
}

Loading