Skip to content

Commit 069f997

Browse files
committed
Add IP_TOS, IPV6_TCLASS, IP_DONTFRAG & IPV6_DONTFRAG socket options
1 parent 846f8f8 commit 069f997

File tree

4 files changed

+118
-6
lines changed

4 files changed

+118
-6
lines changed

Posix-compatibility.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ Columns:
159159
| IPV6_UNICAST_HOPS ||||||||||||||||| [`tcp::(set-)hop-limit`](tcp)<br/>[`udp::(set-)unicast-hop-limit`](udp) |
160160
| IP_RECVTTL ||||||||||||||||| |
161161
| IPV6_RECVHOPLIMIT ||||||||||||||||| |
162-
| IP_TOS | |||||||||||||||| |
163-
| IPV6_TCLASS | |||||||||||||||| |
162+
| IP_TOS | |||||||||||||||| [`tcp::(set-)traffic-class`](tcp)<br/>[`udp::(set-)traffic-class`](udp) |
163+
| IPV6_TCLASS | |||||||||||||||| [`tcp::(set-)traffic-class`](tcp)<br/>[`udp::(set-)traffic-class`](udp) |
164164
| IP_RECVTOS ||||||||||||||||| |
165165
| IPV6_RECVTCLASS ||||||||||||||||| |
166166
| IP_RECVPKTINFO ||||||||||||||||| IP_PKTINFO on Linux & Windows, IP_RECVDSTADDR+IP_RECVIF on MacOS & FreeBSD. |
167167
| IPV6_RECVPKTINFO ||||||||||||||||| IPV6_PKTINFO on Windows. |
168-
| IP_DONTFRAG | |||||||||||||||| IP_DONTFRAGMENT on Windows, implementable using IP_MTU_DISCOVER on Linux. |
169-
| IPV6_DONTFRAG | |||||||||||||||| |
170-
| IP_MTU_DISCOVER | |||||||||||||||| |
171-
| IPV6_MTU_DISCOVER | |||||||||||||||| |
168+
| IP_DONTFRAG | |||||||||||||||| [`udp::(set-)dont-fragment`](udp) <br/><br/> IP_DONTFRAGMENT on Windows, implementable using IP_MTU_DISCOVER on Linux. |
169+
| IPV6_DONTFRAG | |||||||||||||||| [`udp::(set-)dont-fragment`](udp) |
170+
| IP_MTU_DISCOVER |* |||||||||||||||| Only the IP_PMTUDISC_DO behaviour is supported as part of IP_DONTFRAG. |
171+
| IPV6_MTU_DISCOVER |* |||||||||||||||| Only the IP_PMTUDISC_DO behaviour is supported as part of IPV6_DONTFRAG. |
172172
| SO_RCVBUF ||||||||||||||||| [`tcp::(set-)receive-buffer-size`](tcp)<br/>[`udp::(set-)receive-buffer-size`](udp) |
173173
| SO_SNDBUF ||||||||||||||||| [`tcp::(set-)send-buffer-size`](tcp)<br/>[`udp::(set-)send-buffer-size`](udp) |
174174
| SO_RCVLOWAT ||||||||||||||||| |

