gomemif: Add mode support 78/33178/3
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Fri, 7 May 2021 17:39:07 +0000 (19:39 +0200)
committerBeno�t Ganne <bganne@cisco.com>
Mon, 27 Sep 2021 09:03:17 +0000 (09:03 +0000)
Type: feature

Change-Id: I0bc51288bc63a0583b98314e4e2a62383b0d6e43
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
extras/gomemif/memif/control_channel.go
extras/gomemif/memif/interface.go
extras/gomemif/memif/memif.go

index 32e3493..12672e6 100644 (file)
@@ -375,7 +375,6 @@ func (socket *Socket) addListener() (err error) {
                return fmt.Errorf("Failed to create UNIX domain socket")
        }
        usa := &syscall.SockaddrUnix{Name: socket.filename}
-
        // Bind to address and start listening
        err = syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1)
        if err != nil {
@@ -518,7 +517,7 @@ func (cc *controlChannel) msgEnqInit() (err error) {
        init := MsgInit{
                Version: Version,
                Id:      cc.i.args.Id,
-               Mode:    interfaceModeEthernet,
+               Mode:    cc.i.args.Mode,
        }
 
        copy(init.Name[:], []byte(cc.socket.appName))
index a571deb..15a8e87 100644 (file)
@@ -71,6 +71,7 @@ type MemoryConfig struct {
 type Arguments struct {
        Id               uint32 // Interface identifier unique across socket. Used to identify peer interface when connecting
        IsMaster         bool   // Interface role master/slave
+       Mode             interfaceMode
        Name             string
        Secret           [24]byte // optional parameter, secrets of the interfaces must match if they are to connect
        MemoryConfig     MemoryConfig
index 1a7857d..bc1c560 100644 (file)
@@ -52,9 +52,9 @@ const (
 type interfaceMode uint8
 
 const (
-       interfaceModeEthernet interfaceMode = iota
-       interfaceModeIp
-       interfaceModePuntInject
+       InterfaceModeEthernet interfaceMode = iota
+       InterfaceModeIp
+       InterfaceModePuntInject
 )
 
 const msgSize = 128