(t *testing.T)
| 283 | require.True(t, dst.Equal(addr)) |
| 284 | require.True(t, dst.IsMulticast()) |
| 285 | }) |
| 286 | |
| 287 | t.Run("IPv4 unicast", func(t *testing.T) { |
| 288 | addr := net.ParseIP("10.0.0.1") |
| 289 | b := pktInfo4Cmsg(addr) |
| 290 | dst, err := socketControlMessageDstAddr(b, len(b)) |
| 291 | require.NoError(t, err) |
| 292 | require.True(t, dst.Equal(addr)) |
| 293 | require.False(t, dst.IsMulticast()) |
| 294 | }) |
| 295 | |
| 296 | t.Run("no pktinfo", func(t *testing.T) { |
| 297 | _, err := socketControlMessageDstAddr(make([]byte, 16), 16) |
| 298 | require.Error(t, err) |
| 299 | }) |
| 300 | } |
| 301 | |
| 302 | func TestSocketControlMessageTimestamp(t *testing.T) { |
| 303 | if timestamping != unix.SO_TIMESTAMPING_NEW { |
| 304 | t.Skip("This test supports SO_TIMESTAMPING_NEW only. No sample of SO_TIMESTAMPING") |
| 305 | } |
| 306 | |
| 307 | var b []byte |
| 308 | var toob int |
| 309 | |
| 310 | // unix.Cmsghdr used in socketControlMessageTimestamp differs depending on platform |
| 311 | switch runtime.GOARCH { |
| 312 | case "amd64": |
| 313 | b = []byte{ |
| 314 | 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 315 | 0x1, 0x0, 0x0, 0x0, 0x41, 0x0, 0x0, 0x0, |
| 316 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 317 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 318 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 319 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 320 | 0x79, 0xab, 0x24, 0x68, 0x0, 0x0, 0x0, |
nothing calls this directly
no test coverage detected
searching dependent graphs…