example-world.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,60 @@ call <a href="#remote_address"><code>remote-address</code></a> to get their addr
604604
<ul>
605605
<li><a name="set_unicast_hop_limit.0"></a> result&lt;_, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
606606
</ul>
607+
<h4><a name="traffic_class"><code>traffic-class: func</code></a></h4>
608+
<p>Equivalent to the IP_TOS &amp; IPV6_TCLASS socket options.</p>
609+
<p>The value is typically composed of the DSCP (6 high bits) + ECN (2 low bits).</p>
610+
<h1>Typical errors</h1>
611+
<ul>
612+
<li><code>concurrency-conflict</code>: (set) A <code>bind</code>, <code>connect</code> or <code>listen</code> operation is already in progress. (EALREADY)</li>
613+
</ul>
614+
<h5>Params</h5>
615+
<ul>
616+
<li><a name="traffic_class.this"><code>this</code></a>: <a href="#udp_socket"><a href="#udp_socket"><code>udp-socket</code></a></a></li>
617+
</ul>
618+
<h5>Return values</h5>
619+
<ul>
620+
<li><a name="traffic_class.0"></a> result&lt;<code>u8</code>, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
621+
</ul>
622+
<h4><a name="set_traffic_class"><code>set-traffic-class: func</code></a></h4>
623+
<h5>Params</h5>
624+
<ul>
625+
<li><a name="set_traffic_class.this"><code>this</code></a>: <a href="#udp_socket"><a href="#udp_socket"><code>udp-socket</code></a></a></li>
626+
<li><a name="set_traffic_class.value"><code>value</code></a>: <code>u8</code></li>
627+
</ul>
628+
<h5>Return values</h5>
629+
<ul>
630+
<li><a name="set_traffic_class.0"></a> result&lt;_, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
631+
</ul>
632+
<h4><a name="dont_fragment"><code>dont-fragment: func</code></a></h4>
633+
<p>Equivalent to the IP_DONTFRAG &amp; IPV6_DONTFRAG socket options.</p>
634+
<h1>Implementors note</h1>
635+
<ul>
636+
<li>IP_DONTFRAGMENT on Windows</li>
637+
<li>Linux has no direct equivalent, but the same effect can be reached by setting IP_MTU_DISCOVER to IP_PMTUDISC_DO.</li>
638+
</ul>
639+
<h1>Typical errors</h1>
640+
<ul>
641+
<li><code>concurrency-conflict</code>: (set) A <code>bind</code>, <code>connect</code> or <code>listen</code> operation is already in progress. (EALREADY)</li>
642+
</ul>
643+
<h5>Params</h5>
644+
<ul>
645+
<li><a name="dont_fragment.this"><code>this</code></a>: <a href="#udp_socket"><a href="#udp_socket"><code>udp-socket</code></a></a></li>
646+
</ul>
647+
<h5>Return values</h5>
648+
<ul>
649+
<li><a name="dont_fragment.0"></a> result&lt;<code>bool</code>, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
650+
</ul>
651+
<h4><a name="set_dont_fragment"><code>set-dont-fragment: func</code></a></h4>
652+
<h5>Params</h5>
653+
<ul>
654+
<li><a name="set_dont_fragment.this"><code>this</code></a>: <a href="#udp_socket"><a href="#udp_socket"><code>udp-socket</code></a></a></li>
655+
<li><a name="set_dont_fragment.value"><code>value</code></a>: <code>bool</code></li>
656+
</ul>
657+
<h5>Return values</h5>
658+
<ul>
659+
<li><a name="set_dont_fragment.0"></a> result&lt;_, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
660+
</ul>
607661
<h4><a name="receive_buffer_size"><code>receive-buffer-size: func</code></a></h4>
608662
<p>The kernel buffer space reserved for sends/receives on this socket.</p>
609663
<p>Note #1: an implementation may choose to cap or round the buffer size when setting the value.
@@ -1357,6 +1411,33 @@ a pair of streams that can be used to read &amp; write to the connection.</p>
13571411
<ul>
13581412
<li><a name="set_hop_limit.0"></a> result&lt;_, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
13591413
</ul>
1414+
<h4><a name="traffic_class"><code>traffic-class: func</code></a></h4>
1415+
<p>Equivalent to the IP_TOS &amp; IPV6_TCLASS socket options.</p>
1416+
<p>The value is typically composed of the DSCP (6 high bits) + ECN (2 low bits).</p>
1417+
<h1>Typical errors</h1>
1418+
<ul>
1419+
<li><code>already-connected</code>: (set) The socket is already in the Connection state.</li>
1420+
<li><code>already-listening</code>: (set) The socket is already in the Listener state.</li>
1421+
<li><code>concurrency-conflict</code>: (set) A <code>bind</code>, <code>connect</code> or <code>listen</code> operation is already in progress. (EALREADY)</li>
1422+
</ul>
1423+
<h5>Params</h5>
1424+
<ul>
1425+
<li><a name="traffic_class.this"><code>this</code></a>: <a href="#tcp_socket"><a href="#tcp_socket"><code>tcp-socket</code></a></a></li>
1426+
</ul>
1427+
<h5>Return values</h5>
1428+
<ul>
1429+
<li><a name="traffic_class.0"></a> result&lt;<code>u8</code>, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
1430+
</ul>
1431+
<h4><a name="set_traffic_class"><code>set-traffic-class: func</code></a></h4>
1432+
<h5>Params</h5>
1433+
<ul>
1434+
<li><a name="set_traffic_class.this"><code>this</code></a>: <a href="#tcp_socket"><a href="#tcp_socket"><code>tcp-socket</code></a></a></li>
1435+
<li><a name="set_traffic_class.value"><code>value</code></a>: <code>u8</code></li>
1436+
</ul>
1437+
<h5>Return values</h5>
1438+
<ul>
1439+
<li><a name="set_traffic_class.0"></a> result&lt;_, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
1440+
</ul>
13601441
<h4><a name="receive_buffer_size"><code>receive-buffer-size: func</code></a></h4>
13611442
<p>The kernel buffer space reserved for sends/receives on this socket.</p>
13621443
<p>Note #1: an implementation may choose to cap or round the buffer size when setting the value.

