23 #include <sol-common-buildopts.h>
62 #define SOL_NETWORK_INET_ADDR_STR_LEN 48
67 #define SOL_BLUETOOTH_ADDR_STRLEN 18
167 #ifndef SOL_NO_API_VERSION
168 #define SOL_NETWORK_LINK_API_VERSION (1)
180 #ifndef SOL_NO_API_VERSION
188 #define SOL_NETWORK_LINK_CHECK_VERSION(link_, ...) \
189 if (SOL_UNLIKELY((link_)->api_version != \
190 SOL_NETWORK_LINK_API_VERSION)) { \
191 SOL_WRN("Unexpected API version (message is %u, expected %u)", \
192 (link_)->api_version, SOL_NETWORK_LINK_API_VERSION); \
193 return __VA_ARGS__; \
196 #define SOL_NETWORK_LINK_CHECK_VERSION(link_, ...)
241 if (compare_ports && (a->
port != b->
port))
245 const uint8_t *addr_a, *addr_b;
250 bytes =
sizeof(a->
addr.
in);
264 return !memcmp(addr_a, addr_b, bytes);
272 struct ipv6_map_prefix {
273 const uint8_t zeroes[10];
275 } __attribute__ ((packed)) prefix = {
278 const uint8_t *addr_ipv6, *addr_ipv4;
289 bytes =
sizeof(a->
addr.
in);
296 if (!memcmp(addr_ipv6, &prefix,
sizeof(
struct ipv6_map_prefix)) &&
297 !memcmp(addr_ipv6 + 12, addr_ipv4, bytes))
sol_network_event
Type of events generated for a network link.
Definition: sol-network.h:89
sol_network_bt_addr_type
Type of a Bluetooth address.
Definition: sol-network.h:136
Bluetooth "raw" family.
Definition: sol-network.h:122
uint16_t port
The port associed with the IP address.
Definition: sol-network.h:155
Definition: sol-network.h:90
uint16_t index
the index of this link given by SO
Definition: sol-network.h:171
Definition: sol-network.h:139
union sol_network_link_addr::@10 addr
The address itself.
Definition: sol-network.h:104
static bool sol_network_link_addr_eq(const struct sol_network_link_addr *a, const struct sol_network_link_addr *b)
Checks if two address are equal.
Definition: sol-network.h:315
struct sol_network_link sol_network_link
Structure to represent a network link.
int sol_network_link_up(uint16_t link_index)
Sets a network link up.
Structure to represent a network link.
Definition: sol-network.h:166
static uint16_t sol_util_be16_to_cpu(uint16_t val)
Convert a 16 bytes big endian integer to cpu endianness.
Definition: sol-util.h:880
Definition: sol-network.h:103
Definition: sol-network.h:105
struct sol_vector addrs
List of network addresses.
Definition: sol-network.h:177
struct sol_network_link_addr sol_network_link_addr
Structure to represent a network address, both IPv6 and IPv4 are valid.
Definition: sol-network.h:106
Unspecified address type.
Definition: sol-network.h:116
String slice type.
Definition: sol-str-slice.h:84
These are routines that Soletta provides for its buffer implementation.
Structure to represent a network address, both IPv6 and IPv4 are valid.
Definition: sol-network.h:145
enum sol_network_family family
IPv4 or IPv6 family.
Definition: sol-network.h:146
int sol_network_unsubscribe_events(void(*cb)(void *data, const struct sol_network_link *link, enum sol_network_event event), const void *data)
Stops receiving network link events.
char * sol_network_link_get_name(const struct sol_network_link *link)
Gets the name of a network link.
IPv6 family.
Definition: sol-network.h:120
enum sol_network_link_flags flags
The status of the link.
Definition: sol-network.h:172
struct sol_network_hostname_pending * sol_network_get_hostname_address_info(const struct sol_str_slice hostname, enum sol_network_family family, void(*host_info_cb)(void *data, const struct sol_str_slice hostname, const struct sol_vector *addrs_list), const void *data)
Gets a hostname address info.
Bluetooth RFCOMM family.
Definition: sol-network.h:124
Definition: sol-network.h:92
sol_network_family
Type of a network address.
Definition: sol-network.h:114
uint8_t in[4]
Definition: sol-network.h:148
const struct sol_vector * sol_network_get_available_links(void)
Retrieve the available network links on a system.
uint8_t bt_addr[6]
Definition: sol-network.h:152
int sol_network_subscribe_events(void(*cb)(void *data, const struct sol_network_link *link, enum sol_network_event event), const void *data)
Subscribes to receive network link events.
sol_network_link_flags
Bitwise OR-ed flags to represent the status of a sol_network_link.
Definition: sol-network.h:101
uint8_t bt_type
Definition: sol-network.h:151
static bool sol_network_link_addr_eq_full(const struct sol_network_link_addr *a, const struct sol_network_link_addr *b, bool compare_ports)
Checks if two address are equal - possibly including the port field.
Definition: sol-network.h:236
uint16_t api_version
API version.
Definition: sol-network.h:169
Definition: sol-network.h:137
int sol_network_hostname_pending_cancel(struct sol_network_hostname_pending *handle)
Cancels a request to get the hostname info.
const char * sol_network_link_addr_to_str(const struct sol_network_link_addr *addr, struct sol_buffer *buf)
Converts a sol_network_link_addr to a string.
These are routines that Soletta provides for its string slice implementation.
uint8_t in6[16]
Definition: sol-network.h:149
Soletta vector is an array that grows dynamically.
Definition: sol-vector.h:58
IPv4 family.
Definition: sol-network.h:118
const struct sol_network_link_addr * sol_network_link_addr_from_str(struct sol_network_link_addr *addr, const char *buf)
Converts a string address to sol_network_link_addr.
These are routines that Soletta provides for its vector implementation.
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
int sol_network_link_down(uint16_t link_index)
Sets a network link down.
struct sol_network_hostname_pending sol_network_hostname_pending
A handle returned by sol_network_get_hostname_address_info()
Definition: sol-network.h:82
Definition: sol-network.h:91
Definition: sol-network.h:138
Bluetooth L2CAP family.
Definition: sol-network.h:126
Definition: sol-network.h:102