master
h 49 lines 1.04 KB
Raw
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2 #pragma once
3 #include <string>
4 #include <linux/rtnetlink.h>
5 #include <linux/rtnetlink.h>
6
7 inline std::string NetLinkFormatFlagsToString(int flags)
8 {
9 if (flags == 0)
10 {
11 return "[zero]";
12 }
13
14 std::string returnString;
15 if (flags & NLM_F_CREATE)
16 {
17 returnString.append("NLM_F_CREATE ");
18 }
19 if (flags & NLM_F_REPLACE)
20 {
21 returnString.append("NLM_F_REPLACE ");
22 }
23 if (flags & NLM_F_DUMP)
24 {
25 returnString.append("NLM_F_DUMP ");
26 }
27 if (flags & NLM_F_REQUEST)
28 {
29 returnString.append("NLM_F_REQUEST ");
30 }
31 if (flags & NLM_F_EXCL)
32 {
33 returnString.append("NLM_F_EXCL ");
34 }
35 return returnString;
36 }
37
38 inline auto* RouteOperationToString(int operation)
39 {
40 if (operation == RTM_DELROUTE)
41 {
42 return "RTM_DELROUTE ";
43 }
44 if (operation == RTM_NEWROUTE)
45 {
46 return "RTM_NEWROUTE ";
47 }
48 return "[unknown route operation]";
49 }