Mstdlib-1.24.0
m_net.h
1/* The MIT License (MIT)
2 *
3 * Copyright (c) 2019 Monetra Technologies, LLC.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23
24#ifndef __M_NET_H__
25#define __M_NET_H__
26
27/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
28
29#include <mstdlib/mstdlib.h>
30
31/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
32
33__BEGIN_DECLS
34
35/*! \addtogroup m_net_common Common Net functions
36 * \ingroup m_net
37 *
38 * Common net functions
39 *
40 * @{
41 */
42
43/*! Error codes. */
44typedef enum {
45 M_NET_ERROR_SUCCESS = 0, /*!< Success. */
46 M_NET_ERROR_ERROR, /*!< Generic error. */
47 M_NET_ERROR_INTERNAL, /*!< Internal error. */
48 M_NET_ERROR_CREATE, /*!< Error setting up I/O objects. */
49 M_NET_ERROR_PROTOFORMAT, /*!< Protocol format error. */
50 M_NET_ERROR_REDIRECT, /*!< Invalid redirect encountered. */
51 M_NET_ERROR_REDIRECT_LIMIT, /*!< Maximum number of redirects reached. */
52 M_NET_ERROR_DISCONNET, /*!< Unexpected disconnect. */
53 M_NET_ERROR_TLS_REQUIRED, /*!< TLS required but TLS client context was not provided. */
54 M_NET_ERROR_TLS_SETUP_FAILURE, /*!< Failed to add TLS context to I/O object. */
55 M_NET_ERROR_TLS_BAD_CERTIFICATE, /*!< TLS certificate verification failed. */
56 M_NET_ERROR_NOT_FOUND, /*!< Host or location not found. */
57 M_NET_ERROR_TIMEOUT, /*!< Operation timed out. Could be during connect or overall. */
58 M_NET_ERROR_TIMEOUT_STALL, /*!< Operation timed out due to stall. */
59 M_NET_ERROR_OVER_LIMIT, /*!< Maximum data size limit exceeded. */
60 M_NET_ERROR_NOTPERM, /*!< Operation not permitted. */
61 M_NET_ERROR_AUTHENTICATION, /*!< Authenication failed. */
62 M_NET_ERROR_CONNRESET, /*!< Connection reset by peer. */
63 M_NET_ERROR_CONNABORTED, /*!< Connection aborted. */
64 M_NET_ERROR_PROTONOTSUPPORTED, /*!< Protocol not supported. */
65 M_NET_ERROR_CONNREFUSED, /*!< Connection refused. */
66 M_NET_ERROR_UNREACHABLE, /*!< Host or location unreachable. */
68
69/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
70
71/*! Convert a Net error code to a string.
72 *
73 * \param[in] err Error code
74 *
75 * \return Name of error code (not a description, just the enum name, like M_NET_ERROR_SUCCESS)
76 */
77M_API const char *M_net_errcode_to_str(M_net_error_t err);
78
79/*! @} */
80
81__END_DECLS
82
83#endif /* __M_NET_H__ */
const char * M_net_errcode_to_str(M_net_error_t err)
M_net_error_t
Definition: m_net.h:44
@ M_NET_ERROR_NOT_FOUND
Definition: m_net.h:56
@ M_NET_ERROR_INTERNAL
Definition: m_net.h:47
@ M_NET_ERROR_UNREACHABLE
Definition: m_net.h:66
@ M_NET_ERROR_NOTPERM
Definition: m_net.h:60
@ M_NET_ERROR_AUTHENTICATION
Definition: m_net.h:61
@ M_NET_ERROR_OVER_LIMIT
Definition: m_net.h:59
@ M_NET_ERROR_SUCCESS
Definition: m_net.h:45
@ M_NET_ERROR_CONNABORTED
Definition: m_net.h:63
@ M_NET_ERROR_PROTOFORMAT
Definition: m_net.h:49
@ M_NET_ERROR_CONNRESET
Definition: m_net.h:62
@ M_NET_ERROR_TIMEOUT_STALL
Definition: m_net.h:58
@ M_NET_ERROR_PROTONOTSUPPORTED
Definition: m_net.h:64
@ M_NET_ERROR_TLS_BAD_CERTIFICATE
Definition: m_net.h:55
@ M_NET_ERROR_TIMEOUT
Definition: m_net.h:57
@ M_NET_ERROR_CONNREFUSED
Definition: m_net.h:65
@ M_NET_ERROR_TLS_REQUIRED
Definition: m_net.h:53
@ M_NET_ERROR_TLS_SETUP_FAILURE
Definition: m_net.h:54
@ M_NET_ERROR_CREATE
Definition: m_net.h:48
@ M_NET_ERROR_REDIRECT_LIMIT
Definition: m_net.h:51
@ M_NET_ERROR_REDIRECT
Definition: m_net.h:50
@ M_NET_ERROR_ERROR
Definition: m_net.h:46
@ M_NET_ERROR_DISCONNET
Definition: m_net.h:52