Generalize a tiny bit, expand to support UPnP via miniupnpc library (also requires pthreads).