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
Go to the documentation of this file.
1/* 2025 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE: This software and all accompanying materials are the exclusive
5 * property of Quantum Resistant Cryptographic Solutions Corporation (QRCS).
6 * The intellectual and technical concepts contained within this implementation
7 * are proprietary to QRCS and its authorized licensors and are protected under
8 * applicable U.S. and international copyright, patent, and trade secret laws.
9 *
10 * CRYPTOGRAPHIC STANDARDS:
11 * - This software includes implementations of cryptographic algorithms such as
12 * SHA3, AES, and others. These algorithms are public domain or standardized
13 * by organizations such as NIST and are NOT the property of QRCS.
14 * - However, all source code, optimizations, and implementations in this library
15 * are original works of QRCS and are protected under this license.
16 *
17 * RESTRICTIONS:
18 * - Redistribution, modification, or unauthorized distribution of this software,
19 * in whole or in part, is strictly prohibited.
20 * - This software is provided for non-commercial, educational, and research
21 * purposes only. Commercial use in any form is expressly forbidden.
22 * - Licensing and authorized distribution are solely at the discretion of QRCS.
23 * - Any use of this software implies acceptance of these restrictions.
24 *
25 * DISCLAIMER:
26 * This software is provided "as is," without warranty of any kind, express or
27 * implied, including but not limited to warranties of merchantability or fitness
28 * for a particular purpose. QRCS disclaims all liability for any direct, indirect,
29 * incidental, or consequential damages resulting from the use or misuse of this software.
30 *
31 * FULL LICENSE:
32 * This software is subject to the **Quantum Resistant Cryptographic Solutions
33 * Proprietary License (QRCS-PL)**. The complete license terms are included
34 * in the LICENSE.txt file distributed with this software.
35 *
36 * Written by: John G. Underhill
37 * Contact: john.underhill@protonmail.com
38 */
39
40#ifndef QSC_NETUTILS_H
41#define QSC_NETUTILS_H
42
43#include "common.h"
44#include "ipinfo.h"
45#include "socket.h"
46#include "socketbase.h"
47
48QSC_CPLUSPLUS_ENABLED_START
49
65
66/* bogus winbase.h error */
68
69
73#define QSC_NETUTILS_ADAPTOR_NAME_SIZE 0x104U
74
79#define QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE 0x84U
80
85#define QSC_NETUTILS_ADAPTOR_INFO_ARRAY_SIZE 0x08U
86
91#define QSC_NETUTILS_DOMAIN_NAME_SIZE 0x104U
92
97#define QSC_NETUTILS_HOSTS_NAME_SIZE 0x104U
98
103#define QSC_NETUTILS_IP_STRING_SIZE 0x80U
104
109#define QSC_NETUTILS_MAC_ADDRESS_SIZE 0x12U
110
115#define QSC_NETUTILS_NAME_BUFFER_SIZE 0x80U
116
121#define QSC_NETUTILS_SERVICE_NAME_BUFFER_SIZE 0x80U
122
127#define QSC_NETUTILS_SUBNET_STRING_SIZE 0x10U
128
143
144//~~~IP Address~~~//
145
153
160
168QSC_EXPORT_API uint32_t qsc_netutils_atoi(const char* source);
169
178
187
195
203
211
219QSC_EXPORT_API void qsc_netutils_get_ipv4_info(qsc_ipinfo_ipv4_info* pinfo, const char* host, const char* service);
220
228QSC_EXPORT_API void qsc_netutils_get_ipv6_info(qsc_ipinfo_ipv6_info* pinfo, const char* host, const char* service);
229
237
245
254QSC_EXPORT_API uint16_t qsc_netutils_port_name_to_number(const char* portname, const char* protocol);
255
256#if defined(QSC_DEBUG_MODE)
260QSC_EXPORT_API void qsc_netutils_values_print(void);
261#endif
262
263QSC_CPLUSPLUS_ENABLED_END
264
265#endif
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 common.h:520
#define QSC_SYSTEM_CONDITION_IGNORE(x)
MSVC-specific macro to disable a specific warning condition.
Definition common.h:784
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:173
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:38
#define QSC_NETUTILS_DOMAIN_NAME_SIZE
Definition netutils.h:91
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:570
QSC_EXPORT_API bool qsc_netutils_get_ipv4_address(qsc_ipinfo_ipv4_address *padd)
Retrieves the local IPv4 address.
Definition netutils.c:311
QSC_EXPORT_API bool qsc_netutils_get_ipv6_address(qsc_ipinfo_ipv6_address *padd)
Retrieves the local IPv6 address.
Definition netutils.c:441
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:714
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:673
#define QSC_NETUTILS_IP_STRING_SIZE
Definition netutils.h:103
#define QSC_NETUTILS_ADAPTOR_NAME_SIZE
Definition netutils.h:73
#define QSC_NETUTILS_HOSTS_NAME_SIZE
Definition netutils.h:97
#define QSC_NETUTILS_NAME_BUFFER_SIZE
Definition netutils.h:115
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:693
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:618
#define QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE
Definition netutils.h:79
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:134
#define QSC_NETUTILS_MAC_ADDRESS_SIZE
Definition netutils.h:109
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:252
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:223
QSC_EXPORT_API uint32_t qsc_netutils_atoi(const char *source)
Parse a string for a number.
Definition netutils.c:142
TCP/IP function constants and structures.
Socket function definitions.
The IPv4 address structure.
Definition ipinfo.h:150
The IPv4 information structure.
Definition ipinfo.h:161
The IPv6 address structure.
Definition ipinfo.h:309
The IPv6 information structure.
Definition ipinfo.h:320
The netutils adaptor info structure.
Definition netutils.h:133
char name[QSC_NETUTILS_ADAPTOR_NAME_SIZE]
Definition netutils.h:139
char gateway[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:136
char subnet[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:140
char ip[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:137
char dhcp[QSC_NETUTILS_IP_STRING_SIZE]
Definition netutils.h:135
char desc[QSC_NETUTILS_ADAPTOR_DESCRIPTION_SIZE]
Definition netutils.h:134
uint8_t mac[QSC_NETUTILS_MAC_ADDRESS_SIZE]
Definition netutils.h:138
The socket instance structure.
Definition socket.h:121