Debian Codegraph @

abi/linux/netdevice.go

raw symbols SCIP
1 // Copyright 2018 The gVisor Authors.
2 //
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 package linux
16
17 const (
18 // IFNAMSIZ is the size of the name field for IFReq.
19 IFNAMSIZ = 16
20 )
21
22 // IFReq is an interface request.
23 //
24 // +marshal
25 type IFReq struct {
26 // IFName is an encoded name, normally null-terminated. This should be
27 // accessed via the Name and SetName functions.
28 IFName [IFNAMSIZ]byte
29
30 // Data is the union of the following structures:
31 //
32 // struct sockaddr ifr_addr;
33 // struct sockaddr ifr_dstaddr;
34 // struct sockaddr ifr_broadaddr;
35 // struct sockaddr ifr_netmask;
36 // struct sockaddr ifr_hwaddr;
37 // short ifr_flags;
38 // int ifr_ifindex;
39 // int ifr_metric;
40 // int ifr_mtu;
41 // struct ifmap ifr_map;
42 // char ifr_slave[IFNAMSIZ];
43 // char ifr_newname[IFNAMSIZ];
44 // char *ifr_data;
45 Data [24]byte
46 }
47
48 // Name returns the name.
49 func (ifr *IFReq) Name() string {
50 for c := 0; c < len(ifr.IFName); c++ {
51 if ifr.IFName[c] == 0 {
52 return string(ifr.IFName[:c])
53 }
54 }
55 return string(ifr.IFName[:])
56 }
57
58 // SetName sets the name.
59 func (ifr *IFReq) SetName(name string) {
60 n := copy(ifr.IFName[:], []byte(name))
61 for i := n; i < len(ifr.IFName); i++ {
62 ifr.IFName[i] = 0
63 }
64 }
65
66 // SizeOfIFReq is the binary size of an IFReq struct (40 bytes).
67 var SizeOfIFReq = (*IFReq)(nil).SizeBytes()
68
69 // IFMap contains interface hardware parameters.
70 type IFMap struct {
71 MemStart uint64
72 MemEnd uint64
73 BaseAddr int16
74 IRQ byte
75 DMA byte
76 Port byte
77 _ [3]byte // Pad to sizeof(struct ifmap).
78 }
79
80 // IFConf is used to return a list of interfaces and their addresses. See
81 // netdevice(7) and struct ifconf for more detail on its use.
82 //
83 // +marshal
84 type IFConf struct {
85 Len int32
86 _ [4]byte // Pad to sizeof(struct ifconf).
87 Ptr uint64
88 }