Documentation ¶
Overview ¶
Package snet implements interfaces net.Conn and net.PacketConn for SCION connections.
The default (package-wide) SCION network must first be initialized by calling Init. All future package scoped DialSCION and ListenSCION calls will use this initial context to get the local ISD-AS, dispatcher or sciond.
A connection can be created by calling DialSCION or ListenSCION; both functions register an address-port pair with the local dispatcher. For Dial, the remote address is fixed, meaning only Read and Write can be used. Attempting to ReadFrom or WriteTo a connection created by Dial is an invalid operation. For Listen, the remote address cannot be fixed. ReadFrom, ReadFromSCION can be used to read from the connection and find out the sender's address; WriteTo and WriteToSCION can be used to send a message to a chosen destination.
For applications that need to run in multiple ASes, new networking contexts can be created using NewNetwork. Calling the DialSCION or ListenSCION methods on the networking context yields connections that run in that context.
Multiple networking contexts can share the same SCIOND and/or dispatcher.
Write calls never return SCMP errors directly. If a write call caused an SCMP message to be received by the Conn, it can be inspected by calling Read. In this case, the error value is non-nil and can be type asserted to *OpError. Method SCMP() can be called on the error to extract the SCMP header.
Important: not draining SCMP errors via Read calls can cause the dispatcher to block (see Issue #1278). To prevent this on a Conn object with only Write calls, run a separate goroutine that continuously calls Read on the Conn.
Index ¶
- Constants
- func IA() *addr.ISD_AS
- func Init(ia *addr.ISD_AS, sPath string, dPath string) error
- func InitWithNetwork(network *Network) error
- type Addr
- type Conn
- func DialSCION(network string, laddr, raddr *Addr) (*Conn, error)
- func DialSCIONWithBindSVC(network string, laddr, raddr, baddr *Addr, svc addr.HostSVC) (*Conn, error)
- func ListenSCION(network string, laddr *Addr) (*Conn, error)
- func ListenSCIONWithBindSVC(network string, laddr, baddr *Addr, svc addr.HostSVC) (*Conn, error)
- func (c *Conn) BindAddr() net.Addr
- func (c *Conn) BindSnetAddr() *Addr
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) LocalSnetAddr() *Addr
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) ReadFrom(b []byte) (int, net.Addr, error)
- func (c *Conn) ReadFromSCION(b []byte) (int, *Addr, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) RemoteSnetAddr() *Addr
- func (c *Conn) SVC() addr.HostSVC
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (int, error)
- func (c *Conn) WriteTo(b []byte, raddr net.Addr) (int, error)
- func (c *Conn) WriteToSCION(b []byte, raddr *Addr) (int, error)
- type Error
- type Network
- func (n *Network) DialSCION(network string, laddr *Addr, raddr *Addr) (*Conn, error)
- func (n *Network) DialSCIONWithBindSVC(network string, laddr, raddr, baddr *Addr, svc addr.HostSVC) (*Conn, error)
- func (n *Network) IA() *addr.ISD_AS
- func (n *Network) ListenSCION(network string, laddr *Addr) (*Conn, error)
- func (n *Network) ListenSCIONWithBindSVC(network string, laddr, baddr *Addr, svc addr.HostSVC) (*Conn, error)
- func (n *Network) PathResolver() *pathmgr.PR
- func (n *Network) SetPathResolver(resolver *pathmgr.PR)
- type OpError
Constants ¶
const (
// Receive and send buffer sizes
BufSize = 1<<16 - 1
)
Variables ¶
This section is empty.
Functions ¶
func InitWithNetwork ¶
InitWithNetwork initializes snet with the provided SCION networking context.
Types ¶
type Addr ¶
type Addr struct { IA *addr.ISD_AS Host addr.HostAddr L4Port uint16 Path *spath.Path NextHopHost addr.HostAddr NextHopPort uint16 }
func AddrFromString ¶
AddrFromString converts an address string of format isd-as,[ipaddr]:port (e.g., 1-10,[192.168.1.1]:80) to a SCION address.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func DialSCIONWithBindSVC ¶
func DialSCIONWithBindSVC(network string, laddr, raddr, baddr *Addr, svc addr.HostSVC) (*Conn, error)
DialSCIONWithBindSVC calls DialSCIONWithBindSVC on the default networking context.
func ListenSCION ¶
ListenSCION calls ListenSCION on the default networking context.
func ListenSCIONWithBindSVC ¶
ListenSCIONWithBindSVC calls ListenSCIONWithBindSVC on the default networking context.
func (*Conn) BindSnetAddr ¶
func (*Conn) LocalSnetAddr ¶
func (*Conn) Read ¶
Read reads data into b from a connection with a fixed remote address. If the remote address for the connection is unknown, Read returns an error.
func (*Conn) ReadFromSCION ¶
ReadFromSCION reads data into b, returning the length of copied data and the address of the sender. If the remote address for the connection is already known, ReadFromSCION returns an error.
func (*Conn) RemoteAddr ¶
func (*Conn) RemoteSnetAddr ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
SCION networking context, containing local ISD-AS, SCIOND, Dispatcher and Path resolver.
var ( // Default SCION networking context for package-level Dial and Listen DefNetwork *Network )
func NewNetwork ¶
NewNetwork creates a new networking context, on which future Dial or Listen calls can be made. The new connections use the SCIOND server at sPath, the dispatcher at dPath, and ia for the local ISD-AS.
func NewNetworkBasic ¶
NewNetworkBasic creates a minimal networking context without a path resolver. It is meant to be amended with a custom path resolver.
func (*Network) DialSCION ¶
DialSCION returns a SCION connection to raddr. Nil values for laddr are not supported yet. Parameter network must be "udp4". The returned connection's Read and Write methods can be used to receive and send SCION packets.
func (*Network) DialSCIONWithBindSVC ¶
func (n *Network) DialSCIONWithBindSVC(network string, laddr, raddr, baddr *Addr, svc addr.HostSVC) (*Conn, error)
DialSCIONWithBindSVC returns a SCION connection to raddr. Nil values for laddr are not supported yet. Parameter network must be "udp4". The returned connection's Read and Write methods can be used to receive and send SCION packets.
func (*Network) ListenSCION ¶
ListenSCION registers laddr with the dispatcher. Nil values for laddr are not supported yet. The returned connection's ReadFrom and WriteTo methods can be used to receive and send SCION packets with per-packet addressing. Parameter network must be "udp4".
func (*Network) ListenSCIONWithBindSVC ¶
func (n *Network) ListenSCIONWithBindSVC(network string, laddr, baddr *Addr, svc addr.HostSVC) (*Conn, error)
ListenSCIONWithBindSVC registers laddr with the dispatcher. Nil values for laddr are not supported yet. The returned connection's ReadFrom and WriteTo methods can be used to receive and send SCION packets with per-packet addressing. Parameter network must be "udp4".
func (*Network) PathResolver ¶
PathResolver returns the pathmgr.PR that the network is using.
func (*Network) SetPathResolver ¶
SetPathResolver set the pathmgr.PR that the networking is using. It can only be set once and will be ignored if there is already a path resolver set.