One of the most evident characteristics of an ad hoc ubiquitous computing environment is the dynamism of connections. Due to the mobility of nodes, paths between communicating peers change over time and hence should be discovered continually. Applications also dynamically discover available services and replace connections to provide contextually more appropriate services. In such an environment, the reduction of discovery cost and the reflection of context are main design factors. In order to avoid discovery cost being paid by both application and routing layer and to delay a service binding until forwarding time, we propose a shim layer called shared generic routing (or SGR) that discovers paths by accommodating application layer labels as well as IP addresses as routing targets and manages forwarding states. On top of SGR, IP and application layer routing can be efficiently implemented. Through simulation, we show that SGR can effectively remove duplicated discovery efforts.