News for hackers. Stuff that matters.

cihangir

Re:Let's code a TCP/IP stack, 1: Ethernet and ARP on Tuesday March 04, 2025 @05:52AM (#43252996)
Years ago, I attempted to build a user-space network stack in C [0] that processes raw packets through the TUN interface and got it working to a certain point. It currently includes a simple shell that allows configuring IP addresses, routes, and such. A hybrid structure reminiscent of both mbuf and sk_buf is used to hold the network packets. However, after completing the UDP implementation I didn't find the time or motivation to implement TCP. If you want to check it out, here's the link:

[0] https://github.com/cakturk/unet

Re:getopt() but smaller on Thursday November 07, 2024 @09:39AM (#42076991)
Plan 9’s ARG(2) [0] macros are worth a look too. No dependencies at all, just plain macros, super lightweight and easy to use.

[0] https://9fans.github.io/plan9port/man/man3/arg.html

Re:Low-Level C Programming – CSE 325 Lecture Videos on Saturday March 25, 2023 @04:06PM (#35306711)
Wow, It's really weird that a Rust language fanboy has still not left a comment lecturing C programmers about how their favorite blessed programming language solves every problem under the sun.
Re:OOP in C on Sunday January 08, 2023 @09:58AM (#34299604)
Last time I checked, C++ used function pointers behind the scenes to achieve virtual method dispatch.
Re:OOP in C on Sunday January 08, 2023 @07:35AM (#34298579)
Linux kernel code makes heavy use of object-oriented design patterns [0]. It's not the best of its kind, but still provides a reasonable example of how OOP can be achieved in C: https://gist.github.com/cakturk/cd75d0ca588151c86d641cb6d5a1...

[0] https://lwn.net/Articles/444910/

> That is a special page of memory that is mapped read-only into user mode from kernel mode, and it contains things like the current time, so that applications can get this information quickly without having to take a kernel transition. This page is at a fixed location for performance reasons.

I didn't know there was a vdso-like mechanism in Windows as in Linux.