Debian Codegraph @

utils_windows.go

raw symbols SCIP
1 // Copyright The Prometheus Authors
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 //go:build windows
15 // +build windows
16
17 package probing
18
19 import (
20 "math"
21
22 "golang.org/x/net/ipv4"
23 "golang.org/x/net/ipv6"
24 )
25
26 const (
27 minimumBufferLength = 2048
28 )
29
30 // Returns the length of an ICMP message, plus the IP packet header.
31 // Calculated as:
32 // len(ICMP request data) + 2 * (len(ICMP header) + len(IP header))
33 //
34 // On Windows, the buffer needs to be able to contain:
35 // - Response IP Header
36 // - Response ICMP Header
37 // - Request IP Header
38 // - Request ICMP Header
39 // - Request Data
40 func (p *Pinger) getMessageLength() int {
41 if p.ipv4 {
42 calculatedLength := p.Size + (ipv4.HeaderLen+8)*2
43 return int(math.Max(float64(calculatedLength), float64(minimumBufferLength)))
44 }
45 calculatedLength := p.Size + (ipv6.HeaderLen+8)*2
46 return int(math.Max(float64(calculatedLength), float64(minimumBufferLength)))
47 }
48
49 // Attempts to match the ID of an ICMP packet.
50 func (p *Pinger) matchID(ID int) bool {
51 if ID != p.id {
52 return false
53 }
54 return true
55 }
56
57 // SetMark sets the SO_MARK socket option on outgoing ICMP packets.
58 // Setting this option requires CAP_NET_ADMIN.
59 func (c *icmpConn) SetMark(mark uint) error {
60 return ErrMarkNotSupported
61 }
62
63 // SetMark sets the SO_MARK socket option on outgoing ICMP packets.
64 // Setting this option requires CAP_NET_ADMIN.
65 func (c *icmpv4Conn) SetMark(mark uint) error {
66 return ErrMarkNotSupported
67 }
68
69 // SetMark sets the SO_MARK socket option on outgoing ICMP packets.
70 // Setting this option requires CAP_NET_ADMIN.
71 func (c *icmpV6Conn) SetMark(mark uint) error {
72 return ErrMarkNotSupported
73 }
74
75 // SetDoNotFragment sets the do-not-fragment bit in the IP header of outgoing ICMP packets.
76 func (c *icmpConn) SetDoNotFragment() error {
77 return ErrDFNotSupported
78 }
79
80 // SetDoNotFragment sets the do-not-fragment bit in the IP header of outgoing ICMP packets.
81 func (c *icmpv4Conn) SetDoNotFragment() error {
82 return ErrDFNotSupported
83 }
84
85 // SetDoNotFragment sets the do-not-fragment bit in the IPv6 header of outgoing ICMPv6 packets.
86 func (c *icmpV6Conn) SetDoNotFragment() error {
87 return ErrDFNotSupported
88 }
89
90 // No need for SetBroadcastFlag in non-linux OSes
91 func (c *icmpConn) SetBroadcastFlag() error {
92 return nil
93 }
94
95 func (c *icmpv4Conn) SetBroadcastFlag() error {
96 return nil
97 }
98
99 func (c *icmpV6Conn) SetBroadcastFlag() error {
100 return nil
101 }
102
103 func (c *icmpv4Conn) InstallICMPIDFilter(id int) error {
104 return nil
105 }
106
107 func (c *icmpV6Conn) InstallICMPIDFilter(id int) error {
108 return nil
109 }