* 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, hugosantos@gmail.com
*/
#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);