1 /*
2 * Copyright (c) 2017, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 #ifndef DBG
30 #define DBG true
31 #endif /* DBG */
32 #define LOG_TAG "IPAHALService"
33
34 /* HIDL Includes */
35 #include <hwbinder/IPCThreadState.h>
36 #include <hwbinder/ProcessState.h>
37
38 /* Kernel Includes */
39 #include <linux/netfilter/nfnetlink_compat.h>
40
41 /* External Includes */
42 #include <cutils/log.h>
43 #include <cstring>
44 #include <sys/socket.h>
45 #include <sys/types.h>
46 #include <vector>
47
48 /* Internal Includes */
49 #include "HAL.h"
50 #include "LocalLogBuffer.h"
51 #include "PrefixParser.h"
52
53 /* Namespace pollution avoidance */
54 using ::android::hardware::Void;
55 using ::android::status_t;
56
57 using RET = ::IOffloadManager::RET;
58 using Prefix = ::IOffloadManager::Prefix;
59
60 using ::std::map;
61 using ::std::vector;
62
63
64 /* ------------------------------ PUBLIC ------------------------------------ */
makeIPAHAL(int version,IOffloadManager * mgr)65 HAL* HAL::makeIPAHAL(int version, IOffloadManager* mgr) {
66 if (DBG)
67 ALOGI("makeIPAHAL(%d, %s)", version,
68 (mgr != nullptr) ? "provided" : "null");
69 if (nullptr == mgr) return NULL;
70 else if (version != 1) return NULL;
71 HAL* ret = new HAL(mgr);
72 if (nullptr == ret) return NULL;
73 configureRpcThreadpool(1, false);
74 ret->registerAsSystemService("ipacm");
75 return ret;
76 } /* makeIPAHAL */
77
78
79 /* ------------------------------ PRIVATE ----------------------------------- */
HAL(IOffloadManager * mgr)80 HAL::HAL(IOffloadManager* mgr) : mLogs("HAL Function Calls", 50) {
81 mIPA = mgr;
82 mCb.clear();
83 mCbIpa = nullptr;
84 mCbCt = nullptr;
85 } /* HAL */
86
registerAsSystemService(const char * name)87 void HAL::registerAsSystemService(const char* name) {
88 status_t ret = 0;
89
90 ret = IOffloadControl::registerAsService();
91 if (ret != 0) ALOGE("Failed to register IOffloadControl (%d) name(%s)", ret, name);
92 else if (DBG) {
93 ALOGI("Successfully registered IOffloadControl");
94 }
95
96 ret = IOffloadConfig::registerAsService();
97 if (ret != 0) ALOGE("Failed to register IOffloadConfig (%d)", ret);
98 else if (DBG) {
99 ALOGI("Successfully registered IOffloadConfig");
100 }
101 } /* registerAsSystemService */
102
doLogcatDump()103 void HAL::doLogcatDump() {
104 ALOGD("mHandles");
105 ALOGD("========");
106 /* @TODO This will segfault if they aren't initialized and I don't currently
107 * care to check for initialization in a function that isn't used anyways
108 * ALOGD("fd1->%d", mHandle1->data[0]);
109 * ALOGD("fd2->%d", mHandle2->data[0]);
110 */
111 ALOGD("========");
112 } /* doLogcatDump */
113
makeInputCheckFailure(string customErr)114 HAL::BoolResult HAL::makeInputCheckFailure(string customErr) {
115 BoolResult ret;
116 ret.success = false;
117 ret.errMsg = "Failed Input Checks: " + customErr;
118 return ret;
119 } /* makeInputCheckFailure */
120
ipaResultToBoolResult(RET in)121 HAL::BoolResult HAL::ipaResultToBoolResult(RET in) {
122 BoolResult ret;
123 ret.success = (in >= RET::SUCCESS);
124 switch (in) {
125 case RET::FAIL_TOO_MANY_PREFIXES:
126 ret.errMsg = "Too Many Prefixes Provided";
127 break;
128 case RET::FAIL_UNSUPPORTED:
129 ret.errMsg = "Unsupported by Hardware";
130 break;
131 case RET::FAIL_INPUT_CHECK:
132 ret.errMsg = "Failed Input Checks";
133 break;
134 case RET::FAIL_HARDWARE:
135 ret.errMsg = "Hardware did not accept";
136 break;
137 case RET::FAIL_TRY_AGAIN:
138 ret.errMsg = "Try Again";
139 break;
140 case RET::SUCCESS:
141 ret.errMsg = "Successful";
142 break;
143 case RET::SUCCESS_DUPLICATE_CONFIG:
144 ret.errMsg = "Successful: Was a duplicate configuration";
145 break;
146 case RET::SUCCESS_NO_OP:
147 ret.errMsg = "Successful: No action needed";
148 break;
149 case RET::SUCCESS_OPTIMIZED:
150 ret.errMsg = "Successful: Performed optimized version of action";
151 break;
152 default:
153 ret.errMsg = "Unknown Error";
154 break;
155 }
156 return ret;
157 } /* ipaResultToBoolResult */
158
159 /* This will likely always result in doubling the number of loops the execution
160 * goes through. Obviously that is suboptimal. But if we first translate
161 * away from all HIDL specific code, then we can avoid sprinkling HIDL
162 * dependencies everywhere.
163 */
convertHidlStrToStdStr(hidl_vec<hidl_string> in)164 vector<string> HAL::convertHidlStrToStdStr(hidl_vec<hidl_string> in) {
165 vector<string> ret;
166 for (size_t i = 0; i < in.size(); i++) {
167 string add = in[i];
168 ret.push_back(add);
169 }
170 return ret;
171 } /* convertHidlStrToStdStr */
172
registerEventListeners()173 void HAL::registerEventListeners() {
174 registerIpaCb();
175 registerCtCb();
176 } /* registerEventListeners */
177
registerIpaCb()178 void HAL::registerIpaCb() {
179 if (isInitialized() && mCbIpa == nullptr) {
180 LocalLogBuffer::FunctionLog fl("registerEventListener");
181 mCbIpa = new IpaEventRelay(mCb);
182 mIPA->registerEventListener(mCbIpa);
183 mLogs.addLog(fl);
184 } else {
185 ALOGE("Failed to registerIpaCb (isInitialized()=%s, (mCbIpa == nullptr)=%s)",
186 isInitialized() ? "true" : "false",
187 (mCbIpa == nullptr) ? "true" : "false");
188 }
189 } /* registerIpaCb */
190
registerCtCb()191 void HAL::registerCtCb() {
192 if (isInitialized() && mCbCt == nullptr) {
193 LocalLogBuffer::FunctionLog fl("registerCtTimeoutUpdater");
194 mCbCt = new CtUpdateAmbassador(mCb);
195 mIPA->registerCtTimeoutUpdater(mCbCt);
196 mLogs.addLog(fl);
197 } else {
198 ALOGE("Failed to registerCtCb (isInitialized()=%s, (mCbCt == nullptr)=%s)",
199 isInitialized() ? "true" : "false",
200 (mCbCt == nullptr) ? "true" : "false");
201 }
202 } /* registerCtCb */
203
unregisterEventListeners()204 void HAL::unregisterEventListeners() {
205 unregisterIpaCb();
206 unregisterCtCb();
207 } /* unregisterEventListeners */
208
unregisterIpaCb()209 void HAL::unregisterIpaCb() {
210 if (mCbIpa != nullptr) {
211 LocalLogBuffer::FunctionLog fl("unregisterEventListener");
212 mIPA->unregisterEventListener(mCbIpa);
213 mCbIpa = nullptr;
214 mLogs.addLog(fl);
215 } else {
216 ALOGE("Failed to unregisterIpaCb");
217 }
218 } /* unregisterIpaCb */
219
unregisterCtCb()220 void HAL::unregisterCtCb() {
221 if (mCbCt != nullptr) {
222 LocalLogBuffer::FunctionLog fl("unregisterCtTimeoutUpdater");
223 mIPA->unregisterCtTimeoutUpdater(mCbCt);
224 mCbCt = nullptr;
225 mLogs.addLog(fl);
226 } else {
227 ALOGE("Failed to unregisterCtCb");
228 }
229 } /* unregisterCtCb */
230
clearHandles()231 void HAL::clearHandles() {
232 ALOGI("clearHandles()");
233 /* @TODO handle this more gracefully... also remove the log
234 *
235 * Things that would be nice, but I can't do:
236 * [1] Destroy the object (it's on the stack)
237 * [2] Call freeHandle (it's private)
238 *
239 * Things I can do but are hacks:
240 * [1] Look at code and notice that setTo immediately calls freeHandle
241 */
242 mHandle1.setTo(nullptr, true);
243 mHandle2.setTo(nullptr, true);
244 } /* clearHandles */
245
isInitialized()246 bool HAL::isInitialized() {
247 return mCb.get() != nullptr;
248 } /* isInitialized */
249
250
251 /* -------------------------- IOffloadConfig -------------------------------- */
setHandles(const hidl_handle & fd1,const hidl_handle & fd2,setHandles_cb hidl_cb)252 Return<void> HAL::setHandles(
253 const hidl_handle &fd1,
254 const hidl_handle &fd2,
255 setHandles_cb hidl_cb
256 ) {
257 LocalLogBuffer::FunctionLog fl(__func__);
258
259 if (fd1->numFds != 1) {
260 BoolResult res = makeInputCheckFailure("Must provide exactly one FD per handle (fd1)");
261 hidl_cb(res.success, res.errMsg);
262 fl.setResult(res.success, res.errMsg);
263
264 mLogs.addLog(fl);
265 return Void();
266 }
267
268 if (fd2->numFds != 1) {
269 BoolResult res = makeInputCheckFailure("Must provide exactly one FD per handle (fd2)");
270 hidl_cb(res.success, res.errMsg);
271 fl.setResult(res.success, res.errMsg);
272
273 mLogs.addLog(fl);
274 return Void();
275 }
276
277 /* The = operator calls freeHandle internally. Therefore, if we were using
278 * these handles previously, they're now gone... forever. But hopefully the
279 * new ones kick in very quickly.
280 *
281 * After freeing anything previously held, it will dup the FD so we have our
282 * own copy.
283 */
284 mHandle1 = fd1;
285 mHandle2 = fd2;
286
287 /* Log the DUPed FD instead of the actual input FD so that we can lookup
288 * this value in ls -l /proc/<pid>/<fd>
289 */
290 fl.addArg("fd1", mHandle1->data[0]);
291 fl.addArg("fd2", mHandle2->data[0]);
292
293 /* Try to provide each handle to IPACM. Destroy our DUPed hidl_handles if
294 * IPACM does not like either input. This keeps us from leaking FDs or
295 * providing half solutions.
296 *
297 * @TODO unfortunately, this does not cover duplicate configs where IPACM
298 * thinks it is still holding on to a handle that we would have freed above.
299 * It also probably means that IPACM would not know about the first FD being
300 * freed if it rejects the second FD.
301 */
302 RET ipaReturn = mIPA->provideFd(mHandle1->data[0], UDP_SUBSCRIPTIONS);
303 if (ipaReturn == RET::SUCCESS) {
304 ipaReturn = mIPA->provideFd(mHandle2->data[0], TCP_SUBSCRIPTIONS);
305 }
306
307 if (ipaReturn != RET::SUCCESS) {
308 ALOGE("IPACM failed to accept the FDs (%d %d)", mHandle1->data[0],
309 mHandle2->data[0]);
310 clearHandles();
311 } else {
312 /* @TODO remove logs after stabilization */
313 ALOGI("IPACM was provided two FDs (%d, %d)", mHandle1->data[0],
314 mHandle2->data[0]);
315 }
316
317 BoolResult res = ipaResultToBoolResult(ipaReturn);
318 hidl_cb(res.success, res.errMsg);
319
320 fl.setResult(res.success, res.errMsg);
321 mLogs.addLog(fl);
322 return Void();
323 } /* setHandles */
324
325
326 /* -------------------------- IOffloadControl ------------------------------- */
initOffload(const::android::sp<ITetheringOffloadCallback> & cb,initOffload_cb hidl_cb)327 Return<void> HAL::initOffload
328 (
329 const ::android::sp<ITetheringOffloadCallback>& cb,
330 initOffload_cb hidl_cb
331 ) {
332 LocalLogBuffer::FunctionLog fl(__func__);
333
334 if (isInitialized()) {
335 BoolResult res = makeInputCheckFailure("Already initialized");
336 hidl_cb(res.success, res.errMsg);
337 fl.setResult(res.success, res.errMsg);
338 mLogs.addLog(fl);
339 } else {
340 /* Should storing the CB be a function? */
341 mCb = cb;
342 registerEventListeners();
343 BoolResult res = ipaResultToBoolResult(RET::SUCCESS);
344 hidl_cb(res.success, res.errMsg);
345 fl.setResult(res.success, res.errMsg);
346 mLogs.addLog(fl);
347 }
348
349 return Void();
350 } /* initOffload */
351
stopOffload(stopOffload_cb hidl_cb)352 Return<void> HAL::stopOffload
353 (
354 stopOffload_cb hidl_cb
355 ) {
356 LocalLogBuffer::FunctionLog fl(__func__);
357
358 if (!isInitialized()) {
359 BoolResult res = makeInputCheckFailure("Was never initialized");
360 hidl_cb(res.success, res.errMsg);
361 fl.setResult(res.success, res.errMsg);
362 mLogs.addLog(fl);
363 } else {
364 /* Should removing the CB be a function? */
365 mCb.clear();
366 unregisterEventListeners();
367
368 RET ipaReturn = mIPA->stopAllOffload();
369 if (ipaReturn != RET::SUCCESS) {
370 /* Ignore IPAs return value here and provide why stopAllOffload
371 * failed. However, if IPA failed to clearAllFds, then we can't
372 * clear our map because they may still be in use.
373 */
374 RET ret = mIPA->clearAllFds();
375 if (ret == RET::SUCCESS) {
376 clearHandles();
377 }
378 } else {
379 ipaReturn = mIPA->clearAllFds();
380 /* If IPA fails, they may still be using these for some reason. */
381 if (ipaReturn == RET::SUCCESS) {
382 clearHandles();
383 } else {
384 ALOGE("IPACM failed to return success for clearAllFds so they will not be released...");
385 }
386 }
387
388 BoolResult res = ipaResultToBoolResult(ipaReturn);
389 hidl_cb(res.success, res.errMsg);
390
391 fl.setResult(res.success, res.errMsg);
392 mLogs.addLog(fl);
393 }
394
395 return Void();
396 } /* stopOffload */
397
setLocalPrefixes(const hidl_vec<hidl_string> & prefixes,setLocalPrefixes_cb hidl_cb)398 Return<void> HAL::setLocalPrefixes
399 (
400 const hidl_vec<hidl_string>& prefixes,
401 setLocalPrefixes_cb hidl_cb
402 ) {
403 BoolResult res;
404 PrefixParser parser;
405 vector<string> prefixesStr = convertHidlStrToStdStr(prefixes);
406
407 LocalLogBuffer::FunctionLog fl(__func__);
408 fl.addArg("prefixes", prefixesStr);
409
410 memset(&res,0,sizeof(BoolResult));
411
412 if (!isInitialized()) {
413 res = makeInputCheckFailure("Not initialized");
414 } else if(prefixesStr.size() < 1) {
415 res = ipaResultToBoolResult(RET::FAIL_INPUT_CHECK);
416 } else if (!parser.add(prefixesStr)) {
417 res = makeInputCheckFailure(parser.getLastErrAsStr());
418 } else {
419 res = ipaResultToBoolResult(RET::SUCCESS);
420 }
421
422 hidl_cb(res.success, res.errMsg);
423 fl.setResult(res.success, res.errMsg);
424 mLogs.addLog(fl);
425 return Void();
426 } /* setLocalPrefixes */
427
getForwardedStats(const hidl_string & upstream,getForwardedStats_cb hidl_cb)428 Return<void> HAL::getForwardedStats
429 (
430 const hidl_string& upstream,
431 getForwardedStats_cb hidl_cb
432 ) {
433 LocalLogBuffer::FunctionLog fl(__func__);
434 fl.addArg("upstream", upstream);
435
436 OffloadStatistics ret;
437 RET ipaReturn = mIPA->getStats(upstream.c_str(), true, ret);
438 if (ipaReturn == RET::SUCCESS) {
439 hidl_cb(ret.getTotalRxBytes(), ret.getTotalTxBytes());
440 fl.setResult(ret.getTotalRxBytes(), ret.getTotalTxBytes());
441 } else {
442 /* @TODO Ensure the output is zeroed, but this is probably not enough to
443 * tell Framework that an error has occurred. If, for example, they had
444 * not yet polled for statistics previously, they may incorrectly assume
445 * that simply no statistics have transpired on hardware path.
446 *
447 * Maybe ITetheringOffloadCallback:onEvent(OFFLOAD_STOPPED_ERROR) is
448 * enough to handle this case, time will tell.
449 */
450 hidl_cb(0, 0);
451 fl.setResult(0, 0);
452 }
453
454 mLogs.addLog(fl);
455 return Void();
456 } /* getForwardedStats */
457
setDataLimit(const hidl_string & upstream,uint64_t limit,setDataLimit_cb hidl_cb)458 Return<void> HAL::setDataLimit
459 (
460 const hidl_string& upstream,
461 uint64_t limit,
462 setDataLimit_cb hidl_cb
463 ) {
464 LocalLogBuffer::FunctionLog fl(__func__);
465 fl.addArg("upstream", upstream);
466 fl.addArg("limit", limit);
467
468 if (!isInitialized()) {
469 BoolResult res = makeInputCheckFailure("Not initialized (setDataLimit)");
470 hidl_cb(res.success, res.errMsg);
471 fl.setResult(res.success, res.errMsg);
472 } else {
473 RET ipaReturn = mIPA->setQuota(upstream.c_str(), limit);
474 if(ipaReturn == RET::FAIL_TRY_AGAIN) {
475 ipaReturn = RET::SUCCESS;
476 }
477 BoolResult res = ipaResultToBoolResult(ipaReturn);
478 hidl_cb(res.success, res.errMsg);
479 fl.setResult(res.success, res.errMsg);
480 }
481
482 mLogs.addLog(fl);
483 return Void();
484 } /* setDataLimit */
485
setUpstreamParameters(const hidl_string & iface,const hidl_string & v4Addr,const hidl_string & v4Gw,const hidl_vec<hidl_string> & v6Gws,setUpstreamParameters_cb hidl_cb)486 Return<void> HAL::setUpstreamParameters
487 (
488 const hidl_string& iface,
489 const hidl_string& v4Addr,
490 const hidl_string& v4Gw,
491 const hidl_vec<hidl_string>& v6Gws,
492 setUpstreamParameters_cb hidl_cb
493 ) {
494 vector<string> v6GwStrs = convertHidlStrToStdStr(v6Gws);
495
496 LocalLogBuffer::FunctionLog fl(__func__);
497 fl.addArg("iface", iface);
498 fl.addArg("v4Addr", v4Addr);
499 fl.addArg("v4Gw", v4Gw);
500 fl.addArg("v6Gws", v6GwStrs);
501
502 PrefixParser v4AddrParser;
503 PrefixParser v4GwParser;
504 PrefixParser v6GwParser;
505
506 /* @TODO maybe we should enforce that these addresses and gateways are fully
507 * qualified here. But then, how do we allow them to be empty/null as well
508 * while still preserving a sane API on PrefixParser?
509 */
510 if (!isInitialized()) {
511 BoolResult res = makeInputCheckFailure("Not initialized (setUpstreamParameters)");
512 hidl_cb(res.success, res.errMsg);
513 fl.setResult(res.success, res.errMsg);
514 } else if (!v4AddrParser.addV4(v4Addr) && !v4Addr.empty()) {
515 BoolResult res = makeInputCheckFailure(v4AddrParser.getLastErrAsStr());
516 hidl_cb(res.success, res.errMsg);
517 fl.setResult(res.success, res.errMsg);
518 } else if (!v4GwParser.addV4(v4Gw) && !v4Gw.empty()) {
519 BoolResult res = makeInputCheckFailure(v4GwParser.getLastErrAsStr());
520 hidl_cb(res.success, res.errMsg);
521 fl.setResult(res.success, res.errMsg);
522 } else if (v6GwStrs.size() >= 1 && !v6GwParser.addV6(v6GwStrs)) {
523 BoolResult res = makeInputCheckFailure(v6GwParser.getLastErrAsStr());
524 hidl_cb(res.success, res.errMsg);
525 fl.setResult(res.success, res.errMsg);
526 } else if (iface.size()>= 1) {
527 RET ipaReturn = mIPA->setUpstream(
528 iface.c_str(),
529 v4GwParser.getFirstPrefix(),
530 v6GwParser.getFirstPrefix());
531 BoolResult res = ipaResultToBoolResult(ipaReturn);
532 hidl_cb(res.success, res.errMsg);
533 fl.setResult(res.success, res.errMsg);
534 } else {
535 /* send NULL iface string when upstream down */
536 RET ipaReturn = mIPA->setUpstream(
537 NULL,
538 v4GwParser.getFirstPrefix(IP_FAM::V4),
539 v6GwParser.getFirstPrefix(IP_FAM::V6));
540 BoolResult res = ipaResultToBoolResult(ipaReturn);
541 hidl_cb(res.success, res.errMsg);
542 fl.setResult(res.success, res.errMsg);
543 }
544
545 mLogs.addLog(fl);
546 return Void();
547 } /* setUpstreamParameters */
548
addDownstream(const hidl_string & iface,const hidl_string & prefix,addDownstream_cb hidl_cb)549 Return<void> HAL::addDownstream
550 (
551 const hidl_string& iface,
552 const hidl_string& prefix,
553 addDownstream_cb hidl_cb
554 ) {
555 LocalLogBuffer::FunctionLog fl(__func__);
556 fl.addArg("iface", iface);
557 fl.addArg("prefix", prefix);
558
559 PrefixParser prefixParser;
560
561 if (!isInitialized()) {
562 BoolResult res = makeInputCheckFailure("Not initialized (setUpstreamParameters)");
563 hidl_cb(res.success, res.errMsg);
564 fl.setResult(res.success, res.errMsg);
565 }
566 else if (!prefixParser.add(prefix)) {
567 BoolResult res = makeInputCheckFailure(prefixParser.getLastErrAsStr());
568 hidl_cb(res.success, res.errMsg);
569 fl.setResult(res.success, res.errMsg);
570 } else {
571 RET ipaReturn = mIPA->addDownstream(
572 iface.c_str(),
573 prefixParser.getFirstPrefix());
574 BoolResult res = ipaResultToBoolResult(ipaReturn);
575 hidl_cb(res.success, res.errMsg);
576 fl.setResult(res.success, res.errMsg);
577 }
578
579 mLogs.addLog(fl);
580 return Void();
581 } /* addDownstream */
582
removeDownstream(const hidl_string & iface,const hidl_string & prefix,removeDownstream_cb hidl_cb)583 Return<void> HAL::removeDownstream
584 (
585 const hidl_string& iface,
586 const hidl_string& prefix,
587 removeDownstream_cb hidl_cb
588 ) {
589 LocalLogBuffer::FunctionLog fl(__func__);
590 fl.addArg("iface", iface);
591 fl.addArg("prefix", prefix);
592
593 PrefixParser prefixParser;
594
595 if (!isInitialized()) {
596 BoolResult res = makeInputCheckFailure("Not initialized (setUpstreamParameters)");
597 hidl_cb(res.success, res.errMsg);
598 fl.setResult(res.success, res.errMsg);
599 }
600 else if (!prefixParser.add(prefix)) {
601 BoolResult res = makeInputCheckFailure(prefixParser.getLastErrAsStr());
602 hidl_cb(res.success, res.errMsg);
603 fl.setResult(res.success, res.errMsg);
604 } else {
605 RET ipaReturn = mIPA->removeDownstream(
606 iface.c_str(),
607 prefixParser.getFirstPrefix());
608 BoolResult res = ipaResultToBoolResult(ipaReturn);
609 hidl_cb(res.success, res.errMsg);
610 fl.setResult(res.success, res.errMsg);
611 }
612
613 mLogs.addLog(fl);
614 return Void();
615 } /* removeDownstream */
616