blob: cc5afb61208ce11c28312f9e469f72cd0e926acc [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001diff --git a/system/core/libsysutils/src/NetlinkEvent.cpp b/system/core/libsysutils/src/NetlinkEvent.cpp
2old mode 100644
3new mode 100755
4index 23dcd62..bf8ab76
5--- a/system/core/libsysutils/src/NetlinkEvent.cpp
6+++ b/system/core/libsysutils/src/NetlinkEvent.cpp
7@@ -28,12 +28,12 @@
8 #include <arpa/inet.h>
9 #include <net/if.h>
10
11-#include <linux/if.h>
12+//#include <linux/if.h>
13 #include <linux/if_addr.h>
14 #include <linux/if_link.h>
15 #include <linux/netfilter/nfnetlink.h>
16 #include <linux/netfilter/nfnetlink_log.h>
17-#include <linux/netfilter_ipv4/ipt_ULOG.h>
18+//#include <linux/netfilter_ipv4/ipt_ULOG.h>
19
20 /* From kernel's net/netfilter/xt_quota2.c */
21 const int LOCAL_QLOG_NL_EVENT = 112;
22@@ -47,6 +47,10 @@ const int LOCAL_NFLOG_PACKET = NFNL_SUBSYS_ULOG << 8 | NFULNL_MSG_PACKET;
23 #include <netlink/handlers.h>
24 #include <netlink/msg.h>
25
26+
27+#define IFF_LOWER_UP 0x10000
28+#define ND_OPT_RDNSS 25
29+
30 NetlinkEvent::NetlinkEvent() {
31 mAction = Action::kUnknown;
32 memset(mParams, 0, sizeof(mParams));
33@@ -255,23 +259,26 @@ bool NetlinkEvent::parseIfAddrMessage(const struct nlmsghdr *nh) {
34 * Parse a QLOG_NL_EVENT message.
35 */
36 bool NetlinkEvent::parseUlogPacketMessage(const struct nlmsghdr *nh) {
37+ #if 0
38 const char *devname;
39 ulog_packet_msg_t *pm = (ulog_packet_msg_t *) NLMSG_DATA(nh);
40- if (!checkRtNetlinkLength(nh, sizeof(*pm)))
41- return false;
42-
43 devname = pm->indev_name[0] ? pm->indev_name : pm->outdev_name;
44 asprintf(&mParams[0], "ALERT_NAME=%s", pm->prefix);
45 asprintf(&mParams[1], "INTERFACE=%s", devname);
46 mSubsystem = strdup("qlog");
47 mAction = Action::kChange;
48- return true;
49+ #endif
50+ if (nh != NULL)
51+ return true;
52+ else
53+ return false;
54 }
55
56 /*
57 * Parse a LOCAL_NFLOG_PACKET message.
58 */
59 bool NetlinkEvent::parseNfPacketMessage(struct nlmsghdr *nh) {
60+ #if 0
61 int uid = -1;
62 int len = 0;
63 char* raw = NULL;
64@@ -284,7 +291,7 @@ bool NetlinkEvent::parseNfPacketMessage(struct nlmsghdr *nh) {
65 struct nlattr *payload = nlmsg_find_attr(nh, sizeof(struct genlmsghdr), NFULA_PAYLOAD);
66 if (payload) {
67 /* First 256 bytes is plenty */
68- len = nla_len(payload);
69+ len = 0;//nla_len(payload);
70 if (len > 256) len = 256;
71 raw = (char*) nla_data(payload);
72 }
73@@ -300,7 +307,11 @@ bool NetlinkEvent::parseNfPacketMessage(struct nlmsghdr *nh) {
74 mParams[1] = hex;
75 mSubsystem = strdup("strict");
76 mAction = Action::kChange;
77- return true;
78+ #endif
79+ if (nh)
80+ return true;
81+ else
82+ return false;
83 }
84
85 /*
86@@ -399,6 +410,8 @@ bool NetlinkEvent::parseRtMessage(const struct nlmsghdr *nh) {
87 * Parse a RTM_NEWNDUSEROPT message.
88 */
89 bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) {
90+
91+ #if 0
92 struct nduseroptmsg *msg = (struct nduseroptmsg *) NLMSG_DATA(nh);
93 if (!checkRtNetlinkLength(nh, sizeof(*msg)))
94 return false;
95@@ -458,9 +471,13 @@ bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) {
96 const int numaddrs = (optlen - 1) / 2;
97
98 // Find the lifetime.
99+ #if 0
100 struct nd_opt_rdnss *rndss_opt = (struct nd_opt_rdnss *) opthdr;
101 const uint32_t lifetime = ntohl(rndss_opt->nd_opt_rdnss_lifetime);
102-
103+ #endif
104+ struct nd_opt_rdnss *rndss_opt = NULL;
105+
106+ const uint32_t lifetime = 0;
107 // Construct "SERVERS=<comma-separated string of DNS addresses>".
108 static const char kServerTag[] = "SERVERS=";
109 static const size_t kTagLength = strlen(kServerTag);
110@@ -476,7 +493,8 @@ bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) {
111 }
112 strcpy(buf, kServerTag);
113 size_t pos = kTagLength;
114-
115+
116+ #if 0
117 struct in6_addr *addrs = (struct in6_addr *) (rndss_opt + 1);
118 for (int i = 0; i < numaddrs; i++) {
119 if (i > 0) {
120@@ -486,7 +504,7 @@ bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) {
121 pos += strlen(buf + pos);
122 if (IN6_IS_ADDR_LINKLOCAL(addrs + i)) {
123 buf[pos++] = '%';
124- pos += strlcpy(buf + pos, ifname, bufsize - pos);
125+ //pos += strlcpy(buf + pos, ifname, bufsize - pos);
126 }
127 }
128 buf[pos] = '\0';
129@@ -496,12 +514,16 @@ bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) {
130 asprintf(&mParams[0], "INTERFACE=%s", ifname);
131 asprintf(&mParams[1], "LIFETIME=%u", lifetime);
132 mParams[2] = buf;
133+ #endif
134 } else {
135 SLOGD("Unknown ND option type %d\n", opthdr->nd_opt_type);
136 return false;
137 }
138-
139- return true;
140+ #endif
141+ if (nh != NULL)
142+ return true;
143+ else
144+ return false;
145 }
146
147 /*
148diff --git a/system/core/libsysutils/src/NetlinkListener.cpp b/system/core/libsysutils/src/NetlinkListener.cpp
149old mode 100644
150new mode 100755
151index 637aa1e..68bb596
152--- a/system/core/libsysutils/src/NetlinkListener.cpp
153+++ b/system/core/libsysutils/src/NetlinkListener.cpp
154@@ -43,6 +43,7 @@ NetlinkListener::NetlinkListener(int socket, int format) :
155
156 bool NetlinkListener::onDataAvailable(SocketClient *cli)
157 {
158+ #if 0
159 int socket = cli->getSocket();
160 ssize_t count;
161 uid_t uid = -1;
162@@ -52,8 +53,8 @@ bool NetlinkListener::onDataAvailable(SocketClient *cli)
163 require_group = false;
164 }
165
166- count = TEMP_FAILURE_RETRY(uevent_kernel_recv(socket,
167- mBuffer, sizeof(mBuffer), require_group, &uid));
168+ count = 0;/*(uevent_kernel_recv(socket,
169+ mBuffer, sizeof(mBuffer), require_group, &uid));*/
170 if (count < 0) {
171 if (uid > 0)
172 LOG_EVENT_INT(65537, uid);
173@@ -71,5 +72,9 @@ bool NetlinkListener::onDataAvailable(SocketClient *cli)
174 }
175
176 delete evt;
177- return true;
178+ #endif
179+ if (cli)
180+ return true;
181+ else
182+ return false;
183 }
184diff --git a/system/core/libsysutils/src/ServiceManager.cpp b/system/core/libsysutils/src/ServiceManager.cpp
185old mode 100644
186new mode 100755
187index 41ac1dd..28dddc0
188--- a/system/core/libsysutils/src/ServiceManager.cpp
189+++ b/system/core/libsysutils/src/ServiceManager.cpp
190@@ -5,7 +5,7 @@
191
192 #define LOG_TAG "Service"
193 #include <cutils/log.h>
194-#include <cutils/properties.h>
195+//#include <cutils/properties.h>
196
197 ServiceManager::ServiceManager() {
198 }
199@@ -28,7 +28,7 @@ ServiceManager::ServiceManager() {
200 * read its state due to the truncation of "init.svc.<name>" into a
201 * zero-terminated buffer of PROPERTY_KEY_MAX characters.
202 */
203-#define SERVICE_NAME_MAX (PROPERTY_KEY_MAX-10)
204+#define SERVICE_NAME_MAX (32-10)
205
206 /* The maximum amount of time to wait for a service to start or stop,
207 * in micro-seconds (really an approximation) */
208@@ -49,7 +49,7 @@ int ServiceManager::start(const char *name) {
209 }
210
211 SLOGD("Starting service '%s'", name);
212- property_set("ctl.start", name);
213+ //property_set("ctl.start", name);
214
215 int count = SLEEP_MAX_USEC;
216 while(count > 0) {
217@@ -78,7 +78,7 @@ int ServiceManager::stop(const char *name) {
218 }
219
220 SLOGD("Stopping service '%s'", name);
221- property_set("ctl.stop", name);
222+ //property_set("ctl.stop", name);
223
224 int count = SLEEP_MAX_USEC;
225 while(count > 0) {
226@@ -98,8 +98,8 @@ int ServiceManager::stop(const char *name) {
227 }
228
229 bool ServiceManager::isRunning(const char *name) {
230- char propVal[PROPERTY_VALUE_MAX];
231- char propName[PROPERTY_KEY_MAX];
232+ char propVal[92];
233+ char propName[92];
234 int ret;
235
236 ret = snprintf(propName, sizeof(propName), "init.svc.%s", name);
237@@ -108,7 +108,7 @@ bool ServiceManager::isRunning(const char *name) {
238 return false;
239 }
240
241- if (property_get(propName, propVal, NULL)) {
242+ if (0) {
243 if (!strcmp(propVal, "running"))
244 return true;
245 }
246diff --git a/system/core/libsysutils/src/SocketListener.cpp b/system/core/libsysutils/src/SocketListener.cpp
247old mode 100644
248new mode 100755
249index 4d602a6..7b4658c
250--- a/system/core/libsysutils/src/SocketListener.cpp
251+++ b/system/core/libsysutils/src/SocketListener.cpp
252@@ -21,6 +21,7 @@
253 #include <sys/time.h>
254 #include <sys/types.h>
255 #include <sys/un.h>
256+#include <fcntl.h>
257
258 #define LOG_TAG "SocketListener"
259 #include <cutils/log.h>