A computer system, method, and computer program product for controlling
data communication in an ad-hoc network that connects a wireless device
and a nearby wireless device. The method stores an application directory,
determines a priority for each entry in the application directory,
identifies a selected entry based on the priority, and examines the
attributes and security parameters associated with the selected entry.
When the security parameters indicate to use a secure connection, the
method establishes a security association to support the data
communication by querying a database for an existing security association
that will satisfy the security parameters. When the query is successful,
the method reuses the existing security association. When the query is
unsuccessful, the method creates a new security association by
establishing a privileged side channel to the nearby wireless device,
negotiating the new security association over the privileged side
channel, and storing the new security association.