]>
Commit | Line | Data |
---|---|---|
f0cbd3ec FB |
1 | /* |
2 | * Copyright (c) 1995 Danny Gasparovski. | |
5fafdf24 TS |
3 | * |
4 | * Please read the file COPYRIGHT for the | |
f0cbd3ec FB |
5 | * terms and conditions of the copyright. |
6 | */ | |
7 | ||
f0cbd3ec FB |
8 | #ifndef _SLIRP_SOCKET_H_ |
9 | #define _SLIRP_SOCKET_H_ | |
10 | ||
11 | #define SO_EXPIRE 240000 | |
12 | #define SO_EXPIREFAST 10000 | |
13 | ||
14 | /* | |
15 | * Our socket structure | |
16 | */ | |
17 | ||
18 | struct socket { | |
19 | struct socket *so_next,*so_prev; /* For a linked list of sockets */ | |
20 | ||
21 | int s; /* The actual socket */ | |
22 | ||
23 | /* XXX union these with not-yet-used sbuf params */ | |
24 | struct mbuf *so_m; /* Pointer to the original SYN packet, | |
25 | * for non-blocking connect()'s, and | |
26 | * PING reply's */ | |
27 | struct tcpiphdr *so_ti; /* Pointer to the original ti within | |
28 | * so_mconn, for non-blocking connections */ | |
29 | int so_urgc; | |
30 | struct in_addr so_faddr; /* foreign host table entry */ | |
31 | struct in_addr so_laddr; /* local host table entry */ | |
32 | u_int16_t so_fport; /* foreign port */ | |
33 | u_int16_t so_lport; /* local port */ | |
3b46e624 | 34 | |
f0cbd3ec FB |
35 | u_int8_t so_iptos; /* Type of service */ |
36 | u_int8_t so_emu; /* Is the socket emulated? */ | |
3b46e624 | 37 | |
f0cbd3ec FB |
38 | u_char so_type; /* Type of socket, UDP or TCP */ |
39 | int so_state; /* internal state flags SS_*, below */ | |
3b46e624 | 40 | |
f0cbd3ec FB |
41 | struct tcpcb *so_tcpcb; /* pointer to TCP protocol control block */ |
42 | u_int so_expire; /* When the socket will expire */ | |
3b46e624 | 43 | |
f0cbd3ec FB |
44 | int so_queued; /* Number of packets queued from this socket */ |
45 | int so_nqueued; /* Number of packets queued in a row | |
46 | * Used to determine when to "downgrade" a session | |
47 | * from fastq to batchq */ | |
5fafdf24 | 48 | |
f0cbd3ec FB |
49 | struct sbuf so_rcv; /* Receive buffer */ |
50 | struct sbuf so_snd; /* Send buffer */ | |
51 | void * extra; /* Extra pointer */ | |
52 | }; | |
53 | ||
54 | ||
55 | /* | |
56 | * Socket state bits. (peer means the host on the Internet, | |
57 | * local host means the host on the other end of the modem) | |
58 | */ | |
59 | #define SS_NOFDREF 0x001 /* No fd reference */ | |
60 | ||
61 | #define SS_ISFCONNECTING 0x002 /* Socket is connecting to peer (non-blocking connect()'s) */ | |
62 | #define SS_ISFCONNECTED 0x004 /* Socket is connected to peer */ | |
63 | #define SS_FCANTRCVMORE 0x008 /* Socket can't receive more from peer (for half-closes) */ | |
64 | #define SS_FCANTSENDMORE 0x010 /* Socket can't send more to peer (for half-closes) */ | |
f0cbd3ec FB |
65 | #define SS_FWDRAIN 0x040 /* We received a FIN, drain data and set SS_FCANTSENDMORE */ |
66 | ||
67 | #define SS_CTL 0x080 | |
68 | #define SS_FACCEPTCONN 0x100 /* Socket is accepting connections from a host on the internet */ | |
69 | #define SS_FACCEPTONCE 0x200 /* If set, the SS_FACCEPTCONN socket will die after one accept */ | |
70 | ||
f932b6ce | 71 | #define SS_PERSISTENT_MASK 0xf000 /* Unremovable state bits */ |
6dd5ffb6 | 72 | #define SS_HOSTFWD 0x1000 /* Socket describes host->guest forwarding */ |
4a82347a | 73 | #define SS_INCOMING 0x2000 /* Connection was initiated by a host on the internet */ |
f932b6ce | 74 | |
f0cbd3ec FB |
75 | extern struct socket tcb; |
76 | ||
f0cbd3ec FB |
77 | struct socket * solookup _P((struct socket *, struct in_addr, u_int, struct in_addr, u_int)); |
78 | struct socket * socreate _P((void)); | |
79 | void sofree _P((struct socket *)); | |
80 | int soread _P((struct socket *)); | |
81 | void sorecvoob _P((struct socket *)); | |
82 | int sosendoob _P((struct socket *)); | |
83 | int sowrite _P((struct socket *)); | |
84 | void sorecvfrom _P((struct socket *)); | |
85 | int sosendto _P((struct socket *, struct mbuf *)); | |
3c6a0580 | 86 | struct socket * tcp_listen _P((u_int32_t, u_int, u_int32_t, u_int, int)); |
f0cbd3ec FB |
87 | void soisfconnecting _P((register struct socket *)); |
88 | void soisfconnected _P((register struct socket *)); | |
f0cbd3ec | 89 | void sofwdrain _P((struct socket *)); |
b9e82a59 | 90 | struct iovec; /* For win32 */ |
e1c5a2b3 AL |
91 | size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np); |
92 | int soreadbuf(struct socket *so, const char *buf, int size); | |
f0cbd3ec FB |
93 | |
94 | #endif /* _SOCKET_H_ */ |