• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.android.networkstack.tethering;
18 
19 import android.net.MacAddress;
20 
21 import androidx.annotation.NonNull;
22 
23 import com.android.net.module.util.Struct;
24 
25 import java.util.Objects;
26 
27 /** Value type for downstream and upstream IPv6 forwarding maps. */
28 public class Tether6Value extends Struct {
29     @Field(order = 0, type = Type.S32)
30     public final int oif; // The output interface index.
31 
32     // The ethhdr struct which is defined in uapi/linux/if_ether.h
33     @Field(order = 1, type = Type.EUI48)
34     public final MacAddress ethDstMac; // The destination mac address.
35     @Field(order = 2, type = Type.EUI48)
36     public final MacAddress ethSrcMac; // The source mac address.
37     @Field(order = 3, type = Type.UBE16)
38     public final int ethProto; // Packet type ID field.
39 
40     @Field(order = 4, type = Type.U16)
41     public final int pmtu; // The maximum L3 output path/route mtu.
42 
Tether6Value(final int oif, @NonNull final MacAddress ethDstMac, @NonNull final MacAddress ethSrcMac, final int ethProto, final int pmtu)43     public Tether6Value(final int oif, @NonNull final MacAddress ethDstMac,
44             @NonNull final MacAddress ethSrcMac, final int ethProto, final int pmtu) {
45         Objects.requireNonNull(ethSrcMac);
46         Objects.requireNonNull(ethDstMac);
47 
48         this.oif = oif;
49         this.ethDstMac = ethDstMac;
50         this.ethSrcMac = ethSrcMac;
51         this.ethProto = ethProto;
52         this.pmtu = pmtu;
53     }
54 
55     @Override
toString()56     public String toString() {
57         return String.format("oif: %d, dstMac: %s, srcMac: %s, proto: %d, pmtu: %d", oif,
58                 ethDstMac, ethSrcMac, ethProto, pmtu);
59     }
60 }
61