###########################################################
System calls related to socket options:
###########################################################
Set the value in the cell pointed to by optval to the optname option:
int setsockopt(int sockfd, int level, int optname, const void *optval,socklen_t optlen);
Get the current value of the optname option and put it in the cell that optval points to:
int getsockopt(int sockfd, int level, int optname, void *optval,socklen_t *optlen);
Note that the last parameter is a pointer.
SOCKFD: Point to an already opened socket descriptor
Optlen: Specifies the size of the Optval
Optval: Store the value to get or set, type reference table
The other three parameters level, optname reference the corresponding table.
Socket options related to the SCTP library function:
int sctp_opt_info(int sockfd,
sctp_assoc_t assoc_id,//identification of possible associations
int opt,//socket option
void *arg,//socket option parameter
socklen_t *siz//parameter size
);
Gets the function of the SCTP socket option (similar to getsockopt)
Socket Options Categories:
Flag option: Enables or disables the two-tuple option for an attribute, at which time *optval is int or u_int, *optval=0 is disabled, and other means enabled.
Value options: A specific value for the option.
For socket options, for the state of the socket, when to set or get to consider timing issues.
------------------------
Sockets (Data Link layer): The so-called universal socket option, which is independent of the Protocol.
Level:sol_socket
Optname:
So_broadcast: The ability to enable or disable a process to send broadcast messages (only UDP support).
So_debug: (only TCP support).
So_dontroute: Specifies that outgoing packets will bypass the normal routing mechanism of the underlying protocol.
So_error: Error returned
So_keepalive: Stay Alive
So_linger: Specifies the close function for the connection-oriented protocol (TCP\SCTP) if the operation.
So_oobinline: When this option is turned on, out-of-band data is left in the normal input queue.
SO_RCVBUF: Modifying the size of the socket receive buffer
SO_SNDBUF: Modifying the size of the socket send buffer
So_rcvlowat:
So_sndlowat:
So_rcvtimeo: Setting the Receive timeout time
So_sndtimeo: Set Send timeout time
SO_REUSEADDR: Prevents the address from being reused, that is, only one connection is allowed.
So_reuseport: Prevents the port from being reused, that is, it can only have one connection.
So_type:
So_useloopback:
------------------------
IPV4 (Network layer):
Level:ipproto_ip
Optname:
IP_HDRINCL:
Ip_options:
IP_RECVDSTADDR:
Ip_recvif:
Ip_tos:
Ip_ttl:
------------------------
IPV6 (Network layer)):
Level:ipproto_ipv6
Optname:
Ipv6_checksum:
Ipv6_dontfrag:
Ipv6_nexthop:
IPV6_PATHMTU:
Ipv6_recvdstopts:
Ipv6_recvhoplimit:
Ipv6_recvhopopts:
Ipv6_recvpathmty:
Ipv6_recvpktinfo:
IPV6_RECVRTHRD:
Ipv6_recvtclass:
Ipv6_unicast_hops:
IPV6_USE_MIN_MTU:
Ipv6_v6only:
IPV6_XXX:
-----------
ICMPV6 (Network layer):
Level:ipproto_icmpv6
Optname:
Icmp6_filter:
------------------------
TCP (Transport Layer):
Level:ipproto_tcp
Optname:
TCP_MAXSEG:
Tcp_nodelay:
------------------------
SCTP (Transport Layer):
Level:ipproto_sctp
Optname:
Sctp_adaption_layer:
Sctp_associnfo:
Sctp_autoclose:
Sctp_default_send_param:
Sctp_disable_fragments:
Sctp_events: Book Eight events
Sctp_get_peer_addr_info:
SCTP_I_WANT_MAPPED_V4_ADDR:
SCTP_INITMSG: Initializing some information
Sctp_maxburst:
SCTP_MAXSEG:
Sctp_nodelay:
Sctp_peer_addr_params:
SCTP_PRIMARY_ADDR:
Sctp_rtoinfo:
SCTP_SET_PEER_PRIMARY_ADDR:
Sctp_status:
Some of the structure of sockets:
struct SCTP_INITMSG
{
__u16 Sinit_num_ostreams;
__u16 Sinit_max_instreams;
__u16 sinit_max_attempts;
__u16 Sinit_max_init_timeo;
};
Sockets: Socket options Related system calls