aboutsummaryrefslogtreecommitdiff
path: root/core/net
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-08-05 00:28:57 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-08-05 03:05:43 -0400
commit61e770d94398b65c3fe4f47898e248a691181dfd (patch)
treee3122c1a5d536e05804d2cfa6c9e54d68eb78a1c /core/net
parent2b63684ccfd45882fd4f37c054d2ca7437c39c66 (diff)
Clean up some FreeBSD `core:net` code
Diffstat (limited to 'core/net')
-rw-r--r--core/net/errors_freebsd.odin37
-rw-r--r--core/net/socket_freebsd.odin22
2 files changed, 31 insertions, 28 deletions
diff --git a/core/net/errors_freebsd.odin b/core/net/errors_freebsd.odin
index 1f98e9228..fc8287834 100644
--- a/core/net/errors_freebsd.odin
+++ b/core/net/errors_freebsd.odin
@@ -27,8 +27,9 @@ Dial_Error :: enum c.int {
Already_Connected = cast(c.int)freebsd.Errno.EISCONN,
Timeout = cast(c.int)freebsd.Errno.ETIMEDOUT,
Refused_By_Remote_Host = cast(c.int)freebsd.Errno.ECONNREFUSED,
- // `Refused` alias for core:net tests.
- Refused = cast(c.int)freebsd.Errno.ECONNREFUSED,
+ // `Refused` alias for `core:net` tests.
+ // The above default name `Refused_By_Remote_Host` is more explicit.
+ Refused = Refused_By_Remote_Host,
Reset_By_Remote_Host = cast(c.int)freebsd.Errno.ECONNRESET,
Network_Unreachable = cast(c.int)freebsd.Errno.ENETUNREACH,
Host_Unreachable = cast(c.int)freebsd.Errno.EHOSTUNREACH,
@@ -138,13 +139,15 @@ TCP_Send_Error :: enum c.int {
specified, and the requested operation would block. */
Would_Block = cast(c.int)freebsd.Errno.EAGAIN,
- // NOTE: This error arises for two distinct reasons.
- /* The system was unable to allocate an internal buffer.
- The operation may succeed when buffers become available. */
+ /* NOTE: This error arises for two distinct reasons:
- /* The output queue for a network interface was full.
- This generally indicates that the interface has stopped
- sending, but may be caused by transient congestion. */
+ 1. The system was unable to allocate an internal buffer.
+ The operation may succeed when buffers become available.
+
+ 2. The output queue for a network interface was full.
+ This generally indicates that the interface has stopped
+ sending, but may be caused by transient congestion.
+ */
No_Buffer_Space_Available = cast(c.int)freebsd.Errno.ENOBUFS,
Host_Unreachable = cast(c.int)freebsd.Errno.EHOSTUNREACH,
@@ -174,16 +177,16 @@ Shutdown_Error :: enum c.int {
}
Socket_Option_Error :: enum c.int {
- None = 0,
- Value_Out_Of_Range = -1,
- Not_Descriptor = cast(c.int)freebsd.Errno.EBADF,
- Not_Socket = cast(c.int)freebsd.Errno.ENOTSOCK,
- Unknown_Option_For_Level = cast(c.int)freebsd.Errno.ENOPROTOOPT,
- Argument_In_Invalid_Address_Space = cast(c.int)freebsd.Errno.EFAULT,
+ None = 0,
+ Value_Out_Of_Range = -1,
+ Not_Descriptor = cast(c.int)freebsd.Errno.EBADF,
+ Not_Socket = cast(c.int)freebsd.Errno.ENOTSOCK,
+ Unknown_Option_For_Level = cast(c.int)freebsd.Errno.ENOPROTOOPT,
+ Argument_In_Invalid_Address_Space = cast(c.int)freebsd.Errno.EFAULT,
// This error can arise for many different reasons.
- Invalid_Value = cast(c.int)freebsd.Errno.EINVAL,
- System_Memory_Allocation_Failed = cast(c.int)freebsd.Errno.ENOMEM,
- Insufficient_System_Resources = cast(c.int)freebsd.Errno.ENOBUFS,
+ Invalid_Value = cast(c.int)freebsd.Errno.EINVAL,
+ System_Memory_Allocation_Failed = cast(c.int)freebsd.Errno.ENOMEM,
+ Insufficient_System_Resources = cast(c.int)freebsd.Errno.ENOBUFS,
}
Set_Blocking_Error :: enum c.int {
diff --git a/core/net/socket_freebsd.odin b/core/net/socket_freebsd.odin
index 10bc4c63e..db7bb1f56 100644
--- a/core/net/socket_freebsd.odin
+++ b/core/net/socket_freebsd.odin
@@ -245,17 +245,17 @@ _set_option :: proc(socket: Any_Socket, option: Socket_Option, value: any, loc :
.Reuse_Port,
.No_SIGPIPE_From_EPIPE,
.Reuse_Port_Load_Balancing:
- switch real in value {
- case bool: bool_value = cast(b32)real
- case b8: bool_value = cast(b32)real
- case b16: bool_value = cast(b32)real
- case b32: bool_value = real
- case b64: bool_value = cast(b32)real
- case:
- panic("set_option() value must be a boolean here", loc)
- }
- ptr = &bool_value
- len = size_of(bool_value)
+ switch real in value {
+ case bool: bool_value = cast(b32)real
+ case b8: bool_value = cast(b32)real
+ case b16: bool_value = cast(b32)real
+ case b32: bool_value = real
+ case b64: bool_value = cast(b32)real
+ case:
+ panic("set_option() value must be a boolean here", loc)
+ }
+ ptr = &bool_value
+ len = size_of(bool_value)
case
.Linger,
.Send_Timeout,