blob: e2785aef371dd6b8324b29610b7847ccf8aff86b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* libhw_generic/net.c - Device-independent <libhw/generic/net.h> utilities
*
* Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <libmisc/assert.h>
#include <libhw/generic/net.h>
#define NET_EOTHER 1
#define NET_EARP_TIMEOUT 2
#define NET_EACK_TIMEOUT 3
#define NET_ERECV_TIMEOUT 4
#define NET_ETHREAD 5
#define NET_ECLOSED 6
#define NET_EMSGSIZE 7
const char *net_strerror(int net_errno) {
switch (net_errno) {
case NET_EOTHER: return "unknown error";
case NET_EARP_TIMEOUT: return "ARP timeout";
case NET_EACK_TIMEOUT: return "TCP ACK timeout";
case NET_ERECV_TIMEOUT: return "receive timeout";
case NET_ETHREAD: return "thread error";
case NET_ECLOSED: return "already closed";
case NET_EMSGSIZE: return "message too long";
default:
assert_notreached("invalid net_errno");
}
}
|