#rust

Articles tagged #rust, newest first. All tags

Crafting ARP packets to find a remote host's MAC address Alright. ALRIGHT. I know, we’re all excited, but let’s think about what we’re doing again. So we’ve managed to look at real network traffic and parse it completely. We’ve also taken some ICMP… 16 min Parsing and serializing ICMP packets with cookie-factory. In the last part, we’ve finally parsed some IPv4 packets. We even found a way to filter only IPv4 packets that contain ICMP packets. There’s one thing we haven’t done though, and that’s verify their… 25 min Parsing IPv4 packets, including numbers smaller than bytes Hello and welcome to Part 11 of this series, wherein we finally use some of the code I prototyped way back when I was planning this series. Where are we standing? Let’s review the progress we’ve made… 21 min Improving error handling - panics vs. proper errors Before we move on to parsing more of our raw packets, I want to take some time to improve our error handling strategy. Currently, the ersatz codebase contains a mix of Result<T, E>, and some methods… 21 min Rust 2020: Funding Blog posts that praise Rust are many but funding is generally in short supply. If even a small percentage of the money Rust saves companies was put back into the ecosystem it would help secure the… 2 min Consuming Ethernet frames with the nom crate Now that we’ve found the best way to find the “default network interface”… what can we do with that interface? Well, listen for network traffic of course! use rawsock::open_best_library; use… 23 min Binding C APIs with variable-length structs and UTF-16 Okay, I lied. I’m deciding - right this instant - that using wmic is cheating too. Oh, it was fair game when we were learning about Windows, but we’re past that now. We know there’s IPv4 routing… 19 min Finding the default network interface through WMI Let’s set aside our sup project for a while. Don’t get me wrong - it’s a perfectly fine project, and, were we simply rewriting “ping” for Windows in Rust, we could (almost) stop there. We’re… 15 min The builder pattern, and a macro that keeps FFI code DRY Our ping API is simple, but it’s also very limited: pub fn ping(dest: ipv4::Addr) -> Result<(), String>. // called as: ping(ipv4::Addr([8, 8, 8, 8])).unwrap(); It doesn’t allow specifying the TTL… 12 min A simple ping library, parsing strings into IPv4 address We’ve just spent a lot of time abstracting over LoadLibrary, but we still have all the gory details of the Win32 ICMP API straight in our main.rs file! That won’t do. This time will be much quicker… 13 min Designing and implementing a safer API on top of LoadLibrary It’s refactor time! Our complete program is now about a hundred lines, counting blank lines (see the end of part 3 for a complete listing). While this is pretty good for a zero-dependency project… 18 min FFI-safe types in Rust, newtypes and MaybeUninit It’s time to make sup, our own take on ping, use the Win32 APIs to send an ICMP echo. Earlier we discovered that Windows’s ping.exe used IcmpSendEcho2Ex. But for our purposes, the simpler… 12 min Windows dynamic libraries, calling conventions, and transmute So, how does ping.exe actually send a ping? It seems unrealistic that ping.exe itself implements all the protocols involved in sending a ping. So it must be calling some sort of library. Also, since… 18 min Making our own ping When I launched my Patreon, I vowed to explain how computers work. But in 2019, computers rarely work in isolation. So let’s take the time to write a few articles about how computers talk to each… 4 h 22 min Declarative memory management It feels like an eternity since I’ve started using Rust, and yet I remember vividly what it felt like to bang my head against the borrow checker for the first few times. I’m definitely not alone in… 35 min Reading files the hard way - Part 3 (ftrace, disk layouts, ext4) So far, we’ve seen many ways to read a file from different programming languages, we’ve learned about syscalls, how to make those from assembly, then we’ve learned about memory mapping, virtual… 33 min Reading files the hard way Everybody knows how to use files. You just open up File Explorer, the Finder, or a File Manager, and bam - it’s chock-full of files. There’s folders and files as far as the eye can see. It’s a… 1 h 6 min Reading files the hard way - Part 1 (node.js, C, rust, strace) Everybody knows how to use files. You just open up File Explorer, the Finder, or a File Manager, and bam - it’s chock-full of files. There’s folders and files as far as the eye can see. It’s a… 15 min Rust modules vs files A while back, I asked on Twitter what people found confusing in Rust, and one of the top topics was “how the module system maps to files”. I remember struggling with that a lot when I first started… 18 min Rust generics vs Java generics In my previous article, I said I needed to stop thinking of Rust generics as Java generics, because in Rust, generic types are erased. Someone gently pointed out that they are also erased in Java… 9 min Recursive iterators in Rust I’ve been looking for this blog post everywhere, but it doesn’t exist, so I guess it’s my turn to write about Some Fun with Rust. The task at hand. Let’s say you have a recursive, acyclic data… 7 min