Skip to content

Commit

Permalink
[Windows] Support querying all NDIS network adapters (#5385)
Browse files Browse the repository at this point in the history
Signed-off-by: wenyingd <[email protected]>
  • Loading branch information
wenyingd authored Aug 16, 2023
1 parent 119bb7f commit f679100
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/agent/config/ipsec_authentication_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func GetIPsecConfigModes() []IPsecAuthenticationMode {

// String returns value in string.
func (am IPsecAuthenticationMode) String() string {
if am == IPsecAuthenticationModeInvalid {
return "invalid"
}
return supportedIPsecAuthenticationModeStrs[am]
}

Expand Down
10 changes: 8 additions & 2 deletions pkg/agent/util/net_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -1265,13 +1265,19 @@ func getAdaptersByName(name string) ([]adapter, error) {
// flags to return addresses in all routing compartments.
const GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x00000200

// GAA_FLAG_INCLUDE_ALL_INTERFACES is used in windows.GetAdapterAddresses parameter
// flags to return addresses for all NDIS interfaces.
const GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x00000100

// adapterAddresses returns a list of IpAdapterAddresses structures. The structure
// contains an IP adapter and flattened multiple IP addresses including unicast, anycast
// and multicast addresses.
// This function is copied from go/src/net/interface_windows.go, with a change that flag
// GAA_FLAG_INCLUDE_ALL_COMPARTMENTS is introduced to query interfaces in all compartments.
// GAA_FLAG_INCLUDE_ALL_COMPARTMENTS is introduced to query interfaces in all compartments,
// and GAA_FLAG_INCLUDE_ALL_INTERFACES is introduced to query all NDIS interfaces even they
// are not configured with any IP addresses, e.g., uplink.
func adapterAddresses() ([]*windows.IpAdapterAddresses, error) {
flags := uint32(windows.GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_INCLUDE_ALL_COMPARTMENTS)
flags := uint32(windows.GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_INCLUDE_ALL_COMPARTMENTS | GAA_FLAG_INCLUDE_ALL_INTERFACES)
var b []byte
l := uint32(15000) // recommended initial size
for {
Expand Down

0 comments on commit f679100

Please sign in to comment.