haiku/headers/private/net/net_socket.h
Ingo Weinhold 75015ff525 * Renamed THREAD_FLAGS_IOCTL_SYSCALL to THREAD_FLAGS_SYSCALL,
syscall_restart_ioctl_is_restarted() to syscall_restart_is_restarted,
  IoctlSyscallFlagUnsetter to SyscallFlagUnsetter, and
  IoctlSyscallRestartWrapper to SyscallRestartWrapper, as they are no
  longer only used for ioctl().
* Removed unused syscall_restart_ioctl_handle_post().
* Made SyscallRestartWrapper a lot fancier. Instead of storing a
  reference to the result value, it stores the value itself, and it
  features all the interesting operators that make it appear like that
  value. This simplifies the use of the class quite a bit.
* THREAD_FLAGS_SYSCALL is now set for all socket function and the
  read[v](), write[v]() syscalls.
* Added is_syscall() function and net_stack hook to the net stack.
* Removed "kernel" parameter from all net_stack_interface and net_socket
  module hooks. They aren't need any longer, since is_syscall() can be
  used instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24914 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-11 16:13:47 +00:00

115 lines
3.6 KiB
C

/*
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef NET_SOCKET_H
#define NET_SOCKET_H
#include <net_buffer.h>
#include <sys/socket.h>
#include <lock.h>
struct selectsync;
#define NET_SOCKET_MODULE_NAME "network/stack/socket/v1"
typedef struct net_socket {
struct net_protocol *first_protocol;
struct net_protocol_module_info *first_info;
int family;
int type;
int protocol;
struct sockaddr_storage address;
struct sockaddr_storage peer;
int options;
int linger;
struct {
uint32 buffer_size;
uint32 low_water_mark;
bigtime_t timeout;
} send, receive;
status_t error;
struct net_socket *parent;
} 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 (*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);
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 (*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);
// connections
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);
status_t (*set_max_backlog)(net_socket *socket, uint32 backlog);
status_t (*set_connected)(net_socket *socket);
// notifications
status_t (*request_notification)(net_socket *socket, uint8 event,
struct selectsync *sync);
status_t (*cancel_notification)(net_socket *socket, uint8 event,
struct selectsync *sync);
status_t (*notify)(net_socket *socket, uint8 event, int32 value);
// standard socket API
int (*accept)(net_socket *socket, struct sockaddr *address,
socklen_t *_addressLength, net_socket **_acceptedSocket);
int (*bind)(net_socket *socket, const struct sockaddr *address,
socklen_t addressLength);
int (*connect)(net_socket *socket, const struct sockaddr *address,
socklen_t addressLength);
int (*getpeername)(net_socket *socket, struct sockaddr *address,
socklen_t *_addressLength);
int (*getsockname)(net_socket *socket, struct sockaddr *address,
socklen_t *_addressLength);
int (*getsockopt)(net_socket *socket, int level, int option,
void *optionValue, int *_optionLength);
int (*listen)(net_socket *socket, int backlog);
ssize_t (*receive)(net_socket *socket, struct msghdr *, void *data,
size_t length, int flags);
ssize_t (*send)(net_socket *socket, struct msghdr *, const void *data,
size_t length, int flags);
int (*setsockopt)(net_socket *socket, int level, int option,
const void *optionValue, int optionLength);
int (*shutdown)(net_socket *socket, int direction);
status_t (*socketpair)(int family, int type, int protocol,
net_socket* _sockets[2]);
};
#endif // NET_SOCKET_H