Skip to content

Commit

Permalink
Improve socket option story
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Sep 17, 2024
1 parent b14dddc commit bb7942e
Show file tree
Hide file tree
Showing 101 changed files with 199 additions and 558 deletions.
1 change: 1 addition & 0 deletions libc/fmt/magnumstrs.internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern const struct MagnumStr kErrnoDocs[];
extern const struct MagnumStr kErrnoNames[];
extern const struct MagnumStr kFcntlCmds[];
extern const struct MagnumStr kIpOptnames[];
extern const struct MagnumStr kIpv6Optnames[];
extern const struct MagnumStr kOpenFlags[];
extern const struct MagnumStr kRlimitNames[];
extern const struct MagnumStr kSignalNames[];
Expand Down
2 changes: 2 additions & 0 deletions libc/intrin/BUILD.mk
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ o/$(MODE)/libc/intrin/kerrnodocs.o: libc/intrin/kerrnodocs.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/kipoptnames.o: libc/intrin/kipoptnames.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/kipv6optnames.o: libc/intrin/kipv6optnames.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/kerrnonames.o: libc/intrin/kerrnonames.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/kfcntlcmds.o: libc/intrin/kfcntlcmds.S
Expand Down
8 changes: 8 additions & 0 deletions libc/intrin/describesockoptname.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ const char *_DescribeSockOptname(char buf[32], int l, int x) {
*p++ = '_';
*p = 0;
ms = kIpOptnames;
} else if (l == SOL_IPV6) {
*p++ = 'I';
*p++ = 'P';
*p++ = 'V';
*p++ = '6';
*p++ = '_';
*p = 0;
ms = kIpv6Optnames;
} else {
ms = 0;
}
Expand Down
11 changes: 10 additions & 1 deletion libc/intrin/kipoptnames.S
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@
.underrun
kIpOptnames:
.e IP_TOS,"TOS" // int
.e IP_MTU,"MTU" // int
.e IP_TTL,"TTL" // int
.e IP_MTU,"MTU" // int
.e IP_HDRINCL,"HDRINCL" // bool32
.e IP_OPTIONS,"OPTIONS"
.e IP_RECVTTL,"RECVTTL"
.e IP_ADD_MEMBERSHIP,"ADD_MEMBERSHIP"
.e IP_DROP_MEMBERSHIP,"DROP_MEMBERSHIP"
.e IP_MULTICAST_IF,"MULTICAST_IF"
.e IP_MULTICAST_LOOP,"MULTICAST_LOOP"
.e IP_MULTICAST_TTL,"MULTICAST_TTL"
.e IP_PKTINFO,"PKTINFO"
.e IP_RECVTOS,"RECVTOS"
.long MAGNUM_TERMINATOR
.endobj kIpOptnames,globl,hidden
.overrun
52 changes: 52 additions & 0 deletions libc/intrin/kipv6optnames.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
│ vi: set noet ft=asm ts=8 sw=8 fenc=utf-8 :vi │
╞══════════════════════════════════════════════════════════════════════════════╡
│ Copyright 2021 Justine Alexandra Roberts Tunney │
│ │
│ Permission to use, copy, modify, and/or distribute this software for │
│ any purpose with or without fee is hereby granted, provided that the │
│ above copyright notice and this permission notice appear in all copies. │
│ │
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/fmt/magnumstrs.internal.h"
#include "libc/macros.h"

.macro .e e s
.long \e - kIpv6Optnames
.long .L\@ - kIpv6Optnames
.rodata.str1.1
.L\@: .string "\s"
.previous
.endm

.section .rodata
.balign 4
.underrun
kIpv6Optnames:
.e IPV6_V6ONLY,"V6ONLY"
.e IPV6_CHECKSUM,"CHECKSUM"
.e IPV6_JOIN_GROUP,"JOIN_GROUP"
.e IPV6_LEAVE_GROUP,"LEAVE_GROUP"
.e IPV6_MULTICAST_HOPS,"MULTICAST_HOPS"
.e IPV6_MULTICAST_IF,"MULTICAST_IF"
.e IPV6_MULTICAST_LOOP,"MULTICAST_LOOP"
.e IPV6_UNICAST_HOPS,"UNICAST_HOPS"
.e IPV6_RECVTCLASS,"RECVTCLASS"
.e IPV6_TCLASS,"TCLASS"
.e IPV6_DONTFRAG,"DONTFRAG"
.e IPV6_HOPLIMIT,"HOPLIMIT"
.e IPV6_HOPOPTS,"HOPOPTS"
.e IPV6_PKTINFO,"PKTINFO"
.e IPV6_RECVRTHDR,"RECVRTHDR"
.e IPV6_RTHDR,"RTHDR"
.long MAGNUM_TERMINATOR
.endobj kIpv6Optnames,globl,hidden
.overrun
1 change: 1 addition & 0 deletions libc/intrin/ksockoptnames.S
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ kSockOptnames:
.e SO_RCVLOWAT,"RCVLOWAT" // int
.e SO_SNDLOWAT,"SNDLOWAT" // int
.e SO_ERROR,"ERROR" // int
.e SO_OOBINLINE,"OOBINLINE" // int
.long MAGNUM_TERMINATOR
.endobj kSockOptnames,globl,hidden
.overrun
Loading

0 comments on commit bb7942e

Please sign in to comment.