diff options
author | Nishant Chaprana <n.chaprana@samsung.com> | 2019-07-04 17:41:09 +0530 |
---|---|---|
committer | Nishant Chaprana <n.chaprana@samsung.com> | 2019-07-04 17:41:17 +0530 |
commit | 6b2381a2adabea7d8309ff158ef675ff88184305 (patch) | |
tree | 2c9b2bb6d8b214acc18b8e784e6841f468a5a040 /gdhcp/common.c | |
parent | 9362752a471a5c892d679548fbf2828d5fc5684b (diff) | |
download | connman-6b2381a2adabea7d8309ff158ef675ff88184305.tar.gz connman-6b2381a2adabea7d8309ff158ef675ff88184305.tar.bz2 connman-6b2381a2adabea7d8309ff158ef675ff88184305.zip |
Imported Upstream version 1.37upstream/1.37
Change-Id: Ib5957e7ee3a9315ee86a331189bc3e9e71751ee8
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
Diffstat (limited to 'gdhcp/common.c')
-rw-r--r-- | gdhcp/common.c | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/gdhcp/common.c b/gdhcp/common.c index 6f816718..8f7a65cc 100644 --- a/gdhcp/common.c +++ b/gdhcp/common.c @@ -39,6 +39,7 @@ #include "gdhcp.h" #include "common.h" +#include "../src/connman.h" static const DHCPOption client_options[] = { { OPTION_IP, 0x01 }, /* subnet-mask */ @@ -60,42 +61,6 @@ static const DHCPOption client_options[] = { { OPTION_UNKNOWN, 0x00 }, }; -#define URANDOM "/dev/urandom" -static int random_fd = -1; - -int dhcp_get_random(uint64_t *val) -{ - int r; - - if (random_fd < 0) { - random_fd = open(URANDOM, O_RDONLY); - if (random_fd < 0) { - r = -errno; - *val = random(); - - return r; - } - } - - if (read(random_fd, val, sizeof(uint64_t)) < 0) { - r = -errno; - *val = random(); - - return r; - } - - return 0; -} - -void dhcp_cleanup_random(void) -{ - if (random_fd < 0) - return; - - close(random_fd); - random_fd = -1; -} - GDHCPOptionType dhcp_get_code_type(uint8_t code) { int i; @@ -332,8 +297,6 @@ void dhcp_add_option_uint32(struct dhcp_packet *packet, uint8_t code, put_be32(data, option + OPT_DATA); dhcp_add_binary_option(packet, option); - - return; } void dhcp_add_option_uint16(struct dhcp_packet *packet, uint8_t code, @@ -349,8 +312,6 @@ void dhcp_add_option_uint16(struct dhcp_packet *packet, uint8_t code, put_be16(data, option + OPT_DATA); dhcp_add_binary_option(packet, option); - - return; } void dhcp_add_option_uint8(struct dhcp_packet *packet, uint8_t code, @@ -366,8 +327,6 @@ void dhcp_add_option_uint8(struct dhcp_packet *packet, uint8_t code, option[OPT_DATA] = data; dhcp_add_binary_option(packet, option); - - return; } void dhcp_init_header(struct dhcp_packet *packet, char type) @@ -400,7 +359,7 @@ void dhcpv6_init_header(struct dhcpv6_packet *packet, uint8_t type) packet->message = type; - dhcp_get_random(&rand); + __connman_util_get_random(&rand); id = rand; packet->transaction_id[0] = (id >> 16) & 0xff; |