Skip to content

Commit 32fa9ba

Browse files
committed
Follow NetlinkEvent refactoring.
Change-Id: Ibb6101c8741f862f4732fb200f646dfd329f4782
1 parent 6b0ad64 commit 32fa9ba

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(call all-subdir-makefiles)

server/NetlinkHandler.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,26 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
5858
}
5959

6060
if (!strcmp(subsys, "net")) {
61-
int action = evt->getAction();
61+
NetlinkEvent::Action action = evt->getAction();
6262
const char *iface = evt->findParam("INTERFACE");
6363

64-
if (action == evt->NlActionAdd) {
64+
if (action == NetlinkEvent::Action::kAdd) {
6565
notifyInterfaceAdded(iface);
66-
} else if (action == evt->NlActionRemove) {
66+
} else if (action == NetlinkEvent::Action::kRemove) {
6767
notifyInterfaceRemoved(iface);
68-
} else if (action == evt->NlActionChange) {
68+
} else if (action == NetlinkEvent::Action::kChange) {
6969
evt->dump();
7070
notifyInterfaceChanged("nana", true);
71-
} else if (action == evt->NlActionLinkUp) {
71+
} else if (action == NetlinkEvent::Action::kLinkUp) {
7272
notifyInterfaceLinkChanged(iface, true);
73-
} else if (action == evt->NlActionLinkDown) {
73+
} else if (action == NetlinkEvent::Action::kLinkDown) {
7474
notifyInterfaceLinkChanged(iface, false);
75-
} else if (action == evt->NlActionAddressUpdated ||
76-
action == evt->NlActionAddressRemoved) {
75+
} else if (action == NetlinkEvent::Action::kAddressUpdated ||
76+
action == NetlinkEvent::Action::kAddressRemoved) {
7777
const char *address = evt->findParam("ADDRESS");
7878
const char *flags = evt->findParam("FLAGS");
7979
const char *scope = evt->findParam("SCOPE");
80-
if (action == evt->NlActionAddressRemoved && iface && address) {
80+
if (action == NetlinkEvent::Action::kAddressRemoved && iface && address) {
8181
int resetMask = strchr(address, ':') ? RESET_IPV6_ADDRESSES : RESET_IPV4_ADDRESSES;
8282
resetMask |= RESET_IGNORE_INTERFACE_ADDRESS;
8383
if (int ret = ifc_reset_connections(iface, resetMask)) {
@@ -88,14 +88,14 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
8888
if (iface && flags && scope) {
8989
notifyAddressChanged(action, address, iface, flags, scope);
9090
}
91-
} else if (action == evt->NlActionRdnss) {
91+
} else if (action == NetlinkEvent::Action::kRdnss) {
9292
const char *lifetime = evt->findParam("LIFETIME");
9393
const char *servers = evt->findParam("SERVERS");
9494
if (lifetime && servers) {
9595
notifyInterfaceDnsServers(iface, lifetime, servers);
9696
}
97-
} else if (action == evt->NlActionRouteUpdated ||
98-
action == evt->NlActionRouteRemoved) {
97+
} else if (action == NetlinkEvent::Action::kRouteUpdated ||
98+
action == NetlinkEvent::Action::kRouteRemoved) {
9999
const char *route = evt->findParam("ROUTE");
100100
const char *gateway = evt->findParam("GATEWAY");
101101
const char *iface = evt->findParam("INTERFACE");
@@ -174,12 +174,12 @@ void NetlinkHandler::notifyInterfaceClassActivity(const char *name,
174174
"IfaceClass %s %s %s", isActive ? "active" : "idle", name, timestamp);
175175
}
176176

177-
void NetlinkHandler::notifyAddressChanged(int action, const char *addr,
177+
void NetlinkHandler::notifyAddressChanged(NetlinkEvent::Action action, const char *addr,
178178
const char *iface, const char *flags,
179179
const char *scope) {
180180
notify(ResponseCode::InterfaceAddressChange,
181181
"Address %s %s %s %s %s",
182-
(action == NetlinkEvent::NlActionAddressUpdated) ? kUpdated : kRemoved,
182+
(action == NetlinkEvent::Action::kAddressUpdated) ? kUpdated : kRemoved,
183183
addr, iface, flags, scope);
184184
}
185185

@@ -190,11 +190,11 @@ void NetlinkHandler::notifyInterfaceDnsServers(const char *iface,
190190
iface, lifetime, servers);
191191
}
192192

193-
void NetlinkHandler::notifyRouteChange(int action, const char *route,
193+
void NetlinkHandler::notifyRouteChange(NetlinkEvent::Action action, const char *route,
194194
const char *gateway, const char *iface) {
195195
notify(ResponseCode::RouteChange,
196196
"Route %s %s%s%s%s%s",
197-
(action == NetlinkEvent::NlActionRouteUpdated) ? kUpdated : kRemoved,
197+
(action == NetlinkEvent::Action::kRouteUpdated) ? kUpdated : kRemoved,
198198
route,
199199
*gateway ? " via " : "",
200200
gateway,

server/NetlinkHandler.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef _NETLINKHANDLER_H
1818
#define _NETLINKHANDLER_H
1919

20+
#include <sysutils/NetlinkEvent.h>
2021
#include <sysutils/NetlinkListener.h>
2122
#include "NetlinkManager.h"
2223

@@ -41,11 +42,11 @@ class NetlinkHandler: public NetlinkListener {
4142
void notifyQuotaLimitReached(const char *name, const char *iface);
4243
void notifyInterfaceClassActivity(const char *name, bool isActive,
4344
const char *timestamp);
44-
void notifyAddressChanged(int action, const char *addr, const char *iface,
45+
void notifyAddressChanged(NetlinkEvent::Action action, const char *addr, const char *iface,
4546
const char *flags, const char *scope);
4647
void notifyInterfaceDnsServers(const char *iface, const char *lifetime,
4748
const char *servers);
48-
void notifyRouteChange(int action, const char *route, const char *gateway, const char *iface);
49+
void notifyRouteChange(NetlinkEvent::Action action, const char *route, const char *gateway, const char *iface);
4950
void notifyStrictCleartext(const char* uid, const char* hex);
5051
};
5152
#endif

0 commit comments

Comments
 (0)