Documentation ¶
Index ¶
- Constants
- func RoleToString(isServer bool) string
- type ConnectedFunc
- type DisconnectedFunc
- type MemoryConfig
- type MsgAddRegion
- type MsgAddRing
- type MsgConnect
- type MsgConnected
- type MsgDisconnect
- type MsgHello
- type MsgInit
- type Port
- func (p *Port) Delete() (err error)
- func (p *Port) Disconnect() (err error)
- func (p *Port) GetExtendData() interface{}
- func (p *Port) GetId() uint32
- func (p *Port) GetMemoryConfig() MemoryConfig
- func (p *Port) GetName() string
- func (p *Port) GetPeerName() string
- func (p *Port) GetRemoteName() string
- func (p *Port) GetRxQueue(qid int) (*Queue, error)
- func (p *Port) GetSocket() *Socket
- func (p *Port) GetTxQueue(qid int) (*Queue, error)
- func (p *Port) IsConnected() bool
- func (p *Port) IsConnecting() bool
- func (p *Port) IsServer() bool
- func (p *Port) RequestConnection() error
- func (p *Port) String() string
- type PortCfg
- type Queue
- type Socket
Constants ¶
const ( DefaultSocketFilename = "/tmp/memif.sock" DefaultNumQueuePairs = 1 DefaultLog2RingSize = 10 DefaultPacketBufferSize = 2048 )
const Version = ((VersionMajor << 8) | VersionMinor)
Version is memif protocols version as uint16 (M-Major m-minor: MMMMMMMMmmmmmmmm)
const VersionMajor = 2
VersionMajor is memif protocols major version
const VersionMinor = 0
VersionMinor is memif protocols minor version
Variables ¶
This section is empty.
Functions ¶
func RoleToString ¶
RoleToString returns 'Server' if isServer os true, else returns 'Client'
Types ¶
type ConnectedFunc ¶
ConnectedFunc is a callback called when an interface is connected
type DisconnectedFunc ¶
DisconnectedFunc is a callback called when an interface is disconnected
type MemoryConfig ¶
type MemoryConfig struct { NumQueuePairs uint16 // number of queue pairs Log2RingSize uint8 // ring size as log2 PacketBufferSize uint32 // size of single packet buffer }
MemoryConfig represents shared memory configuration
type MsgAddRegion ¶
type MsgAddRing ¶
type MsgConnect ¶
type MsgConnect struct { // interface name Name [32]byte }
type MsgConnected ¶
type MsgConnected struct { // interface name Name [32]byte }
type MsgDisconnect ¶
type Port ¶
type Port struct { ExtendData interface{} ErrChan chan error QuitChan chan struct{} Wg sync.WaitGroup // contains filtered or unexported fields }
Port represents memif network interface
func (*Port) GetExtendData ¶
func (p *Port) GetExtendData() interface{}
GetExtendData returns interfaces extend data
func (*Port) GetMemoryConfig ¶
func (p *Port) GetMemoryConfig() MemoryConfig
GetMemoryConfig returns interfaces active memory config. If Port is not connected the config is invalid.
func (*Port) GetPeerName ¶
GetPeerName returns peer interfaces name
func (*Port) GetRemoteName ¶
GetRemoteName returns the name of the application on which the peer interface exists
func (*Port) GetRxQueue ¶
GetRxQueue returns an rx queue specified by queue index
func (*Port) GetTxQueue ¶
GetRxQueue returns a tx queue specified by queue index
func (*Port) IsConnected ¶
IsConnected returns true if the port is connected
func (*Port) IsConnecting ¶
IsConnecting returns true if the port is connecting
func (*Port) RequestConnection ¶
RequestConnection is used by client port to connect to a socket and create a control channel
type PortCfg ¶
type PortCfg struct { Id uint32 // Port identifier unique across socket. Used to identify peer Port when connecting IsServer bool // Port role server/client Name string Secret [24]byte // optional parameter, secrets of the Ports must match if they are to connect MemoryConfig MemoryConfig ConnectedFunc ConnectedFunc // callback called when Port changes status to connected DisconnectedFunc DisconnectedFunc // callback called when Port changes status to disconnected ExtendData interface{} // ExtendData used by client program }
PortCfg represent port configuration
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue represents rx or tx queue
func (*Queue) GetEventFd ¶
GetEventFd returns queues interrupt event fd
func (*Queue) ReadPacket ¶
ReadPacket reads one packet form the shared memory and returns the number of bytes read
func (*Queue) WritePacket ¶
WritePacket writes one packet to the shared memory and returns the number of bytes written
type Socket ¶
type Socket struct { ErrChan chan error // contains filtered or unexported fields }
Socket represents a UNIX domain socket used for communication between memif peers
func (*Socket) AddListener ¶
AddListener adds a lisntener to the socket. The fd must describe a UNIX domain socket already bound to a UNIX domain filename and marked as listener
func (*Socket) GetFilename ¶
GetFilename returns sockets filename
func (*Socket) NewPort ¶
NewPort returns a new memif network port. When creating an port it's id must be unique across socket with the exception of loopback interface in which case the id is the same but role differs
func (*Socket) StartPolling ¶
func (socket *Socket) StartPolling()
StartPolling starts polling and handling events on the socket, enabling communication between memif peers
func (*Socket) StopPolling ¶
StopPolling stops polling events on the socket