github.com/apernet/sing-tun@v0.2.6-0.20240323130332-b9f6511036ad/internal/winipcfg/zwinipcfg_windows.go (about)

     1  // Code generated by 'go generate'; DO NOT EDIT.
     2  
     3  package winipcfg
     4  
     5  import (
     6  	"syscall"
     7  	"unsafe"
     8  
     9  	"golang.org/x/sys/windows"
    10  )
    11  
    12  var _ unsafe.Pointer
    13  
    14  // Do the interface allocations only once for common
    15  // Errno values.
    16  const (
    17  	errnoERROR_IO_PENDING = 997
    18  )
    19  
    20  var (
    21  	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
    22  	errERROR_EINVAL     error = syscall.EINVAL
    23  )
    24  
    25  // errnoErr returns common boxed Errno values, to prevent
    26  // allocations at runtime.
    27  func errnoErr(e syscall.Errno) error {
    28  	switch e {
    29  	case 0:
    30  		return errERROR_EINVAL
    31  	case errnoERROR_IO_PENDING:
    32  		return errERROR_IO_PENDING
    33  	}
    34  	// TODO: add more here, after collecting data on the common
    35  	// error values see on Windows. (perhaps when running
    36  	// all.bat?)
    37  	return e
    38  }
    39  
    40  var (
    41  	modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
    42  
    43  	procCancelMibChangeNotify2          = modiphlpapi.NewProc("CancelMibChangeNotify2")
    44  	procConvertInterfaceGuidToLuid      = modiphlpapi.NewProc("ConvertInterfaceGuidToLuid")
    45  	procConvertInterfaceIndexToLuid     = modiphlpapi.NewProc("ConvertInterfaceIndexToLuid")
    46  	procConvertInterfaceLuidToGuid      = modiphlpapi.NewProc("ConvertInterfaceLuidToGuid")
    47  	procCreateAnycastIpAddressEntry     = modiphlpapi.NewProc("CreateAnycastIpAddressEntry")
    48  	procCreateIpForwardEntry2           = modiphlpapi.NewProc("CreateIpForwardEntry2")
    49  	procCreateUnicastIpAddressEntry     = modiphlpapi.NewProc("CreateUnicastIpAddressEntry")
    50  	procDeleteAnycastIpAddressEntry     = modiphlpapi.NewProc("DeleteAnycastIpAddressEntry")
    51  	procDeleteIpForwardEntry2           = modiphlpapi.NewProc("DeleteIpForwardEntry2")
    52  	procDeleteUnicastIpAddressEntry     = modiphlpapi.NewProc("DeleteUnicastIpAddressEntry")
    53  	procFreeMibTable                    = modiphlpapi.NewProc("FreeMibTable")
    54  	procGetAnycastIpAddressEntry        = modiphlpapi.NewProc("GetAnycastIpAddressEntry")
    55  	procGetAnycastIpAddressTable        = modiphlpapi.NewProc("GetAnycastIpAddressTable")
    56  	procGetIfEntry2                     = modiphlpapi.NewProc("GetIfEntry2")
    57  	procGetIfTable2Ex                   = modiphlpapi.NewProc("GetIfTable2Ex")
    58  	procGetIpForwardEntry2              = modiphlpapi.NewProc("GetIpForwardEntry2")
    59  	procGetIpForwardTable2              = modiphlpapi.NewProc("GetIpForwardTable2")
    60  	procGetIpInterfaceEntry             = modiphlpapi.NewProc("GetIpInterfaceEntry")
    61  	procGetIpInterfaceTable             = modiphlpapi.NewProc("GetIpInterfaceTable")
    62  	procGetUnicastIpAddressEntry        = modiphlpapi.NewProc("GetUnicastIpAddressEntry")
    63  	procGetUnicastIpAddressTable        = modiphlpapi.NewProc("GetUnicastIpAddressTable")
    64  	procInitializeIpForwardEntry        = modiphlpapi.NewProc("InitializeIpForwardEntry")
    65  	procInitializeIpInterfaceEntry      = modiphlpapi.NewProc("InitializeIpInterfaceEntry")
    66  	procInitializeUnicastIpAddressEntry = modiphlpapi.NewProc("InitializeUnicastIpAddressEntry")
    67  	procNotifyIpInterfaceChange         = modiphlpapi.NewProc("NotifyIpInterfaceChange")
    68  	procNotifyRouteChange2              = modiphlpapi.NewProc("NotifyRouteChange2")
    69  	procNotifyUnicastIpAddressChange    = modiphlpapi.NewProc("NotifyUnicastIpAddressChange")
    70  	procSetInterfaceDnsSettings         = modiphlpapi.NewProc("SetInterfaceDnsSettings")
    71  	procSetIpForwardEntry2              = modiphlpapi.NewProc("SetIpForwardEntry2")
    72  	procSetIpInterfaceEntry             = modiphlpapi.NewProc("SetIpInterfaceEntry")
    73  	procSetUnicastIpAddressEntry        = modiphlpapi.NewProc("SetUnicastIpAddressEntry")
    74  )
    75  
    76  func cancelMibChangeNotify2(notificationHandle windows.Handle) (ret error) {
    77  	r0, _, _ := syscall.Syscall(procCancelMibChangeNotify2.Addr(), 1, uintptr(notificationHandle), 0, 0)
    78  	if r0 != 0 {
    79  		ret = syscall.Errno(r0)
    80  	}
    81  	return
    82  }
    83  
    84  func convertInterfaceGUIDToLUID(interfaceGUID *windows.GUID, interfaceLUID *LUID) (ret error) {
    85  	r0, _, _ := syscall.Syscall(procConvertInterfaceGuidToLuid.Addr(), 2, uintptr(unsafe.Pointer(interfaceGUID)), uintptr(unsafe.Pointer(interfaceLUID)), 0)
    86  	if r0 != 0 {
    87  		ret = syscall.Errno(r0)
    88  	}
    89  	return
    90  }
    91  
    92  func convertInterfaceIndexToLUID(interfaceIndex uint32, interfaceLUID *LUID) (ret error) {
    93  	r0, _, _ := syscall.Syscall(procConvertInterfaceIndexToLuid.Addr(), 2, uintptr(interfaceIndex), uintptr(unsafe.Pointer(interfaceLUID)), 0)
    94  	if r0 != 0 {
    95  		ret = syscall.Errno(r0)
    96  	}
    97  	return
    98  }
    99  
   100  func convertInterfaceLUIDToGUID(interfaceLUID *LUID, interfaceGUID *windows.GUID) (ret error) {
   101  	r0, _, _ := syscall.Syscall(procConvertInterfaceLuidToGuid.Addr(), 2, uintptr(unsafe.Pointer(interfaceLUID)), uintptr(unsafe.Pointer(interfaceGUID)), 0)
   102  	if r0 != 0 {
   103  		ret = syscall.Errno(r0)
   104  	}
   105  	return
   106  }
   107  
   108  func createAnycastIPAddressEntry(row *MibAnycastIPAddressRow) (ret error) {
   109  	r0, _, _ := syscall.Syscall(procCreateAnycastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   110  	if r0 != 0 {
   111  		ret = syscall.Errno(r0)
   112  	}
   113  	return
   114  }
   115  
   116  func createIPForwardEntry2(route *MibIPforwardRow2) (ret error) {
   117  	r0, _, _ := syscall.Syscall(procCreateIpForwardEntry2.Addr(), 1, uintptr(unsafe.Pointer(route)), 0, 0)
   118  	if r0 != 0 {
   119  		ret = syscall.Errno(r0)
   120  	}
   121  	return
   122  }
   123  
   124  func createUnicastIPAddressEntry(row *MibUnicastIPAddressRow) (ret error) {
   125  	r0, _, _ := syscall.Syscall(procCreateUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   126  	if r0 != 0 {
   127  		ret = syscall.Errno(r0)
   128  	}
   129  	return
   130  }
   131  
   132  func deleteAnycastIPAddressEntry(row *MibAnycastIPAddressRow) (ret error) {
   133  	r0, _, _ := syscall.Syscall(procDeleteAnycastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   134  	if r0 != 0 {
   135  		ret = syscall.Errno(r0)
   136  	}
   137  	return
   138  }
   139  
   140  func deleteIPForwardEntry2(route *MibIPforwardRow2) (ret error) {
   141  	r0, _, _ := syscall.Syscall(procDeleteIpForwardEntry2.Addr(), 1, uintptr(unsafe.Pointer(route)), 0, 0)
   142  	if r0 != 0 {
   143  		ret = syscall.Errno(r0)
   144  	}
   145  	return
   146  }
   147  
   148  func deleteUnicastIPAddressEntry(row *MibUnicastIPAddressRow) (ret error) {
   149  	r0, _, _ := syscall.Syscall(procDeleteUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   150  	if r0 != 0 {
   151  		ret = syscall.Errno(r0)
   152  	}
   153  	return
   154  }
   155  
   156  func freeMibTable(memory unsafe.Pointer) {
   157  	syscall.Syscall(procFreeMibTable.Addr(), 1, uintptr(memory), 0, 0)
   158  	return
   159  }
   160  
   161  func getAnycastIPAddressEntry(row *MibAnycastIPAddressRow) (ret error) {
   162  	r0, _, _ := syscall.Syscall(procGetAnycastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   163  	if r0 != 0 {
   164  		ret = syscall.Errno(r0)
   165  	}
   166  	return
   167  }
   168  
   169  func getAnycastIPAddressTable(family AddressFamily, table **mibAnycastIPAddressTable) (ret error) {
   170  	r0, _, _ := syscall.Syscall(procGetAnycastIpAddressTable.Addr(), 2, uintptr(family), uintptr(unsafe.Pointer(table)), 0)
   171  	if r0 != 0 {
   172  		ret = syscall.Errno(r0)
   173  	}
   174  	return
   175  }
   176  
   177  func getIfEntry2(row *MibIfRow2) (ret error) {
   178  	r0, _, _ := syscall.Syscall(procGetIfEntry2.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   179  	if r0 != 0 {
   180  		ret = syscall.Errno(r0)
   181  	}
   182  	return
   183  }
   184  
   185  func getIfTable2Ex(level MibIfEntryLevel, table **mibIfTable2) (ret error) {
   186  	r0, _, _ := syscall.Syscall(procGetIfTable2Ex.Addr(), 2, uintptr(level), uintptr(unsafe.Pointer(table)), 0)
   187  	if r0 != 0 {
   188  		ret = syscall.Errno(r0)
   189  	}
   190  	return
   191  }
   192  
   193  func getIPForwardEntry2(route *MibIPforwardRow2) (ret error) {
   194  	r0, _, _ := syscall.Syscall(procGetIpForwardEntry2.Addr(), 1, uintptr(unsafe.Pointer(route)), 0, 0)
   195  	if r0 != 0 {
   196  		ret = syscall.Errno(r0)
   197  	}
   198  	return
   199  }
   200  
   201  func getIPForwardTable2(family AddressFamily, table **mibIPforwardTable2) (ret error) {
   202  	r0, _, _ := syscall.Syscall(procGetIpForwardTable2.Addr(), 2, uintptr(family), uintptr(unsafe.Pointer(table)), 0)
   203  	if r0 != 0 {
   204  		ret = syscall.Errno(r0)
   205  	}
   206  	return
   207  }
   208  
   209  func getIPInterfaceEntry(row *MibIPInterfaceRow) (ret error) {
   210  	r0, _, _ := syscall.Syscall(procGetIpInterfaceEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   211  	if r0 != 0 {
   212  		ret = syscall.Errno(r0)
   213  	}
   214  	return
   215  }
   216  
   217  func getIPInterfaceTable(family AddressFamily, table **mibIPInterfaceTable) (ret error) {
   218  	r0, _, _ := syscall.Syscall(procGetIpInterfaceTable.Addr(), 2, uintptr(family), uintptr(unsafe.Pointer(table)), 0)
   219  	if r0 != 0 {
   220  		ret = syscall.Errno(r0)
   221  	}
   222  	return
   223  }
   224  
   225  func getUnicastIPAddressEntry(row *MibUnicastIPAddressRow) (ret error) {
   226  	r0, _, _ := syscall.Syscall(procGetUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   227  	if r0 != 0 {
   228  		ret = syscall.Errno(r0)
   229  	}
   230  	return
   231  }
   232  
   233  func getUnicastIPAddressTable(family AddressFamily, table **mibUnicastIPAddressTable) (ret error) {
   234  	r0, _, _ := syscall.Syscall(procGetUnicastIpAddressTable.Addr(), 2, uintptr(family), uintptr(unsafe.Pointer(table)), 0)
   235  	if r0 != 0 {
   236  		ret = syscall.Errno(r0)
   237  	}
   238  	return
   239  }
   240  
   241  func initializeIPForwardEntry(route *MibIPforwardRow2) {
   242  	syscall.Syscall(procInitializeIpForwardEntry.Addr(), 1, uintptr(unsafe.Pointer(route)), 0, 0)
   243  	return
   244  }
   245  
   246  func initializeIPInterfaceEntry(row *MibIPInterfaceRow) {
   247  	syscall.Syscall(procInitializeIpInterfaceEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   248  	return
   249  }
   250  
   251  func initializeUnicastIPAddressEntry(row *MibUnicastIPAddressRow) {
   252  	syscall.Syscall(procInitializeUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   253  	return
   254  }
   255  
   256  func notifyIPInterfaceChange(family AddressFamily, callback uintptr, callerContext uintptr, initialNotification bool, notificationHandle *windows.Handle) (ret error) {
   257  	var _p0 uint32
   258  	if initialNotification {
   259  		_p0 = 1
   260  	}
   261  	r0, _, _ := syscall.Syscall6(procNotifyIpInterfaceChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
   262  	if r0 != 0 {
   263  		ret = syscall.Errno(r0)
   264  	}
   265  	return
   266  }
   267  
   268  func notifyRouteChange2(family AddressFamily, callback uintptr, callerContext uintptr, initialNotification bool, notificationHandle *windows.Handle) (ret error) {
   269  	var _p0 uint32
   270  	if initialNotification {
   271  		_p0 = 1
   272  	}
   273  	r0, _, _ := syscall.Syscall6(procNotifyRouteChange2.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
   274  	if r0 != 0 {
   275  		ret = syscall.Errno(r0)
   276  	}
   277  	return
   278  }
   279  
   280  func notifyUnicastIPAddressChange(family AddressFamily, callback uintptr, callerContext uintptr, initialNotification bool, notificationHandle *windows.Handle) (ret error) {
   281  	var _p0 uint32
   282  	if initialNotification {
   283  		_p0 = 1
   284  	}
   285  	r0, _, _ := syscall.Syscall6(procNotifyUnicastIpAddressChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
   286  	if r0 != 0 {
   287  		ret = syscall.Errno(r0)
   288  	}
   289  	return
   290  }
   291  
   292  func setInterfaceDnsSettingsByDwords(guid1 uintptr, guid2 uintptr, guid3 uintptr, guid4 uintptr, settings *DnsInterfaceSettings) (ret error) {
   293  	ret = procSetInterfaceDnsSettings.Find()
   294  	if ret != nil {
   295  		return
   296  	}
   297  	r0, _, _ := syscall.Syscall6(procSetInterfaceDnsSettings.Addr(), 5, uintptr(guid1), uintptr(guid2), uintptr(guid3), uintptr(guid4), uintptr(unsafe.Pointer(settings)), 0)
   298  	if r0 != 0 {
   299  		ret = syscall.Errno(r0)
   300  	}
   301  	return
   302  }
   303  
   304  func setInterfaceDnsSettingsByQwords(guid1 uintptr, guid2 uintptr, settings *DnsInterfaceSettings) (ret error) {
   305  	ret = procSetInterfaceDnsSettings.Find()
   306  	if ret != nil {
   307  		return
   308  	}
   309  	r0, _, _ := syscall.Syscall(procSetInterfaceDnsSettings.Addr(), 3, uintptr(guid1), uintptr(guid2), uintptr(unsafe.Pointer(settings)))
   310  	if r0 != 0 {
   311  		ret = syscall.Errno(r0)
   312  	}
   313  	return
   314  }
   315  
   316  func setInterfaceDnsSettingsByPtr(guid *windows.GUID, settings *DnsInterfaceSettings) (ret error) {
   317  	ret = procSetInterfaceDnsSettings.Find()
   318  	if ret != nil {
   319  		return
   320  	}
   321  	r0, _, _ := syscall.Syscall(procSetInterfaceDnsSettings.Addr(), 2, uintptr(unsafe.Pointer(guid)), uintptr(unsafe.Pointer(settings)), 0)
   322  	if r0 != 0 {
   323  		ret = syscall.Errno(r0)
   324  	}
   325  	return
   326  }
   327  
   328  func setIPForwardEntry2(route *MibIPforwardRow2) (ret error) {
   329  	r0, _, _ := syscall.Syscall(procSetIpForwardEntry2.Addr(), 1, uintptr(unsafe.Pointer(route)), 0, 0)
   330  	if r0 != 0 {
   331  		ret = syscall.Errno(r0)
   332  	}
   333  	return
   334  }
   335  
   336  func setIPInterfaceEntry(row *MibIPInterfaceRow) (ret error) {
   337  	r0, _, _ := syscall.Syscall(procSetIpInterfaceEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   338  	if r0 != 0 {
   339  		ret = syscall.Errno(r0)
   340  	}
   341  	return
   342  }
   343  
   344  func setUnicastIPAddressEntry(row *MibUnicastIPAddressRow) (ret error) {
   345  	r0, _, _ := syscall.Syscall(procSetUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
   346  	if r0 != 0 {
   347  		ret = syscall.Errno(r0)
   348  	}
   349  	return
   350  }