blob: c11e72f5c58b80eaf9fbe13c73a1f16fd34a7d15 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//go:build !build_with_native_toolchain
// +build !build_with_native_toolchain
package netstack
import (
"syscall/zx/fidl"
syslog "go.fuchsia.dev/fuchsia/src/lib/syslog/go"
"fidl/fuchsia/net/debug"
"fidl/fuchsia/net/interfaces/admin"
"gvisor.dev/gvisor/pkg/tcpip"
)
var _ debug.InterfacesWithCtx = (*debugInterfacesImpl)(nil)
type debugInterfacesImpl struct {
ns *Netstack
}
func (ci *debugInterfacesImpl) GetAdmin(_ fidl.Context, nicid uint64, request admin.ControlWithCtxInterfaceRequest) error {
{
nicid := tcpip.NICID(nicid)
nicInfo, ok := ci.ns.stack.NICInfo()[nicid]
if !ok {
// Just close the channel without a terminal event.
if err := request.Close(); err != nil {
_ = syslog.WarnTf(debug.InterfacesName, "GetAdmin(%d) close error: %s", nicid, err)
}
return nil
}
ifs := nicInfo.Context.(*ifState)
ifs.addAdminConnection(request, false /* strong */)
return nil
}
}