Debian Codegraph @

tcpip/network/ipv6/stats.go

raw symbols SCIP
1 // Copyright 2020 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 ipv6
16
17 import (
18 "inet.af/netstack/tcpip"
19 "inet.af/netstack/tcpip/network/internal/ip"
20 "inet.af/netstack/tcpip/stack"
21 )
22
23 var _ stack.IPNetworkEndpointStats = (*Stats)(nil)
24
25 // Stats holds statistics related to the IPv6 protocol family.
26 type Stats struct {
27 // IP holds IPv6 statistics.
28 IP tcpip.IPStats
29
30 // ICMP holds ICMPv6 statistics.
31 ICMP tcpip.ICMPv6Stats
32
33 // UnhandledRouterAdvertisements is the number of Router Advertisements that
34 // were observed but not handled.
35 UnhandledRouterAdvertisements *tcpip.StatCounter
36 }
37
38 // IsNetworkEndpointStats implements stack.NetworkEndpointStats.
39 func (*Stats) IsNetworkEndpointStats() {}
40
41 // IPStats implements stack.IPNetworkEndointStats
42 func (s *Stats) IPStats() *tcpip.IPStats {
43 return &s.IP
44 }
45
46 type sharedStats struct {
47 localStats Stats
48 ip ip.MultiCounterIPStats
49 icmp multiCounterICMPv6Stats
50 }
51
52 // LINT.IfChange(multiCounterICMPv6PacketStats)
53
54 type multiCounterICMPv6PacketStats struct {
55 echoRequest tcpip.MultiCounterStat
56 echoReply tcpip.MultiCounterStat
57 dstUnreachable tcpip.MultiCounterStat
58 packetTooBig tcpip.MultiCounterStat
59 timeExceeded tcpip.MultiCounterStat
60 paramProblem tcpip.MultiCounterStat
61 routerSolicit tcpip.MultiCounterStat
62 routerAdvert tcpip.MultiCounterStat
63 neighborSolicit tcpip.MultiCounterStat
64 neighborAdvert tcpip.MultiCounterStat
65 redirectMsg tcpip.MultiCounterStat
66 multicastListenerQuery tcpip.MultiCounterStat
67 multicastListenerReport tcpip.MultiCounterStat
68 multicastListenerDone tcpip.MultiCounterStat
69 }
70
71 func (m *multiCounterICMPv6PacketStats) init(a, b *tcpip.ICMPv6PacketStats) {
72 m.echoRequest.Init(a.EchoRequest, b.EchoRequest)
73 m.echoReply.Init(a.EchoReply, b.EchoReply)
74 m.dstUnreachable.Init(a.DstUnreachable, b.DstUnreachable)
75 m.packetTooBig.Init(a.PacketTooBig, b.PacketTooBig)
76 m.timeExceeded.Init(a.TimeExceeded, b.TimeExceeded)
77 m.paramProblem.Init(a.ParamProblem, b.ParamProblem)
78 m.routerSolicit.Init(a.RouterSolicit, b.RouterSolicit)
79 m.routerAdvert.Init(a.RouterAdvert, b.RouterAdvert)
80 m.neighborSolicit.Init(a.NeighborSolicit, b.NeighborSolicit)
81 m.neighborAdvert.Init(a.NeighborAdvert, b.NeighborAdvert)
82 m.redirectMsg.Init(a.RedirectMsg, b.RedirectMsg)
83 m.multicastListenerQuery.Init(a.MulticastListenerQuery, b.MulticastListenerQuery)
84 m.multicastListenerReport.Init(a.MulticastListenerReport, b.MulticastListenerReport)
85 m.multicastListenerDone.Init(a.MulticastListenerDone, b.MulticastListenerDone)
86 }
87
88 // LINT.ThenChange(../../tcpip.go:ICMPv6PacketStats)
89
90 // LINT.IfChange(multiCounterICMPv6SentPacketStats)
91
92 type multiCounterICMPv6SentPacketStats struct {
93 multiCounterICMPv6PacketStats
94 dropped tcpip.MultiCounterStat
95 rateLimited tcpip.MultiCounterStat
96 }
97
98 func (m *multiCounterICMPv6SentPacketStats) init(a, b *tcpip.ICMPv6SentPacketStats) {
99 m.multiCounterICMPv6PacketStats.init(&a.ICMPv6PacketStats, &b.ICMPv6PacketStats)
100 m.dropped.Init(a.Dropped, b.Dropped)
101 m.rateLimited.Init(a.RateLimited, b.RateLimited)
102 }
103
104 // LINT.ThenChange(../../tcpip.go:ICMPv6SentPacketStats)
105
106 // LINT.IfChange(multiCounterICMPv6ReceivedPacketStats)
107
108 type multiCounterICMPv6ReceivedPacketStats struct {
109 multiCounterICMPv6PacketStats
110 unrecognized tcpip.MultiCounterStat
111 invalid tcpip.MultiCounterStat
112 routerOnlyPacketsDroppedByHost tcpip.MultiCounterStat
113 }
114
115 func (m *multiCounterICMPv6ReceivedPacketStats) init(a, b *tcpip.ICMPv6ReceivedPacketStats) {
116 m.multiCounterICMPv6PacketStats.init(&a.ICMPv6PacketStats, &b.ICMPv6PacketStats)
117 m.unrecognized.Init(a.Unrecognized, b.Unrecognized)
118 m.invalid.Init(a.Invalid, b.Invalid)
119 m.routerOnlyPacketsDroppedByHost.Init(a.RouterOnlyPacketsDroppedByHost, b.RouterOnlyPacketsDroppedByHost)
120 }
121
122 // LINT.ThenChange(../../tcpip.go:ICMPv6ReceivedPacketStats)
123
124 // LINT.IfChange(multiCounterICMPv6Stats)
125
126 type multiCounterICMPv6Stats struct {
127 packetsSent multiCounterICMPv6SentPacketStats
128 packetsReceived multiCounterICMPv6ReceivedPacketStats
129 }
130
131 func (m *multiCounterICMPv6Stats) init(a, b *tcpip.ICMPv6Stats) {
132 m.packetsSent.init(&a.PacketsSent, &b.PacketsSent)
133 m.packetsReceived.init(&a.PacketsReceived, &b.PacketsReceived)
134 }
135
136 // LINT.ThenChange(../../tcpip.go:ICMPv6Stats)