You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

63 line
1.6 KiB

  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package ipv4
  5. const (
  6. // See ws2tcpip.h.
  7. sysIP_OPTIONS = 0x1
  8. sysIP_HDRINCL = 0x2
  9. sysIP_TOS = 0x3
  10. sysIP_TTL = 0x4
  11. sysIP_MULTICAST_IF = 0x9
  12. sysIP_MULTICAST_TTL = 0xa
  13. sysIP_MULTICAST_LOOP = 0xb
  14. sysIP_ADD_MEMBERSHIP = 0xc
  15. sysIP_DROP_MEMBERSHIP = 0xd
  16. sysIP_DONTFRAGMENT = 0xe
  17. sysIP_ADD_SOURCE_MEMBERSHIP = 0xf
  18. sysIP_DROP_SOURCE_MEMBERSHIP = 0x10
  19. sysIP_PKTINFO = 0x13
  20. sizeofInetPktinfo = 0x8
  21. sizeofIPMreq = 0x8
  22. sizeofIPMreqSource = 0xc
  23. )
  24. type inetPktinfo struct {
  25. Addr [4]byte
  26. Ifindex int32
  27. }
  28. type ipMreq struct {
  29. Multiaddr [4]byte
  30. Interface [4]byte
  31. }
  32. type ipMreqSource struct {
  33. Multiaddr [4]byte
  34. Sourceaddr [4]byte
  35. Interface [4]byte
  36. }
  37. // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx
  38. var (
  39. ctlOpts = [ctlMax]ctlOpt{}
  40. sockOpts = [ssoMax]sockOpt{
  41. ssoTOS: {sysIP_TOS, ssoTypeInt},
  42. ssoTTL: {sysIP_TTL, ssoTypeInt},
  43. ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt},
  44. ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface},
  45. ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt},
  46. ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt},
  47. ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq},
  48. ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq},
  49. }
  50. )
  51. func (pi *inetPktinfo) setIfindex(i int) {
  52. pi.Ifindex = int32(i)
  53. }