Skip to content

Instantly share code, notes, and snippets.

@topnotcher
Last active March 24, 2016 23:47
Show Gist options
  • Save topnotcher/05047b6b6894858d8c28 to your computer and use it in GitHub Desktop.
Save topnotcher/05047b6b6894858d8c28 to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct {
uint8_t b[6];
} bdaddr_t;
#if defined(LINUX)
typedef struct {
short rc_family;
bdaddr_t bddadr;
int rc_channel;
} sockaddr_rc;
static void bt_set_bdaddr(sockaddr_rc *sa, bdaddr_t *bdaddr) {
memcpy(&sa->bdaddr, bdaddr);
}
#elif defined(MS_WINDOWS)
struct sockaddr_not_rc {
short some_gay_shit;
short some_gay_family_thing;
uint64_t bdaddr;
uint64_t blahblahServiceGuid[2];
int port;
} __attribute__((packed));
typedef struct sockaddr_not_rc sockaddr_rc;
static void bt_set_bdaddr(sockaddr_rc *sa, bdaddr_t *bdaddr) {
sa->bdaddr = 0;
for (int i = 0; i < 6; ++i)
sa->bdaddr |= bdaddr[i] << (8 * i);
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment