libcosmos
Linux C++ System Programming Library
Loading...
Searching...
No Matches
cosmos::IP6Options Class Reference

IPv6 level socket option setter/getter helper. More...

#include <IPOptions.hxx>

+ Inheritance diagram for cosmos::IP6Options:

Public Member Functions

void setAddrForm (const SocketFamily family)
 Turn the INET6 socket into a socket of a different address family.
 
int getMTU () const
 Returns the currently known path MTU of the socket.
 
MTUDiscoveryMode getMTUDiscoveryMode () const
 Gets the current MTU discovery mode setting for the socket.
 
void setMTUDiscoveryMode (const MTUDiscoveryMode mode)
 Sets a new MTU discovery mode setting.
 
void setMTU (const int mtu)
 Sets the MTU used for the socket.
 
void setReceivePktInfo (const bool on_off)
 Enable delivery of IPV6_PKTINFO control messages on incoming datagrams.
 
void setReceiveErrors (const bool on_off)
 Enable extended reliable error reporting for datagram sockets.
 
void setReceiveRoutingHeader (const bool on_off)
 Enable delivery of routing header control messages.
 
void setReceiveAuthHeader (const bool on_off)
 Enable delivery of auth header control messages.
 
void setReceiveDestOpts (const bool on_off)
 Enable delivery of of destination options control messages.
 
void setReceiveHopOpts (const bool on_off)
 Enable delivery of hop options control messages.
 
void setReceiveHopLimit (const bool on_off)
 Enable delivery of hop limit control messages.
 
void setRouterAlert (const bool on_off)
 Pass to-be forwarded packets with the IP router alert option set to this socket.
 
void setUnicastHops (const int hops)
 Set the unicast hop limit for the socket.
 
void setV6Only (const bool on_off)
 Restrict the socket to sending and receiving IPv6 packets only.
 

Friends

class IPSocketT< SocketFamily::INET6 >
 

Additional Inherited Members

- Public Types inherited from cosmos::IPOptBase< OptLevel::IPV6 >
enum  MTUDiscoveryMode
 Discovery mode settings used in setMTUDiscoveryMode(). More...
 
- Protected Member Functions inherited from cosmos::SockOptBase< LEVEL >
 SockOptBase (FileDescriptor fd)
 Perform socket options on the given file descriptor.
 
bool getBoolOption (const OptName name) const
 Return a boolean style option.
 
void setBoolOption (const OptName name, const bool val)
 Set a boolean style option.
 
int getIntOption (const OptName name) const
 Return an integer option.
 
void setIntOption (const OptName name, const int val)
 Set an integer option.
 
std::string getStringOption (const OptName name, size_t max_len) const
 Return a null terminated string option.
 
void setStringOption (const OptName name, const SysString str)
 Set a null terminated string option.
 
std::string getPeerSec () const
 Returns the labeled IPSEC or NetLabel of the peer.
 
 SockOptBase (const SockOptBase &)=delete
 
SockOptBaseoperator= (const SockOptBase &)=delete
 
- Protected Attributes inherited from cosmos::SockOptBase< LEVEL >
FileDescriptor m_sock
 The socket file descriptor to operate on.
 
- Static Protected Attributes inherited from cosmos::SockOptBase< LEVEL >
static constexpr OptLevel M_LEVEL = LEVEL
 The option level to operate on.
 

Detailed Description

IPv6 level socket option setter/getter helper.

This helper type offers IPv6 level options that are shared between all IPv6 protocol based sockets.

This type cannot be freely created, but can only be obtained via e.g. UDP6Socket::ipOptions().

Definition at line 276 of file IPOptions.hxx.

Member Function Documentation

◆ getMTU()

int cosmos::IP6Options::getMTU ( ) const
inline

Returns the currently known path MTU of the socket.

This is only valid when the socket has been connected.

Definition at line 298 of file IPOptions.hxx.

298 {
299 return getIntOption(OptName{IPV6_MTU});
300 }
int getIntOption(const OptName name) const
Return an integer option.

◆ getMTUDiscoveryMode()

MTUDiscoveryMode cosmos::IP6Options::getMTUDiscoveryMode ( ) const
inline

Gets the current MTU discovery mode setting for the socket.

Definition at line 303 of file IPOptions.hxx.

303 {
304 const auto int_mode = getIntOption(OptName{IPV6_MTU_DISCOVER});
305 return MTUDiscoveryMode{int_mode};
306 }

◆ setAddrForm()

void cosmos::IP6Options::setAddrForm ( const SocketFamily family)
inline

Turn the INET6 socket into a socket of a different address family.

This is currently only possible for family == SocketFamily::INET. The IPv6 socket needs to be connected and bound to a v4-mapped-on-v6 address.

The purpose of this is to allow to pass an IPv6 socket to programs that otherwise don't know how to deal with the IPv6 API.

Definition at line 290 of file IPOptions.hxx.

