plibsys 0.0.5
psocketaddress.h
Go to the documentation of this file.
1/*
2 * The MIT License
3 *
4 * Copyright (C) 2010-2017 Alexander Saprykin <saprykin.spb@gmail.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * 'Software'), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
55#if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
56# error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
57#endif
58
59#ifndef PLIBSYS_HEADER_PSOCKETADDRESS_H
60#define PLIBSYS_HEADER_PSOCKETADDRESS_H
61
62#include <pmacros.h>
63#include <ptypes.h>
64
65#ifndef P_OS_WIN
66# include <sys/types.h>
67# include <sys/socket.h>
68# include <netinet/in.h>
69#endif
70
72
74typedef enum PSocketFamily_ {
77#ifdef AF_INET6
78 P_SOCKET_FAMILY_INET6 = AF_INET6
79#else
81#endif
83
85typedef struct PSocketAddress_ PSocketAddress;
86
95 psize len);
96
111 puint16 port);
112
125 puint16 port);
126
139 puint16 port);
140
150 ppointer dest,
151 psize destlen);
152
161
169
178
186
197
208
219 puint32 flowinfo);
220
231 puint32 scope_id);
232
239
246
253
264
274
281
283
284#endif /* PLIBSYS_HEADER_PSOCKETADDRESS_H */
Miscellaneous macros.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition pmacros.h:298
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS.
Definition pmacros.h:299
#define P_LIB_API
Exports a symbol from a shared library.
Definition pmacros.h:138
P_LIB_API pboolean p_socket_address_is_ipv6_supported(void)
Checks whether IPv6 protocol is supported.
P_LIB_API void p_socket_address_free(PSocketAddress *addr)
Frees a socket address structure and its resources.
P_LIB_API pchar * p_socket_address_get_address(const PSocketAddress *addr)
Gets a socket address in a string representation, i.e.
enum PSocketFamily_ PSocketFamily
Socket address family.
P_LIB_API PSocketFamily p_socket_address_get_family(const PSocketAddress *addr)
Gets a family of a socket address.
PSocketFamily_
Socket address family.
@ P_SOCKET_FAMILY_INET6
No IPv6 family.
@ P_SOCKET_FAMILY_INET
IPv4 family.
@ P_SOCKET_FAMILY_UNKNOWN
Unknown family.
P_LIB_API puint32 p_socket_address_get_flow_info(const PSocketAddress *addr)
Gets IPv6 traffic class and flow information.
P_LIB_API psize p_socket_address_get_native_size(const PSocketAddress *addr)
Gets the size of the native socket address raw data, in bytes.
struct PSocketAddress_ PSocketAddress
Socket address opaque structure.
P_LIB_API PSocketAddress * p_socket_address_new(const pchar *address, puint16 port)
Creates new PSocketAddress.
P_LIB_API pboolean p_socket_address_is_any(const PSocketAddress *addr)
Checks whether a given socket address is an any-address representation.
P_LIB_API pboolean p_socket_address_is_loopback(const PSocketAddress *addr)
Checks whether a given socket address is for the loopback interface.
P_LIB_API pboolean p_socket_address_to_native(const PSocketAddress *addr, ppointer dest, psize destlen)
Converts PSocketAddress to the native socket address raw data.
P_LIB_API void p_socket_address_set_scope_id(PSocketAddress *addr, puint32 scope_id)
Sets an IPv6 set of interfaces for a scope.
P_LIB_API pboolean p_socket_address_is_scope_id_supported(void)
Checks whether a set of interfaces for a scope is supported in IPv6.
P_LIB_API PSocketAddress * p_socket_address_new_from_native(pconstpointer native, psize len)
Creates new PSocketAddress from the native socket address raw data.
P_LIB_API PSocketAddress * p_socket_address_new_loopback(PSocketFamily family, puint16 port)
Creates new PSocketAddress for the loopback interface.
P_LIB_API pboolean p_socket_address_is_flow_info_supported(void)
Checks whether flow information is supported in IPv6.
P_LIB_API void p_socket_address_set_flow_info(PSocketAddress *addr, puint32 flowinfo)
Sets IPv6 traffic class and flow information.
P_LIB_API puint16 p_socket_address_get_port(const PSocketAddress *addr)
Gets a port number of a socket address.
P_LIB_API PSocketAddress * p_socket_address_new_any(PSocketFamily family, puint16 port)
Creates new PSocketAddress for the any-address representation.
P_LIB_API puint32 p_socket_address_get_scope_id(const PSocketAddress *addr)
Gets an IPv6 set of interfaces for a scope.
Types definitions.
unsigned short puint16
Type for unsigned 16 bit.
Definition ptypes.h:79
char pchar
Type for a char.
Definition ptypes.h:116
unsigned int psize
Type for a platform independent size_t.
Definition ptypes.h:224
const void * pconstpointer
Type for a const pointer.
Definition ptypes.h:111
void * ppointer
Type for a pointer.
Definition ptypes.h:109
signed int pboolean
Type for a bool.
Definition ptypes.h:114
unsigned int puint32
Type for unsigned 32 bit.
Definition ptypes.h:83