Next: , Previous: , Up: posix socket addresses   [Index]


4.15.1.3 IPv6 addresses

Instances of struct sockaddr_in6 can be handled at the Scheme level as follows:

#!vicare
(import (vicare)
  (prefix (vicare posix) px.))

(define sockaddr
  (px.make-sockaddr_in6 '#vu16b(1 2 3 4  5 6 7 8) 88))

(px.sockaddr_in6.in6_addr sockaddr) ⇒ #vu16b(1 2 3 4  5 6 7 8)
(px.sockaddr_in6.in6_port sockaddr) ⇒ 88

care must be taken when handling such raw values.

Function: make-sockaddr_in6 host-address port

Given a bytevector host-address holding a struct in6_addr and a fixnum port representing a network port number, build and return a bytevector holding a struct sockaddr_in6 initialised with this data.

Function: sockaddr_in6.in6_addr socket-address
Function: sockaddr_in6.in6_port socket-address

Given a bytevector socket-address holding a struct sockaddr_in6, extract the in6_addr and in6_port fields and return them as bytevector holding the corresponding struct in6_addr and as fixnum. If the data in socket_address is invalid: an exception is raised.

Internally convert the port number to host byte order using ntohs() after the extraction of the value from the data structure.

Function: in6addr_loopback
Function: in6addr_any

Build and return a bytevector holding the constant structures of type struct in6_addr defined by in6addr_loopback and in6addr_any.