QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
netutils.h File Reference

Network utilities; common networking support functions. More...

#include "common.h"
#include "ipinfo.h"
#include "socket.h"
#include "socketbase.h"

Go to the source code of this file.

Data Structures

struct  qsc_netutils_adaptor_info
 The netutils adaptor info structure. More...
 

Macros

#define QSC_NETUTILS_ADAPTOR_NAME_SIZE   0x104U
 
#define QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE   0x84U
 
#define QSC_NETUTILS_ADAPTOR_INFO_ARRAY_SIZE   0x08U
 
#define QSC_NETUTILS_DOMAIN_NAME_SIZE   0x104U
 
#define QSC_NETUTILS_HOSTS_NAME_SIZE   0x104U
 
#define QSC_NETUTILS_IP_STRING_SIZE   0x80U
 
#define QSC_NETUTILS_MAC_ADDRESS_SIZE   0x12U
 
#define QSC_NETUTILS_NAME_BUFFER_SIZE   0x80U
 
#define QSC_NETUTILS_SERVICE_NAME_BUFFER_SIZE   0x80U
 
#define QSC_NETUTILS_SUBNET_STRING_SIZE   0x10U
 

Functions

QSC_EXPORT_API void qsc_netutils_get_adaptor_info (qsc_netutils_adaptor_info *info, const char *infname)
 Retrieves the address information on a named addressable interface.
 
QSC_EXPORT_API void qsc_netutils_get_mac_address (uint8_t mac[QSC_NETUTILS_MAC_ADDRESS_SIZE])
 Retrieves the mac address of the primary interface.
 
QSC_EXPORT_API uint32_t qsc_netutils_atoi (const char *source)
 Parse a string for a number.
 
QSC_EXPORT_API size_t qsc_netutils_get_domain_name (char output[QSC_NETUTILS_DOMAIN_NAME_SIZE])
 Retrieves the hosts domain name.
 
QSC_EXPORT_API bool qsc_netutils_get_host_name (char host[QSC_NETUTILS_HOSTS_NAME_SIZE])
 Retrieves the host name of the local machine.
 
QSC_EXPORT_API void qsc_netutils_get_name_from_ipv4_address (const qsc_ipinfo_ipv4_address *address, char host[QSC_NETUTILS_HOSTS_NAME_SIZE])
 Retrieves fully qualified name from an IPv4 address.
 
QSC_EXPORT_API bool qsc_netutils_get_ipv4_address (qsc_ipinfo_ipv4_address *padd)
 Retrieves the local IPv4 address.
 
QSC_EXPORT_API bool qsc_netutils_get_ipv6_address (qsc_ipinfo_ipv6_address *padd)
 Retrieves the local IPv6 address.
 
QSC_EXPORT_API void qsc_netutils_get_ipv4_info (qsc_ipinfo_ipv4_info *pinfo, const char *host, const char *service)
 Retrieves the IPv4 address information for a remote host.
 
QSC_EXPORT_API void qsc_netutils_get_ipv6_info (qsc_ipinfo_ipv6_info *pinfo, const char *host, const char *service)
 Retrieves the IPv6 address information for a remote host.
 
QSC_EXPORT_API void qsc_netutils_get_peer_name (char output[QSC_NETUTILS_HOSTS_NAME_SIZE], const qsc_socket *sock)
 Retrieves the host name of the connected peer.
 
QSC_EXPORT_API void qsc_netutils_get_socket_name (char output[QSC_NETUTILS_NAME_BUFFER_SIZE], const qsc_socket *sock)
 Retrieves the socket name of the connected peer.
 
QSC_EXPORT_API uint16_t qsc_netutils_port_name_to_number (const char *portname, const char *protocol)
 Get the port number using the connection parameters.
 

Detailed Description

Network utilities; common networking support functions.

This header provides utility functions for common networking tasks, including socket creation, connection management, data transmission, and reception over TCP/IP. The implementation supports both Microsoft Windows and POSIX-compliant systems, ensuring cross-platform compatibility with the underlying networking protocols.

Reference Links:

Macro Definition Documentation

◆ QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE

#define QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE   0x84U

The network adaptors description string

◆ QSC_NETUTILS_ADAPTOR_INFO_ARRAY_SIZE

#define QSC_NETUTILS_ADAPTOR_INFO_ARRAY_SIZE   0x08U

The network adaptors info array size

◆ QSC_NETUTILS_ADAPTOR_NAME_SIZE

#define QSC_NETUTILS_ADAPTOR_NAME_SIZE   0x104U

The network adaptors info string

◆ QSC_NETUTILS_DOMAIN_NAME_SIZE

#define QSC_NETUTILS_DOMAIN_NAME_SIZE   0x104U

The size of the domain name buffer

◆ QSC_NETUTILS_HOSTS_NAME_SIZE

#define QSC_NETUTILS_HOSTS_NAME_SIZE   0x104U

The size of the hosts name buffer

◆ QSC_NETUTILS_IP_STRING_SIZE

#define QSC_NETUTILS_IP_STRING_SIZE   0x80U

The IP address string size

◆ QSC_NETUTILS_MAC_ADDRESS_SIZE

#define QSC_NETUTILS_MAC_ADDRESS_SIZE   0x12U

