summaryrefslogtreecommitdiff
path: root/gdhcp/ipv4ll.c
diff options
context:
space:
mode:
authorhyunuktak <hyunuk.tak@samsung.com>2015-08-07 17:11:34 +0900
committerhyunuktak <hyunuk.tak@samsung.com>2015-08-07 17:11:56 +0900
commit6aa4055ef0544ae85457c25c510fe3db04949c43 (patch)
tree94018be3cef92c33b60650c488dc15536c8f978a /gdhcp/ipv4ll.c
parentbc55a3df0d4d2d97964ce2fadc9fe3ffc4953f4e (diff)
downloadconnman-6aa4055ef0544ae85457c25c510fe3db04949c43.tar.gz
connman-6aa4055ef0544ae85457c25c510fe3db04949c43.tar.bz2
connman-6aa4055ef0544ae85457c25c510fe3db04949c43.zip
Base Code merged to SPIN 2.4submit/tizen/20150810.034432
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com> Change-Id: I84a42375b5c59739e4caca1f726699ea7647ef17
Diffstat (limited to 'gdhcp/ipv4ll.c')
-rwxr-xr-x[-rw-r--r--]gdhcp/ipv4ll.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/gdhcp/ipv4ll.c b/gdhcp/ipv4ll.c
index 9bf52b0a..c43971f0 100644..100755
--- a/gdhcp/ipv4ll.c
+++ b/gdhcp/ipv4ll.c
@@ -34,23 +34,19 @@
#include <glib.h>
#include "ipv4ll.h"
+#include "common.h"
/**
* Return a random link local IP (in host byte order)
*/
-uint32_t ipv4ll_random_ip(int seed)
+uint32_t ipv4ll_random_ip(void)
{
unsigned tmp;
+ uint64_t rand;
- if (seed)
- srand(seed);
- else {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- srand(tv.tv_usec);
- }
do {
- tmp = rand();
+ dhcp_get_random(&rand);
+ tmp = rand;
tmp = tmp & IN_CLASSB_HOST;
} while (tmp > (IN_CLASSB_HOST - 0x0200));
return ((LINKLOCAL_ADDR + 0x0100) + tmp);
@@ -61,13 +57,10 @@ uint32_t ipv4ll_random_ip(int seed)
*/
guint ipv4ll_random_delay_ms(guint secs)
{
- struct timeval tv;
- guint tmp;
+ uint64_t rand;
- gettimeofday(&tv, NULL);
- srand(tv.tv_usec);
- tmp = rand();
- return tmp % (secs * 1000);
+ dhcp_get_random(&rand);
+ return rand % (secs * 1000);
}
int ipv4ll_send_arp_packet(uint8_t* source_eth, uint32_t source_ip,