EnableTimestamps enables timestamps on the socket based on requested type
(ts Timestamp, connFd int, iface *net.Interface)
| 411 | } |
| 412 | |
| 413 | if timestamp, err := socketControlMessageSeqIDTimestamp(toob, tboob, seqID); err == nil { |
| 414 | return timestamp, attempts, nil |
| 415 | } |
| 416 | } |
| 417 | timeout := time.Since(timeStart) |
| 418 | return time.Time{}, attempts, fmt.Errorf("no TX timestamp found after %d tries (%d ms)", AttemptsTXTS, timeout.Milliseconds()) |
| 419 | } |
| 420 | |
| 421 | // ReadTXtimestamp returns HW TX timestamp |
| 422 | func ReadTXtimestamp(connFd int) (time.Time, int, error) { |
| 423 | // Accessing hw timestamp |
| 424 | oob := make([]byte, ControlSizeBytes) |
| 425 | // TMP buffers |
| 426 | toob := make([]byte, ControlSizeBytes) |
| 427 | |
| 428 | return ReadTXtimestampBuf(connFd, oob, toob) |
| 429 | } |
| 430 | |
| 431 | // EnableTimestamps enables timestamps on the socket based on requested type |
| 432 | func EnableTimestamps(ts Timestamp, connFd int, iface *net.Interface) error { |
| 433 | switch ts { |
| 434 | case HW: |
| 435 | if err := EnableHWTimestamps(connFd, iface); err != nil { |
| 436 | return fmt.Errorf("cannot enable hardware timestamps: %w", err) |
| 437 | } |
| 438 | case HWRX: |
searching dependent graphs…