(fd int, ifname string, filter int32)
| 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 |
| 144 | func EnableSWTimestampsRx(connFd int) error { |
| 145 | flags := unix.SOF_TIMESTAMPING_RX_SOFTWARE | |
| 146 | unix.SOF_TIMESTAMPING_SOFTWARE |
| 147 | // Allow reading of SW timestamps via socket |
no outgoing calls
no test coverage detected
searching dependent graphs…