1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef I_NETSYSCONTROLLER_SERVICE_H 17 #define I_NETSYSCONTROLLER_SERVICE_H 18 19 #include <linux/if.h> 20 #include <memory> 21 #include <netdb.h> 22 #include <string> 23 #include <vector> 24 25 #include "dns_config_client.h" 26 #include "interface_type.h" 27 #include "i_net_diag_callback.h" 28 #include "i_net_dns_result_callback.h" 29 #include "i_net_dns_health_callback.h" 30 #include "net_stats_info.h" 31 #include "netsys_controller_callback.h" 32 #include "netsys_dns_report_callback.h" 33 #include "netsys_controller_define.h" 34 #include "network_sharing.h" 35 #include "uid_range.h" 36 37 namespace OHOS { 38 namespace NetManagerStandard { 39 class INetsysControllerService : public RefBase { 40 public: 41 virtual ~INetsysControllerService() = default; 42 43 /** 44 * Init netsys service proxy 45 * 46 */ 47 virtual void Init() = 0; 48 49 /** 50 * Disallow or allow a app to create AF_INET or AF_INET6 socket 51 * 52 * @param uid App's uid which need to be disallowed ot allowed to create AF_INET or AF_INET6 socket 53 * @param allow 0 means disallow, 1 means allow 54 * @return return 0 if OK, return error number if not OK 55 */ 56 virtual int32_t SetInternetPermission(uint32_t uid, uint8_t allow) = 0; 57 58 /** 59 * Create a physical network 60 * 61 * @param netId Net Id 62 * @param permission Permission to create a physical network 63 * @return Return the return value of the netsys interface call 64 */ 65 virtual int32_t NetworkCreatePhysical(int32_t netId, int32_t permission) = 0; 66 67 virtual int32_t NetworkCreateVirtual(int32_t netId, bool hasDns) = 0; 68 69 /** 70 * Destroy the network 71 * 72 * @param netId Net Id 73 * @return Return the return value of the netsys interface call 74 */ 75 virtual int32_t NetworkDestroy(int32_t netId) = 0; 76 77 virtual int32_t NetworkAddUids(int32_t netId, const std::vector<UidRange> &uidRanges) = 0; 78 virtual int32_t NetworkDelUids(int32_t netId, const std::vector<UidRange> &uidRanges) = 0; 79 80 /** 81 * Add network port device 82 * 83 * @param netId Net Id 84 * @param iface Network port device name 85 * @return Return the return value of the netsys interface call 86 */ 87 virtual int32_t NetworkAddInterface(int32_t netId, const std::string &iface) = 0; 88 89 /** 90 * Delete network port device 91 * 92 * @param netId Net Id 93 * @param iface Network port device name 94 * @return Return the return value of the netsys interface call 95 */ 96 virtual int32_t NetworkRemoveInterface(int32_t netId, const std::string &iface) = 0; 97 98 /** 99 * Add route 100 * 101 * @param netId Net Id 102 * @param ifName Network port device name 103 * @param destination Target host ip 104 * @param nextHop Next hop address 105 * @return Return the return value of the netsys interface call 106 */ 107 virtual int32_t NetworkAddRoute(int32_t netId, const std::string &ifName, const std::string &destination, 108 const std::string &nextHop) = 0; 109 110 /** 111 * Remove route 112 * 113 * @param netId Net Id 114 * @param ifName Network port device name 115 * @param destination Target host ip 116 * @param nextHop Next hop address 117 * @return Return the return value of the netsys interface call 118 */ 119 virtual int32_t NetworkRemoveRoute(int32_t netId, const std::string &ifName, const std::string &destination, 120 const std::string &nextHop) = 0; 121 122 /** 123 * Get interface config 124 * 125 * @param iface Network port device name 126 * @return Return the result of this action, ERR_NONE is success. 127 */ 128 virtual int32_t GetInterfaceConfig(OHOS::nmd::InterfaceConfigurationParcel &cfg) = 0; 129 130 /** 131 * Set interface config 132 * 133 * @param cfg Network port info 134 * @return Return the result of this action, ERR_NONE is success. 135 */ 136 virtual int32_t SetInterfaceConfig(const OHOS::nmd::InterfaceConfigurationParcel &cfg) = 0; 137 138 /** 139 * Turn off the device 140 * 141 * @param iface Network port device name 142 * @return Return the result of this action 143 */ 144 virtual int32_t SetInterfaceDown(const std::string &iface) = 0; 145 146 /** 147 * Turn on the device 148 * 149 * @param iface Network port device name 150 * @return Return the result of this action 151 */ 152 virtual int32_t SetInterfaceUp(const std::string &iface) = 0; 153 154 /** 155 * Clear the network interface ip address 156 * 157 * @param ifName Network port device name 158 */ 159 virtual void ClearInterfaceAddrs(const std::string &ifName) = 0; 160 161 /** 162 * Obtain mtu from the network interface device 163 * 164 * @param ifName Network port device name 165 * @return Return the return value of the netsys interface call 166 */ 167 virtual int32_t GetInterfaceMtu(const std::string &ifName) = 0; 168 169 /** 170 * Set mtu to network interface device 171 * 172 * @param ifName Network port device name 173 * @param mtu 174 * @return Return the return value of the netsys interface call 175 */ 176 virtual int32_t SetInterfaceMtu(const std::string &ifName, int32_t mtu) = 0; 177 178 /** 179 * Set tcp buffer sizes 180 * 181 * @param tcpBufferSizes tcpBufferSizes 182 * @return Return the return value of the netsys interface call 183 */ 184 virtual int32_t SetTcpBufferSizes(const std::string &tcpBufferSizes) = 0; 185 186 /** 187 * Add ip address 188 * 189 * @param ifName Network port device name 190 * @param ipAddr Ip address 191 * @param prefixLength subnet mask 192 * @return Return the return value of the netsys interface call 193 */ 194 virtual int32_t AddInterfaceAddress(const std::string &ifName, const std::string &ipAddr, int32_t prefixLength) = 0; 195 196 /** 197 * Delete ip address 198 * 199 * @param ifName Network port device name 200 * @param ipAddr Ip address 201 * @param prefixLength subnet mask 202 * @return Return the return value of the netsys interface call 203 */ 204 virtual int32_t DelInterfaceAddress(const std::string &ifName, const std::string &ipAddr, int32_t prefixLength) = 0; 205 /** 206 * Set iface ip address 207 * 208 * @param ifaceName Network port device name 209 * @param ipAddress Ip address 210 * @return Return the return value of the netsys interface call 211 */ 212 virtual int32_t InterfaceSetIpAddress(const std::string &ifaceName, const std::string &ipAddress) = 0; 213 214 /** 215 * Set iface up 216 * 217 * @param ifaceName Network port device name 218 * @return Return the return value of the netsys interface call 219 */ 220 virtual int32_t InterfaceSetIffUp(const std::string &ifaceName) = 0; 221 222 /** 223 * Set dns 224 * 225 * @param netId Net Id 226 * @param baseTimeoutMsec Base timeout msec 227 * @param retryCount Retry count 228 * @param servers The name of servers 229 * @param domains The name of domains 230 * @return Return the return value of the netsys interface call 231 */ 232 virtual int32_t SetResolverConfig(uint16_t netId, uint16_t baseTimeoutMsec, uint8_t retryCount, 233 const std::vector<std::string> &servers, 234 const std::vector<std::string> &domains) = 0; 235 236 /** 237 * Get dns server param info 238 * 239 * @param netId Net Id 240 * @param servers The name of servers 241 * @param domains The name of domains 242 * @param baseTimeoutMsec Base timeout msec 243 * @param retryCount Retry count 244 * @return Return the return value of the netsys interface call 245 */ 246 virtual int32_t GetResolverConfig(uint16_t netId, std::vector<std::string> &servers, 247 std::vector<std::string> &domains, uint16_t &baseTimeoutMsec, 248 uint8_t &retryCount) = 0; 249 250 /** 251 * Create dns cache before set dns 252 * 253 * @param netId Net Id 254 * @return Return the return value for status of call 255 */ 256 virtual int32_t CreateNetworkCache(uint16_t netId) = 0; 257 258 /** 259 * Destroy dns cache 260 * 261 * @param netId Net Id 262 * @return Return the return value of the netsys interface call 263 */ 264 virtual int32_t DestroyNetworkCache(uint16_t netId) = 0; 265 266 /** 267 * Domain name resolution Obtains the domain name address 268 * 269 * @param hostName Domain name to be resolved 270 * @param serverName Server name used for query 271 * @param hints Limit parameters when querying 272 * @param netId Network id 273 * @param res return addrinfo 274 * @return Return the return value of the netsys interface call 275 */ 276 virtual int32_t GetAddrInfo(const std::string &hostName, const std::string &serverName, const AddrInfo &hints, 277 uint16_t netId, std::vector<AddrInfo> &res) = 0; 278 279 /** 280 * Obtains the bytes of the sharing network. 281 * 282 * @return Success return 0. 283 */ 284 virtual int32_t GetNetworkSharingTraffic(const std::string &downIface, const std::string &upIface, 285 nmd::NetworkSharingTraffic &traffic) = 0; 286 287 /** 288 * Obtains the bytes received over the cellular network. 289 * 290 * @return The number of received bytes. 291 */ 292 virtual int64_t GetCellularRxBytes() = 0; 293 294 /** 295 * Obtains the bytes sent over the cellular network. 296 * 297 * @return The number of sent bytes. 298 */ 299 virtual int64_t GetCellularTxBytes() = 0; 300 301 /** 302 * Obtains the bytes received through all NICs. 303 * 304 * @return The number of received bytes. 305 */ 306 virtual int64_t GetAllRxBytes() = 0; 307 308 /** 309 * Obtains the bytes sent through all NICs. 310 * 311 * @return The number of sent bytes. 312 */ 313 virtual int64_t GetAllTxBytes() = 0; 314 315 /** 316 * Obtains the bytes received through a specified UID. 317 * 318 * @param uid app id. 319 * @return The number of received bytes. 320 */ 321 virtual int64_t GetUidRxBytes(uint32_t uid) = 0; 322 323 /** 324 * Obtains the bytes sent through a specified UID. 325 * 326 * @param uid app id. 327 * @return The number of sent bytes. 328 */ 329 virtual int64_t GetUidTxBytes(uint32_t uid) = 0; 330 331 /** 332 * Obtains the bytes received through a specified UID on Iface. 333 * 334 * @param uid app id. 335 * @param iface The name of the interface. 336 * @return The number of received bytes. 337 */ 338 virtual int64_t GetUidOnIfaceRxBytes(uint32_t uid, const std::string &interfaceName) = 0; 339 340 /** 341 * Obtains the bytes sent through a specified UID on Iface. 342 * 343 * @param uid app id. 344 * @param iface The name of the interface. 345 * @return The number of sent bytes. 346 */ 347 virtual int64_t GetUidOnIfaceTxBytes(uint32_t uid, const std::string &interfaceName) = 0; 348 349 /** 350 * Obtains the bytes received through a specified NIC. 351 * 352 * @param iface The name of the interface. 353 * @return The number of received bytes. 354 */ 355 virtual int64_t GetIfaceRxBytes(const std::string &interfaceName) = 0; 356 357 /** 358 * Obtains the bytes sent through a specified NIC. 359 * 360 * @param iface The name of the interface. 361 * @return The number of sent bytes. 362 */ 363 virtual int64_t GetIfaceTxBytes(const std::string &interfaceName) = 0; 364 365 /** 366 * Obtains the NIC list. 367 * 368 * @return The list of interface. 369 */ 370 virtual std::vector<std::string> InterfaceGetList() = 0; 371 372 /** 373 * Obtains the uid list. 374 * 375 * @return The list of uid. 376 */ 377 virtual std::vector<std::string> UidGetList() = 0; 378 379 /** 380 * Obtains the packets received through a specified NIC. 381 * 382 * @param iface The name of the interface. 383 * @return The number of received packets. 384 */ 385 virtual int64_t GetIfaceRxPackets(const std::string &interfaceName) = 0; 386 387 /** 388 * Obtains the packets sent through a specified NIC. 389 * 390 * @param iface The name of the interface. 391 * @return The number of sent packets. 392 */ 393 virtual int64_t GetIfaceTxPackets(const std::string &interfaceName) = 0; 394 395 /** 396 * set default network. 397 * 398 * @return Return the return value of the netsys interface call 399 */ 400 virtual int32_t SetDefaultNetWork(int32_t netId) = 0; 401 402 /** 403 * clear default network netId. 404 * 405 * @return Return the return value of the netsys interface call 406 */ 407 virtual int32_t ClearDefaultNetWorkNetId() = 0; 408 409 /** 410 * Obtains the NIC list. 411 * 412 * @param socketFd Socket fd 413 * @param netId Net id 414 * @return Return the return value of the netsys interface call 415 */ 416 virtual int32_t BindSocket(int32_t socketFd, uint32_t netId) = 0; 417 418 /** 419 * Enable ip forwarding. 420 * 421 * @param requestor the requestor of forwarding 422 * @return Return the return value of the netsys interface call. 423 */ 424 virtual int32_t IpEnableForwarding(const std::string &requestor) = 0; 425 426 /** 427 * Disable ip forwarding. 428 * 429 * @param requestor the requestor of forwarding 430 * @return Return the return value of the netsys interface call. 431 */ 432 virtual int32_t IpDisableForwarding(const std::string &requestor) = 0; 433 434 /** 435 * EnableNat. 436 * 437 * @param downstreamIface the name of downstream interface 438 * @param upstreamIface the name of upstream interface 439 * @return Return the return value of the netsys interface call. 440 */ 441 virtual int32_t EnableNat(const std::string &downstreamIface, const std::string &upstreamIface) = 0; 442 443 /** 444 * Disable nat. 445 * 446 * @param downstreamIface the name of downstream interface 447 * @param upstreamIface the name of upstream interface 448 * @return Return the return value of the netsys interface call. 449 */ 450 virtual int32_t DisableNat(const std::string &downstreamIface, const std::string &upstreamIface) = 0; 451 452 /** 453 * Add interface forward. 454 * 455 * @param fromIface the name of incoming interface 456 * @param toIface the name of outcoming interface 457 * @return Return the return value of the netsys interface call. 458 */ 459 virtual int32_t IpfwdAddInterfaceForward(const std::string &fromIface, const std::string &toIface) = 0; 460 461 /** 462 * Remove interface forward. 463 * 464 * @param fromIface the name of incoming interface 465 * @param toIface the name of outcoming interface 466 * @return Return the return value of the netsys interface call. 467 */ 468 virtual int32_t IpfwdRemoveInterfaceForward(const std::string &fromIface, const std::string &toIface) = 0; 469 470 /** 471 * Set tether dns. 472 * 473 * @param netId network id 474 * @param dnsAddr the list of dns address 475 * @return Return the return value of the netsys interface call. 476 */ 477 virtual int32_t ShareDnsSet(uint16_t netId) = 0; 478 479 /** 480 * start dns proxy listen 481 * 482 * @return int32_t 0--success -1---failed 483 */ 484 virtual int32_t StartDnsProxyListen() = 0; 485 486 /** 487 * stop dns proxy listen 488 * 489 * @return int32_t int32_t 0--success -1---failed 490 */ 491 virtual int32_t StopDnsProxyListen() = 0; 492 493 /** 494 * Set net callbackfuction. 495 * 496 * @param callback callbackfuction class 497 * @return Return the return value of the netsys interface call. 498 */ 499 virtual int32_t RegisterNetsysNotifyCallback(const NetsysNotifyCallback &callback) = 0; 500 501 /** 502 * protect tradition network to connect VPN. 503 * 504 * @param socketFd socket file description 505 * @return Return the return value of the netsys interface call. 506 */ 507 virtual int32_t BindNetworkServiceVpn(int32_t socketFd) = 0; 508 509 /** 510 * Enable virtual network iterface card. 511 * 512 * @param socketFd socket file description 513 * @param ifRequest interface request 514 * @param ifaceFd interface file description at output paramenter 515 * @return Return the return value of the netsys interface call. 516 */ 517 virtual int32_t EnableVirtualNetIfaceCard(int32_t socketFd, struct ifreq &ifRequest, int32_t &ifaceFd) = 0; 518 519 /** 520 * Set ip address. 521 * 522 * @param socketFd socket file description 523 * @param ipAddress ip address 524 * @param prefixLen the mask of ip address 525 * @param ifRequest interface request 526 * @return Return the return value of the netsys interface call. 527 */ 528 virtual int32_t SetIpAddress(int32_t socketFd, const std::string &ipAddress, int32_t prefixLen, 529 struct ifreq &ifRequest) = 0; 530 531 /** 532 * Set network blocking. 533 * 534 * @param ifaceFd interface file description 535 * @param isBlock network blocking 536 * @return Return the return value of the netsys interface call. 537 */ 538 virtual int32_t SetBlocking(int32_t ifaceFd, bool isBlock) = 0; 539 /** 540 * Start dhcp client. 541 * 542 * @param iface interface file description 543 * @param bIpv6 network blocking 544 * @return Return the return value of the netsys interface call. 545 */ 546 virtual int32_t StartDhcpClient(const std::string &iface, bool bIpv6) = 0; 547 /** 548 * Stop Dhcp Client. 549 * 550 * @param iface interface file description 551 * @param bIpv6 network blocking 552 * @return Return the return value of the netsys interface call. 553 */ 554 virtual int32_t StopDhcpClient(const std::string &iface, bool bIpv6) = 0; 555 /** 556 * Register Notify Callback 557 * 558 * @param callback 559 * @return Return the return value of the netsys interface call. 560 */ 561 virtual int32_t RegisterCallback(sptr<NetsysControllerCallback> callback) = 0; 562 563 /** 564 * start dhcpservice. 565 * 566 * @param iface interface name 567 * @param ipv4addr ipv4 addr 568 * @return Return the return value of the netsys interface call. 569 */ 570 virtual int32_t StartDhcpService(const std::string &iface, const std::string &ipv4addr) = 0; 571 572 /** 573 * stop dhcpservice. 574 * 575 * @param iface interface name 576 * @return Return the return value of the netsys interface call. 577 */ 578 virtual int32_t StopDhcpService(const std::string &iface) = 0; 579 580 /** 581 * Turn on data saving mode. 582 * 583 * @param enable enable or disable 584 * @return value the return value of the netsys interface call. 585 */ 586 virtual int32_t BandwidthEnableDataSaver(bool enable) = 0; 587 588 /** 589 * Set quota. 590 * 591 * @param iface interface name 592 * @param bytes 593 * @return Return the return value of the netsys interface call. 594 */ 595 virtual int32_t BandwidthSetIfaceQuota(const std::string &ifName, int64_t bytes) = 0; 596 597 /** 598 * Delete quota. 599 * 600 * @param iface interface name 601 * @return Return the return value of the netsys interface call. 602 */ 603 virtual int32_t BandwidthRemoveIfaceQuota(const std::string &ifName) = 0; 604 605 /** 606 * Add DeniedList. 607 * 608 * @param uid 609 * @return Return the return value of the netsys interface call. 610 */ 611 virtual int32_t BandwidthAddDeniedList(uint32_t uid) = 0; 612 613 /** 614 * Remove DeniedList. 615 * 616 * @param uid 617 * @return Return the return value of the netsys interface call. 618 */ 619 virtual int32_t BandwidthRemoveDeniedList(uint32_t uid) = 0; 620 621 /** 622 * Add DeniedList. 623 * 624 * @param uid 625 * @return Return the return value of the netsys interface call. 626 */ 627 virtual int32_t BandwidthAddAllowedList(uint32_t uid) = 0; 628 629 /** 630 * Remove DeniedList. 631 * 632 * @param uid 633 * @return Return the return value of the netsys interface call. 634 */ 635 virtual int32_t BandwidthRemoveAllowedList(uint32_t uid) = 0; 636 637 /** 638 * Set firewall rules. 639 * 640 * @param chain chain type 641 * @param isAllowedList is or not AllowedList 642 * @param uids 643 * @return value the return value of the netsys interface call. 644 */ 645 virtual int32_t FirewallSetUidsAllowedListChain(uint32_t chain, const std::vector<uint32_t> &uids) = 0; 646 647 /** 648 * Set firewall rules. 649 * 650 * @param chain chain type 651 * @param isAllowedList is or not AllowedList 652 * @param uids 653 * @return value the return value of the netsys interface call. 654 */ 655 virtual int32_t FirewallSetUidsDeniedListChain(uint32_t chain, const std::vector<uint32_t> &uids) = 0; 656 657 /** 658 * Enable or disable the specified firewall chain. 659 * 660 * @param chain chain type 661 * @param enable enable or disable 662 * @return Return the return value of the netsys interface call. 663 */ 664 virtual int32_t FirewallEnableChain(uint32_t chain, bool enable) = 0; 665 666 /** 667 * Firewall set uid rule. 668 * 669 * @param chain chain type 670 * @param uid uid 671 * @param firewallRule firewall rule 672 * @return Return the return value of the netsys interface call. 673 */ 674 virtual int32_t FirewallSetUidRule(uint32_t chain, const std::vector<uint32_t> &uids, uint32_t firewallRule) = 0; 675 676 /** 677 * Get total traffic 678 * 679 * @param stats stats 680 * @param type type 681 * @return returns the total traffic of the specified type 682 */ 683 virtual int32_t GetTotalStats(uint64_t &stats, uint32_t type) = 0; 684 685 /** 686 * Get uid traffic 687 * 688 * @param stats stats 689 * @param type type 690 * @param uid uid 691 * @return returns the traffic of the uid 692 */ 693 virtual int32_t GetUidStats(uint64_t &stats, uint32_t type, uint32_t uid) = 0; 694 695 /** 696 * Get Iface traffic 697 * 698 * @param stats stats 699 * @param type type 700 * @param interfaceName interfaceName 701 * @return returns the traffic of the Iface 702 */ 703 virtual int32_t GetIfaceStats(uint64_t &stats, uint32_t type, const std::string &interfaceName) = 0; 704 705 /** 706 * Get all stats info 707 * 708 * @param stats stats 709 * @return returns the all info of the stats 710 */ 711 virtual int32_t GetAllStatsInfo(std::vector<OHOS::NetManagerStandard::NetStatsInfo> &stats) = 0; 712 713 /** 714 * Set iptables for result 715 * 716 * @param cmd Iptables command 717 * @param respond The respond of execute iptables command 718 * @return Value the return value of the netsys interface call 719 */ 720 virtual int32_t SetIptablesCommandForRes(const std::string &cmd, std::string &respond) = 0; 721 722 /** 723 * Check network connectivity by sending packets to a host and reporting its response. 724 * 725 * @param pingOption Ping option 726 * @param callback The respond of execute ping cmd. 727 * @return Value the return value of the netsys interface call 728 */ 729 virtual int32_t NetDiagPingHost(const OHOS::NetsysNative::NetDiagPingOption &pingOption, 730 const sptr<OHOS::NetsysNative::INetDiagCallback> &callback) = 0; 731 732 /** 733 * Get networking route table 734 * 735 * @param routeTables Network route table list. 736 * @return Value the return value of the netsys interface call 737 */ 738 virtual int32_t NetDiagGetRouteTable(std::list<OHOS::NetsysNative::NetDiagRouteTable> &routeTables) = 0; 739 740 /** 741 * Get networking sockets info. 742 * 743 * @param socketType Network protocol. 744 * @param socketsInfo The result of network sockets info. 745 * @return Value the return value of the netsys interface call 746 */ 747 virtual int32_t NetDiagGetSocketsInfo(OHOS::NetsysNative::NetDiagProtocolType socketType, 748 OHOS::NetsysNative::NetDiagSocketsInfo &socketsInfo) = 0; 749 750 /** 751 * Get network interface configuration. 752 * 753 * @param configs The result of network interface configuration. 754 * @param ifaceName Get interface configuration information for the specified interface name. 755 * If the interface name is empty, default to getting all interface configuration information. 756 * @return Value the return value of the netsys interface call 757 */ 758 virtual int32_t NetDiagGetInterfaceConfig(std::list<OHOS::NetsysNative::NetDiagIfaceConfig> &configs, 759 const std::string &ifaceName) = 0; 760 761 /** 762 * Update network interface configuration. 763 * 764 * @param configs Network interface configuration. 765 * @param ifaceName Interface name. 766 * @param add Add or delete. 767 * @return Value the return value of the netsys interface call 768 */ 769 virtual int32_t NetDiagUpdateInterfaceConfig(const OHOS::NetsysNative::NetDiagIfaceConfig &config, 770 const std::string &ifaceName, bool add) = 0; 771 772 /** 773 * Set network interface up/down state. 774 * 775 * @param ifaceName Interface name. 776 * @param up Up or down. 777 * @return Value the return value of the netsys interface call 778 */ 779 virtual int32_t NetDiagSetInterfaceActiveState(const std::string &ifaceName, bool up) = 0; 780 virtual int32_t AddStaticArp(const std::string &ipAddr, const std::string &macAddr, 781 const std::string &ifName) = 0; 782 virtual int32_t DelStaticArp(const std::string &ipAddr, const std::string &macAddr, 783 const std::string &ifName) = 0; 784 785 /** 786 * Register Dns Result Callback Listener. 787 * 788 * @param callback Callback function 789 * @param timestep Time gap between two callbacks 790 * @return Value the return value of the netsys interface call 791 */ 792 virtual int32_t RegisterDnsResultCallback(const sptr<OHOS::NetManagerStandard::NetsysDnsReportCallback> &callback, 793 uint32_t timeStep) = 0; 794 795 /** 796 * Unregister Dns Result Callback Listener. 797 * 798 * @param callback Callback function 799 * @return Value the return value of the netsys interface call 800 */ 801 virtual int32_t UnregisterDnsResultCallback( 802 const sptr<OHOS::NetManagerStandard::NetsysDnsReportCallback> &callback) = 0; 803 804 /** 805 * Register Dns Health Callback Listener. 806 * 807 * @param callback Callback function 808 * @return Value the return value of the netsys interface call 809 */ 810 virtual int32_t RegisterDnsHealthCallback(const sptr<OHOS::NetsysNative::INetDnsHealthCallback> &callback) = 0; 811 812 /** 813 * Unregister Dns Health Callback Listener. 814 * 815 * @param callback Callback function 816 * @return Value the return value of the netsys interface call 817 */ 818 virtual int32_t UnregisterDnsHealthCallback(const sptr<OHOS::NetsysNative::INetDnsHealthCallback> &callback) = 0; 819 820 /** 821 * Get Cookie Stats. 822 * 823 * @param stats stats 824 * @param type type 825 * @param cookie cookie 826 * @return Value the return value of the netsys interface call 827 */ 828 virtual int32_t GetCookieStats(uint64_t &stats, uint32_t type, uint64_t cookie) = 0; 829 }; 830 } // namespace NetManagerStandard 831 } // namespace OHOS 832 #endif // I_NETSYSCONTROLLER_SERVICE_H 833