]> git.ipfire.org Git - thirdparty/systemd.git/commit
socket-util: introduce tos_to_priority()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 2 May 2026 13:31:03 +0000 (22:31 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 3 May 2026 09:17:20 +0000 (10:17 +0100)
commitfa9b3b26c7421ebf39004094ecee0ca9bcea2bd9
tree983d9f2a2c670ab5b59d6c4f36d12dbf53be2d6d
parent2cfaf50cc86670b4b671dd4d4f9614b2c2cfb736
socket-util: introduce tos_to_priority()

This maps from TOS, which can be used for setsockopt(IPPROTO_IP, IP_TOS),
to socket priority, which can be used for setsockopt(SOL_SOCKET, SO_PRIORITY).

With this, we can set priority like the following:
```
uint8_t tos = IPTOS_CLASS_CS6;
setsockopt_int(fd, IPPROTO_IP, IP_TOS, tos);
setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, tos_to_priority(tos));
```

Co-authored with Google Gemini.
src/basic/socket-util.c
src/basic/socket-util.h
src/test/test-socket-util.c