mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-25 21:24:16 +08:00
core: Remove legacy parsing of OUI database
This commit is contained in:
parent
55afc94e94
commit
2a147a610d
68
src/oui.c
68
src/oui.c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user