290 {
291 setIntOption(OptName{IPV6_ADDRFORM}, to_integral(family));
292 }
void setIntOption(const OptName name, const int val)
Set an integer option.

◆ setMTU()

void cosmos::IP6Options::setMTU ( const int mtu)
inline

Sets the MTU used for the socket.

The MTU is limited by the device MTU or the path MTU, if path MTU discovery is enabled.

Definition at line 318 of file IPOptions.hxx.

318 {
319 setIntOption(OptName{IPV6_MTU}, mtu);
320 }

◆ setMTUDiscoveryMode()

void cosmos::IP6Options::setMTUDiscoveryMode ( const MTUDiscoveryMode mode)
inline

Sets a new MTU discovery mode setting.

Definition at line 309 of file IPOptions.hxx.

309 {
310 setIntOption(OptName{IPV6_MTU_DISCOVER}, to_integral(mode));
311 }

◆ setReceiveAuthHeader()

void cosmos::IP6Options::setReceiveAuthHeader ( const bool on_off)
inline

Enable delivery of auth header control messages.

Definition at line 345 of file IPOptions.hxx.

345 {
346 setBoolOption(OptName{IPV6_AUTHHDR}, on_off);
347 }
void setBoolOption(const OptName name, const bool val)
Set a boolean style option.

◆ setReceiveDestOpts()

void cosmos::IP6Options::setReceiveDestOpts ( const bool on_off)
inline

Enable delivery of of destination options control messages.

Definition at line 350 of file IPOptions.hxx.

350 {
351 setBoolOption(OptName{IPV6_DSTOPTS}, on_off);
352 }

◆ setReceiveErrors()

void cosmos::IP6Options::setReceiveErrors ( const bool on_off)
inline

Enable extended reliable error reporting for datagram sockets.

See also
IP4Options::setReceiveErrors().

Definition at line 335 of file IPOptions.hxx.

335 {
336 setBoolOption(OptName{IPV6_RECVERR}, on_off);
337 }

◆ setReceiveHopLimit()

void cosmos::IP6Options::setReceiveHopLimit ( const bool on_off)
inline

Enable delivery of hop limit control messages.

The hop info control message delivers an integer containing the hop count of the packet.

Definition at line 364 of file IPOptions.hxx.

364 {
365 setBoolOption(OptName{IPV6_HOPLIMIT}, on_off);
366 }

◆ setReceiveHopOpts()

void cosmos::IP6Options::setReceiveHopOpts ( const bool on_off)
inline

Enable delivery of hop options control messages.

Definition at line 355 of file IPOptions.hxx.

355 {
356 setBoolOption(OptName{IPV6_HOPOPTS}, on_off);
357 }

◆ setReceivePktInfo()

void cosmos::IP6Options::setReceivePktInfo ( const bool on_off)
inline

Enable delivery of IPV6_PKTINFO control messages on incoming datagrams.

Such control messages contain a struct in6_pktinfo. This option is allowed only for SocketType::DGRAM or SocketType::RAW.

Definition at line 327 of file IPOptions.hxx.

327 {
328 setBoolOption(OptName{IPV6_RECVPKTINFO}, on_off);
329 }

◆ setReceiveRoutingHeader()

void cosmos::IP6Options::setReceiveRoutingHeader ( const bool on_off)
inline

Enable delivery of routing header control messages.

Definition at line 340 of file IPOptions.hxx.

340 {
341 setBoolOption(OptName{IPV6_RTHDR}, on_off);
342 }

◆ setRouterAlert()

void cosmos::IP6Options::setRouterAlert ( const bool on_off)
inline

Pass to-be forwarded packets with the IP router alert option set to this socket.

See also
IP4Options::setRouterAlert()

Definition at line 372 of file IPOptions.hxx.

372 {
373 setBoolOption(OptName{IPV6_ROUTER_ALERT}, on_off);
374 }

◆ setUnicastHops()

void cosmos::IP6Options::setUnicastHops ( const int hops)
inline

Set the unicast hop limit for the socket.

If hops is -1 then the route default will be used. Otherwise the value should be between 0 and 255.

Definition at line 381 of file IPOptions.hxx.

381 {
382 setIntOption(OptName{IPV6_UNICAST_HOPS}, hops);
383 }

◆ setV6Only()

void cosmos::IP6Options::setV6Only ( const bool on_off)
inline

Restrict the socket to sending and receiving IPv6 packets only.

When this option is set then the same local port can be bound at the same time by an IPv4 and IPv6 application. If this option is unset then the same socket can be used to send and receive packets to and from IPv6 addresses and IPv4-mapped IPv6 addresses.

Definition at line 392 of file IPOptions.hxx.

392 {
393 setBoolOption(OptName{IPV6_V6ONLY}, on_off);
394 }

Friends And Related Symbol Documentation

◆ IPSocketT< SocketFamily::INET6 >

friend class IPSocketT< SocketFamily::INET6 >
friend

Definition at line 257 of file IPOptions.hxx.


The documentation for this class was generated from the following file: