Add more socket options for FreeBSD core:net

This commit is contained in:
Feoramund
2024-08-05 00:30:24 -04:00
parent 3f9ddfe029
commit 46455dd0a6
+7 -6
View File
@@ -10,7 +10,6 @@ Fd :: freebsd.Fd
Socket_Option :: enum c.int { Socket_Option :: enum c.int {
// TODO: Test and implement more socket options. // TODO: Test and implement more socket options.
// DEBUG // DEBUG
// ACCEPTCONN
Reuse_Address = cast(c.int)freebsd.Socket_Option.REUSEADDR, Reuse_Address = cast(c.int)freebsd.Socket_Option.REUSEADDR,
Keep_Alive = cast(c.int)freebsd.Socket_Option.KEEPALIVE, Keep_Alive = cast(c.int)freebsd.Socket_Option.KEEPALIVE,
// DONTROUTE // DONTROUTE
@@ -18,14 +17,14 @@ Socket_Option :: enum c.int {
Use_Loopback = cast(c.int)freebsd.Socket_Option.USELOOPBACK, Use_Loopback = cast(c.int)freebsd.Socket_Option.USELOOPBACK,
Linger = cast(c.int)freebsd.Socket_Option.LINGER, Linger = cast(c.int)freebsd.Socket_Option.LINGER,
Out_Of_Bounds_Data_Inline = cast(c.int)freebsd.Socket_Option.OOBINLINE, Out_Of_Bounds_Data_Inline = cast(c.int)freebsd.Socket_Option.OOBINLINE,
// REUSEPORT Reuse_Port = cast(c.int)freebsd.Socket_Option.REUSEPORT,
// TIMESTAMP // TIMESTAMP
// NOSIGPIPE No_SIGPIPE_From_EPIPE = cast(c.int)freebsd.Socket_Option.NOSIGPIPE,
// ACCEPTFILTER // ACCEPTFILTER
// BINTIME // BINTIME
// NO_OFFLOAD // NO_OFFLOAD
// NO_DDP // NO_DDP
// REUSEPORT_LB Reuse_Port_Load_Balancing = cast(c.int)freebsd.Socket_Option.REUSEPORT_LB,
// RERROR // RERROR
Send_Buffer_Size = cast(c.int)freebsd.Socket_Option.SNDBUF, Send_Buffer_Size = cast(c.int)freebsd.Socket_Option.SNDBUF,
@@ -219,14 +218,16 @@ _set_option :: proc(socket: Any_Socket, option: Socket_Option, value: any, loc :
ptr: rawptr ptr: rawptr
len: freebsd.socklen_t len: freebsd.socklen_t
// TODO: Verify that these options perform adequately.
switch option { switch option {
case case
.Reuse_Address, .Reuse_Address,
.Keep_Alive, .Keep_Alive,
.Broadcast, .Broadcast,
.Use_Loopback, .Use_Loopback,
.Out_Of_Bounds_Data_Inline: .Out_Of_Bounds_Data_Inline,
.Reuse_Port,
.No_SIGPIPE_From_EPIPE,
.Reuse_Port_Load_Balancing:
switch real in value { switch real in value {
case bool: bool_value = cast(b32)real case bool: bool_value = cast(b32)real
case b8: bool_value = cast(b32)real case b8: bool_value = cast(b32)real