2 * Copyright 2008, Haiku, Inc. All Rights Reserved.
3 * This file may be used under the terms of the MIT License.
5 #ifndef NET_STACK_INTERFACE_H
6 #define NET_STACK_INTERFACE_H
9 #include <sys/socket.h>
12 // name of the kernel stack interface
13 #define NET_STACK_INTERFACE_MODULE_NAME "network/stack/kernel_interface/v1"
15 // name of the userland stack interface
16 #define NET_STACK_USERLAND_INTERFACE_MODULE_NAME \
17 "network/stack/userland_interface/v1"
24 struct net_stack_interface_module_info
{
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
);
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
);
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
);
46 ssize_t (*send
)(net_socket
* socket
, const void* data
, size_t length
,
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
,
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
);
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
);
64 int (*sockatmark
)(net_socket
* socket
);
66 status_t (*socketpair
)(int family
, int type
, int protocol
,
67 net_socket
* _sockets
[2]);
69 status_t (*ioctl
)(net_socket
* socket
, uint32 op
, void *buffer
,
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
);
76 status_t (*get_next_socket_stat
)(int family
, uint32
*cookie
,
77 struct net_stat
*stat
);
81 #endif // NET_STACK_INTERFACE_H