Could probably use a clean-up, but this code is functional on FreeBSD 10.3.
This is the initial upload from OpenBSD. Kept for history and comparision with future releases.