added random check, new random generator
This commit is contained in:
parent
c43984e3cd
commit
a6b9a614ed
|
|
@ -2,11 +2,13 @@ This is a BETA release, as such it's not guaranteed to work perfectly any
|
||||||
problems let me know, they'll be sorted out in the next Beta release. At the
|
problems let me know, they'll be sorted out in the next Beta release. At the
|
||||||
point at which people stop complaining the non-beta release will be let out.
|
point at which people stop complaining the non-beta release will be let out.
|
||||||
|
|
||||||
|
You can get beta version from CVS on sf.net there are tagged fsp-281-bXX.
|
||||||
|
|
||||||
FSP Development Battle plan:
|
FSP Development Battle plan:
|
||||||
============================
|
============================
|
||||||
* for next 2.8 Stable version (will be called 2.8.2)
|
* for next 2.8 Stable version (will be called 2.8.2)
|
||||||
- add FSP Rename command
|
- add FSP Rename command
|
||||||
- add FSP info command
|
- add FSP Info command
|
||||||
- go out this version as soon as possible. 2.8.1b3 and lower are buggy.
|
- go out this version as soon as possible. 2.8.1b3 and lower are buggy.
|
||||||
* for next point Stable version 2.8.3
|
* for next point Stable version 2.8.3
|
||||||
- add native symbolic link support
|
- add native symbolic link support
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Version 2.8.1b18 - 24 Nov 24 2003
|
Version 2.8.1b18 - 25 Nov 24 2003
|
||||||
This is MINIMUM REQUIRED VERSION for applicatins which are using
|
This is MINIMUM REQUIRED VERSION for applicatins which are using
|
||||||
javafsp library, only download machine atm. javafsp library will
|
javafsp library, only download machine atm. javafsp library will
|
||||||
be released shortly as separate package.
|
be released shortly as separate package.
|
||||||
|
|
@ -26,6 +26,8 @@ Version 2.8.1b18 - 24 Nov 24 2003
|
||||||
parsecheck added to 'make check'
|
parsecheck added to 'make check'
|
||||||
support for multiple \n in filename - in future there will be
|
support for multiple \n in filename - in future there will be
|
||||||
used for symlinks.
|
used for symlinks.
|
||||||
|
random generator changed to one recommended by Jiann-Ming Su.
|
||||||
|
new test program tests/randomcheck.c - tests random number generators.
|
||||||
|
|
||||||
Version 2.8.1b17 -- 17 Nov 2003
|
Version 2.8.1b17 -- 17 Nov 2003
|
||||||
Allow filenames with spaces inside
|
Allow filenames with spaces inside
|
||||||
|
|
|
||||||
6
TODO
6
TODO
|
|
@ -1,11 +1,12 @@
|
||||||
FSP SUITE TO DO LIST BY RADIM KOLAR /hsn -at- cybermail * net /
|
FSP SUITE TO DO LIST BY RADIM KOLAR
|
||||||
|
/* maintained by hsn -at- cybermail * net */
|
||||||
|
|
||||||
LARGEFILES64 how to turn them on:
|
LARGEFILES64 how to turn them on:
|
||||||
Cygwin: #define __LARGE64_FILES fopen64,ftello64,fseeko64 _off64_t
|
Cygwin: #define __LARGE64_FILES fopen64,ftello64,fseeko64 _off64_t
|
||||||
glibc 2.3: #define _LARGEFILE64_SOURCE off64_t
|
glibc 2.3: #define _LARGEFILE64_SOURCE off64_t
|
||||||
native: _FILE_OFFSETS_BITS = 32 / 64 then use off_t
|
native: _FILE_OFFSETS_BITS = 32 / 64 then use off_t
|
||||||
|
|
||||||
Radim Kolar's personal wishlist 1997
|
Radim Kolar's personal wishlist from 1997
|
||||||
show loosers online (finfo command) and server statz
|
show loosers online (finfo command) and server statz
|
||||||
rename command
|
rename command
|
||||||
password change command
|
password change command
|
||||||
|
|
@ -26,7 +27,6 @@ PORTING
|
||||||
Sven's Slowaris 8 compile problem
|
Sven's Slowaris 8 compile problem
|
||||||
|
|
||||||
NEEDS IMPROVMENT:
|
NEEDS IMPROVMENT:
|
||||||
random number generator in server is low random quality on low bits.
|
|
||||||
|
|
||||||
Client LIBRARY
|
Client LIBRARY
|
||||||
local bind address FSP_LOCALIP
|
local bind address FSP_LOCALIP
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
dnl Process this file with autoconf to produce a working configure script.
|
dnl Process this file with autoconf to produce a working configure script.
|
||||||
dnl tested with autoconf 2.57
|
dnl tested with autoconf 2.57
|
||||||
AC_INIT(fsp,2.8.1b17+cvs,hsn@cybermail.net)
|
AC_INIT(fsp,2.8.1b18,hsn@cybermail.net)
|
||||||
AC_CONFIG_SRCDIR(server/main.c)
|
AC_CONFIG_SRCDIR(server/main.c)
|
||||||
AM_INIT_AUTOMAKE([dist-bzip2])
|
AM_INIT_AUTOMAKE([dist-bzip2])
|
||||||
AM_MAINTAINER_MODE
|
AM_MAINTAINER_MODE
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ int init_caches PROTO0((void));
|
||||||
void shutdown_caches PROTO0((void));
|
void shutdown_caches PROTO0((void));
|
||||||
void stat_caches PROTO1(FILE *,fp);
|
void stat_caches PROTO1(FILE *,fp);
|
||||||
const char *validate_path PROTO0((char *, unsigned, PPATH *,DIRINFO **, int));
|
const char *validate_path PROTO0((char *, unsigned, PPATH *,DIRINFO **, int));
|
||||||
const char *parse_path PROTO3(char *, fullp, unsigned int, len, PPATH *, pp);
|
|
||||||
const char *server_get_dir PROTO0((DIRLISTING **,const DIRINFO *));
|
const char *server_get_dir PROTO0((DIRLISTING **,const DIRINFO *));
|
||||||
const char *server_del_file PROTO0((PPATH *, DIRINFO *));
|
const char *server_del_file PROTO0((PPATH *, DIRINFO *));
|
||||||
const char *server_del_dir PROTO2(PPATH *, pp, DIRINFO *,di);
|
const char *server_del_dir PROTO2(PPATH *, pp, DIRINFO *,di);
|
||||||
|
|
@ -48,6 +47,12 @@ void init_home_dir PROTO0((void));
|
||||||
|
|
||||||
/* filecache.c, open filehandles cache */
|
/* filecache.c, open filehandles cache */
|
||||||
|
|
||||||
|
/* path.c, path parser */
|
||||||
|
const char *parse_path PROTO3(char *, fullp, unsigned int, len, PPATH *, pp);
|
||||||
|
|
||||||
|
/* random.c, next key random degenerator */
|
||||||
|
unsigned short gen_next_key PROTO0((void));
|
||||||
|
|
||||||
/* iprange.c IP range services */
|
/* iprange.c IP range services */
|
||||||
extern IPrange *iptab;
|
extern IPrange *iptab;
|
||||||
const char *check_ip_table PROTO2(unsigned long, inet_num,IPrange *,table);
|
const char *check_ip_table PROTO2(unsigned long, inet_num,IPrange *,table);
|
||||||
|
|
@ -77,7 +82,7 @@ const char * require_access_rights PROTO4(const DIRINFO *,di,unsigned char,right
|
||||||
|
|
||||||
/* main.c, startup and init code */
|
/* main.c, startup and init code */
|
||||||
|
|
||||||
/* log.c */
|
/* log.c, log writter */
|
||||||
extern int logfd;
|
extern int logfd;
|
||||||
extern int tlogfd;
|
extern int tlogfd;
|
||||||
void fsplogf PROTO0((void));
|
void fsplogf PROTO0((void));
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
bin_PROGRAMS=fspd
|
bin_PROGRAMS=fspd
|
||||||
|
|
||||||
fspd_SOURCES=file.c host.c main.c conf.c filecache.c server.c fifocache.c \
|
fspd_SOURCES=file.c host.c main.c conf.c filecache.c server.c fifocache.c \
|
||||||
log.c iprange.c acl.c path.c
|
log.c iprange.c acl.c path.c random.c
|
||||||
fspd_CFLAGS=-DSYSCONFDIR="\"@sysconfdir@\"" $(AM_CFLAGS)
|
fspd_CFLAGS=-DSYSCONFDIR="\"@sysconfdir@\"" $(AM_CFLAGS)
|
||||||
fspd_LDADD=-L../common -lcommon
|
fspd_LDADD=-L../common -lcommon
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "tweak.h"
|
#include "tweak.h"
|
||||||
#include "server_def.h"
|
#include "server_def.h"
|
||||||
#include "s_extern.h"
|
#include "s_extern.h"
|
||||||
|
#include "my-string.h"
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Routine to parse a path string given by the client.
|
* Routine to parse a path string given by the client.
|
||||||
|
|
|
||||||
28
server/random.c
Normal file
28
server/random.c
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "tweak.h"
|
||||||
|
#include "server_def.h"
|
||||||
|
#include "s_extern.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Routine to return a 16-bit key with random number.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* The following algorithm is recommended by Numerical Recipies. */
|
||||||
|
/* Best, but needs floating point division. */
|
||||||
|
unsigned short gen_next_key PROTO0 ((void))
|
||||||
|
{
|
||||||
|
unsigned short ulRandom = ((float)(0xffff)*rand()/(RAND_MAX+1.0f));
|
||||||
|
return(ulRandom);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
unsigned short gen_next_key PROTO0((void))
|
||||||
|
{
|
||||||
|
unsigned long k;
|
||||||
|
|
||||||
|
k = random();
|
||||||
|
k = k ^ (k >> 8) ^ (k >> 16) ^ (k << 8);
|
||||||
|
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -295,20 +295,6 @@ int server_loop PROTO2(int, fd, time_t, timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Routine to return a 16-bit key with random number.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static unsigned short gen_next_key PROTO0((void))
|
|
||||||
{
|
|
||||||
unsigned long k;
|
|
||||||
|
|
||||||
k = random();
|
|
||||||
k = k ^ (k >> 8) ^ (k >> 16) ^ (k << 8);
|
|
||||||
|
|
||||||
return(k & 0xffff);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Generic routine for sending reply back to clients.
|
* Generic routine for sending reply back to clients.
|
||||||
* from: client address structure.
|
* from: client address structure.
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,4 @@ Makefile.in
|
||||||
mklargefile
|
mklargefile
|
||||||
cachecheck
|
cachecheck
|
||||||
parsecheck
|
parsecheck
|
||||||
|
randomcheck
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
noinst_PROGRAMS=mklargefile cachecheck parsecheck
|
noinst_PROGRAMS=mklargefile cachecheck parsecheck randomcheck
|
||||||
|
|
||||||
extra_DIST=mklargefile.py
|
extra_DIST=mklargefile.py
|
||||||
|
|
||||||
cachecheck_SOURCES=../server/fifocache.c cachecheck.c
|
cachecheck_SOURCES=../server/fifocache.c cachecheck.c
|
||||||
parsecheck_SOURCES=parsecheck.c ../server/path.c
|
parsecheck_SOURCES=parsecheck.c ../server/path.c
|
||||||
TESTS=parsecheck
|
TESTS=parsecheck randomcheck
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
* made by radim kolar.
|
* made by radim kolar.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "tweak.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "tweak.h"
|
|
||||||
#include "../server/fifocache.h"
|
#include "../server/fifocache.h"
|
||||||
|
|
||||||
static int intcompare(const int *i1,const int *i2)
|
static int intcompare(const int *i1,const int *i2)
|
||||||
|
|
|
||||||
114
tests/randomcheck.c
Normal file
114
tests/randomcheck.c
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
#include "tweak.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "my-string.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
static int bitcount[16];
|
||||||
|
static int rounds;
|
||||||
|
static int result;
|
||||||
|
#define MAX_WORST_ALLOWED 0.2f
|
||||||
|
|
||||||
|
/* FSP classic algo */
|
||||||
|
static unsigned short classic PROTO0((void))
|
||||||
|
{
|
||||||
|
unsigned long k;
|
||||||
|
|
||||||
|
k = random();
|
||||||
|
k = k ^ (k >> 8) ^ (k >> 16) ^ (k << 8);
|
||||||
|
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get low bits from random result */
|
||||||
|
static unsigned short simple PROTO0((void))
|
||||||
|
{
|
||||||
|
return random();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get high bits from random result - better */
|
||||||
|
static unsigned short simple2 PROTO0((void))
|
||||||
|
{
|
||||||
|
return (random() >> 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The following algorithm is recommended by Numerical Recipies: */
|
||||||
|
/* Best, but needs floating point division */
|
||||||
|
static unsigned short nr(void)
|
||||||
|
{
|
||||||
|
unsigned short ulRandom = ((float)(0xffff)*rand()/(RAND_MAX+1.0f));
|
||||||
|
return(ulRandom);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void run_randomtest( unsigned short (*keygen)(void) )
|
||||||
|
{
|
||||||
|
int i,j;
|
||||||
|
unsigned short rnd;
|
||||||
|
|
||||||
|
/* zero bitcount first */
|
||||||
|
memset(bitcount,0,16*sizeof(int));
|
||||||
|
|
||||||
|
for(i=0;i<rounds;i++)
|
||||||
|
{
|
||||||
|
rnd=keygen();
|
||||||
|
|
||||||
|
for(j=0;j<16;j++)
|
||||||
|
{
|
||||||
|
if(rnd & 1)
|
||||||
|
bitcount[j]++;
|
||||||
|
rnd=rnd>>1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_bitcount(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
float worst;
|
||||||
|
float ratio;
|
||||||
|
|
||||||
|
printf("Set ratio: ");
|
||||||
|
worst=0;
|
||||||
|
|
||||||
|
for(i=0;i<16;i++)
|
||||||
|
{
|
||||||
|
ratio=(float)bitcount[i]/rounds;
|
||||||
|
if(fabs(ratio-0.5f)>worst)
|
||||||
|
worst=fabs(ratio-0.5f);
|
||||||
|
printf("%.2f ",ratio);
|
||||||
|
}
|
||||||
|
printf(" Worst: %.3f\n",worst);
|
||||||
|
if(worst>MAX_WORST_ALLOWED) result++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc,const char *argv[])
|
||||||
|
{
|
||||||
|
rounds=200;
|
||||||
|
if(argc>1)
|
||||||
|
{
|
||||||
|
rounds=atoi(argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Running %d rounds.\n\n",rounds);
|
||||||
|
|
||||||
|
result=0;
|
||||||
|
|
||||||
|
printf("Generator: classic\n");
|
||||||
|
run_randomtest(classic);
|
||||||
|
print_bitcount();
|
||||||
|
|
||||||
|
printf("Generator: simple\n");
|
||||||
|
run_randomtest(simple);
|
||||||
|
print_bitcount();
|
||||||
|
|
||||||
|
printf("Generator: simple2\n");
|
||||||
|
run_randomtest(simple2);
|
||||||
|
print_bitcount();
|
||||||
|
|
||||||
|
result=0;
|
||||||
|
printf("Generator: Numerical Recipes\n");
|
||||||
|
run_randomtest(nr);
|
||||||
|
print_bitcount();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user