ReadTXtimestampBuf returns HW TX timestamp, needs to be provided 2 buffers which all can be re-used after ReadTXtimestampBuf finishes.
(connFd int, oob, toob []byte)
| 336 | return time.Time{}, ErrNoTimestamp |
| 337 | } |
| 338 | } |
| 339 | if h.Level == unix.SOL_IPV6 && int(h.Type) == unix.IPV6_RECVERR || |
| 340 | h.Level == unix.SOL_IP && int(h.Type) == unix.IP_RECVERR { |
| 341 | cseq, err = scmDataToSeqID(b[i+socketControlMessageHeaderOffset : i+mlen]) |
| 342 | if err != nil { |
| 343 | return time.Time{}, ErrNoTimestamp |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | if tstamp.IsZero() { |
| 348 | return time.Time{}, ErrNoTimestamp |
| 349 | } |
| 350 | if cseq == seqID { |
| 351 | return tstamp, nil |
| 352 | } |
| 353 | return time.Time{}, ErrNoTimestamp |
| 354 | } |
| 355 | |
| 356 | // ReadTXtimestampBuf returns HW TX timestamp, needs to be provided 2 buffers which all can be re-used after ReadTXtimestampBuf finishes. |
| 357 | func ReadTXtimestampBuf(connFd int, oob, toob []byte) (time.Time, int, error) { |
| 358 | // Accessing hw timestamp |
| 359 | var boob int |
| 360 | |
| 361 | txfound := false |
| 362 | // Sometimes we end up with more than 1 TX TS in the buffer. |
| 363 | // We need to empty it and completely otherwise we end up with a shifted queue read: |
| 364 | // Sync is out -> read TS from the previous Sync |
| 365 | // Because we always perform at least 2 tries we start with 0 so on success we are at 1. |
| 366 | timeStart := time.Now() |
| 367 | attempts := 0 |
| 368 | for ; attempts < AttemptsTXTS; attempts++ { |
| 369 | if !txfound { |
| 370 | // Wait for the poll event, ignore the error |
| 371 | _ = waitForHWTS(connFd) |
| 372 | } |
| 373 | |
| 374 | tboob, err := recvoob(connFd, toob) |
| 375 | if err != nil { |
| 376 | // We've already seen the valid TX TS and now we have an empty queue. |
| 377 | // All good |
| 378 | if txfound { |
| 379 | break |
| 380 | } |
no test coverage detected
searching dependent graphs…