* int32_t, uint32_t are now of type "int", and no longer of type "long".

This should help to reduce the number of warnings imported code will throw
  during compilation (helps a lot with tcpdump, for example).
* Since long is 64 bit on 64 bit platforms, we might want to think about doing
  that change for the Haiku types int32 and uint32 as well.
* Fixed several occurences of hidden type problems.
* Fixed build of the stack and TCP under BeOS.
* Fixed incorrect typedef in socket_interface.h.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22643 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-10-21 20:10:43 +00:00
parent 3dfa121266
commit 15ab0bcf01
22 changed files with 169 additions and 117 deletions
+1 -1
View File
@@ -14,7 +14,7 @@
#define B_SOCKET_MODULE_NAME "network/socket/v1"
typedef struct socket_module_info {
struct socket_module_info {
struct module_info info;
int (*accept)(int socket, struct sockaddr *address, socklen_t *_addressLength);
+2 -1
View File
@@ -22,7 +22,8 @@ typedef uint32_t in_addr_t;
* and we are not allowed to import all the BeOS types here.
*/
#ifndef htonl
extern uint32_t __swap_int32(uint32_t); /* private */
// extern uint32_t __swap_int32(uint32_t); /* private */
extern unsigned long __swap_int32(unsigned long); /* private */
extern uint16_t __swap_int16(uint16_t); /* private */
#if BYTE_ORDER == LITTLE_ENDIAN
#define htonl(x) __swap_int32(x)
+6 -5
View File
@@ -1,6 +1,7 @@
/*
** Distributed under the terms of the Haiku License.
*/
/*
* Copyright 2003-2007, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _STDINT_H_
#define _STDINT_H_
@@ -27,8 +28,8 @@ typedef unsigned short uint16_t;
#define INT32_MIN (-INT32_MAX-1)
#define UINT32_MAX (4294967295UL)
typedef signed long int32_t;
typedef unsigned long uint32_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
#define INT64_MAX (9223372036854775807LL)
#define INT64_MIN (-INT64_MAX-1)
+5 -6
View File
@@ -83,13 +83,12 @@ struct sockaddr {
uint8_t sa_data[30];
};
/* this can hold ANY sockaddr we care to throw at it! */
struct sockaddr_storage {
uint8_t ss_len; /* total length */
uint8_t ss_family; /* address family */
uint8_t __ss_pad1[6]; /* align to quad */
uint64_t __ss_pad2; /* force alignment for stupid compilers */
uint8_t __ss_pad3[112]; /* pad to a total of 128 bytes */
uint8_t ss_len; /* total length */
uint8_t ss_family; /* address family */
uint8_t __ss_pad1[6]; /* align to quad */
uint64_t __ss_pad2; /* force alignment to 64 bit */
uint8_t __ss_pad3[112]; /* pad to a total of 128 bytes */
};
struct msghdr {
+3 -2
View File
@@ -5,20 +5,21 @@
* Authors:
* Hugo Santos, [email protected]
*/
#ifndef PROTOCOL_UTILITIES_H
#define PROTOCOL_UTILITIES_H
#include <lock.h>
#include <Select.h>
#include <util/AutoLock.h>
#include <util/DoublyLinkedList.h>
#include <AddressUtilities.h>
#include <net_buffer.h>
#include <net_protocol.h>
#include <net_socket.h>
#include <net_stack.h>
#include <AddressUtilities.h>
class BenaphoreLocking {
public:
+20 -15
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef NET_SOCKET_H
@@ -9,9 +9,10 @@
#include <net_buffer.h>
#include <sys/socket.h>
#include <Select.h>
#include <lock.h>
struct selectsync;
#define NET_SOCKET_MODULE_NAME "network/stack/socket/v1"
@@ -42,32 +43,36 @@ typedef struct net_socket {
struct net_socket_module_info {
struct module_info info;
status_t (*open_socket)(int family, int type, int protocol, net_socket **_socket);
status_t (*open_socket)(int family, int type, int protocol,
net_socket **_socket);
status_t (*close)(net_socket *socket);
status_t (*free)(net_socket *socket);
status_t (*readv)(net_socket *socket, const iovec *vecs, size_t vecCount,
size_t *_length);
status_t (*writev)(net_socket *socket, const iovec *vecs, size_t vecCount,
size_t *_length);
status_t (*control)(net_socket *socket, int32 op, void *data, size_t length);
status_t (*readv)(net_socket *socket, const iovec *vecs,
size_t vecCount, size_t *_length);
status_t (*writev)(net_socket *socket, const iovec *vecs,
size_t vecCount, size_t *_length);
status_t (*control)(net_socket *socket, int32 op, void *data,
size_t length);
ssize_t (*read_avail)(net_socket *socket);
ssize_t (*send_avail)(net_socket *socket);
status_t (*send_data)(net_socket *socket, net_buffer *buffer);
status_t (*receive_data)(net_socket *socket, size_t length, uint32 flags,
net_buffer **_buffer);
status_t (*receive_data)(net_socket *socket, size_t length,
uint32 flags, net_buffer **_buffer);
status_t (*get_option)(net_socket *socket, int level, int option,
void *value, int *_length);
status_t (*set_option)(net_socket *socket, int level, int option,
const void *value, int length);
status_t (*get_next_stat)(uint32 *cookie, int family, struct net_stat *stat);
status_t (*get_next_stat)(uint32 *cookie, int family,
struct net_stat *stat);
// connections
status_t (*spawn_pending_socket)(net_socket *parent, net_socket **_socket);
status_t (*spawn_pending_socket)(net_socket *parent,
net_socket **_socket);
void (*delete_socket)(net_socket *socket);
status_t (*dequeue_connected)(net_socket *parent, net_socket **_socket);
ssize_t (*count_connected)(net_socket *parent);
@@ -75,10 +80,10 @@ struct net_socket_module_info {
status_t (*set_connected)(net_socket *socket);
// notifications
status_t (*request_notification)(net_socket *socket, uint8 event, uint32 ref,
selectsync *sync);
status_t (*request_notification)(net_socket *socket, uint8 event,
uint32 ref, struct selectsync *sync);
status_t (*cancel_notification)(net_socket *socket, uint8 event,
selectsync *sync);
struct selectsync *sync);
status_t (*notify)(net_socket *socket, uint8 event, int32 value);
// standard socket API
+16 -11
View File
@@ -78,9 +78,10 @@ struct net_stack_module_info {
status_t (*register_domain_receiving_protocol)(int family, int type,
const char *moduleName);
status_t (*get_domain_receiving_protocol)(struct net_domain *domain, uint32 type,
struct net_protocol_module_info **_module);
status_t (*put_domain_receiving_protocol)(struct net_domain *domain, uint32 type);
status_t (*get_domain_receiving_protocol)(struct net_domain *domain,
uint32 type, struct net_protocol_module_info **_module);
status_t (*put_domain_receiving_protocol)(struct net_domain *domain,
uint32 type);
// devices
status_t (*register_device_deframer)(struct net_device *device,
@@ -94,33 +95,37 @@ struct net_stack_module_info {
status_t (*unregister_device_handler)(struct net_device *device, int32 type);
status_t (*register_device_monitor)(struct net_device *device,
struct net_device_monitor *monitor);
struct net_device_monitor *monitor);
status_t (*unregister_device_monitor)(struct net_device *device,
struct net_device_monitor *monitor);
struct net_device_monitor *monitor);
status_t (*device_link_changed)(struct net_device *device);
status_t (*device_removed)(struct net_device *device);
status_t (*device_enqueue_buffer)(struct net_device *device,
struct net_buffer *buffer);
struct net_buffer *buffer);
// Utility Functions
// notification
status_t (*notify_socket)(struct net_socket *socket, uint8 event, int32 value);
status_t (*notify_socket)(struct net_socket *socket, uint8 event,
int32 value);
// checksum
uint16 (*checksum)(uint8 *buffer, size_t length);
// fifo
status_t (*init_fifo)(struct net_fifo *fifo, const char *name, size_t maxBytes);
status_t (*init_fifo)(struct net_fifo *fifo, const char *name,
size_t maxBytes);
void (*uninit_fifo)(struct net_fifo *fifo);
status_t (*fifo_enqueue_buffer)(struct net_fifo *fifo, struct net_buffer *buffer);
status_t (*fifo_enqueue_buffer)(struct net_fifo *fifo,
struct net_buffer *buffer);
ssize_t (*fifo_dequeue_buffer)(struct net_fifo *fifo, uint32 flags,
bigtime_t timeout, struct net_buffer **_buffer);
status_t (*clear_fifo)(struct net_fifo *fifo);
status_t (*fifo_socket_enqueue_buffer)(struct net_fifo *, struct net_socket *,
uint8 event, struct net_buffer *);
status_t (*fifo_socket_enqueue_buffer)(struct net_fifo *fifo,
struct net_socket *socket, uint8 event,
struct net_buffer *buffer);
// timer
void (*init_timer)(struct net_timer *timer, net_timer_func hook, void *data);
@@ -9,14 +9,16 @@
#include "EndpointManager.h"
#include "TCPEndpoint.h"
#include <NetUtilities.h>
#include <util/AutoLock.h>
#include <unistd.h>
#include <KernelExport.h>
#include <NetUtilities.h>
#include <util/AutoLock.h>
#include "TCPEndpoint.h"
//#define TRACE_ENDPOINT_MANAGER
#ifdef TRACE_ENDPOINT_MANAGER
@@ -24,6 +24,7 @@
#include <util/list.h>
#include <KernelExport.h>
#include <Select.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@@ -196,9 +197,10 @@ WaitList::Wait(MutexLocker &locker, bigtime_t timeout, bool wakeNext)
status_t status = B_OK;
while (status == B_OK && !atomic_test_and_set(&fCondition, 0, 1))
while (status == B_OK && !atomic_test_and_set(&fCondition, 0, 1)) {
status = acquire_sem_etc(fSem, 1, B_ABSOLUTE_TIMEOUT | B_CAN_INTERRUPT,
timeout);
}
locker.Lock();
if (status == B_OK && wakeNext)
@@ -212,7 +214,13 @@ void
WaitList::Signal()
{
atomic_or(&fCondition, 1);
#ifdef __HAIKU__
release_sem_etc(fSem, 1, B_DO_NOT_RESCHEDULE | B_RELEASE_IF_WAITING_ONLY);
#else
int32 count;
if (get_sem_count(fSem, &count) == B_OK && count < 0)
release_sem_etc(fSem, 1, B_DO_NOT_RESCHEDULE);
#endif
}
@@ -1,10 +1,11 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, [email protected]
* Andrew Galante, [email protected]
* Hugo Santos, [email protected]
*/
@@ -134,9 +135,9 @@ add_options(tcp_segment_header &segment, uint8 *buffer, size_t bufferSize)
bump_option(option, length);
option->kind = TCP_OPTION_TIMESTAMP;
option->length = 10;
option->timestamp.timestamp_value = htonl(segment.timestamp_value);
option->timestamp.value = htonl(segment.timestamp_value);
// TSecr is opaque to us, we send it as we received it.
option->timestamp.timestamp_reply = segment.timestamp_reply;
option->timestamp.reply = segment.timestamp_reply;
bump_option(option, length);
}
@@ -307,9 +308,9 @@ process_options(tcp_segment_header &segment, net_buffer *buffer, size_t size)
case TCP_OPTION_TIMESTAMP:
if (option->length == 10 && (size - 10) >= 0) {
segment.options |= TCP_HAS_TIMESTAMPS;
segment.timestamp_value = option->timestamp.timestamp_value;
segment.timestamp_value = option->timestamp.value;
segment.timestamp_reply =
ntohl(option->timestamp.timestamp_reply);
ntohl(option->timestamp.reply);
}
break;
case TCP_OPTION_SACK_PERMITTED:
@@ -386,6 +387,33 @@ dump_tcp_header(tcp_header &header)
#endif
static int
dump_endpoints(int argc, char *argv[])
{
EndpointManagerList::Iterator it = sEndpointManagers.GetIterator();
while (it.HasNext())
it.Next()->DumpEndpoints();
return 0;
}
static int
dump_endpoint(int argc, char *argv[])
{
if (argc < 2) {
kprintf("usage: tcp_endpoint [address]\n");
return 0;
}
TCPEndpoint *endpoint = (TCPEndpoint *)strtoul(argv[1], NULL, 16);
endpoint->DumpInternalState();
return 0;
}
// #pragma mark - protocol API
@@ -674,33 +702,6 @@ tcp_error_reply(net_protocol *protocol, net_buffer *causedError, uint32 code,
}
static int
dump_endpoints(int argc, char *argv[])
{
EndpointManagerList::Iterator it = sEndpointManagers.GetIterator();
while (it.HasNext())
it.Next()->DumpEndpoints();
return 0;
}
static int
dump_endpoint(int argc, char *argv[])
{
if (argc < 2) {
kprintf("usage: tcp_endpoint [address]\n");
return 0;
}
TCPEndpoint *endpoint = (TCPEndpoint *)strtoul(argv[1], NULL, 16);
endpoint->DumpInternalState();
return 0;
}
// #pragma mark -
@@ -1,9 +1,11 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, [email protected]
* Andrew Galante, [email protected]
* Hugo Santos, [email protected]
*/
#ifndef TCP_H
#define TCP_H
@@ -115,13 +117,13 @@ struct tcp_option {
uint8 kind;
uint8 length;
union {
uint8 window_shift;
uint16 max_segment_size;
uint8 window_shift;
uint16 max_segment_size;
struct {
uint32 timestamp_value;
uint32 timestamp_reply;
} timestamp;
tcp_sack sack[0];
uint32 value;
uint32 reply;
} timestamp;
tcp_sack sack[0];
};
} _PACKED;
+2 -2
View File
@@ -221,7 +221,7 @@ sendmsg(int socket, const struct msghdr *message, int flags)
int
getsockopt(int socket, int level, int option, void *value, size_t *_length)
getsockopt(int socket, int level, int option, void *value, socklen_t *_length)
{
sockopt_args args;
args.level = level;
@@ -240,7 +240,7 @@ getsockopt(int socket, int level, int option, void *value, size_t *_length)
int
setsockopt(int socket, int level, int option, const void *value, size_t length)
setsockopt(int socket, int level, int option, const void *value, socklen_t length)
{
sockopt_args args;
args.level = level;
@@ -14,6 +14,7 @@
#include <net_stat.h>
#include <KernelExport.h>
#include <Select.h>
#include <team.h>
#include <util/AutoLock.h>
#include <util/list.h>
@@ -91,9 +91,13 @@ UserBuffer::Copy(void *source, size_t length)
return NULL;
}
#ifdef _KERNEL_MODE
fStatus = user_memcpy(fBuffer, source, length);
if (fStatus < B_OK)
return NULL;
#else
memcpy(fBuffer, source, length);
#endif
void *current = fBuffer;
@@ -242,7 +246,11 @@ Fifo::Clear()
void
Fifo::WakeAll()
{
#ifdef __HAIKU__
release_sem_etc(notify, 0, B_RELEASE_ALL);
#else
release_sem_etc(notify, 0, waiting);
#endif
}
+1 -1
View File
@@ -611,7 +611,7 @@ dst_s_write_public_key(const DST_KEY *key)
b64_ntop(&out_key[6], len - 6, enc_key, sizeof(enc_key));
else
b64_ntop(&out_key[4], len - 4, enc_key, sizeof(enc_key));
fprintf(fp, "%s IN KEY %ld %d %d %s\n",
fprintf(fp, "%s IN KEY %d %d %d %s\n",
key->dk_key_name,
key->dk_flags, key->dk_proto, key->dk_alg, enc_key);
fclose(fp);
+1 -1
View File
@@ -280,7 +280,7 @@ dst_s_build_filename(char *filename, const char *name, u_int16_t id,
if (filename_length < 1 + strlen(name) + 4 + 6 + 1 + strlen(suffix))
return (-1);
my_id = id;
sprintf(filename, "K%s+%03d+%05ld.%s", name, alg, my_id,
sprintf(filename, "K%s+%03d+%05d.%s", name, alg, my_id,
(const char *) suffix);
if (strrchr(filename, '/'))
return (-1);
+1 -1
View File
@@ -89,7 +89,7 @@ static const char rcsid[] = "$Id$";
* Ascii internet address interpretation routine.
* The value returned is in network order.
*/
u_long
in_addr_t
inet_addr(const char *cp) {
struct in_addr val;
+6 -6
View File
@@ -46,8 +46,8 @@ static const char rcsid[] = "$Id$";
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static const char *inet_ntop4 __P((const u_char *src, char *dst, size_t size));
static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size));
static const char *inet_ntop4 __P((const u_char *src, char *dst, socklen_t size));
static const char *inet_ntop6 __P((const u_char *src, char *dst, socklen_t size));
/* char *
* inet_ntop(af, src, dst, size)
@@ -62,7 +62,7 @@ inet_ntop(af, src, dst, size)
int af;
const void *src;
char *dst;
size_t size;
socklen_t size;
{
switch (af) {
case AF_INET:
@@ -91,7 +91,7 @@ static const char *
inet_ntop4(src, dst, size)
const u_char *src;
char *dst;
size_t size;
socklen_t size;
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
@@ -114,7 +114,7 @@ static const char *
inet_ntop6(src, dst, size)
const u_char *src;
char *dst;
size_t size;
socklen_t size;
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
@@ -194,7 +194,7 @@ inet_ntop6(src, dst, size)
/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
if ((socklen_t)(tp - tmp) > size) {
errno = ENOSPC;
return (NULL);
}
+3 -3
View File
@@ -89,11 +89,11 @@ static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
int
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
const struct sockaddr *sa;
size_t salen;
socklen_t salen;
char *host;
size_t hostlen;
socklen_t hostlen;
char *serv;
size_t servlen;
socklen_t servlen;
int flags;
{
struct afd *afd;
+2 -2
View File
@@ -190,7 +190,7 @@ do_section(const res_state statp,
else if (section == ns_s_ar && ns_rr_type(rr) == ns_t_opt) {
u_int32_t ttl = ns_rr_ttl(rr);
fprintf(file,
"; EDNS: version: %lu, udp=%u, flags=%04lx\n",
"; EDNS: version: %u, udp=%u, flags=%04x\n",
(ttl>>16)&0xff, ns_rr_class(rr), ttl&0xffff);
} else {
n = ns_sprintrr(handle, &rr, NULL, NULL,
@@ -642,7 +642,7 @@ p_time(u_int32_t value) {
static char nbuf[40]; /* XXX nonreentrant */
if (ns_format_ttl(value, nbuf, sizeof nbuf) < 0)
sprintf(nbuf, "%lu", value);
sprintf(nbuf, "%u", value);
return (nbuf);
}
+3 -2
View File
@@ -418,7 +418,7 @@ sendmsg(int socket, const struct msghdr *message, int flags)
extern "C" int
getsockopt(int socket, int level, int option, void *value, size_t *_length)
getsockopt(int socket, int level, int option, void *value, socklen_t *_length)
{
if (check_r5_compatibility()) {
if (option == R5_SO_FIONREAD) {
@@ -447,7 +447,8 @@ getsockopt(int socket, int level, int option, void *value, size_t *_length)
extern "C" int
setsockopt(int socket, int level, int option, const void *value, size_t length)
setsockopt(int socket, int level, int option, const void *value,
socklen_t length)
{
if (check_r5_compatibility())
convert_from_r5_sockopt(level, option);
+31 -14
View File
@@ -80,7 +80,13 @@ enum message_type {
};
struct dhcp_option_cookie {
dhcp_option_cookie() : state(0), file_has_options(false), server_name_has_options(false) {}
dhcp_option_cookie()
:
state(0),
file_has_options(false),
server_name_has_options(false)
{
}
const uint8* next;
uint8 state;
@@ -122,7 +128,8 @@ struct dhcp_message {
uint8* PutOption(uint8* options, message_option option, uint8 data);
uint8* PutOption(uint8* options, message_option option, uint16 data);
uint8* PutOption(uint8* options, message_option option, uint32 data);
uint8* PutOption(uint8* options, message_option option, const uint8* data, uint32 size);
uint8* PutOption(uint8* options, message_option option, const uint8* data,
uint32 size);
uint8* FinishOptions(uint8 *);
} _PACKED;
@@ -263,7 +270,8 @@ dhcp_message::PrepareMessage(uint8 type)
{
uint8 *next = options;
next = PutOption(next, OPTION_MESSAGE_TYPE, type);
next = PutOption(next, OPTION_MESSAGE_SIZE, (uint16)htons(sizeof(dhcp_message)));
next = PutOption(next, OPTION_MESSAGE_SIZE,
(uint16)htons(sizeof(dhcp_message)));
return next;
}
@@ -298,7 +306,8 @@ dhcp_message::PutOption(uint8* options, message_option option, uint32 data)
uint8*
dhcp_message::PutOption(uint8* options, message_option option, const uint8* data, uint32 size)
dhcp_message::PutOption(uint8* options, message_option option,
const uint8* data, uint32 size)
{
options[0] = option;
options[1] = size;
@@ -438,9 +447,10 @@ DHCPClient::_Negotiate(dhcp_state state)
if (state == INIT)
status = _SendMessage(socket, discover, broadcast);
else
else {
status = _SendMessage(socket, request, state != RENEWAL
? broadcast : fServer);
}
if (status < B_OK)
break;
@@ -490,13 +500,15 @@ DHCPClient::_Negotiate(dhcp_state state)
_PrepareMessage(request, state);
status = _SendMessage(socket, request, broadcast);
// we're sending a broadcast so that all potential offers get an answer
// we're sending a broadcast so that all potential offers
// get an answer
break;
}
case DHCP_ACK:
{
if (state != REQUESTING && state != REBINDING && state != RENEWAL)
if (state != REQUESTING && state != REBINDING
&& state != RENEWAL)
continue;
// TODO: we might want to configure the stuff, don't we?
@@ -520,7 +532,8 @@ DHCPClient::_Negotiate(dhcp_state state)
if (state != REQUESTING)
continue;
// try again (maybe we should prefer other servers if this happens more than once)
// try again (maybe we should prefer other servers if this
// happens more than once)
status = _SendMessage(socket, discover, broadcast);
if (status == B_OK)
state = INIT;
@@ -591,8 +604,10 @@ DHCPClient::_ParseOptions(dhcp_message& message, BMessage& address)
FILE* file = fopen("/etc/resolv.conf", "w");
for (uint32 i = 0; i < size / 4; i++) {
printf("DNS: %s\n", _ToString(&data[i*4]).String());
if (file != NULL)
fprintf(file, "nameserver %s\n", _ToString(&data[i*4]).String());
if (file != NULL) {
fprintf(file, "nameserver %s\n",
_ToString(&data[i*4]).String());
}
}
fclose(file);
break;
@@ -652,7 +667,8 @@ DHCPClient::_PrepareMessage(dhcp_message& message, dhcp_state state)
message.hardware_type = ARP_HARDWARE_TYPE_ETHER;
message.hardware_address_length = 6;
message.transaction_id = htonl(fTransactionID);
message.seconds_since_start = htons(min_c((fStartTime - system_time()) / 1000000LL, 65535));
message.seconds_since_start = htons(min_c((fStartTime - system_time())
/ 1000000LL, 65535));
memcpy(message.mac_address, fMAC, 6);
message_type type = message.Type();
@@ -669,9 +685,10 @@ DHCPClient::_PrepareMessage(dhcp_message& message, dhcp_state state)
// In RENEWAL or REBINDING state, we must set the client_address field, and not
// use OPTION_REQUEST_IP_ADDRESS for DHCP_REQUEST messages
if (type == DHCP_REQUEST && (state == INIT || state == REQUESTING)) {
next = message.PutOption(next, OPTION_REQUEST_IP_ADDRESS, fAssignedAddress);
next = message.PutOption(next, OPTION_REQUEST_IP_ADDRESS,
(uint32)fAssignedAddress);
next = message.PutOption(next, OPTION_REQUEST_PARAMETERS,
kRequiredParameters, sizeof(kRequiredParameters));
kRequiredParameters, sizeof(kRequiredParameters));
} else
message.client_address = fAssignedAddress;
@@ -683,7 +700,7 @@ DHCPClient::_PrepareMessage(dhcp_message& message, dhcp_state state)
{
uint8 *next = message.PrepareMessage(type);
next = message.PutOption(next, OPTION_REQUEST_PARAMETERS,
kRequiredParameters, sizeof(kRequiredParameters));
kRequiredParameters, sizeof(kRequiredParameters));
message.FinishOptions(next);
break;
}