raw: Rename old list-based socket management source code.
[swifty.git] / src / raw / include / swift_list.h
1 #ifndef __SOCK_LIST
2
3 #define __SOCK_LIST
4
5 enum sock_bind_state {
6         STATE_NOTBOUND,
7         STATE_BOUND
8 };
9
10 /* socket management structure */
11 struct sock_list {
12         int s;
13         struct sockaddr_sw addr;
14         enum sock_bind_state bind_state;
15         struct sock_list *next;
16         struct sock_list *prev;
17 };
18
19 static struct sock_list sock_list_head = {
20         .next = &sock_list_head,
21         .prev = &sock_list_head
22 };
23
24 /*
25  * Add new socket to list. Called by sw_socket "syscall".
26  */
27 struct sock_list *list_add_socket(int s);
28
29 /*
30  * Bind socket to given address. Called by sw_bind "syscall".
31  */
32
33 struct sock_list *list_update_socket_address(int s, __CONST_SOCKADDR_ARG addr);
34
35 /*
36  * Get list element containing socket s. Called by sw_send* "syscalls".
37  */
38
39 struct sock_list *list_elem_from_socket(int s);
40
41 /*
42  * Get list element containing address addr. Called by sw_bind "syscall".
43  */
44
45 struct sock_list *list_elem_from_address(__CONST_SOCKADDR_ARG addr);
46
47 /*
48  * Remove socket from list. Called by sw_close "syscall".
49  */
50
51 int list_remove_socket(int s);
52
53 /*
54  * Check if a socket is bound.
55  */
56 int list_socket_is_bound(int s);
57
58 #endif