title: How do I join a wireless network programmatically under OS X?
body: <p>C or C++ preferred. This is not an Objective-C project.</p>
  
  <p>I already know the SSID. There may be WPA2 security on the network. I need to join from a specific interface (e.g. eth2) in case the machine has more than one wireless interface.</p>
  
  <p>I realize that there are various commandline tools out there (e.g. the ones provided in answers to <a href="https://stackoverflow.com/questions/4481005/get-wireless-ssid-through-shell-script-on-mac-os-x">this question</a>), but I'd like to join the network without exec'ing external dependencies that may or may not be on the machine. Thanks.</p>