• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "RadioData.h"
18 
19 #include <aidl/android/hardware/radio/RadioConst.h>
20 #include <libminradio/debug.h>
21 #include <libminradio/response.h>
22 #include <libnetdevice/libnetdevice.h>
23 
24 #define RADIO_MODULE "DataImpl"
25 
26 namespace android::hardware::radio::service {
27 
28 using namespace ::android::hardware::radio::minimal::binder_printing;
29 using ::aidl::android::hardware::radio::RadioConst;
30 using ::aidl::android::hardware::radio::RadioError;
31 using ::android::hardware::radio::minimal::errorResponse;
32 using ::android::hardware::radio::minimal::noError;
33 using ::ndk::ScopedAStatus;
34 namespace aidl = ::aidl::android::hardware::radio::data;
35 namespace aidlCommon = ::aidl::android::hardware::radio;
36 constexpr auto ok = &ScopedAStatus::ok;
37 
setupDataCall(int32_t serial,aidlCommon::AccessNetwork accessNetwork,const aidl::DataProfileInfo & dataProfileInfo,bool roamingAllowed,aidl::DataRequestReason reason,const std::vector<aidl::LinkAddress> & addresses,const std::vector<std::string> & dnses,int32_t pduSessId,const std::optional<aidl::SliceInfo> & sliceInfo,bool matchAllRuleAllowed)38 ScopedAStatus RadioData::setupDataCall(int32_t serial, aidlCommon::AccessNetwork accessNetwork,
39                                        const aidl::DataProfileInfo& dataProfileInfo,
40                                        bool roamingAllowed, aidl::DataRequestReason reason,
41                                        const std::vector<aidl::LinkAddress>& addresses,
42                                        const std::vector<std::string>& dnses, int32_t pduSessId,
43                                        const std::optional<aidl::SliceInfo>& sliceInfo,
44                                        bool matchAllRuleAllowed) {
45     LOG_CALL << accessNetwork                             //
46              << " {" << dataProfileInfo.profileId << '}'  //
47              << ' ' << roamingAllowed                     //
48              << ' ' << reason                             //
49              << ' ' << addresses.size()                   //
50              << ' ' << dnses.size() << ' ' << pduSessId   //
51              << ' ' << sliceInfo.has_value()              //
52              << ' ' << matchAllRuleAllowed;
53 
54     bool ifaceOk = netdevice::setAddr4("buried_eth0", "192.168.97.2", 30);
55     ifaceOk = ifaceOk && netdevice::up("buried_eth0");
56     if (!ifaceOk) {
57         respond()->setupDataCallResponse(errorResponse(serial, RadioError::INTERNAL_ERR), {});
58         return ok();
59     }
60 
61     aidl::SetupDataCallResult result{
62             .cause = aidl::DataCallFailCause::NONE,
63             .suggestedRetryTime = RadioConst::VALUE_UNAVAILABLE_LONG,
64             .cid = setupDataCallCid(),
65             .active = aidl::SetupDataCallResult::DATA_CONNECTION_STATUS_ACTIVE,
66             .type = aidl::PdpProtocolType::IP,
67             .ifname = "buried_eth0",
68             .addresses = {{
69                     .address = "192.168.97.2/30",
70                     .addressProperties = 0,
71                     .deprecationTime = RadioConst::VALUE_UNAVAILABLE_LONG,
72                     .expirationTime = RadioConst::VALUE_UNAVAILABLE_LONG,
73             }},
74             .dnses = {"8.8.8.8"},
75             .gateways = {"192.168.97.1"},
76             .pcscf = {},
77             .mtuV4 = 0,
78             .mtuV6 = 0,
79             .defaultQos = {},
80             .qosSessions = {},
81             .handoverFailureMode = aidl::SetupDataCallResult::HANDOVER_FAILURE_MODE_LEGACY,
82             .pduSessionId = 0,
83             .sliceInfo = std::nullopt,
84             .trafficDescriptors = {},
85     };
86 
87     setupDataCallBase(result);
88 
89     respond()->setupDataCallResponse(noError(serial), result);
90     return ok();
91 }
92 
93 }  // namespace android::hardware::radio::service
94