This patch avoids duplicate session IDs in RADIUS accounting,
when the same pppd instance has multiple sessions during
the same second. This can happen when you have a really
fast RADIUS server and fast clients, e. g. when using pppd
as a back-end for PPPoE (either directly or via L2TP).
/*
- * $Id: util.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
+ * $Id: util.c,v 1.3 2004/10/28 00:21:48 paulus Exp $
*
* Copyright (C) 1995,1996,1997 Lars Fenneberg
*
char *
rc_mksid (void)
{
- static char buf[14];
- sprintf (buf, "%08lX%04X", (unsigned long int) time (NULL), (unsigned int) getpid ());
+ static char buf[15];
+ static unsigned short int cnt = 0;
+ sprintf (buf, "%08lX%04X%02hX",
+ (unsigned long int) time (NULL),
+ (unsigned int) getpid (),
+ cnt & 0xFF);
+ cnt++;
return buf;
}