QSC Post Quantum Cryptographic Library 1.3.0.0 (C1)
A post quantum secure library written in Ansi C
Loading...
Searching...
No Matches
netutils.h
Go to the documentation of this file.
1/* 2020-2026 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE:
5 * This software and all accompanying materials are the exclusive property of
6 * Quantum Resistant Cryptographic Solutions Corporation (QRCS). The intellectual
7 * and technical concepts contained herein are proprietary to QRCS and are
8 * protected under applicable Canadian, U.S., and international copyright,
9 * patent, and trade secret laws.
10 *
11 * CRYPTOGRAPHIC ALGORITHMS AND IMPLEMENTATIONS:
12 * - This software includes implementations of cryptographic primitives and
13 * algorithms that are standardized or in the public domain, such as AES
14 * and SHA-3, which are not proprietary to QRCS.
15 * - This software also includes cryptographic primitives, constructions, and
16 * algorithms designed by QRCS, including but not limited to RCS, SCB, CSX, QMAC, and
17 * related components, which are proprietary to QRCS.
18 * - All source code, implementations, protocol compositions, optimizations,
19 * parameter selections, and engineering work contained in this software are
20 * original works of QRCS and are protected under this license.
21 *
22 * LICENSE AND USE RESTRICTIONS:
23 * - This software is licensed under the Quantum Resistant Cryptographic Solutions
24 * Public Research and Evaluation License (QRCS-PREL), 2025-2026.
25 * - Permission is granted solely for non-commercial evaluation, academic research,
26 * cryptographic analysis, interoperability testing, and feasibility assessment.
27 * - Commercial use, production deployment, commercial redistribution, or
28 * integration into products or services is strictly prohibited without a
29 * separate written license agreement executed with QRCS.
30 * - Licensing and authorized distribution are solely at the discretion of QRCS.
31 *
32 * EXPERIMENTAL CRYPTOGRAPHY NOTICE:
33 * Portions of this software may include experimental, novel, or evolving
34 * cryptographic designs. Use of this software is entirely at the user's risk.
35 *
36 * DISCLAIMER:
37 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
39 * FOR A PARTICULAR PURPOSE, SECURITY, OR NON-INFRINGEMENT. QRCS DISCLAIMS ALL
40 * LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
41 * ARISING FROM THE USE OR MISUSE OF THIS SOFTWARE.
42 *
43 * FULL LICENSE:
44 * This software is subject to the Quantum Resistant Cryptographic Solutions
45 * Public Research and Evaluation License (QRCS-PREL), 2025-2026. The complete license terms
46 * are provided in the accompanying LICENSE file or at https://www.qrcscorp.ca.
47 *
48 * Written by: John G. Underhill
49 * Contact: contact@qrcscorp.ca
50 */
51
52#ifndef QSC_NETUTILS_H
53#define QSC_NETUTILS_H
54
55#include "qsccommon.h"
56#include "ipinfo.h"
57#include "socket.h"
58#include "socketbase.h"
59
60QSC_CPLUSPLUS_ENABLED_START
61
77
78/* bogus winbase.h error */
80
81
85#define QSC_NETUTILS_ADAPTOR_NAME_SIZE 0x104U
86
91#define QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE 0x84U
92
97#define QSC_NETUTILS_ADAPTOR_INFO_ARRAY_SIZE 0x08U
98
103#define QSC_NETUTILS_DOMAIN_NAME_SIZE 0x104U
104
109#define QSC_NETUTILS_HOSTS_NAME_SIZE 0x104U
110
115#define QSC_NETUTILS_IP_STRING_SIZE 0x80U
116
121#define QSC_NETUTILS_MAC_ADDRESS_SIZE 0x12U
122
127#define QSC_NETUTILS_NAME_BUFFER_SIZE 0x80U
128
133#define QSC_NETUTILS_SERVICE_NAME_BUFFER_SIZE 0x80U
134
139#define QSC_NETUTILS_SUBNET_STRING_SIZE 0x10U
140
155
156//~~~IP Address~~~//
157
165
172
180QSC_EXPORT_API uint32_t qsc_netutils_atoi(const char* source);
181
190
199
207
215
223
231QSC_EXPORT_API void qsc_netutils_get_ipv4_info(qsc_ipinfo_ipv4_info* pinfo, const char* host, const char* service);
232
240QSC_EXPORT_API void qsc_netutils_get_ipv6_info(qsc_ipinfo_ipv6_info* pinfo, const char* host, const char* service);
241
249
257
266QSC_EXPORT_API uint16_t qsc_netutils_port_name_to_number(const char* portname, const char* protocol);
267
268#if defined(QSC_DEBUG_MODE)
272QSC_EXPORT_API void qsc_netutils_values_print(void);
273#endif
274
275QSC_CPLUSPLUS_ENABLED_END
276
277#endif
IP information function definitions.
QSC_EXPORT_API size_t qsc_netutils_get_domain_name(char output[QSC_NETUTILS_DOMAIN_NAME_SIZE])
Retrieves the hosts domain name.
Definition netutils.c:451
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.
Definition netutils.c:80
#define QSC_NETUTILS_DOMAIN_NAME_SIZE
Definition netutils.h:103
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.
Definition netutils.c:884
QSC_EXPORT_API bool qsc_netutils_get_ipv4_address(qsc_ipinfo_ipv4_address *padd)
Retrieves the local IPv4 address.
Definition netutils.c:615
QSC_EXPORT_API bool qsc_netutils_get_ipv6_address(qsc_ipinfo_ipv6_address *padd)
Retrieves the local IPv6 address.
Definition netutils.c:750
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.
Definition netutils.c:1035
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.
Definition netutils.c:993
#define QSC_NETUTILS_IP_STRING_SIZE
Definition netutils.h:115
#define QSC_NETUTILS_ADAPTOR_NAME_SIZE
Definition netutils.h:85
#define QSC_NETUTILS_HOSTS_NAME_SIZE
Definition netutils.h:109
#define QSC_NETUTILS_NAME_BUFFER_SIZE
Definition netutils.h:127
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.
Definition netutils.c:1014
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.
Definition netutils.c:935
#define QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE
Definition netutils.h:91
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.
Definition netutils.c:202
#define QSC_NETUTILS_MAC_ADDRESS_SIZE
Definition netutils.h:121
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.
Definition netutils.c:544
QSC_EXPORT_API bool qsc_netutils_get_host_name(char host[QSC_NETUTILS_HOSTS_NAME_SIZE])
Retrieves the host name of the local machine.
Definition netutils.c:515
QSC_EXPORT_API uint32_t qsc_netutils_atoi(const char *source)
Parse a string for a number.
Definition netutils.c:420
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition qsccommon.h:645
#define QSC_SYSTEM_CONDITION_IGNORE(x)
A macro to disable a specific warning condition.
Definition qsccommon.h:835
TCP/IP function constants and structures.
Socket function definitions.
The IPv4 address structure.
Definition ipinfo.h:161
The IPv4 information structure.
Definition ipinfo.h:172
The IPv6 address structure.
Definition ipinfo.h:330
The IPv6 information structure.
Definition ipinfo.h:341
The netutils adaptor info structure.
Definition netutils.h:145
char name[QSC_NETUTILS_ADAPTOR_NAME_SIZE]
Definition netutils.h:151
char gateway[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:148
char subnet[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:152
char ip[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:149
char dhcp[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:147
char desc[QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE]
Definition netutils.h:146
char mac[QSC_NETUTILS_MAC_ADDRESS_SIZE]
Definition netutils.h:150
The socket instance structure.
Definition socket.h:133