Merge of current trunk to branch 1.6.x.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@251 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez
2007-11-19 14:15:45 +00:00
parent 2a76749682
commit 0475a46680
31 changed files with 2506 additions and 2260 deletions

View File

@@ -33,17 +33,16 @@
This sample implementation generates a random node ID
*/
void
get_ieee_node_identifier( uuid_node_t * node )
get_ieee_node_identifier(uuid_node_t *node)
{
char seed[16];
static int inited = 0;
static uuid_node_t saved_node;
if( !inited ) {
get_random_info( seed );
if (!inited) {
get_random_info(seed);
seed[0] |= 0x80;
memcpy( &saved_node, seed, sizeof( uuid_node_t ) );
memcpy(&saved_node, seed, sizeof (uuid_node_t));
inited = 1;
};
@@ -83,52 +82,48 @@ get_system_time( uuid_time_t * uuid_time )
/*-----------------------------------------------------------------------------*/
void
get_random_info( char seed[16] )
get_random_info(char seed[16])
{
MD5_CTX c;
typedef struct {
MEMORYSTATUS m;
SYSTEM_INFO s;
FILETIME t;
LARGE_INTEGER pc;
DWORD tc;
DWORD l;
char hostname[MAX_COMPUTERNAME_LENGTH + 1];
} randomness;
randomness r;
MD5_CTX c;
typedef struct {
MEMORYSTATUS m;
SYSTEM_INFO s;
FILETIME t;
LARGE_INTEGER pc;
DWORD tc;
DWORD l;
char hostname[MAX_COMPUTERNAME_LENGTH + 1];
} randomness;
randomness r;
MD5Init( &c );
/*
memory usage stats
*/
GlobalMemoryStatus( &r.m );
/*
random system stats
*/
GetSystemInfo( &r.s );
/*
100ns resolution (nominally) time of day
*/
GetSystemTimeAsFileTime( &r.t );
/*
high resolution performance counter
*/
QueryPerformanceCounter( &r.pc );
/*
milliseconds since last boot
*/
r.tc = GetTickCount( );
r.l = MAX_COMPUTERNAME_LENGTH + 1;
/* Initialize memory area so that valgrind does not complain */
memset(&r, 0, sizeof r);
GetComputerName( r.hostname, &r.l );
MD5Update( &c, &r, sizeof( randomness ) );
MD5Final( seed, &c );
/* memory usage stats */
GlobalMemoryStatus( &r.m );
/* random system stats */
GetSystemInfo( &r.s );
/* 100ns resolution (nominally) time of day */
GetSystemTimeAsFileTime( &r.t );
/* high resolution performance counter */
QueryPerformanceCounter( &r.pc );
/* milliseconds since last boot */
r.tc = GetTickCount();
r.l = MAX_COMPUTERNAME_LENGTH + 1;
GetComputerName( r.hostname, &r.l );
/* MD5 it */
MD5Init(&c);
MD5Update(&c, &r, sizeof r);
MD5Final(seed, &c);
};
#else
#else /* _WINDOWS_ */
/*-----------------------------------------------------------------------------*/
void
get_system_time( uuid_time_t * uuid_time )
get_system_time(uuid_time_t *uuid_time)
{
struct timeval tp;
@@ -145,22 +140,28 @@ get_system_time( uuid_time_t * uuid_time )
/*-----------------------------------------------------------------------------*/
void
get_random_info( char seed[16] )
get_random_info(char seed[16])
{
MD5_CTX c;
typedef struct {
// struct sysinfo s;
struct timeval t;
char hostname[257];
} randomness;
randomness r;
MD5_CTX c;
typedef struct {
//struct sysinfo s;
struct timeval t;
char hostname[257];
} randomness;
randomness r;
MD5Init( &c );
/* Initialize memory area so that valgrind does not complain */
memset(&r, 0, sizeof r);
gettimeofday( &r.t, ( struct timezone * )0 );
gethostname( r.hostname, 256 );
MD5Update( &c, &r, sizeof( randomness ) );
MD5Final( seed, &c );
/* Get some random stuff */
gettimeofday(&r.t, (struct timezone *)0);
gethostname(r.hostname, 256 );
/* MD5 it */
MD5Init(&c);
MD5Update(&c, &r, sizeof r);
MD5Final(seed, &c);
};
#endif
#endif /* _WINDOWS_ */