Sunday, January 3, 2016

Building an ethernet tap with linux

Say you want to see what's going on an ethernet line. And say the line runs something like PPPoE, i.e. a protocol below the internet layer, where the addressing is done by MAC addresses.

It's not possible to put an ordinary switch in the middle, as the ethernet frames would not get through. What is needed is an ethernet tap or port mirroring. An old-fashioned ethernet hub would work here, mirroring the traffic from either end of the original wire to a third port that could be monitored e.g. by Wireshark. But can this done be without a special device, with plain linux?

Thursday, June 11, 2015

Global proxy with Node.js

It would be nice if applications written in node.js respected system proxy setting (i.e. http_proxy and https_proxy). But this doesn't seem to be the case.
If you make http(s) requests from your node.js application, the system setting is ignored unless you take extra care to do the right thing.
So how does one even use a proxy with http and https modules? It turns out the answer is: use an agent (the same for https). Agents can do many things and they can also implement proxying. The most popular agents for proxying seem to be http-proxy-agent and https-proxy-agent but there's also proxying-agent which can do both HTTP and HTTPS.

QEMU too slow? -enable-kvm!

I've been using QEMU for emulating other architectures on my PC for quite some time. But when I needed to emulate an ordinary PC (x86_64 on x86_64), I had been using VirtualBox most of the time.
When I tried QEMU for such emulation I always felt it's terribly slow. Only once I read the docs more carefully I realized what I had been missing was -enable-kvm. Adding this switch makes a huge difference. Interestingly, when I read other documents about QEMU, I don't see this mentioned more prominently.
KVM only works when the architecture you emulate is the same as the host architecture and the host has KVM support. But that is something I assume all recent PCs have, so KVM should work for you.

Wednesday, June 3, 2015

Linux 4.1.0-rc6 on the Alix 2d3

The Alix 2d3 is not exactly the newest of devices but I still like it. While the last kernel config I posted was for linux 3.4.0-rc5, I progressively went through the introduction of systemd in Debian and currently I'm running linux 4.1.0-rc6. If anyone finds it useful, here is my 4.1.0-rc6 config.
There are some important changes compared to the linux 3.4.0-rc5 config:

Monday, June 1, 2015

Filesystem capabilities, kernel configuration, ping and Operation not supported

If you happen to be building your own Linux kernel for some embedded target and are eager to trim down unneeded features and you have been living under a rock (like I had been, until recently), you might end up being surprised by:
usr@host:~$ ping google.com
ping: icmp open socket: Operation not permitted

Tuesday, May 1, 2012

Linux 3.4 on the Alix 2d3

After proper support for the ALIX LEDs got into mainline in 3.3, the ALIX GPIO button support found its way into 3.4. Hoooray! So now it's finally possible to have GPIO + LEDs + button, with vanilla upstream and done the proper way. For this I enabled the input subsystem in the config. So, you should see the button as /dev/input/event0. It generates an EV_KEY with code KEY_RESTART. You can test that with evtest. (Debian package evtest, or get the sources from git://anongit.freedesktop.org/git/evtest.)
Here is the 3.4.0-rc5 config. So far 3.4 is only RC.
If you prefer a more stable version, here is a 3.3.4 config. This config also comes with the input subsystem and polled GPIO enabled, but the GPIO button patch is not included in 3.3. If you want it, apply the patch on top of 3.3.
As always, use these as a working starting point, but you certainly want to fine-tune these to your setup.

Tuesday, April 3, 2012

Adding support for more characters in Android

Just a short summary of http://www.mydigitallife.info/how-to-install-and-add-hebrew-arabic-and-unsupported-language-fonts-to-android-phone/.

For ICS the coverage is better, IIRC, so this issue is hopefully getting less topical with time. But if you run Android 2.3 (Gingerbread) on your phone, then you might find this useful.

If you happen to want to display characters that are not covered by the default android font, there seems to be an easy way around. That is - if it's only the font coverage that's the issue. I have no idea to what extent does Android support more complex writing systems, like Devanagari.

The trick works by replacing /system/fonts/DroidSansFallback.ttf by some other font. It seems that DejaVu Sans is be favoured. If you're on Debian or Ubuntu you probably have it installed already (package ttf-dejavu) in /usr/share/fonts/truetype/ttf-dejavu/ (use DejaVuSans.ttf). If not you can always grab it from the project's sourceforge page.

Oh, and you need root. <rant>But why wouldn't the user have root acces to his/her device, right? After all they bought it and own it. At least they might think so...</rant>

So, a bit condensed and cleaned up instructions (for adb):
  1. remount /system read-write: adb shell mount /system -o remount,rw
  2. copy the font file to /system/fonts on the target: adb push $PATH_TO/DejaVuSans.ttf /system/fonts (obviously, replace $PATH_TO with wherever your DejavuSans.ttf is on your PC)
  3. backup original DroidSansFallback.ttf: adb shell mv /system/fonts/DroidSansFallback.ttf /system/fonts/DroidSansFallback.ttf.original
  4. symlink your new font to DroidSansFallback.ttf: adb shell ln -s DejaVuSans.ttf /system/fonts/DroidSansFallback.ttf
  5. restart you phone

Note to self: if the Droid font as supplied on the ICS has wider -- and sufficient for whatever one wants to display -- coverage, it might be better to just use that