Better failure handling in linuxradiodrv

This commit is contained in:
Vladimir Pouzanov 2014-01-25 17:16:01 +00:00 committed by Vladimir Pouzanov
parent 5fed4a3f1c
commit 113d9761f7

View file

@ -67,6 +67,9 @@ static int
init(void) init(void)
{ {
sockbuf = malloc(MAX_PACKET_SIZE); sockbuf = malloc(MAX_PACKET_SIZE);
if (sockbuf == 0) {
return 1;
}
return 0; return 0;
} }
@ -163,8 +166,13 @@ on(void)
return 0; return 0;
} else { } else {
struct ifreq ifr; struct ifreq ifr;
strncpy((char *)ifr.ifr_name, "wpan0", IFNAMSIZ); // TODO: make interface configurable // TODO: interface should not be hard-coded
ioctl(sockfd, SIOCGIFINDEX, &ifr); strncpy((char *)ifr.ifr_name, "wpan0", IFNAMSIZ);
int err = ioctl(sockfd, SIOCGIFINDEX, &ifr);
if (err == -1) {
perror ("linuxradio ioctl()");
return 0;
}
struct sockaddr_ll sll; struct sockaddr_ll sll;
sll.sll_family = AF_PACKET; sll.sll_family = AF_PACKET;