1 /*
2 * Copyright (C) 2020 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 "structs.h"
18
19 namespace android::nl::protocols::route {
20
mapToStream(std::stringstream & ss,const Buffer<nlattr> attr)21 void mapToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
22 const auto& [ok, data] = attr.data<rtnl_link_ifmap>().getFirst();
23 if (!ok) {
24 ss << "invalid structure";
25 return;
26 }
27 ss << '{' //
28 << data.mem_start << ',' //
29 << data.mem_end << ',' //
30 << data.base_addr << ',' //
31 << data.irq << ',' //
32 << unsigned(data.dma) << ',' //
33 << unsigned(data.port) << '}';
34 }
35
ifla_cacheinfoToStream(std::stringstream & ss,const Buffer<nlattr> attr)36 void ifla_cacheinfoToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
37 const auto& [ok, data] = attr.data<ifla_cacheinfo>().getFirst();
38 if (!ok) {
39 ss << "invalid structure";
40 return;
41 }
42 ss << '{' //
43 << data.max_reasm_len << ',' //
44 << data.tstamp << ',' //
45 << data.reachable_time << ',' //
46 << data.retrans_time << '}';
47 }
48
49 } // namespace android::nl::protocols::route
50