Lely core libraries 2.3.4
addr.h
Go to the documentation of this file.
1
22#ifndef LELY_IO_ADDR_H_
23#define LELY_IO_ADDR_H_
24
25#include <lely/io/io.h>
26
27#include <stdint.h>
28
30struct __io_addr {
34 union {
35 char __size[128];
36 long __align;
38};
39
41#define IO_ADDR_INIT \
42 { \
43 0, \
44 { \
45 { \
46 0 \
47 } \
48 } \
49 }
50
55#define IO_ADDR_BTH_STRLEN 18
56
61#define IO_ADDR_IPV4_STRLEN 16
62
67#define IO_ADDR_IPV6_STRLEN 46
68
73#define IO_ADDR_UNIX_STRLEN 108
74
81 int domain;
83 int type;
86};
87
89#define IO_ADDRINFO_INIT \
90 { \
91 0, 0, IO_ADDR_INIT \
92 }
93
94#ifdef __cplusplus
95extern "C" {
96#endif
97
104int io_addr_cmp(const void *p1, const void *p2);
105
124int io_addr_get_rfcomm_a(const io_addr_t *addr, char *ba, int *port);
125
142int io_addr_set_rfcomm_a(io_addr_t *addr, const char *ba, int port);
143
161int io_addr_get_rfcomm_n(const io_addr_t *addr, uint8_t ba[6], int *port);
162
175void io_addr_set_rfcomm_n(io_addr_t *addr, const uint8_t ba[6], int port);
176
186void io_addr_set_rfcomm_local(io_addr_t *addr, int port);
187
203int io_addr_get_ipv4_a(const io_addr_t *addr, char *ip, int *port);
204
215int io_addr_set_ipv4_a(io_addr_t *addr, const char *ip, int port);
216
232int io_addr_get_ipv4_n(const io_addr_t *addr, uint8_t ip[4], int *port);
233
244void io_addr_set_ipv4_n(io_addr_t *addr, const uint8_t ip[4], int port);
245
253void io_addr_set_ipv4_loopback(io_addr_t *addr, int port);
254
262void io_addr_set_ipv4_broadcast(io_addr_t *addr, int port);
263
279int io_addr_get_ipv6_a(const io_addr_t *addr, char *ip, int *port);
280
294int io_addr_set_ipv6_a(io_addr_t *addr, const char *ip, int port);
295
311int io_addr_get_ipv6_n(const io_addr_t *addr, uint8_t ip[16], int *port);
312
323void io_addr_set_ipv6_n(io_addr_t *addr, const uint8_t ip[16], int port);
324
332void io_addr_set_ipv6_loopback(io_addr_t *addr, int port);
333
347int io_addr_get_unix(const io_addr_t *addr, char *path);
348
357void io_addr_set_unix(io_addr_t *addr, const char *path);
358
368int io_addr_get_domain(const io_addr_t *addr);
369
382int io_addr_get_port(const io_addr_t *addr, int *port);
383
395int io_addr_set_port(io_addr_t *addr, int port);
396
398int io_addr_is_loopback(const io_addr_t *addr);
399
401int io_addr_is_broadcast(const io_addr_t *addr);
402
404int io_addr_is_multicast(const io_addr_t *addr);
405
427int io_get_addrinfo(int maxinfo, struct io_addrinfo *info, const char *nodename,
428 const char *servname, const struct io_addrinfo *hints);
429
430#ifdef __cplusplus
431}
432#endif
433
434#endif // !LELY_IO_ADDR_H_
int io_addr_get_domain(const io_addr_t *addr)
Obtains the domain of a network address.
Definition: addr.c:530
int io_addr_get_ipv6_n(const io_addr_t *addr, uint8_t ip[16], int *port)
Obtains an IPv6 address and port number from a network address.
Definition: addr.c:426
void io_addr_set_ipv4_n(io_addr_t *addr, const uint8_t ip[4], int port)
Initializes a network address from an IPv4 address and port number.
Definition: addr.c:332
void io_addr_set_ipv6_n(io_addr_t *addr, const uint8_t ip[16], int port)
Initializes a network address from an IPv6 address and port number.
Definition: addr.c:451
int io_addr_is_broadcast(const io_addr_t *addr)
Returns 1 if the network address is a broadcast address, and 0 if not.
Definition: addr.c:694
int io_get_addrinfo(int maxinfo, struct io_addrinfo *info, const char *nodename, const char *servname, const struct io_addrinfo *hints)
Obtains a list of network addresses corresponding to a host and/or service name.
Definition: addr.c:741
void io_addr_set_rfcomm_n(io_addr_t *addr, const uint8_t ba[6], int port)
Initializes a network address from an RFCOMM Bluetooth device address and port number.
Definition: addr.c:199
void io_addr_set_ipv6_loopback(io_addr_t *addr, int port)
Initializes a network address with the IPv6 loopback address and a port number.
Definition: addr.c:468
void io_addr_set_rfcomm_local(io_addr_t *addr, int port)
Initializes a network address with the local Bluetooth (RFCOMM) device address (FF:FF:FF:00:00:00) an...
Definition: addr.c:229
int io_addr_set_port(io_addr_t *addr, int port)
Initializes the port number of an IPv4 or IPv6 network address.
Definition: addr.c:617
int io_addr_is_multicast(const io_addr_t *addr)
Returns 1 if the network address is a multicast address, and 0 if not.
Definition: addr.c:714
int io_addr_cmp(const void *p1, const void *p2)
Compares two network addresses.
Definition: addr.c:51
int io_addr_set_ipv6_a(io_addr_t *addr, const char *ip, int port)
Initializes a network address from an IPv6 address and port number.
Definition: addr.c:405
int io_addr_get_port(const io_addr_t *addr, int *port)
Obtains the port number of an IPv4 or IPv6 network address.
Definition: addr.c:551
int io_addr_get_rfcomm_n(const io_addr_t *addr, uint8_t ba[6], int *port)
Obtains an RFCOMM Bluetooth device address and port number from a network address.
Definition: addr.c:154
void io_addr_set_ipv4_broadcast(io_addr_t *addr, int port)
Initializes a network address with the IPv4 broadcast address and a port number.
Definition: addr.c:363
int io_addr_get_ipv4_a(const io_addr_t *addr, char *ip, int *port)
Obtains an IPv4 address and port number from a network address.
Definition: addr.c:258
int io_addr_get_ipv6_a(const io_addr_t *addr, char *ip, int *port)
Obtains an IPv6 address and port number from a network address.
Definition: addr.c:377
int io_addr_get_ipv4_n(const io_addr_t *addr, uint8_t ip[4], int *port)
Obtains an IPv4 address and port number from a network address.
Definition: addr.c:307
int io_addr_get_rfcomm_a(const io_addr_t *addr, char *ba, int *port)
Obtains an RFCOMM Bluetooth device address and port number from a network address.
Definition: addr.c:77
int io_addr_set_rfcomm_a(io_addr_t *addr, const char *ba, int port)
Initializes a network address from an RFCOMM Bluetooth device address and port number.
Definition: addr.c:120
int io_addr_is_loopback(const io_addr_t *addr)
Returns 1 if the network address is a loopback address, and 0 if not.
Definition: addr.c:666
int io_addr_set_ipv4_a(io_addr_t *addr, const char *ip, int port)
Initializes a network address from an IPv4 address and port number.
Definition: addr.c:286
int io_addr_get_unix(const io_addr_t *addr, char *path)
Obtains a UNIX domain socket path name from a network address.
Definition: addr.c:486
void io_addr_set_unix(io_addr_t *addr, const char *path)
Initializes a network address from a UNIX domain socket path name.
Definition: addr.c:509
void io_addr_set_ipv4_loopback(io_addr_t *addr, int port)
Initializes a network address with the IPv4 loopback address and a port number.
Definition: addr.c:349
This is the public header file of the I/O library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdint....
An opaque network address type.
Definition: addr.h:30
union __io_addr::@5 addr
The network address.
int addrlen
The size (in bytes) of addr.
Definition: addr.h:32
A network address info structure.
Definition: addr.h:76
int type
The type of the socket (either IO_SOCK_STREAM or IO_SOCK_DGRAM).
Definition: addr.h:83
int domain
The domain of the socket (only IO_SOCK_IPV4 and IO_SOCK_IPV6 are supported).
Definition: addr.h:81
io_addr_t addr
The network address.
Definition: addr.h:85