A blog for Linux programming enthusiasts

Linux Kernel Modules: Character Devices

This post will be part of a series where device drivers will be presented and quickly analized for people that need a quick reference of how to make device drivers on an updated kernel. The driver presented here was tested on a 3.2 and 3.16 Linux Kernel. I will make a driver with more features and test it on a newer kernel next time.

Capturing Websites With Sockets and HTTP

This post shows a program that captures web pages’s index.html with sockets. To do this, it creates a TCP client socket, connects to a web server and takes all the data to stdout. The input supports IPv4, IPv6, and hostname resolution.

Implementing a Prethreaded Web Server

p>In this post I will analyze an implementation of a prethreaded TCP server that leverages the HTTP protocol. This is a personal ongoing project that will continue its development and I found it to be at a good place to start sharing what I have done so far. The whole purpose of this is to later on built a tool to test its performance and how to break it with malformed packets. It is such an interesting project that everytime I sit down with it, I start thinking about different features to implement on it. Again all this is coded in C with the POSIX threads and sockets API.

Coding Your Own Network Sniffer

This a small project that came to mind after reading some reference material while stuyding HTTP. It basically consists of using raw sockets to make the kernel handle L2 data/frames to the user application. From there anything is possible, a ping server, a traceroute appication, IP spoofing, man-in-the-middle attacks, the sky is the limits.

Code Performance Analysis With Assembly & C: Part 2

In this second part, the optimization code will be shown. Specifically O1, O2, and O3. We are going to be able to see, what performance decisions the gcc compiler makes; for example, we are going to check if the compilers takes the function that calculates the string length calls out of the loop.

Installing and Configuring OpenvSwitch With QEMU-KVM

The maturity reached by Software Defined Networking (SDN) in the lastest years is a very important one. We are at a point where we could see this architecture /framework become a standard. And what makes it so amazing is its fundamental idea of openness, just like Linux did it around 20 years ago. OpenvSwitch (OVS) is a tool used to create virtual bridges which can then connect virtual or physical hosts. It implements both traditional L2 switching protocols or Openflow.

Automating Quagga With QEMU-KVM: Part 1

Some days ago I needed a proof of concept for some routing configuration using Linux that was stuck in my head for days already. So I needed a way to bring up some Linux boxes to quickly to check this. The ONL website proved very useful, but I needed to use CentOS. So I came up with a script based on the mentioned tutorial that brings up QEMU-KVM images with Quagga already installed and configured.

The Basics of a TCP Server With C Sockets

This post serves as a explanation of the basics of a TCP socket server, which serves as the base to a future post explaining the basics of a web server.

Note: the complete code of an older version is fully posted in the end. Check my github repo for an updated version. Link.

Linux Shell Programming Basics

A shell is an interactive program that in its core forks for new processes and wait for their termination. In other words, we present a prompt, the user enters the commands, we parse the input , and execute it. Good error and signal handling is needed, as well as the return values of the different system calls that we will use. The man pages come real handy for this since we have a very good reference just a terminal screen away. This program is considered a good start to learn the basic of system calls and signal processing. This post serves as a quick analysis of the code in the github repository.