blob: 67591cd88691b3fe6b5b51a90504a594657a2682 [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001/*
2 * Copyright (c) 1995 Danny Gasparovski.
3 *
4 * Please read the file COPYRIGHT for the
5 * terms and conditions of the copyright.
6 */
7
8/* MINE */
9
10#ifndef _SLIRP_SOCKET_H_
11#define _SLIRP_SOCKET_H_
12
13#define SO_EXPIRE 240000
14#define SO_EXPIREFAST 10000
15
16/*
17 * Our socket structure
18 */
19
20struct socket {
21 struct socket *so_next,*so_prev; /* For a linked list of sockets */
22
23 int s; /* The actual socket */
24
25 /* XXX union these with not-yet-used sbuf params */
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070026 struct mbuf *so_m; /* Pointer to the original SYN packet,
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080027 * for non-blocking connect()'s, and
28 * PING reply's */
29 struct tcpiphdr *so_ti; /* Pointer to the original ti within
30 * so_mconn, for non-blocking connections */
31 int so_urgc;
32 uint32_t so_faddr_ip;
33 uint32_t so_laddr_ip;
34 uint16_t so_faddr_port;
35 uint16_t so_laddr_port;
36 uint16_t so_haddr_port;
37
38 u_int8_t so_iptos; /* Type of service */
39 u_int8_t so_emu; /* Is the socket emulated? */
40
41 u_char so_type; /* Type of socket, UDP or TCP */
42 int so_state; /* internal state flags SS_*, below */
43
44 struct tcpcb *so_tcpcb; /* pointer to TCP protocol control block */
45 u_int so_expire; /* When the socket will expire */
46
47 int so_queued; /* Number of packets queued from this socket */
48 int so_nqueued; /* Number of packets queued in a row
49 * Used to determine when to "downgrade" a session
50 * from fastq to batchq */
51
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070052 struct sbuf so_rcv; /* Receive buffer */
53 struct sbuf so_snd; /* Send buffer */
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080054 void * extra; /* Extra pointer */
55};
56
57
58/*
59 * Socket state bits. (peer means the host on the Internet,
60 * local host means the host on the other end of the modem)
61 */
62#define SS_NOFDREF 0x001 /* No fd reference */
63
64#define SS_ISFCONNECTING 0x002 /* Socket is connecting to peer (non-blocking connect()'s) */
65#define SS_ISFCONNECTED 0x004 /* Socket is connected to peer */
66#define SS_FCANTRCVMORE 0x008 /* Socket can't receive more from peer (for half-closes) */
67#define SS_FCANTSENDMORE 0x010 /* Socket can't send more to peer (for half-closes) */
68/* #define SS_ISFDISCONNECTED 0x020*/ /* Socket has disconnected from peer, in 2MSL state */
69#define SS_FWDRAIN 0x040 /* We received a FIN, drain data and set SS_FCANTSENDMORE */
70
71#define SS_CTL 0x080
72#define SS_FACCEPTCONN 0x100 /* Socket is accepting connections from a host on the internet */
73#define SS_FACCEPTONCE 0x200 /* If set, the SS_FACCEPTCONN socket will die after one accept */
74#define SS_PROXIFIED 0x400 /* Socket is trying to connect through a proxy, only makes sense
75 when SS_ISFCONNECTING is also set */
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070076
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080077extern struct socket tcb;
78
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080079void so_init _P((void));
80struct socket * solookup _P((struct socket *, uint32_t, u_int, uint32_t, u_int));
81struct socket * socreate _P((void));
82void sofree _P((struct socket *));
83int soread _P((struct socket *));
84void sorecvoob _P((struct socket *));
85int sosendoob _P((struct socket *));
86int sowrite _P((struct socket *));
87void sorecvfrom _P((struct socket *));
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070088int sosendto _P((struct socket *, struct mbuf *));
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080089struct socket * solisten _P((u_int, u_int32_t, u_int, int));
90int sounlisten _P((u_int port));
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080091void soisfconnecting _P((register struct socket *));
92void soisfconnected _P((register struct socket *));
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080093void soisfdisconnected _P((struct socket *));
94void sofwdrain _P((struct socket *));
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070095struct iovec; /* For win32 */
96size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np);
97int soreadbuf(struct socket *so, const char *buf, int size);
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080098
99#endif /* _SOCKET_H_ */