github.com/ttpreport/gvisor-ligolo@v0.0.0-20240123134145-a858404967ba/pkg/tcpip/network/arp/stats.go (about) 1 // Copyright 2021 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 arp 16 17 import ( 18 "github.com/ttpreport/gvisor-ligolo/pkg/tcpip" 19 "github.com/ttpreport/gvisor-ligolo/pkg/tcpip/stack" 20 ) 21 22 var _ stack.NetworkEndpointStats = (*Stats)(nil) 23 24 // Stats holds statistics related to ARP. 25 type Stats struct { 26 // ARP holds ARP statistics. 27 ARP tcpip.ARPStats 28 } 29 30 // IsNetworkEndpointStats implements stack.NetworkEndpointStats. 31 func (*Stats) IsNetworkEndpointStats() {} 32 33 type sharedStats struct { 34 localStats Stats 35 arp multiCounterARPStats 36 } 37 38 // LINT.IfChange(multiCounterARPStats) 39 40 type multiCounterARPStats struct { 41 packetsReceived tcpip.MultiCounterStat 42 disabledPacketsReceived tcpip.MultiCounterStat 43 malformedPacketsReceived tcpip.MultiCounterStat 44 requestsReceived tcpip.MultiCounterStat 45 requestsReceivedUnknownTargetAddress tcpip.MultiCounterStat 46 outgoingRequestInterfaceHasNoLocalAddressErrors tcpip.MultiCounterStat 47 outgoingRequestBadLocalAddressErrors tcpip.MultiCounterStat 48 outgoingRequestsDropped tcpip.MultiCounterStat 49 outgoingRequestsSent tcpip.MultiCounterStat 50 repliesReceived tcpip.MultiCounterStat 51 outgoingRepliesDropped tcpip.MultiCounterStat 52 outgoingRepliesSent tcpip.MultiCounterStat 53 } 54 55 func (m *multiCounterARPStats) init(a, b *tcpip.ARPStats) { 56 m.packetsReceived.Init(a.PacketsReceived, b.PacketsReceived) 57 m.disabledPacketsReceived.Init(a.DisabledPacketsReceived, b.DisabledPacketsReceived) 58 m.malformedPacketsReceived.Init(a.MalformedPacketsReceived, b.MalformedPacketsReceived) 59 m.requestsReceived.Init(a.RequestsReceived, b.RequestsReceived) 60 m.requestsReceivedUnknownTargetAddress.Init(a.RequestsReceivedUnknownTargetAddress, b.RequestsReceivedUnknownTargetAddress) 61 m.outgoingRequestInterfaceHasNoLocalAddressErrors.Init(a.OutgoingRequestInterfaceHasNoLocalAddressErrors, b.OutgoingRequestInterfaceHasNoLocalAddressErrors) 62 m.outgoingRequestBadLocalAddressErrors.Init(a.OutgoingRequestBadLocalAddressErrors, b.OutgoingRequestBadLocalAddressErrors) 63 m.outgoingRequestsDropped.Init(a.OutgoingRequestsDropped, b.OutgoingRequestsDropped) 64 m.outgoingRequestsSent.Init(a.OutgoingRequestsSent, b.OutgoingRequestsSent) 65 m.repliesReceived.Init(a.RepliesReceived, b.RepliesReceived) 66 m.outgoingRepliesDropped.Init(a.OutgoingRepliesDropped, b.OutgoingRepliesDropped) 67 m.outgoingRepliesSent.Init(a.OutgoingRepliesSent, b.OutgoingRepliesSent) 68 } 69 70 // LINT.ThenChange(../../tcpip.go:ARPStats)