package ns
import (
- "errors"
"fmt"
"os"
"runtime"
// netNS implements the NetNS interface
var _ NetNS = &netNS{}
-// NotImplementedError is used to indicate that a method is not implemented for the given platform
-var NotImplementedError = errors.New("Not Implemented")
-
-// Returns an object representing the current OS thread's network namespace
-func GetCurrentNS() (NetNS, error) {
- return GetNS(getCurrentThreadNetNSPath())
-}
-
const (
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/magic.h
NSFS_MAGIC = 0x6e736673
}
containedCall := func(hostNS NetNS) error {
- threadNS, err := GetNS(getCurrentThreadNetNSPath())
+ threadNS, err := GetCurrentNS()
if err != nil {
return fmt.Errorf("failed to open current netns: %v", err)
}
}
// save a handle to current network namespace
- hostNS, err := GetNS(getCurrentThreadNetNSPath())
+ hostNS, err := GetCurrentNS()
if err != nil {
return fmt.Errorf("Failed to open current namespace: %v", err)
}
"golang.org/x/sys/unix"
)
+// Returns an object representing the current OS thread's network namespace
+func GetCurrentNS() (NetNS, error) {
+ return GetNS(getCurrentThreadNetNSPath())
+}
+
func getCurrentThreadNetNSPath() string {
// /proc/self/ns/net returns the namespace of the main thread, not
// of whatever thread this goroutine is running on. Make sure we
package ns
-func getCurrentThreadNetNSPath() string {
- return ""
+import "github.com/containernetworking/cni/pkg/types"
+
+// Returns an object representing the current OS thread's network namespace
+func GetCurrentNS() (NetNS, error) {
+ return nil, types.NotImplementedError
}
func NewNS() (NetNS, error) {
- return nil, NotImplementedError
+ return nil, types.NotImplementedError
}
func (ns *netNS) Close() error {
- return NotImplementedError
+ return types.NotImplementedError
}
func (ns *netNS) Set() error {
- return NotImplementedError
+ return types.NotImplementedError
}
import (
"encoding/json"
+ "errors"
"fmt"
"net"
"os"
_, err = os.Stdout.Write(data)
return err
}
+
+// NotImplementedError is used to indicate that a method is not implemented for the given platform
+var NotImplementedError = errors.New("Not Implemented")