libwebsockets
Lightweight C library for HTML5 websockets
|
Data Structures | |
struct | lws_dns_score |
struct | lws_route |
Macros | |
#define | LWS_ITOSA_USABLE 0 |
#define | LWS_ITOSA_NOT_EXIST -1 |
#define | LWS_ITOSA_NOT_USABLE -2 |
#define | LWS_ITOSA_BUSY |
Typedefs | |
typedef uint16_t | lws_route_uidx_t |
typedef struct lws_dns_score | lws_dns_score_t |
typedef struct lws_route | lws_route_t |
typedef lws_route_t | lws_dns_sort_t |
These wrap miscellaneous useful network-related functions
struct lws_dns_score |
Definition at line 39 of file lws-network-helper.h.
Data Fields | ||
---|---|---|
uint8_t | precedence | |
uint8_t | label |
struct lws_route |
Definition at line 48 of file lws-network-helper.h.
Data Fields | ||
---|---|---|
lws_dll2_t | list | |
lws_sockaddr46 | src | |
lws_sockaddr46 | dest | |
lws_sockaddr46 | gateway | |
struct lws_route * | source | |
lws_dns_score_t | score | |
int | if_idx | |
int | priority | |
int | ifa_flags | |
lws_route_uidx_t | uidx | |
uint8_t | proto | |
uint8_t | dest_len | |
uint8_t | src_len | |
uint8_t | scope | |
uint8_t | af | |
uint8_t | source_ads:1 |
#define LWS_ITOSA_USABLE 0 |
#include <include/libwebsockets/lws-network-helper.h>
Definition at line 126 of file lws-network-helper.h.
#define LWS_ITOSA_NOT_EXIST -1 |
#include <include/libwebsockets/lws-network-helper.h>
Definition at line 127 of file lws-network-helper.h.
#define LWS_ITOSA_NOT_USABLE -2 |
#include <include/libwebsockets/lws-network-helper.h>
Definition at line 128 of file lws-network-helper.h.
#define LWS_ITOSA_BUSY |
#include <include/libwebsockets/lws-network-helper.h>
Definition at line 129 of file lws-network-helper.h.
typedef uint16_t lws_route_uidx_t |
#include <include/libwebsockets/lws-network-helper.h>
Definition at line 37 of file lws-network-helper.h.
typedef struct lws_dns_score lws_dns_score_t |
#include <include/libwebsockets/lws-network-helper.h>
typedef struct lws_route lws_route_t |
#include <include/libwebsockets/lws-network-helper.h>
typedef lws_route_t lws_dns_sort_t |
#include <include/libwebsockets/lws-network-helper.h>
Definition at line 78 of file lws-network-helper.h.
LWS_VISIBLE LWS_EXTERN const char* LWS_WARN_UNUSED_RESULT lws_canonical_hostname | ( | struct lws_context * | context | ) |
#include <include/libwebsockets/lws-network-helper.h>
lws_canonical_hostname() - returns this host's hostname
This is typically used by client code to fill in the host parameter when making a client connection. You can only call it after the context has been created.
context | Websocket context |
LWS_VISIBLE LWS_EXTERN void lws_get_peer_addresses | ( | struct lws * | wsi, |
lws_sockfd_type | fd, | ||
char * | name, | ||
int | name_len, | ||
char * | rip, | ||
int | rip_len | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_get_peer_addresses() - Get client address information
wsi | Local struct lws associated with |
fd | Connection socket descriptor |
name | Buffer to take client address name |
name_len | Length of client address name buffer |
rip | Buffer to take client address IP dotted quad |
rip_len | Length of client address IP buffer This function fills in name and rip with the name and IP of the client connected with socket descriptor fd. Names may be truncated if there is not enough room. If either cannot be determined, they will be returned as valid zero-length strings. |
LWS_VISIBLE LWS_EXTERN const char* lws_get_peer_simple | ( | struct lws * | wsi, |
char * | name, | ||
size_t | namelen | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_get_peer_simple() - Get client address information without RDNS
wsi | Local struct lws associated with |
name | Buffer to take client address name |
namelen | Length of client address name buffer |
This provides a 123.123.123.123 type IP address in name from the peer that has connected to wsi
LWS_VISIBLE LWS_EXTERN const char* lws_get_peer_simple_fd | ( | lws_sockfd_type | fd, |
char * | name, | ||
size_t | namelen | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
LWS_VISIBLE LWS_EXTERN int lws_interface_to_sa | ( | int | ipv6, |
const char * | ifname, | ||
struct sockaddr_in * | addr, | ||
size_t | addrlen | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_interface_to_sa() - Convert interface name or IP to sockaddr struct
ipv6 | Allow IPV6 addresses |
ifname | Interface name or IP |
addr | struct sockaddr_in * to be written |
addrlen | Length of addr |
This converts a textual network interface name to a sockaddr usable by other network functions.
If the network interface doesn't exist, it will return LWS_ITOSA_NOT_EXIST.
If the network interface is not usable, eg ethernet cable is removed, it may logically exist but not have any IP address. As such it will return LWS_ITOSA_NOT_USABLE.
If the network interface exists and is usable, it will return LWS_ITOSA_USABLE.
LWS_VISIBLE LWS_EXTERN int lws_sa46_compare_ads | ( | const lws_sockaddr46 * | sa46a, |
const lws_sockaddr46 * | sa46b | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_sa46_compare_ads() - checks if two sa46 have the same address
sa46a | first |
sa46b | second |
Returns 0 if the address family is INET or INET6 and the address is the same, or if the AF is the same but not INET or INET6, otherwise nonzero.
LWS_VISIBLE LWS_EXTERN int lws_sa46_on_net | ( | const lws_sockaddr46 * | sa46a, |
const lws_sockaddr46 * | sa46_net, | ||
int | net_len | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_sa46_on_net() - checks if an sa46 is on the subnet represented by another
sa46a | first |
sa46_net | network |
net_len | length of network non-mask |
Returns 0 if sa46a belongs on network sa46_net/net_len
If there is an ipv4 / v6 mismatch between the ip and the net, the ipv4 address is promoted to ::ffff:x.x.x.x before the comparison.
LWS_VISIBLE LWS_EXTERN int lws_parse_numeric_address | ( | const char * | ads, |
uint8_t * | result, | ||
size_t | max_len | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
LWS_VISIBLE LWS_EXTERN int lws_sa46_parse_numeric_address | ( | const char * | ads, |
lws_sockaddr46 * | sa46 | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
LWS_VISIBLE LWS_EXTERN int lws_write_numeric_address | ( | const uint8_t * | ads, |
int | size, | ||
char * | buf, | ||
size_t | len | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_write_numeric_address() - convert network byte order ads to text
ads | network byte order address array |
size | number of bytes valid in ads |
buf | result buffer to take text format |
len | max size of text buffer |
Converts an array of network-ordered byte address elements to a textual representation of the numeric address, like "1.2.3.4" or "::1". Returns the number of chars written into buf, else < 0. ipv6 only supported with LWS_IPV6=1 at cmake.
LWS_VISIBLE LWS_EXTERN int lws_sa46_write_numeric_address | ( | lws_sockaddr46 * | sa46, |
char * | buf, | ||
size_t | len | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_sa46_write_numeric_address() - convert sa46 ads to textual numeric ads
sa46 | the sa46 whose address to show |
buf | result buffer to take text format |
len | max size of text buffer |
Converts the ipv4 or ipv6 address in an lws_sockaddr46 to a textual representation of the numeric address, like "1.2.3.4" or "::1". Returns the number of chars written into buf, else < 0. ipv6 only supported with LWS_IPV6=1 at cmake.
LWS_VISIBLE LWS_EXTERN int lws_parse_mac | ( | const char * | ads, |
uint8_t * | result_6_bytes | ||
) |
#include <include/libwebsockets/lws-network-helper.h>
lws_parse_mac() - convert XX:XX:XX:XX:XX:XX to 6-byte MAC address
ads | mac address as XX:XX:XX:XX:XX:XX string |
result_6_bytes | result buffer to take 6 bytes |
Converts a string representation of a 6-byte hex mac address to a 6-byte array.