qlibs:
Section: Misc. Reference Manual Pages (socket_if)
Updated: 3
Index
Return to Main Contents
NAME
socket_if - retrieve scope_id for interface name and vice versa
SYNTAX
#include "socket_if.h"
uint32 socket_getifidx(const char *ifname);
const char *socket_getifname(uint32 scope_id);
DESCRIPTION
socket_getifidx
returns the scope_id of an interface named as
ifname
typically ''eth0''.
socket_getifname
retrieves from the operating system's assigned
scope_id
the interface name
ifname.
INTERFACE_NAME VERSUS SCOPE_ID
For IPv6 LLU addresses an additional
ifname
(interface name) has to be provided accompanying the IPv6 address:
fe80::1%eth0.
The operating systems rather uses
scope_id
as index for
ifname.
For global IPv6 and ULA addresses
ifname
can be set to
0.
Since IPv4 addresses on any interface are always unique,
simply use
0
for all cases.
BACKGROUND
Qlib's socket routines provide an easy API to setup
TCP or UDP connections over IPv4 or IPv6 networks. Together with
Qlib's IP address parsing capabilities, a set of high-level
socket routines allow a common IPv4/IPv6 handling.
SOCKET FILES
- socket_bind.c
-
bind to or reuse the local IPv4/IPv6 address and port
for a socket connection
- socket_connect.c
-
attempts to setup a TCP or UDP client connection
- socket_info.c
-
get local/remote IPv4/IPv6 address of socket
- socket_recv.c
-
set up a receiving IPv4/IPv6 connection
- socket_send.c
-
send UDP datagram over a IPv4 or IPv6 connection
- socket_setup.c
-
listen to and accept an IPv4/IPv6 TCP socket connection
- socket_tcp.c
-
create a non-blocking TCP stream socket
- socket_udp.c
-
create a non-blocking UDP datagram socket
USAGE
Most of the above files include their IPv4 and
IPv6 counterparts together with a combined usage
requiring in addition a
scope_id
or simply
0.
IPv4 addresses are usually converted upon reading to
IPv4-mapped IPv6 addresses using Qlib's IP address
parsing functions.
IPv4 and IPv6 socket calls - if required -
need to be distinguished
by the calling routines testing
ip6_isv4mapped(ip)
Otherwise, the unified IPv6/IPv4 versions will be used.
SEE ALSO
socket_bind(3),
socket_connect(3),
socket_info(3),
socket_recv(3),
socket_send(3),
socket_setup(3),
socket_tcp(3),
socket_udp(3)
Index
- NAME
-
- SYNTAX
-
- DESCRIPTION
-
- INTERFACE_NAME VERSUS SCOPE_ID
-
- BACKGROUND
-
- SOCKET FILES
-
- USAGE
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 14:55:39 GMT, December 15, 2024