Move the reading code out into tap_read/udp_read

Also cosmetic changes to use buf/len and addr/addrlen consistently, and
use n instead of err for syscall returns.
Fix a silly thinko in tap_write