core: Remove legacy parsing of OUI database

This commit is contained in:
Marcel Holtmann 2013-09-15 20:01:00 -07:00
parent 55afc94e94
commit 2a147a610d

View File

@ -66,74 +66,8 @@ done:
return comp;
}
#else
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/mman.h>
/* http://standards.ieee.org/regauth/oui/oui.txt */
#ifndef OUIFILE
#define OUIFILE "/usr/share/hwdata/oui.txt"
#endif
static char *ouitocomp(const char *oui)
{
struct stat st;
char *str, *map, *off, *end;
int fd;
fd = open(OUIFILE, O_RDONLY);
if (fd < 0)
return NULL;
if (fstat(fd, &st) < 0) {
close(fd);
return NULL;
}
str = malloc(128);
if (!str) {
close(fd);
return NULL;
}
memset(str, 0, 128);
map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (!map || map == MAP_FAILED) {
free(str);
close(fd);
return NULL;
}
off = strstr(map, oui);
if (off) {
off += 18;
end = strpbrk(off, "\r\n");
strncpy(str, off, end - off);
} else {
free(str);
str = NULL;
}
munmap(map, st.st_size);
close(fd);
return str;
}
char *batocomp(const bdaddr_t *ba)
{
char oui[9];
sprintf(oui, "%2.2X-%2.2X-%2.2X", ba->b[5], ba->b[4], ba->b[3]);
return ouitocomp(oui);
return NULL;
}
#endif