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

Function socketControlMessageTimestamp

timestamp/timestamp_linux.go:268–282  ·  view source on GitHub ↗

socketControlMessageTimestamp is a very optimised version of ParseSocketControlMessage https://github.com/golang/go/blob/2ebe77a2fda1ee9ff6fd9a3e08933ad1ebaea039/src/syscall/sockcmsg_unix.go#L40 which only parses the timestamp message type

(b []byte, boob int)

Source from the content-addressed store, hash-verified

266 mlen := 0
267 for i := 0; i < boob; i += unix.CmsgSpace(mlen - unix.SizeofCmsghdr) {
268 h := (*unix.Cmsghdr)(unsafe.Pointer(&b[i]))
269 mlen = int(h.Len) //#nosec G115
270 if mlen == 0 {
271 break
272 }
273 // depending on the kernel version, when we ask for SO_TIMESTAMPING_NEW we still might get messages with type SO_TIMESTAMPING
274 if h.Level == unix.SOL_SOCKET && int(h.Type) == unix.SO_TIMESTAMPING_NEW || int(h.Type) == unix.SO_TIMESTAMPING {
275 return scmDataToTime(b[i+socketControlMessageHeaderOffset : i+mlen])
276 }
277 }
278 return time.Time{}, ErrNoTimestamp
279}
280
281// socketControlMessageDrops parses SocketControlMessage for drops count
282// drops are provided by SO_RXQ_OVFL control message when enabled
283func socketControlMessageDrops(b []byte, boob int) uint32 {
284 mlen := 0
285 var drops uint32

Callers 5

ReadRXTimestampFunction · 0.70
ReadTXtimestampBufFunction · 0.70

Calls 1

scmDataToTimeFunction · 0.70

Used in the wild real call sites across dependent graphs

searching dependent graphs…