xref: /haiku/headers/private/net/net_stack_interface.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 /*
2  * Copyright 2008, Haiku, Inc. All Rights Reserved.
3  * This file may be used under the terms of the MIT License.
4  */
5 #ifndef NET_STACK_INTERFACE_H
6 #define NET_STACK_INTERFACE_H
7 
8 
9 #include <sys/socket.h>
10 
11 
12 // name of the kernel stack interface
13 #define NET_STACK_INTERFACE_MODULE_NAME "network/stack/kernel_interface/v1"
14 
15 // name of the userland stack interface
16 #define NET_STACK_USERLAND_INTERFACE_MODULE_NAME \
17 	"network/stack/userland_interface/v1"
18 
19 
20 struct net_socket;
21 struct net_stat;
22 
23 
24 struct net_stack_interface_module_info {
25 	module_info info;
26 
27 	status_t (*open)(int family, int type, int protocol, net_socket** _socket);
28 	status_t (*close)(net_socket* socket);
29 	status_t (*free)(net_socket* socket);
30 
31 	status_t (*bind)(net_socket* socket, const struct sockaddr* address,
32 					socklen_t addressLength);
33 	status_t (*shutdown)(net_socket* socket, int how);
34 	status_t (*connect)(net_socket* socket, const struct sockaddr* address,
35 					socklen_t addressLength);
36 	status_t (*listen)(net_socket* socket, int backlog);
37 	status_t (*accept)(net_socket* socket, struct sockaddr* address,
38 					socklen_t* _addressLength, net_socket** _acceptedSocket);
39 
40 	ssize_t (*recv)(net_socket* socket, void* data, size_t length, int flags);
41 	ssize_t (*recvfrom)(net_socket* socket, void* data, size_t length,
42 					int flags, struct sockaddr* address,
43 					socklen_t* _addressLength);
44 	ssize_t (*recvmsg)(net_socket* socket, struct msghdr* message, int flags);
45 
46 	ssize_t (*send)(net_socket* socket, const void* data, size_t length,
47 					int flags);
48 	ssize_t (*sendto)(net_socket* socket, const void* data, size_t length,
49 					int flags, const struct sockaddr* address,
50 					socklen_t addressLength);
51 	ssize_t (*sendmsg)(net_socket* socket, const struct msghdr* message,
52 					int flags);
53 
54 	status_t (*getsockopt)(net_socket* socket, int level, int option,
55 					void* value, socklen_t* _length);
56 	status_t (*setsockopt)(net_socket* socket, int level, int option,
57 					const void* value, socklen_t length);
58 
59 	status_t (*getpeername)(net_socket* socket, struct sockaddr* address,
60 					socklen_t* _addressLength);
61 	status_t (*getsockname)(net_socket* socket, struct sockaddr* address,
62 					socklen_t* _addressLength);
63 
64 	int (*sockatmark)(net_socket* socket);
65 
66 	status_t (*socketpair)(int family, int type, int protocol,
67 					net_socket* _sockets[2]);
68 
69 	status_t (*ioctl)(net_socket* socket, uint32 op, void *buffer,
70 					size_t length);
71 	status_t (*select)(net_socket* socket, uint8 event,
72 					struct selectsync *sync);
73 	status_t (*deselect)(net_socket* socket, uint8 event,
74 					struct selectsync *sync);
75 
76 	status_t (*get_next_socket_stat)(int family, uint32 *cookie,
77 					struct net_stat *stat);
78 };
79 
80 
81 #endif	// NET_STACK_INTERFACE_H
82