2019-08-27 16:09:16 +00:00
|
|
|
/* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2020-05-02 08:08:26 +00:00
|
|
|
* Copyright (C) 2020 WireGuard LLC. All Rights Reserved.
|
2019-08-27 16:09:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package iphlpapi
|
|
|
|
|
|
|
|
import "golang.org/x/sys/windows"
|
|
|
|
|
|
|
|
//sys convertInterfaceLUIDToGUID(interfaceLUID *uint64, interfaceGUID *windows.GUID) (ret error) = iphlpapi.ConvertInterfaceLuidToGuid
|
|
|
|
//sys convertInterfaceAliasToLUID(interfaceAlias *uint16, interfaceLUID *uint64) (ret error) = iphlpapi.ConvertInterfaceAliasToLuid
|
|
|
|
|
|
|
|
func InterfaceGUIDFromAlias(alias string) (*windows.GUID, error) {
|
|
|
|
var luid uint64
|
|
|
|
var guid windows.GUID
|
|
|
|
err := convertInterfaceAliasToLUID(windows.StringToUTF16Ptr(alias), &luid)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = convertInterfaceLUIDToGUID(&luid, &guid)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &guid, nil
|
|
|
|
}
|