import VTY code from zebra/quagga (from my cardshell project)