diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-03-13 13:27:33 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-03-13 13:27:56 -0700 |
commit | e4f394087d2073dbe8309e5a2d87127cfda66ff9 (patch) | |
tree | f3e95bbf501b38487e26e05ba848f8d2ca693a92 /include/sysutils/NetlinkEvent.h | |
parent | b5662f93238978dba1877209bb88a1ca294fe521 (diff) | |
download | system_core-e4f394087d2073dbe8309e5a2d87127cfda66ff9.zip system_core-e4f394087d2073dbe8309e5a2d87127cfda66ff9.tar.gz system_core-e4f394087d2073dbe8309e5a2d87127cfda66ff9.tar.bz2 |
Define enum class for NetlinkEvent actions.
This lets us use it for switch statements, and gives us stronger
type safety.
Change-Id: Idb3ad7098657a09f13c95dc7070611d35ede66ae
Diffstat (limited to 'include/sysutils/NetlinkEvent.h')
-rw-r--r-- | include/sysutils/NetlinkEvent.h | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/include/sysutils/NetlinkEvent.h b/include/sysutils/NetlinkEvent.h index 4fa49c5..b80f3ea 100644 --- a/include/sysutils/NetlinkEvent.h +++ b/include/sysutils/NetlinkEvent.h @@ -21,25 +21,29 @@ #define NL_PARAMS_MAX 32 class NetlinkEvent { +public: + enum class Action { + kUnknown = 0, + kAdd = 1, + kRemove = 2, + kChange = 3, + kLinkUp = 4, + kLinkDown = 5, + kAddressUpdated = 6, + kAddressRemoved = 7, + kRdnss = 8, + kRouteUpdated = 9, + kRouteRemoved = 10, + }; + +private: int mSeq; char *mPath; - int mAction; + Action mAction; char *mSubsystem; char *mParams[NL_PARAMS_MAX]; public: - const static int NlActionUnknown; - const static int NlActionAdd; - const static int NlActionRemove; - const static int NlActionChange; - const static int NlActionLinkDown; - const static int NlActionLinkUp; - const static int NlActionAddressUpdated; - const static int NlActionAddressRemoved; - const static int NlActionRdnss; - const static int NlActionRouteUpdated; - const static int NlActionRouteRemoved; - NetlinkEvent(); virtual ~NetlinkEvent(); @@ -47,7 +51,7 @@ public: const char *findParam(const char *paramName); const char *getSubsystem() { return mSubsystem; } - int getAction() { return mAction; } + Action getAction() { return mAction; } void dump(); |