sockaddrnet

package
v0.4.0-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

package sockaddrnet provides conversions between net.Addr and syscall.Sockaddr

Index

Constants

View Source
const (
	AF_INET   = syscall.AF_INET
	AF_INET6  = syscall.AF_INET6
	AF_UNIX   = syscall.AF_UNIX
	AF_UNSPEC = syscall.AF_UNSPEC

	IPPROTO_IP   = syscall.IPPROTO_IP
	IPPROTO_IPV4 = syscall.IPPROTO_IPIP
	IPPROTO_IPV6 = syscall.IPPROTO_IPV6
	IPPROTO_TCP  = syscall.IPPROTO_TCP
	IPPROTO_UDP  = syscall.IPPROTO_UDP

	SOCK_DGRAM     = syscall.SOCK_DGRAM
	SOCK_STREAM    = syscall.SOCK_STREAM
	SOCK_SEQPACKET = syscall.SOCK_SEQPACKET
)

Variables

This section is empty.

Functions

func IP6ZoneToInt

func IP6ZoneToInt(zone string) int

IP6ZoneToInt converts an IP6 Zone net string to a syscall int returns 0 if zone is ""

func IP6ZoneToString

func IP6ZoneToString(zone int) string

IP6ZoneToString converts an IP6 Zone syscall int to a net string returns "" if zone is 0

func IPAF

func IPAF(ip net.IP) int

IPAF returns the syscall AF_* type for a given IP address returns AF_UNSPEC if unknown

func IPAddrToSockaddr

func IPAddrToSockaddr(addr *net.IPAddr) syscall.Sockaddr

IPAddrToSockaddr converts a net.IPAddr to a syscall.Sockaddr. Returns nil if conversion fails.

func IPAndZoneToSockaddr

func IPAndZoneToSockaddr(ip net.IP, zone string) syscall.Sockaddr

IPAndZoneToSockaddr converts a net.IP (with optional IPv6 Zone) to a syscall.Sockaddr Returns nil if conversion fails.

func NetAddrAF

func NetAddrAF(addr net.Addr) int

NetAddrAF returns the syscall AF_* type for a given net.Addr returns AF_UNSPEC if unknown

func NetAddrIPPROTO

func NetAddrIPPROTO(addr net.Addr) int

NetAddrIPPROTO returns the syscall IPPROTO_* type for a given net.Addr returns -1 if protocol unknown

func NetAddrSOCK

func NetAddrSOCK(addr net.Addr) int

NetAddrSOCK returns the syscall SOCK_* type for a given net.Addr returns 0 if type unknown

func NetAddrToSockaddr

func NetAddrToSockaddr(addr net.Addr) syscall.Sockaddr

NetAddrToSockaddr converts a net.Addr to a syscall.Sockaddr. Returns nil if the input is invalid or conversion is not possible.

func SockaddrToIPAddr

func SockaddrToIPAddr(sa syscall.Sockaddr) *net.IPAddr

SockaddrToIPAddr converts a syscall.Sockaddr to a net.IPAddr Returns nil if conversion fails.

func SockaddrToIPAndZone

func SockaddrToIPAndZone(sa syscall.Sockaddr) (net.IP, string)

IPAndZoneToSockaddr converts a net.IP (with optional IPv6 Zone) to a syscall.Sockaddr Returns nil if conversion fails.

func SockaddrToTCPAddr

func SockaddrToTCPAddr(sa syscall.Sockaddr) *net.TCPAddr

SockaddrToTCPAddr converts a syscall.Sockaddr to a net.TCPAddr Returns nil if conversion fails.

func SockaddrToUDPAddr

func SockaddrToUDPAddr(sa syscall.Sockaddr) *net.UDPAddr

SockaddrToUDPAddr converts a syscall.Sockaddr to a net.UDPAddr Returns nil if conversion fails.

func SockaddrToUnixAddr

func SockaddrToUnixAddr(sa syscall.Sockaddr) *net.UnixAddr

SockaddrToUnixAddr converts a syscall.Sockaddr to a net.UnixAddr Returns nil if conversion fails.

func SockaddrToUnixgramAddr

func SockaddrToUnixgramAddr(sa syscall.Sockaddr) *net.UnixAddr

SockaddrToUnixgramAddr converts a syscall.Sockaddr to a net.UnixAddr Returns nil if conversion fails.

func SockaddrToUnixpacketAddr

func SockaddrToUnixpacketAddr(sa syscall.Sockaddr) *net.UnixAddr

SockaddrToUnixpacketAddr converts a syscall.Sockaddr to a net.UnixAddr Returns nil if conversion fails.

func TCPAddrToSockaddr

func TCPAddrToSockaddr(addr *net.TCPAddr) syscall.Sockaddr

TCPAddrToSockaddr converts a net.TCPAddr to a syscall.Sockaddr. Returns nil if conversion fails.

func UDPAddrToSockaddr

func UDPAddrToSockaddr(addr *net.UDPAddr) syscall.Sockaddr

UDPAddrToSockaddr converts a net.UDPAddr to a syscall.Sockaddr. Returns nil if conversion fails.

func UnixAddrToSockaddr

func UnixAddrToSockaddr(addr *net.UnixAddr) (syscall.Sockaddr, int)

UnixAddrToSockaddr converts a net.UnixAddr to a syscall.Sockaddr, and returns the type (syscall.SOCK_STREAM, syscall.SOCK_DGRAM, syscall.SOCK_SEQPACKET) Returns (nil, 0) if conversion fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL