MCPcopy Create free account
hub / github.com/facebook/time / ioctlTimestamp

Function ioctlTimestamp

timestamp/timestamp_linux.go:124–144  ·  view source on GitHub ↗
(fd int, ifname string, filter int32)

Source from the content-addressed store, hash-verified

122 hw, err := unix.IoctlGetHwTstamp(fd, ifname)
123 if errors.Is(err, unix.ENOTSUP) {
124 // for the loopback interface
125 hw = &unix.HwTstampConfig{}
126 } else if err != nil {
127 return fmt.Errorf("failed to run ioctl SIOCGHWTSTAMP to see what is enabled: %w", err)
128 }
129
130 // now check if it matches what we want
131 if hw.Tx_type == unix.HWTSTAMP_TX_ON && hw.Rx_filter == filter {
132 return nil
133 }
134 // set to desired values
135 hw.Tx_type = unix.HWTSTAMP_TX_ON
136 hw.Rx_filter = filter
137 if err := unix.IoctlSetHwTstamp(fd, ifname, hw); err != nil {
138 return fmt.Errorf("failed to run ioctl SIOCSHWTSTAMP to set timestamps enabled: %w", err)
139 }
140 return nil
141}
142
143// EnableSWTimestampsRx enables SW RX timestamps on the socket
144func EnableSWTimestampsRx(connFd int) error {
145 flags := unix.SOF_TIMESTAMPING_RX_SOFTWARE |
146 unix.SOF_TIMESTAMPING_SOFTWARE
147 // Allow reading of SW timestamps via socket

Callers 2

EnableHWTimestampsFunction · 0.85
EnableHWTimestampsRxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…