experimental OpenBSD support
Brian Fundakowski Feldman
bfeldman
Tue Jun 24 13:36:08 PDT 2003
BTW, if you find it runs too slowly, you may need to do this:
Index: common.c
===================================================================
RCS file: /u/cvs/SNOWNET/Snownet/hostap/hostapd/common.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- common.c 17 Jun 2003 19:01:21 -0000 1.1
+++ common.c 24 Jun 2003 16:26:43 -0000 1.2
@@ -10,24 +10,26 @@
*/
#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
#include "common.h"
int hostapd_get_rand(u8 *buf, size_t len)
{
- FILE *f;
- size_t rc;
+ ssize_t rc;
+ int fd;
- f = fopen("/dev/urandom", "r");
- if (f == NULL) {
- printf("Could not open /dev/urandom.\n");
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd == -1) {
+ perror("Could not open /dev/urandom");
return -1;
}
- rc = fread(buf, 1, len, f);
- fclose(f);
+ rc = read(fd, buf, len);
+ close(fd);
- return rc != len ? -1 : 0;
+ return rc == len ? 0 : -1;
}
I don't think it's appropriate to be doing that with fread(3) at all
unless it's going to be cached.
More information about the Hostap
mailing list