Switches between adhoc and infrastructure networks