wit/tcp.wit

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ interface tcp {
201201
hop-limit: func(this: tcp-socket) -> result<u8, error-code>
202202
set-hop-limit: func(this: tcp-socket, value: u8) -> result<_, error-code>
203203

204+
/// Equivalent to the IP_TOS & IPV6_TCLASS socket options.
205+
///
206+
/// The value is typically composed of the DSCP (6 high bits) + ECN (2 low bits).
207+
///
208+
/// # Typical errors
209+
/// - `already-connected`: (set) The socket is already in the Connection state.
210+
/// - `already-listening`: (set) The socket is already in the Listener state.
211+
/// - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
212+
traffic-class: func(this: tcp-socket) -> result<u8, error-code>
213+
set-traffic-class: func(this: tcp-socket, value: u8) -> result<_, error-code>
214+
204215
/// The kernel buffer space reserved for sends/receives on this socket.
205216
///
206217
/// Note #1: an implementation may choose to cap or round the buffer size when setting the value.

wit/udp.wit

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,26 @@ interface udp {
189189
unicast-hop-limit: func(this: udp-socket) -> result<u8, error-code>
190190
set-unicast-hop-limit: func(this: udp-socket, value: u8) -> result<_, error-code>
191191

192+
/// Equivalent to the IP_TOS & IPV6_TCLASS socket options.
193+
///
194+
/// The value is typically composed of the DSCP (6 high bits) + ECN (2 low bits).
195+
///
196+
/// # Typical errors
197+
/// - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
198+
traffic-class: func(this: udp-socket) -> result<u8, error-code>
199+
set-traffic-class: func(this: udp-socket, value: u8) -> result<_, error-code>
200+
201+
/// Equivalent to the IP_DONTFRAG & IPV6_DONTFRAG socket options.
202+
///
203+
/// # Implementors note
204+
/// - IP_DONTFRAGMENT on Windows
205+
/// - Linux has no direct equivalent, but the same effect can be reached by setting IP_MTU_DISCOVER to IP_PMTUDISC_DO.
206+
///
207+
/// # Typical errors
208+
/// - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
209+
dont-fragment: func(this: udp-socket) -> result<bool, error-code>
210+
set-dont-fragment: func(this: udp-socket, value: bool) -> result<_, error-code>
211+
192212
/// The kernel buffer space reserved for sends/receives on this socket.
193213
///
194214
/// Note #1: an implementation may choose to cap or round the buffer size when setting the value.

0 commit comments

Comments
 (0)