Lely core libraries  2.2.5
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 
30 struct __io_addr {
32  int addrlen;
34  union {
35  char __size[128];
36  long __align;
37  } addr;
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 
76 struct io_addrinfo {
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
95 extern "C" {
96 #endif
97 
104 int io_addr_cmp(const void *p1, const void *p2);
105 
124 int io_addr_get_rfcomm_a(const io_addr_t *addr, char *ba, int *port);
125 
142 int io_addr_set_rfcomm_a(io_addr_t *addr, const char *ba, int port);
143 
161 int io_addr_get_rfcomm_n(const io_addr_t *addr, uint8_t ba[6], int *port);
162 
175 void io_addr_set_rfcomm_n(io_addr_t *addr, const uint8_t ba[6], int port);
176 
186 void io_addr_set_rfcomm_local(io_addr_t *addr, int port);
187 
203 int io_addr_get_ipv4_a(const io_addr_t *addr, char *ip, int *port);
204 
215 int io_addr_set_ipv4_a(io_addr_t *addr, const char *ip, int port);
216 
232 int io_addr_get_ipv4_n(const io_addr_t *addr, uint8_t ip[4], int *port);
233 
244 void io_addr_set_ipv4_n(io_addr_t *addr, const uint8_t ip[4], int port);
245 
253 void io_addr_set_ipv4_loopback(io_addr_t *addr, int port);
254 
262 void io_addr_set_ipv4_broadcast(io_addr_t *addr, int port);
263 
279 int io_addr_get_ipv6_a(const io_addr_t *addr, char *ip, int *port);
280 
294 int io_addr_set_ipv6_a(io_addr_t *addr, const char *ip, int port);
295 
311 int io_addr_get_ipv6_n(const io_addr_t *addr, uint8_t ip[16], int *port);
312 
323 void io_addr_set_ipv6_n(io_addr_t *addr, const uint8_t ip[16], int port);
324 
332 void io_addr_set_ipv6_loopback(io_addr_t *addr, int port);
333 
347 int io_addr_get_unix(const io_addr_t *addr, char *path);
348 
357 void io_addr_set_unix(io_addr_t *addr, const char *path);
358 
368 int io_addr_get_domain(const io_addr_t *addr);
369 
382 int io_addr_get_port(const io_addr_t *addr, int *port);
383 
395 int io_addr_set_port(io_addr_t *addr, int port);
396 
398 int io_addr_is_loopback(const io_addr_t *addr);
399 
401 int io_addr_is_broadcast(const io_addr_t *addr);
402 
404 int io_addr_is_multicast(const io_addr_t *addr);
405 
427 int 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:527
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:423
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:329
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:448
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:691
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:738
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:196
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:465
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:226
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:614
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:711
int io_addr_cmp(const void *p1, const void *p2)
Compares two network addresses.
Definition: addr.c:48
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:402
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:548
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:151
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:360
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:255
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:374
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:304
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:74
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:117
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:663
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:283
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:483
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:506
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:346
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