Debian Codegraph @

tcpip/header/ndp_neighbor_solicit.go

raw symbols SCIP
1 // Copyright 2019 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 header
16
17 import "inet.af/netstack/tcpip"
18
19 // NDPNeighborSolicit is an NDP Neighbor Solicitation message. It will only
20 // contain the body of an ICMPv6 packet.
21 //
22 // See RFC 4861 section 4.3 for more details.
23 type NDPNeighborSolicit []byte
24
25 const (
26 // NDPNSMinimumSize is the minimum size of a valid NDP Neighbor
27 // Solicitation message (body of an ICMPv6 packet).
28 NDPNSMinimumSize = 20
29
30 // ndpNSTargetAddessOffset is the start of the Target Address
31 // field within an NDPNeighborSolicit.
32 ndpNSTargetAddessOffset = 4
33
34 // ndpNSOptionsOffset is the start of the NDP options in an
35 // NDPNeighborSolicit.
36 ndpNSOptionsOffset = ndpNSTargetAddessOffset + IPv6AddressSize
37 )
38
39 // TargetAddress returns the value within the Target Address field.
40 func (b NDPNeighborSolicit) TargetAddress() tcpip.Address {
41 return tcpip.Address(b[ndpNSTargetAddessOffset:][:IPv6AddressSize])
42 }
43
44 // SetTargetAddress sets the value within the Target Address field.
45 func (b NDPNeighborSolicit) SetTargetAddress(addr tcpip.Address) {
46 copy(b[ndpNSTargetAddessOffset:][:IPv6AddressSize], addr)
47 }
48
49 // Options returns an NDPOptions of the the options body.
50 func (b NDPNeighborSolicit) Options() NDPOptions {
51 return NDPOptions(b[ndpNSOptionsOffset:])
52 }