1202006Smarius/*
2202006Smarius * Copyright 2008, Haiku, Inc. All Rights Reserved.
3202006Smarius * This file may be used under the terms of the MIT License.
4202006Smarius */
5202006Smarius#ifndef NET_STACK_INTERFACE_H
6202006Smarius#define NET_STACK_INTERFACE_H
7202006Smarius
8202006Smarius
9202006Smarius#include <sys/socket.h>
10202006Smarius
11202006Smarius
12202006Smarius// name of the kernel stack interface
13202006Smarius#define NET_STACK_INTERFACE_MODULE_NAME "network/stack/kernel_interface/v1"
14202006Smarius
15202006Smarius// name of the userland stack interface
16202006Smarius#define NET_STACK_USERLAND_INTERFACE_MODULE_NAME \
17202006Smarius	"network/stack/userland_interface/v1"
18202006Smarius
19202006Smarius
20202006Smariusstruct net_socket;
21202006Smariusstruct net_stat;
22202006Smarius
23202006Smarius
24202006Smariusstruct net_stack_interface_module_info {
25202006Smarius	module_info info;
26202006Smarius
27202006Smarius	status_t (*open)(int family, int type, int protocol, net_socket** _socket);
28202006Smarius	status_t (*close)(net_socket* socket);
29202006Smarius	status_t (*free)(net_socket* socket);
30202006Smarius
31202006Smarius	status_t (*bind)(net_socket* socket, const struct sockaddr* address,
32202006Smarius					socklen_t addressLength);
33202006Smarius	status_t (*shutdown)(net_socket* socket, int how);
34202006Smarius	status_t (*connect)(net_socket* socket, const struct sockaddr* address,
35202006Smarius					socklen_t addressLength);
36202006Smarius	status_t (*listen)(net_socket* socket, int backlog);
37202006Smarius	status_t (*accept)(net_socket* socket, struct sockaddr* address,
38202006Smarius					socklen_t* _addressLength, net_socket** _acceptedSocket);
39202006Smarius
40202006Smarius	ssize_t (*recv)(net_socket* socket, void* data, size_t length, int flags);
41202006Smarius	ssize_t (*recvfrom)(net_socket* socket, void* data, size_t length,
42202006Smarius					int flags, struct sockaddr* address,
43202006Smarius					socklen_t* _addressLength);
44202006Smarius	ssize_t (*recvmsg)(net_socket* socket, struct msghdr* message, int flags);
45202006Smarius
46202006Smarius	ssize_t (*send)(net_socket* socket, const void* data, size_t length,
47202006Smarius					int flags);
48202006Smarius	ssize_t (*sendto)(net_socket* socket, const void* data, size_t length,
49202006Smarius					int flags, const struct sockaddr* address,
50202006Smarius					socklen_t addressLength);
51202006Smarius	ssize_t (*sendmsg)(net_socket* socket, const struct msghdr* message,
52202006Smarius					int flags);
53202006Smarius
54202006Smarius	status_t (*getsockopt)(net_socket* socket, int level, int option,
55202006Smarius					void* value, socklen_t* _length);
56202006Smarius	status_t (*setsockopt)(net_socket* socket, int level, int option,
57202006Smarius					const void* value, socklen_t length);
58202006Smarius
59202006Smarius	status_t (*getpeername)(net_socket* socket, struct sockaddr* address,
60202006Smarius					socklen_t* _addressLength);
61202006Smarius	status_t (*getsockname)(net_socket* socket, struct sockaddr* address,
62202006Smarius					socklen_t* _addressLength);
63202006Smarius
64202006Smarius	int (*sockatmark)(net_socket* socket);
65202006Smarius
66202006Smarius	status_t (*socketpair)(int family, int type, int protocol,
67202006Smarius					net_socket* _sockets[2]);
68202006Smarius
69202006Smarius	status_t (*ioctl)(net_socket* socket, uint32 op, void *buffer,
70202006Smarius					size_t length);
71202006Smarius	status_t (*select)(net_socket* socket, uint8 event,
72202006Smarius					struct selectsync *sync);
73202006Smarius	status_t (*deselect)(net_socket* socket, uint8 event,
74202006Smarius					struct selectsync *sync);
75202006Smarius
76202006Smarius	status_t (*get_next_socket_stat)(int family, uint32 *cookie,
77202006Smarius					struct net_stat *stat);
78202006Smarius};
79202006Smarius
80202006Smarius
81202006Smarius#endif	// NET_STACK_INTERFACE_H
82202006Smarius