The MAC address buffer length

◆ QSC_NETUTILS_NAME_BUFFER_SIZE

#define QSC_NETUTILS_NAME_BUFFER_SIZE   0x80U

The size of the protocol name buffer

◆ QSC_NETUTILS_SERVICE_NAME_BUFFER_SIZE

#define QSC_NETUTILS_SERVICE_NAME_BUFFER_SIZE   0x80U

The size of the service name buffer

◆ QSC_NETUTILS_SUBNET_STRING_SIZE

#define QSC_NETUTILS_SUBNET_STRING_SIZE   0x10U

The size of the subnet string

Function Documentation

◆ qsc_netutils_atoi()

QSC_EXPORT_API uint32_t qsc_netutils_atoi ( const char * source)

Parse a string for a number.

Parameters
source[const char*] The string to convert
Returns
[uint32_t] The number found in the string

◆ qsc_netutils_get_adaptor_info()

QSC_EXPORT_API void qsc_netutils_get_adaptor_info ( qsc_netutils_adaptor_info * info,
const char * infname )

Retrieves the address information on a named addressable interface.

Parameters
info[qsc_netutils_adaptor_info*] The adaptor info structure
infname[const char*]The adaptor interface name, ex 'eth0' or 'wlan0'

◆ qsc_netutils_get_domain_name()

QSC_EXPORT_API size_t qsc_netutils_get_domain_name ( char output[QSC_NETUTILS_DOMAIN_NAME_SIZE])

Retrieves the hosts domain name.

Parameters
output[char*] The source socket instance
Returns
[size_t] Returns the peers name string

◆ qsc_netutils_get_host_name()

QSC_EXPORT_API bool qsc_netutils_get_host_name ( char host[QSC_NETUTILS_HOSTS_NAME_SIZE])

Retrieves the host name of the local machine.

Parameters
host[char*] The host-name string
Returns
[bool] Returns true if the call succeeded

◆ qsc_netutils_get_ipv4_address()

QSC_EXPORT_API bool qsc_netutils_get_ipv4_address ( qsc_ipinfo_ipv4_address * padd)

Retrieves the local IPv4 address.

Parameters
padd[qsc_ipinfo_ipv4_address*] The ipv6 address structure
Returns
[bool] Returns true on function success

◆ qsc_netutils_get_ipv4_info()

QSC_EXPORT_API void qsc_netutils_get_ipv4_info ( qsc_ipinfo_ipv4_info * pinfo,
const char * host,
const char * service )

Retrieves the IPv4 address information for a remote host.

Parameters
pinfo[qsc_ipinfo_ipv4_info*] A pointer to the output ipinfo structure
host[const char*] The hosts qualified name
service[const char*] The service name

◆ qsc_netutils_get_ipv6_address()

QSC_EXPORT_API bool qsc_netutils_get_ipv6_address ( qsc_ipinfo_ipv6_address * padd)

Retrieves the local IPv6 address.

Parameters
padd[qsc_ipinfo_ipv6_address*] The ipv6 address structure
Returns
[bool] Returns true on function success

◆ qsc_netutils_get_ipv6_info()

QSC_EXPORT_API void qsc_netutils_get_ipv6_info ( qsc_ipinfo_ipv6_info * pinfo,
const char * host,
const char * service )

Retrieves the IPv6 address information for a remote host.

Parameters
pinfo[qsc_ipinfo_ipv6_info*] A pointer to the output ipinfo structure
host[const char*] The hosts qualified name
service[const char*] The service name

◆ qsc_netutils_get_mac_address()

QSC_EXPORT_API void qsc_netutils_get_mac_address ( uint8_t mac[QSC_NETUTILS_MAC_ADDRESS_SIZE])

Retrieves the mac address of the primary interface.

Parameters
mac[uint8_t*] The output array receiving the MAC address

◆ qsc_netutils_get_name_from_ipv4_address()

QSC_EXPORT_API void qsc_netutils_get_name_from_ipv4_address ( const qsc_ipinfo_ipv4_address * address,
char host[QSC_NETUTILS_HOSTS_NAME_SIZE] )

Retrieves fully qualified name from an IPv4 address.

Parameters
address[const qsc_ipinfo_ipv4_address*] The input IPv4 address string
host[char*] The output host name

◆ qsc_netutils_get_peer_name()

QSC_EXPORT_API void qsc_netutils_get_peer_name ( char output[QSC_NETUTILS_HOSTS_NAME_SIZE],
const qsc_socket * sock )

Retrieves the host name of the connected peer.

Parameters
output[char*] The output buffer
sock[const char*] The source socket instance

◆ qsc_netutils_get_socket_name()

QSC_EXPORT_API void qsc_netutils_get_socket_name ( char output[QSC_NETUTILS_NAME_BUFFER_SIZE],
const qsc_socket * sock )

Retrieves the socket name of the connected peer.

Parameters
output[char*] The output buffer
sock[const qsc_socket*] The source socket instance

◆ qsc_netutils_port_name_to_number()

QSC_EXPORT_API uint16_t qsc_netutils_port_name_to_number ( const char * portname,
const char * protocol )

Get the port number using the connection parameters.

Parameters
portname[const char*] The port name
protocol[const char*] The protocol name
Returns
The port number, or zero on failure