Commit 91f0eff
ip: Replace
According to the IANA protocol number specification
(https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml),
protocol numbers are always within the u8 range.
Using `as` for type conversion is dangerous because it can silently
discard higher-order data, leading to bugs that are hard to detect.
This change ensures all protocol number conversions are type-safe and
explicit, avoiding accidental data loss and aligning the code with the
protocol specification.as u8 casts with explicit From conversions for IpProtocol1 parent 4148220 commit 91f0eff
2 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
0 commit comments